コード例 #1
0
ファイル: admin.py プロジェクト: Backenkoehler/Misago
def UserFormFactory(FormType, instance):
    extra_fields = {}

    extra_fields['rank'] = forms.ModelChoiceField(
        label=_("Rank"),
        help_text=_("Ranks are used to group and distinguish users. "
                    "They are also used to add permissions to groups of "
                    "users."),
        queryset=Rank.objects.order_by('name'),
        initial=instance.rank)

    roles = Role.objects.order_by('name')
    extra_fields['roles'] = forms.ModelMultipleChoiceField(
        label=_("Roles"),
        help_text=_('Individual roles of this user. '
                    'All users must have "member" role.'),
        queryset=roles,
        initial=instance.roles.all() if instance.pk else None,
        widget=forms.CheckboxSelectMultiple)

    if instance.pk:
        extra_fields['timezone'] = forms.ChoiceField(
            label=_("Timezone"), choices=timezones.choices())

    return type('UserFormFinal', (FormType,), extra_fields)
コード例 #2
0
ファイル: admin.py プロジェクト: pombreda/Misago
def UserFormFactory(FormType, instance):
    extra_fields = {}

    extra_fields['rank'] = forms.ModelChoiceField(
        label=_("Rank"),
        help_text=_("Ranks are used to group and distinguish users. "
                    "They are also used to add permissions to groups of "
                    "users."),
        queryset=Rank.objects.order_by('name'),
        initial=instance.rank)

    roles = Role.objects.order_by('name')
    extra_fields['roles'] = forms.ModelMultipleChoiceField(
        label=_("Roles"),
        help_text=_('Individual roles of this user. '
                    'All users must have "member" role.'),
        queryset=roles,
        initial=instance.roles.all() if instance.pk else None,
        widget=forms.CheckboxSelectMultiple)

    if instance.pk:
        extra_fields['timezone'] = forms.ChoiceField(
            label=_("Timezone"), choices=timezones.choices())

    return type('UserFormFinal', (FormType, ), extra_fields)
コード例 #3
0
ファイル: usercp.py プロジェクト: Backenkoehler/Misago
def ChangeForumOptionsForm(*args, **kwargs):
    timezone = forms.ChoiceField(
        label=_("Your current timezone"), choices=timezones.choices(),
        help_text=_("If dates and hours displayed by forums are inaccurate, "
                    "you can fix it by adjusting timezone setting."))

    FinalFormType = type('FinalChangeForumOptionsForm',
                         (ChangeForumOptionsBaseForm,),
                         {'timezone': timezone})
    return FinalFormType(*args, **kwargs)
コード例 #4
0
ファイル: usercp.py プロジェクト: pombreda/Misago
def ChangeForumOptionsForm(*args, **kwargs):
    timezone = forms.ChoiceField(
        label=_("Your current timezone"),
        choices=timezones.choices(),
        help_text=_("If dates and hours displayed by forums are inaccurate, "
                    "you can fix it by adjusting timezone setting."))

    FinalFormType = type('FinalChangeForumOptionsForm',
                         (ChangeForumOptionsBaseForm, ),
                         {'timezone': timezone})
    return FinalFormType(*args, **kwargs)
コード例 #5
0
ファイル: forms.py プロジェクト: Backenkoehler/Misago
def create_choice(setting, kwargs, extra):
    if setting.form_field == 'choice':
        kwargs['widget'] = forms.RadioSelect()
    else:
        kwargs['widget'] = forms.Select()

    kwargs['choices'] = extra.get('choices', [])
    if kwargs['choices'] == '#TZ#':
        kwargs['choices'] = timezones.choices()

    if setting.python_type == 'int':
        return forms.TypedChoiceField(coerce='int', **kwargs)
    else:
        return forms.ChoiceField(**kwargs)
コード例 #6
0
ファイル: forms.py プロジェクト: qhhonx/Misago
def create_choice(setting, kwargs, extra):
    if setting.form_field == 'choice':
        kwargs['widget'] = forms.RadioSelect()
    else:
        kwargs['widget'] = forms.Select()

    kwargs['choices'] = extra.get('choices', [])
    if kwargs['choices'] == '#TZ#':
        kwargs['choices'] = timezones.choices()

    if setting.python_type == 'int':
        return forms.TypedChoiceField(coerce='int', **kwargs)
    else:
        return forms.ChoiceField(**kwargs)