Exemplo n.º 1
0
    class PermissionSetForm(forms.ModelForm):
        class Meta:
            model = PermissionSet

        directory = forms.ModelChoiceField(
            queryset=Directory.objects.filter(pk=current_directory.pk),
            initial=current_directory.pk,
            widget=forms.HiddenInput,
        )
        profile = GroupedModelChoiceField(
            label=_('Username'),
            querysets=querysets,
            queryset=PootleProfile.objects.all(),
            required=True,
            widget=forms.Select(attrs={
                'class': 'js-select2 select2-username',
            }),
        )
        positive_permissions = PermissionFormField(
            label=_('Permissions'),
            queryset=permission_queryset,
            required=False,
            widget=forms.SelectMultiple(
                attrs={
                    'class': 'js-select2 select2-multiple',
                    'data-placeholder': _('Select one or more permissions'),
                }),
        )
    class PermissionSetForm(forms.ModelForm):
        class Meta:
            model = PermissionSet

        directory = forms.ModelChoiceField(queryset=Directory.objects.filter(pk=current_directory.pk),
                                           initial=current_directory.pk, widget=forms.HiddenInput)
        profile = GroupedModelChoiceField(querysets=querysets, queryset=PootleProfile.objects.all(), required=True)
        positive_permissions = PermissionFormField(label=_('Permissions'), queryset=permission_queryset, required=False)
Exemplo n.º 3
0
    class PermissionSetForm(forms.ModelForm):
        class Meta(object):
            model = PermissionSet
            fields = ('user', 'directory', 'positive_permissions',
                      'negative_permissions')

        directory = forms.ModelChoiceField(
            queryset=Directory.objects.filter(pk=current_directory.pk),
            initial=current_directory.pk,
            widget=forms.HiddenInput,
        )
        user = GroupedModelChoiceField(
            label=_('Username'),
            choice_groups=choice_groups,
            queryset=User.objects.all(),
            required=True,
            widget=RemoteSelectWidget(
                attrs={
                    "data-s2-placeholder":
                    _("Search for users to add"),
                    'class': ('js-select2-remote select2-username '
                              'js-s2-new-members')
                }))
        positive_permissions = PermissionFormField(
            label=_('Add Permissions'),
            queryset=positive_permissions_qs,
            required=False,
            widget=forms.SelectMultiple(
                attrs={
                    'class': 'js-select2 select2-multiple',
                    'data-placeholder': _('Select one or more permissions'),
                }),
        )
        negative_permissions = PermissionFormField(
            label=_('Revoke Permissions'),
            queryset=negative_permissions_qs,
            required=False,
            widget=forms.SelectMultiple(
                attrs={
                    'class': 'js-select2 select2-multiple',
                    'data-placeholder': _('Select one or more permissions'),
                }),
        )

        def __init__(self, *args, **kwargs):
            super(PermissionSetForm, self).__init__(*args, **kwargs)

            self.fields["user"].widget.attrs["data-select2-url"] = reverse(
                "pootle-permissions-users",
                kwargs=dict(directory=current_directory.pk))

            # Don't display extra negative permissions field where they
            # are not applicable
            if language is not None:
                del self.fields['negative_permissions']
Exemplo n.º 4
0
    class PermissionSetForm(forms.ModelForm):
        class Meta(object):
            model = PermissionSet
            fields = (
                "user",
                "directory",
                "positive_permissions",
                "negative_permissions",
            )

        directory = forms.ModelChoiceField(
            queryset=Directory.objects.filter(pk=current_directory.pk),
            initial=current_directory.pk,
            widget=forms.HiddenInput,
        )
        user = GroupedModelChoiceField(
            label=_("Username"),
            choice_groups=choice_groups,
            queryset=User.objects.all(),
            required=True,
            widget=forms.Select(
                attrs={"class": "js-select2 select2-username"}),
        )
        positive_permissions = PermissionFormField(
            label=_("Add Permissions"),
            queryset=positive_permissions_qs,
            required=False,
            widget=forms.SelectMultiple(
                attrs={
                    "class": "js-select2 select2-multiple",
                    "data-placeholder": _("Select one or more permissions"),
                }),
        )
        negative_permissions = PermissionFormField(
            label=_("Revoke Permissions"),
            queryset=negative_permissions_qs,
            required=False,
            widget=forms.SelectMultiple(
                attrs={
                    "class": "js-select2 select2-multiple",
                    "data-placeholder": _("Select one or more permissions"),
                }),
        )

        def __init__(self, *args, **kwargs):
            super(PermissionSetForm, self).__init__(*args, **kwargs)

            # Don't display extra negative permissions field where they
            # are not applicable
            if language is not None:
                del self.fields["negative_permissions"]
Exemplo n.º 5
0
    class PermissionSetForm(forms.ModelForm):
        class Meta(object):
            model = PermissionSet
            fields = ('user', 'directory', 'positive_permissions',
                      'negative_permissions')

        directory = forms.ModelChoiceField(
            queryset=Directory.objects.filter(pk=current_directory.pk),
            initial=current_directory.pk,
            widget=forms.HiddenInput,
        )
        user = GroupedModelChoiceField(
            label=_('Username'),
            querysets=querysets,
            queryset=User.objects.all(),
            required=True,
            widget=forms.Select(attrs={
                'class': 'js-select2 select2-username',
            }),
        )
        positive_permissions = PermissionFormField(
            label=_('Add Permissions'),
            queryset=positive_permissions_qs,
            required=False,
            widget=forms.SelectMultiple(
                attrs={
                    'class': 'js-select2 select2-multiple',
                    'data-placeholder': _('Select one or more permissions'),
                }),
        )
        negative_permissions = PermissionFormField(
            label=_('Revoke Permissions'),
            queryset=negative_permissions_qs,
            required=False,
            widget=forms.SelectMultiple(
                attrs={
                    'class': 'js-select2 select2-multiple',
                    'data-placeholder': _('Select one or more permissions'),
                }),
        )

        def __init__(self, *args, **kwargs):
            super(PermissionSetForm, self).__init__(*args, **kwargs)

            # Don't display extra negative permissions field where they
            # are not applicable
            if language is not None:
                del self.fields['negative_permissions']