Exemplo n.º 1
0
 class Meta:
     if use_select2:
         widgets = {
             'authors':
             HeavySelect2MultipleWidget(data_view='profile_select2'),
             'banned_users':
             HeavySelect2MultipleWidget(data_view='profile_select2'),
             'types':
             Select2MultipleWidget,
             'group':
             Select2Widget,
         }
Exemplo n.º 2
0
 class Meta:
     if use_select2:
         widgets = {
             'admins':
             HeavySelect2MultipleWidget(data_view='profile_select2'),
             'registrant': HeavySelect2Widget(data_view='profile_select2'),
         }
    def get_formfield_kwargs(self):
        if settings.COSINNUS_MANAGED_TAG_DYNAMIC_USER_FIELD_FILTER_ON_TAG_SLUG:
            data_url = reverse(
                'cosinnus:select2:managed-tag-members',
                kwargs={
                    'tag_slug':
                    settings.
                    COSINNUS_MANAGED_TAG_DYNAMIC_USER_FIELD_FILTER_ON_TAG_SLUG
                })
        else:
            data_url = reverse('cosinnus:select2:all-members')

        if self._dynamic_field_initial:
            initial_user_ids = get_user_model().objects.filter(
                id__in=self._dynamic_field_initial)
        else:
            initial_user_ids = get_user_model().objects.none()
        preresults = get_user_select2_pills(initial_user_ids, text_only=False)
        new_initial = [key for key, val in preresults]
        self._new_initial_after_formfield_creation = new_initial
        return {
            'data_url':
            data_url,
            'widget':
            HeavySelect2MultipleWidget(data_url=data_url, choices=preresults),
            'choices':
            preresults,
            'initial':
            new_initial
        }
Exemplo n.º 4
0
class ProblemTypeForm(ModelForm):
    problems = ModelMultipleChoiceField(
        label='Included problems',
        queryset=Problem.objects.all(),
        required=False,
        help_text='These problems are included in this type of problems',
        widget=HeavySelect2MultipleWidget(data_view='problem_select2')
        if use_select2 else FilteredSelectMultiple('problems', False))
Exemplo n.º 5
0
class LanguageForm(ModelForm):
    problems = ModelMultipleChoiceField(
        label='Disallowed problems',
        queryset=Problem.objects.all(),
        required=False,
        help_text=
        'These problems are NOT allowed to be submitted in this language',
        widget=HeavySelect2MultipleWidget(data_view='problem_select2')
        if use_select2 else FilteredSelectMultiple('problems', False))
Exemplo n.º 6
0
 class Meta(object):
     model = PrivateMessage
     fields = ('receivers', 'subject', 'body', 'parent')
     widgets = {
         'body':
         util.get_markup_engine().get_widget_cls(),
         'receivers':
         HeavySelect2MultipleWidget(data_view='private_messages:select2')
     }
     labels = {
         'receivers': _('To'),
     }
Exemplo n.º 7
0
    def __init__(self, *args, **kwargs):
        """ INIT ME. """

        self.owner = kwargs.pop('owner')

        super(AddSubscriptionForm, self).__init__(*args, **kwargs)

        # HEADS: this query is replicated in the completer view.
        potential_feeds = self.owner.unsubscribed_feeds

        self.fields['feeds'].queryset = potential_feeds

        count = potential_feeds.count()

        self.fields['feeds'].widget = HeavySelect2MultipleWidget(
            data_url=reverse_lazy('feeds_completer'))

        self.fields['feeds'].widget.set_placeholder(
            _(u'Select feed(s) from the {0} referenced').format(count))
Exemplo n.º 8
0
 def test_is_hidden_multiple(self):
     from django_select2.widgets import HeavySelect2MultipleWidget
     new_widget = HeavySelect2MultipleWidget(data_url="/")
     assert new_widget.is_hidden is False
Exemplo n.º 9
0
 class Meta:
     if use_select2:
         widgets = {
             'organizers':
             HeavySelect2MultipleWidget(data_view='profile_select2'),
         }
Exemplo n.º 10
0
class HeavySelect2MultipleWidgetForm(forms.Form):
    heavy_number = forms.MultipleChoiceField(widget=HeavySelect2MultipleWidget(data_view='heavy_data'))