]> git.openstreetmap.org Git - osqa.git/commitdiff
Some fixes in custom pages logic.
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Mon, 7 Jun 2010 17:37:49 +0000 (17:37 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Mon, 7 Jun 2010 17:37:49 +0000 (17:37 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@388 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/actions/page.py
forum/skins/default/templates/osqaadmin/djstyle_base.html
forum/skins/default/templates/osqaadmin/edit_page.html
forum/skins/default/templates/osqaadmin/set.html
forum/templatetags/extra_filters.py

index bfeda165efa94513ebfd2cf212f2b70b5b56c4a2..508e8c250db63d7a23447cb1ea88601d3aee31a1 100644 (file)
@@ -15,8 +15,8 @@ class NewPageAction(ActionProxy):
 
     def describe(self, viewer=None):
         return _("%(user)s created a new page titled %(page)s") % {
-            'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
-            'page': self.hyperlink(self.node.get_absolute_url(), self.node.title)
+        'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
+        'page': self.hyperlink(self.node.get_absolute_url(), self.node.title)
         }
 
 class EditPageAction(ActionProxy):
@@ -26,7 +26,7 @@ class EditPageAction(ActionProxy):
         title = data.pop('title')
         body = data.pop('content')
 
-        if (title != self.node.title) and (body != self.node.body):
+        if (title != self.node.title) or (body != self.node.body):
             self.node.create_revision(self.user, title=title, body=body)
 
         self.node.extra = data
@@ -34,8 +34,8 @@ class EditPageAction(ActionProxy):
 
     def describe(self, viewer=None):
         return _("%(user)s edited the page titled %(page)s") % {
-            'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
-            'page': self.hyperlink(self.node.get_absolute_url(), self.node.title)
+        'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
+        'page': self.hyperlink(self.node.get_absolute_url(), self.node.title)
         }
 
 class PublishAction(ActionProxy):
@@ -53,6 +53,6 @@ class PublishAction(ActionProxy):
 
     def describe(self, viewer=None):
         return _("%(user)s published a new page titled %(page)s") % {
-            'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
-            'page': self.hyperlink(self.node.get_absolute_url(), self.node.title)
+        'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
+        'page': self.hyperlink(self.node.get_absolute_url(), self.node.title)
         }
index 3f09125bc3f9ae8649ca06574b31ae9482999d8c..dcea80fa3550e52464dc91f7731648f1c63fcf90 100644 (file)
@@ -1,5 +1,4 @@
-{% load extra_tags %}
-{% load i18n %}
+{% load extra_tags extra_filters i18n %}
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
                         <li><a href="{% url admin_set allsets.sidebar.name %}">{{ allsets.sidebar.title }}</a></li>
                         <li>
                             <a href="{% url admin_set allsets.css.name %}">{{ allsets.css.title }}</a>
-                            {% if "css" in unsaved %}<img width="12" height="12" src="{{ settings.ADMIN_MEDIA_PREFIX }}img/admin/icon_alert.gif" alt="{% trans "Unsaved changes" %}" />{% endif %}
+                            {% if "css"|contained_in:unsaved %}<img width="12" height="12" src="{{ settings.ADMIN_MEDIA_PREFIX }}img/admin/icon_alert.gif" alt="{% trans "Unsaved changes" %}" />{% endif %}
                         </li>
                         <li>
                             <a href="{% url admin_set allsets.headandfoot.name %}">{{ allsets.headandfoot.title }}</a>
-                            {% if "headandfoot" in unsaved %}<img width="12" height="12" src="{{ settings.ADMIN_MEDIA_PREFIX }}img/admin/icon_alert.gif" alt="{% trans "Unsaved changes" %}" />{% endif %}
+                            {% if "headandfoot"|contained_in:unsaved %}<img width="12" height="12" src="{{ settings.ADMIN_MEDIA_PREFIX }}img/admin/icon_alert.gif" alt="{% trans "Unsaved changes" %}" />{% endif %}
                         </li>
                         <li>
                             <a href="{% url admin_set allsets.head.name %}">{{ allsets.head.title }}</a>
-                            {% if "head" in unsaved %}<img width="12" height="12" src="{{ settings.ADMIN_MEDIA_PREFIX }}img/admin/icon_alert.gif" alt="{% trans "Unsaved changes" %}" />{% endif %}
+                            {% if "head"|contained_in:unsaved %}<img width="12" height="12" src="{{ settings.ADMIN_MEDIA_PREFIX }}img/admin/icon_alert.gif" alt="{% trans "Unsaved changes" %}" />{% endif %}
                         </li>
                     </ul>
                 </div>
                     {% for set in othersets %}
                         <li>
                             <a href="{% url admin_set set.name %}">{{ set.title }}</a>
-                            {% if set.name in unsaved %}<img width="12" height="12" src="{{ settings.ADMIN_MEDIA_PREFIX }}img/admin/icon_alert.gif" alt="{% trans "Unsaved changes" %}" />{% endif %}
+                            {% if set.name|contained_in:unsaved %}<img width="12" height="12" src="{{ settings.ADMIN_MEDIA_PREFIX }}img/admin/icon_alert.gif" alt="{% trans "Unsaved changes" %}" />{% endif %}
                         </li>
                     {% endfor %}
                     </ul>
index 269cec874ffb2de174b1401ad69e0caa14ef225f..d8d251ff405ec97c17253e81b9a71fb3643f3a43 100644 (file)
@@ -1,6 +1,6 @@
 {% extends basetemplate %}
 
-{% load i18n %}
+{% load i18n extra_filters %}
 
 {% block subtitle %}{% trans "Editing page" %}{% endblock %}
 {% block pagename %}
         <tr>
             <th></th>
             <td>
-                <input id="submit" name="submit" type="submit" value="{% trans "Save" %}" />
+                {% if page %}
+                    <input id="submit" name="submit" type="submit" value="{% trans "Edit" %}" />
+                {% else %}
+                    <input id="submit" name="submit" type="submit" value="{% trans "Save" %}" />
+                {% endif %}
                 {% if published %}
                     <input id="unpublish" name="unpublish" type="submit" value="{% trans "Unpublish" %}" />
                 {% else %}
index c909f9bb6b463c81566b8b6bc55e5d7a315fd081..2377e84682445c51f1b66a2c9f5b75ed42275a2b 100644 (file)
@@ -17,7 +17,7 @@
                     <input id="submit" name="submit" type="submit" value="{% trans "Save" %}" onclick="this.form.target=''; return true;" />\r
                     {% if form.set.can_preview %}\r
                         <input id="preview" name="preview" type="submit" value="{% trans "Preview" %}" onclick="this.form.target='_blank'; return true;" />\r
-                        {% if form.set.name in unsaved %}\r
+                        {% if form.set.name|contained_in:unsaved %}\r
                             <input id="reset" name="reset" type="submit" value="{% trans "Reset Changes" %}" onclick="this.form.target=''; return true;" />\r
                         {% endif %}\r
                     {% endif %}\r
index b2887eced9fddddc6b8bc4232ad916a3b3497a6c..6f3679ce94089db875e0279bcbe89531571ca684 100644 (file)
@@ -13,7 +13,7 @@ def collapse(input):
 def can_edit_post(user, post):
     return user.can_edit_post(post)
 
-    
+
 @register.filter
 def cnprog_intword(number):
     try:
@@ -33,3 +33,8 @@ def or_preview(setting, request):
             return previewing[setting.name]
 
     return setting.value
+
+
+@register.filter
+def contained_in(item, container):
+    return item in container
\ No newline at end of file