Rafał Pitoń 10 years ago
parent
commit
d01a39b77b

+ 1 - 1
misago/templates/misago/thread/posts_actions.html

@@ -5,7 +5,7 @@
     <ul class="dropdown-menu scrollable" role="menu">
     <ul class="dropdown-menu scrollable" role="menu">
       {% for action in posts_actions.get_list %}
       {% for action in posts_actions.get_list %}
       <li>
       <li>
-        <button type="submit" name="action" value="{{ action.action }}" class="action-{{ action.action }}" {% if action.confirmation %}data-confirmation="{{ action.confirmation }}"{% endif %}>
+        <button type="{% if not action.is_button %}submit{% else %}button{% endif %}" name="action" value="{{ action.action }}" class="action-{{ action.action }}" {% if action.confirmation %}data-confirmation="{{ action.confirmation }}"{% endif %}>
           <span class="fa fa-{{ action.icon }} fa-fw"></span>
           <span class="fa fa-{{ action.icon }} fa-fw"></span>
           {{ action.name }}
           {{ action.name }}
         </button>
         </button>

+ 1 - 1
misago/templates/misago/thread/thread_actions.html

@@ -9,7 +9,7 @@
     <ul class="dropdown-menu scrollable" role="menu">
     <ul class="dropdown-menu scrollable" role="menu">
       {% for action in thread_actions.get_list %}
       {% for action in thread_actions.get_list %}
       <li>
       <li>
-        <button type="submit" name="thread_action" value="{{ action.action }}" class="action-{{ action.action }}" {% if action.confirmation %}data-confirmation="{{ action.confirmation }}"{% endif %}>
+        <button type="{% if not action.is_button %}submit{% else %}button{% endif %}" name="thread_action" value="{{ action.action }}" class="action-{{ action.action }}" {% if action.confirmation %}data-confirmation="{{ action.confirmation }}"{% endif %}>
           <span class="fa fa-{{ action.icon }} fa-fw"></span>
           <span class="fa fa-{{ action.icon }} fa-fw"></span>
           {{ action.name }}
           {{ action.name }}
         </button>
         </button>

+ 1 - 1
misago/templates/misago/threads/actions.html

@@ -12,7 +12,7 @@
     <ul class="dropdown-menu scrollable" role="menu">
     <ul class="dropdown-menu scrollable" role="menu">
       {% for action in threads_actions.get_list %}
       {% for action in threads_actions.get_list %}
       <li>
       <li>
-        <button type="submit" name="action" value="{{ action.action }}" class="action-{{ action.action }}" {% if action.confirmation %}data-confirmation="{{ action.confirmation }}"{% endif %}>
+        <button type="{% if not action.is_button %}submit{% else %}button{% endif %}" name="action" value="{{ action.action }}" class="action-{{ action.action }}" {% if action.confirmation %}data-confirmation="{{ action.confirmation }}"{% endif %}>
           <span class="fa fa-{{ action.icon }} fa-fw"></span>
           <span class="fa fa-{{ action.icon }} fa-fw"></span>
           {{ action.name }}
           {{ action.name }}
         </button>
         </button>

+ 6 - 1
misago/threads/views/generic/actions.py

@@ -23,11 +23,16 @@ class ActionsBase(object):
             self.available_actions = self.get_available_actions(kwargs)
             self.available_actions = self.get_available_actions(kwargs)
         else:
         else:
             self.available_actions = []
             self.available_actions = []
+
+        self.actions_names = [a['action'] for a in self.available_actions]
         self.selected_ids = []
         self.selected_ids = []
 
 
     def __nonzero__(self):
     def __nonzero__(self):
         return bool(self.available_actions)
         return bool(self.available_actions)
 
 
+    def __contains__(self, item):
+        return item in self.actions_names
+
     def get_available_actions(self, kwargs):
     def get_available_actions(self, kwargs):
         raise NotImplementedError("get_available_actions has to return list "
         raise NotImplementedError("get_available_actions has to return list "
                                   "of dicts with allowed actions")
                                   "of dicts with allowed actions")
@@ -36,7 +41,7 @@ class ActionsBase(object):
         action_name = request.POST.get(self.query_key)
         action_name = request.POST.get(self.query_key)
 
 
         for action in self.available_actions:
         for action in self.available_actions:
-            if action['action'] == action_name:
+            if action['action'] == action_name and not action.get('is_button'):
                 if ':' in action_name:
                 if ':' in action_name:
                     action_bits = action_name.split(':')
                     action_bits = action_name.split(':')
                     action_name = action_bits[0]
                     action_name = action_bits[0]