Browse Source

Dont share extra actions between everything. #359

Rafał Pitoń 11 years ago
parent
commit
e561347363

+ 8 - 3
misago/admin/views/generic.py

@@ -74,10 +74,13 @@ class ListView(AdminView):
     items_per_page = 0
     ordering = None
 
-    extra_actions = []
+    extra_actions = None
 
     @classmethod
     def add_item_action(cls, name, icon, link, style=None):
+        if not cls.extra_actions:
+            cls.extra_actions = []
+
         cls.extra_actions.append({
             'name': name,
             'icon': icon,
@@ -146,14 +149,16 @@ class ListView(AdminView):
                 current_ordering['order_by'])
 
     def dispatch(self, request, *args, **kwargs):
+        extra_actions_list = self.extra_actions or []
+
         context = {
             'items': self.get_queryset(),
             'paginator': None,
             'page': None,
             'order_by': [],
             'order': None,
-            'extra_actions': self.extra_actions,
-            'extra_actions_len': len(self.extra_actions),
+            'extra_actions': extra_actions_list,
+            'extra_actions_len': len(extra_actions_list),
         }
 
         if self.ordering:

+ 11 - 1
misago/templates/misago/admin/forums/list.html

@@ -14,6 +14,9 @@
 
 {% block table-header %}
 <th>{% trans "Forum" %}</th>
+{% for action in extra_actions %}
+<th style="width: 1%;">&nbsp;</th>
+{% endfor %}
 <th>&nbsp;</th>
 <th>&nbsp;</th>
 <th>&nbsp;</th>
@@ -35,6 +38,13 @@
   {% endif %}
   {{ item.name }}
 </td>
+{% for action in extra_actions %}
+<td class="row-action">
+  <a href="{% url action.link forum_id=item.id %}" class="btn btn-{% if action.style %}{{ action.style }}{% else %}default{% endif %} tooltip-top" title="{{ action.name }}">
+    <span class="{{ action.icon }}"></span>
+  </a>
+</td>
+{% endfor %}
 <td class="row-action">
   {% if not item.last %}
   <form action="{% url 'misago:admin:forums:nodes:down' forum_id=item.id %}" method="post">
@@ -73,7 +83,7 @@
 
 
 {% block emptylist %}
-<td colspan="2">
+<td colspan="{{ 5|add:extra_actions_len }}">
   <p>{% trans "No forums are currently defined." %}</p>
 </td>
 {% endblock emptylist %}

+ 11 - 1
misago/templates/misago/admin/ranks/list.html

@@ -15,6 +15,9 @@
 {% block table-header %}
 <th style="width: 30%;">{% trans "Rank" %}</th>
 <th>{% trans "Title" %}</th>
+{% for action in extra_actions %}
+<th style="width: 1%;">&nbsp;</th>
+{% endfor %}
 <th style="width: 1%;">&nbsp;</th>
 <th style="width: 1%;">&nbsp;</th>
 <th style="width: 1%;">&nbsp;</th>
@@ -43,6 +46,13 @@
   <i class="text-muted">{% trans "No title set" %}</i>
   {% endif %}
 </td>
+{% for action in extra_actions %}
+<td class="row-action">
+  <a href="{% url action.link rank_id=item.id %}" class="btn btn-{% if action.style %}{{ action.style }}{% else %}default{% endif %} tooltip-top" title="{{ action.name }}">
+    <span class="{{ action.icon }}"></span>
+  </a>
+</td>
+{% endfor %}
 <td class="row-action">
   {% if not item.is_default %}
   <form action="{% url 'misago:admin:users:ranks:default' rank_id=item.id %}" method="post">
@@ -96,7 +106,7 @@
 
 
 {% block emptylist %}
-<td colspan="7">
+<td colspan="{{ 7|add:extra_actions_len }}">
   <p>{% trans "No ranks are currently defined." %}</p>
 </td>
 {% endblock emptylist %}