Improve the multi item action dropdown separator appearance

This commit is contained in:
Roberto Rosario
2015-01-08 00:45:18 -04:00
parent c96279cb14
commit f7f71d706d
8 changed files with 24 additions and 11 deletions

View File

@@ -1,13 +1,24 @@
from django import forms
from django.utils.translation import ugettext as _
from .links import link_spacer
class MultiItemForm(forms.Form):
def __init__(self, *args, **kwargs):
actions = kwargs.pop('actions', [])
super(MultiItemForm, self).__init__(*args, **kwargs)
choices = []
choices.extend([(action[0], action[1]) for action in actions])
group = []
for action in actions:
if not action[0]:
if group:
choices.append((link_spacer['text'], group))
group = []
else:
group.append(action)
self.fields['action'].choices = choices
action = forms.ChoiceField(label=_(u'Actions'), required=False)