Esempio n. 1
0
class RolePermissionsForm(forms.Form):
    legend = _("Threads")

    can_see_unapproved_content_lists = forms.YesNoSwitch(
        label=_("Can see unapproved content list"),
        help_text=_('Allows access to "unapproved" tab on threads lists for '
                    "easy listing of threads that are unapproved or contain "
                    "unapproved posts. Despite the tab being available on all "
                    "threads lists, it will only display threads belonging to "
                    "categories in which the user has permission to approve "
                    "content.")
    )
    can_see_reported_content_lists = forms.YesNoSwitch(
        label=_("Can see reported content list"),
        help_text=_('Allows access to "reported" tab on threads lists for '
                    "easy listing of threads that contain reported posts. "
                    "Despite the tab being available on all categories "
                    "threads lists, it will only display threads belonging to "
                    "categories in which the user has permission to see posts "
                    "reports.")
    )
    can_omit_flood_protection = forms.YesNoSwitch(
        label=_("Can omit flood protection"),
        help_text=_("Allows posting more frequently than flood protection would.")
    )
Esempio n. 2
0
class PermissionsForm(forms.Form):
    legend = _("Private threads")

    can_use_private_threads = forms.YesNoSwitch(
        label=_("Can use private threads"))
    can_start_private_threads = forms.YesNoSwitch(
        label=_("Can start private threads"))

    max_private_thread_participants = forms.IntegerField(
        label=_("Max number of users invited to private thread"),
        help_text=_("Enter 0 to don't limit number of participants."),
        initial=3,
        min_value=0
    )

    can_add_everyone_to_private_threads = forms.YesNoSwitch(
        label=_("Can add everyone to threads"),
        help_text=_("Allows user to add users that are "
                    "blocking him to private threads.")
    )

    can_report_private_threads = forms.YesNoSwitch(
        label=_("Can report private threads"),
        help_text=_("Allows user to report private threads they are "
                    "participating in, making them accessible to moderators.")
    )

    can_moderate_private_threads = forms.YesNoSwitch(
        label=_("Can moderate private threads"),
        help_text=_("Allows user to read, reply, edit and delete "
                "content in reported private threads.")
    )
Esempio n. 3
0
class RolePermissionsForm(forms.Form):
    legend = _("Threads")

    can_download_other_users_attachments = forms.YesNoSwitch(
        label=_("Can download other users attachments"))
    max_attachment_size = forms.IntegerField(
        label=_("Max attached file size (in kb)"),
        help_text=_("Enter 0 to disable attachments."),
        initial=500,
        min_value=0)
    can_delete_other_users_attachments = forms.YesNoSwitch(
        label=_("Can delete other users attachments"))

    can_see_unapproved_content_lists = forms.YesNoSwitch(
        label=_("Can see unapproved content list"),
        help_text=_('Allows access to "unapproved" tab on threads lists for '
                    "easy listing of threads that are unapproved or contain "
                    "unapproved posts. Despite the tab being available on all "
                    "threads lists, it will only display threads belonging to "
                    "categories in which the user has permission to approve "
                    "content."))
    can_see_reported_content_lists = forms.YesNoSwitch(
        label=_("Can see reported content list"),
        help_text=_('Allows access to "reported" tab on threads lists for '
                    "easy listing of threads that contain reported posts. "
                    "Despite the tab being available on all categories "
                    "threads lists, it will only display threads belonging to "
                    "categories in which the user has permission to see posts "
                    "reports."))
    can_omit_flood_protection = forms.YesNoSwitch(
        label=_("Can omit flood protection"),
        help_text=_(
            "Allows posting more frequently than flood protection would."))
Esempio n. 4
0
class SearchUsersFormBase(forms.Form):
    username = forms.CharField(label=_("Username starts with"), required=False)
    email = forms.CharField(label=_("E-mail starts with"), required=False)
    inactive = forms.YesNoSwitch(label=_("Inactive only"))
    is_staff = forms.YesNoSwitch(label=_("Admins only"))

    def filter_queryset(self, search_criteria, queryset):
        criteria = search_criteria
        if criteria.get('username'):
            queryset = queryset.filter(
                slug__startswith=criteria.get('username').lower())

        if criteria.get('email'):
            queryset = queryset.filter(
                email__istartswith=criteria.get('email'))

        if criteria.get('rank'):
            queryset = queryset.filter(rank_id=criteria.get('rank'))

        if criteria.get('role'):
            queryset = queryset.filter(roles__id=criteria.get('role'))

        if criteria.get('inactive'):
            queryset = queryset.filter(requires_activation__gt=0)

        if criteria.get('is_staff'):
            queryset = queryset.filter(is_staff=True)

        return queryset
Esempio n. 5
0
def StaffFlagUserFormFactory(FormType, instance):
    staff_fields = {
        'is_staff':
        forms.YesNoSwitch(label=EditUserForm.IS_STAFF_LABEL,
                          help_text=EditUserForm.IS_STAFF_HELP_TEXT,
                          initial=instance.is_staff),
        'is_superuser':
        forms.YesNoSwitch(label=EditUserForm.IS_SUPERUSER_LABEL,
                          help_text=EditUserForm.IS_SUPERUSER_HELP_TEXT,
                          initial=instance.is_superuser),
    }

    return type('StaffUserForm', (FormType, ), staff_fields)
Esempio n. 6
0
class PermissionsForm(LimitedPermissionsForm):
    can_warn_users = forms.YesNoSwitch(label=_("Can warn users"))
    can_be_warned = forms.YesNoSwitch(label=_("Can be warned"), initial=False)
    can_cancel_warnings = forms.TypedChoiceField(
        label=_("Can cancel warnings"),
        coerce=int,
        choices=NO_OWNED_ALL,
        initial=0)
    can_delete_warnings = forms.TypedChoiceField(
        label=_("Can delete warnings"),
        coerce=int,
        choices=NO_OWNED_ALL,
        initial=0)
Esempio n. 7
0
class PermissionsForm(forms.Form):
    legend = _("Attachments")

    max_attachment_size = forms.IntegerField(
        label=_("Max attached file size (in kb)"),
        help_text=_("Enter 0 to disable attachments."),
        initial=500,
        min_value=0)

    can_download_other_users_attachments = forms.YesNoSwitch(
        label=_("Can download other users attachments"))
    can_delete_other_users_attachments = forms.YesNoSwitch(
        label=_("Can delete other users attachments"))
Esempio n. 8
0
class PermissionsForm(LimitedPermissionsForm):
    can_browse_users_list = CAN_BROWSE_USERS_LIST
    can_search_users = CAN_SEARCH_USERS
    can_follow_users = forms.YesNoSwitch(label=_("Can follow other users"),
                                         initial=1)
    can_be_blocked = forms.YesNoSwitch(
        label=_("Can be blocked by other users"), initial=0)
    can_see_users_name_history = CAN_SEE_USER_NAME_HISTORY
    can_see_ban_details = CAN_SEE_BAN_DETAILS
    can_see_users_emails = forms.YesNoSwitch(
        label=_("Can see members e-mails"))
    can_see_users_ips = forms.YesNoSwitch(label=_("Can see members IPs"))
    can_see_hidden_users = forms.YesNoSwitch(
        label=_("Can see members that hide their presence"))
Esempio n. 9
0
class ChangeForumOptionsBaseForm(forms.ModelForm):
    timezone = forms.ChoiceField(
        label=_("Your current timezone"),
        choices=[],
        help_text=_("If dates and hours displayed by forums are inaccurate, "
                    "you can fix it by adjusting timezone setting."))

    is_hiding_presence = forms.YesNoSwitch(
        label=_("Hide my presence"),
        help_text=_("If you hide your presence, only members with permission "
                    "to see hidden will see when you are online."))

    limits_private_thread_invites_to = forms.TypedChoiceField(
        label=_("Who can add me to private threads"),
        coerce=int,
        choices=PRIVATE_THREAD_INVITES_LIMITS_CHOICES)

    subscribe_to_started_threads = forms.TypedChoiceField(
        label=_("Threads I start"), coerce=int, choices=AUTO_SUBSCRIBE_CHOICES)

    subscribe_to_replied_threads = forms.TypedChoiceField(
        label=_("Threads I reply to"),
        coerce=int,
        choices=AUTO_SUBSCRIBE_CHOICES)

    class Meta:
        model = get_user_model()
        fields = [
            'timezone', 'is_hiding_presence',
            'limits_private_thread_invites_to', 'subscribe_to_started_threads',
            'subscribe_to_replied_threads'
        ]
Esempio n. 10
0
class RolePermissionsForm(forms.Form):
    legend = _("Polls")

    can_start_polls = forms.TypedChoiceField(label=_("Can start polls"),
                                             coerce=int,
                                             initial=0,
                                             choices=((0, _("No")),
                                                      (1, _("Own threads")),
                                                      (2, _("All threads"))))
    can_edit_polls = forms.TypedChoiceField(label=_("Can edit polls"),
                                            coerce=int,
                                            initial=0,
                                            choices=((0, _("No")),
                                                     (1, _("Own polls")),
                                                     (2, _("All polls"))))
    can_delete_polls = forms.TypedChoiceField(label=_("Can delete polls"),
                                              coerce=int,
                                              initial=0,
                                              choices=((0, _("No")),
                                                       (1, _("Own polls")),
                                                       (2, _("All polls"))))
    poll_edit_time = forms.IntegerField(
        label=_("Time limit for own polls edits, in minutes"),
        help_text=_("Enter 0 to don't limit time for editing own polls."),
        initial=0,
        min_value=0)
    can_always_see_poll_voters = forms.YesNoSwitch(
        label=_("Can always see polls voters"),
        help_text=
        _("Allows users to see who voted in poll even if poll votes are secret."
          ))
Esempio n. 11
0
class ModerateAvatarForm(forms.ModelForm):
    is_avatar_locked = forms.YesNoSwitch(
        label=_("Lock avatar"),
        help_text=_("Setting this to yes will stop user from "
                    "changing his/her avatar, and will reset "
                    "his/her avatar to procedurally generated one."))
    avatar_lock_user_message = forms.CharField(
        label=_("User message"),
        help_text=_("Optional message for user explaining "
                    "why he/she is banned form changing avatar."),
        widget=forms.Textarea(attrs={'rows': 3}),
        required=False)
    avatar_lock_staff_message = forms.CharField(
        label=_("Staff message"),
        help_text=_("Optional message for forum team members explaining "
                    "why user is banned form changing avatar."),
        widget=forms.Textarea(attrs={'rows': 3}),
        required=False)

    class Meta:
        model = get_user_model()
        fields = [
            'is_avatar_locked',
            'avatar_lock_user_message',
            'avatar_lock_staff_message',
        ]
Esempio n. 12
0
class ThreadCloseForm(forms.Form):
    is_supporting = True
    location = 'lefthand'
    template = "misago/posting/threadcloseform.html"

    is_closed = forms.YesNoSwitch(label=_("Close thread"),
                                  yes_label=_("Closed thread"),
                                  no_label=_("Open thread"))
Esempio n. 13
0
class ThreadPinForm(forms.Form):
    is_supporting = True
    location = 'lefthand'
    template = "misago/posting/threadpinform.html"

    is_pinned = forms.YesNoSwitch(label=_("Pin thread"),
                                  yes_label=_("Pinned thread"),
                                  no_label=_("Unpinned thread"))
Esempio n. 14
0
class PermissionsForm(forms.Form):
    legend = _("Users moderation")

    can_rename_users = forms.YesNoSwitch(label=_("Can rename users"))
    can_moderate_avatars = forms.YesNoSwitch(label=_("Can moderate avatars"))
    can_moderate_signatures = forms.YesNoSwitch(
        label=_("Can moderate signatures"))
    can_ban_users = forms.YesNoSwitch(label=_("Can ban users"))
    max_ban_length = forms.IntegerField(
        label=_("Max length, in days, of imposed ban"),
        help_text=_("Enter zero to let moderators impose permanent bans."),
        min_value=0,
        initial=0)
    can_lift_bans = forms.YesNoSwitch(label=_("Can lift bans"))
    max_lifted_ban_length = forms.IntegerField(
        label=_("Max length, in days, of lifted ban"),
        help_text=_("Enter zero to let moderators lift permanent bans."),
        min_value=0,
        initial=0)
Esempio n. 15
0
class ModerateAvatarForm(forms.ModelForm):
    is_avatar_locked = forms.YesNoSwitch()
    avatar_lock_user_message = forms.CharField(required=False)
    avatar_lock_staff_message = forms.CharField(required=False)

    class Meta:
        model = get_user_model()
        fields = [
            'is_avatar_locked',
            'avatar_lock_user_message',
            'avatar_lock_staff_message',
        ]
Esempio n. 16
0
class PermissionsForm(forms.Form):
    legend = _("Account settings")

    name_changes_allowed = forms.IntegerField(
        label=_("Allowed username changes number"), min_value=0, initial=1)
    name_changes_expire = forms.IntegerField(
        label=_("Don't count username changes older than"),
        help_text=_("Number of days since name change that makes "
                    "that change no longer count to limit. Enter "
                    "zero to make all changes count."),
        min_value=0,
        initial=0)
    can_have_signature = forms.YesNoSwitch(label=_("Can have signature"))
    allow_signature_links = forms.YesNoSwitch(
        label=_("Can put links in signature"))
    allow_signature_images = forms.YesNoSwitch(
        label=_("Can put images in signature"))
    allow_signature_blocks = forms.YesNoSwitch(
        label=_("Can use text blocks in signature"),
        help_text=_("Controls whether or not users can put quote, code, "
                    "spoiler blocks and horizontal lines in signatures."))
Esempio n. 17
0
def UserIsActiveFormFactory(FormType, instance):
    is_active_fields = {
        'is_active':
        forms.YesNoSwitch(label=EditUserForm.IS_ACTIVE_LABEL,
                          help_text=EditUserForm.IS_ACTIVE_HELP_TEXT,
                          initial=instance.is_active),
        'is_active_staff_message':
        forms.CharField(
            label=EditUserForm.IS_ACTIVE_STAFF_MESSAGE_LABEL,
            help_text=EditUserForm.IS_ACTIVE_STAFF_MESSAGE_HELP_TEXT,
            initial=instance.is_active_staff_message,
            widget=forms.Textarea(attrs={'rows': 3}),
            required=False),
    }

    return type('UserIsActiveForm', (FormType, ), is_active_fields)
Esempio n. 18
0
class ForumOptionsForm(forms.ModelForm):
    is_hiding_presence = forms.YesNoSwitch()

    limits_private_thread_invites_to = forms.TypedChoiceField(
        coerce=int, choices=PRIVATE_THREAD_INVITES_LIMITS_CHOICES)

    subscribe_to_started_threads = forms.TypedChoiceField(
        coerce=int, choices=AUTO_SUBSCRIBE_CHOICES)

    subscribe_to_replied_threads = forms.TypedChoiceField(
        coerce=int, choices=AUTO_SUBSCRIBE_CHOICES)

    class Meta:
        model = get_user_model()
        fields = [
            'is_hiding_presence', 'limits_private_thread_invites_to',
            'subscribe_to_started_threads', 'subscribe_to_replied_threads'
        ]
Esempio n. 19
0
class ModerateSignatureForm(forms.ModelForm):
    signature = forms.CharField(
        label=_("Signature contents"),
        widget=forms.Textarea(attrs={'rows': 3}),
        required=False)
    is_signature_locked = forms.YesNoSwitch(
        label=_("Lock signature"),
        help_text=_("Setting this to yes will stop user from "
                    "making changes to his/her signature."))
    signature_lock_user_message = forms.CharField(
        label=_("User message"),
        help_text=_("Optional message to user explaining "
                    "why his/hers signature is locked."),
        widget=forms.Textarea(attrs={'rows': 3}),
        required=False)
    signature_lock_staff_message = forms.CharField(
        label=_("Staff message"),
        help_text=_("Optional message to team members explaining "
                    "why user signature is locked."),
        widget=forms.Textarea(attrs={'rows': 3}),
        required=False)

    class Meta:
        model = get_user_model()
        fields = [
            'signature',
            'is_signature_locked',
            'signature_lock_user_message',
            'signature_lock_staff_message'
        ]

    def clean_signature(self):
        data = self.cleaned_data['signature']

        length_limit = settings.signature_length_max
        if len(data) > length_limit:
            raise forms.ValidationError(ungettext(
                "Signature can't be longer than %(limit)s character.",
                "Signature can't be longer than %(limit)s characters.",
                length_limit) % {'limit': length_limit})

        return data
Esempio n. 20
0
class CategoryPermissionsForm(forms.Form):
    legend = _("Threads")

    can_see_all_threads = forms.TypedChoiceField(
        label=_("Can see threads"),
        coerce=int,
        initial=0,
        choices=((0, _("Started threads")), (1, _("All threads"))))

    can_start_threads = forms.YesNoSwitch(label=_("Can start threads"))
    can_reply_threads = forms.YesNoSwitch(label=_("Can reply to threads"))

    can_edit_threads = forms.TypedChoiceField(label=_("Can edit threads"),
                                              coerce=int,
                                              initial=0,
                                              choices=((0, _("No")),
                                                       (1, _("Own threads")),
                                                       (2, _("All threads"))))
    can_hide_own_threads = forms.TypedChoiceField(
        label=_("Can hide own threads"),
        help_text=_("Only threads started within time limit and "
                    "with no replies can be hidden."),
        coerce=int,
        initial=0,
        choices=((0, _("No")), (1, _("Hide threads")), (2,
                                                        _("Delete threads"))))
    thread_edit_time = forms.IntegerField(
        label=_("Time limit for own threads edits, in minutes"),
        help_text=_("Enter 0 to don't limit time for editing own threads."),
        initial=0,
        min_value=0)
    can_hide_threads = forms.TypedChoiceField(label=_("Can hide all threads"),
                                              coerce=int,
                                              initial=0,
                                              choices=((0, _("No")),
                                                       (1, _("Hide threads")),
                                                       (2,
                                                        _("Delete threads"))))

    can_pin_threads = forms.TypedChoiceField(label=_("Can pin threads"),
                                             coerce=int,
                                             initial=0,
                                             choices=((0, _("No")),
                                                      (1, _("Locally")),
                                                      (2, _("Globally"))))
    can_close_threads = forms.YesNoSwitch(label=_("Can close threads"))
    can_move_threads = forms.YesNoSwitch(label=_("Can move threads"))
    can_merge_threads = forms.YesNoSwitch(label=_("Can merge threads"))

    can_edit_posts = forms.TypedChoiceField(label=_("Can edit posts"),
                                            coerce=int,
                                            initial=0,
                                            choices=((0, _("No")),
                                                     (1, _("Own posts")),
                                                     (2, _("All posts"))))
    can_hide_own_posts = forms.TypedChoiceField(
        label=_("Can hide own posts"),
        help_text=
        _("Only last posts to thread made within edit time limit can be hidden."
          ),
        coerce=int,
        initial=0,
        choices=((0, _("No")), (1, _("Hide posts")), (2, _("Delete posts"))))
    post_edit_time = forms.IntegerField(
        label=_("Time limit for own post edits, in minutes"),
        help_text=_("Enter 0 to don't limit time for editing own posts."),
        initial=0,
        min_value=0)
    can_hide_posts = forms.TypedChoiceField(label=_("Can hide all posts"),
                                            coerce=int,
                                            initial=0,
                                            choices=((0, _("No")),
                                                     (1, _("Hide posts")),
                                                     (2, _("Delete posts"))))

    can_see_posts_likes = forms.TypedChoiceField(
        label=_("Can see posts likes"),
        coerce=int,
        initial=0,
        choices=((0, _("No")), (1, _("Number only")),
                 (2, _("Number and list of likers"))))
    can_like_posts = forms.YesNoSwitch(label=_("Can like posts"))

    can_protect_posts = forms.YesNoSwitch(
        label=_("Can protect posts"),
        help_text=_(
            "Only users with this permission can edit protected posts."))
    can_move_posts = forms.YesNoSwitch(
        label=_("Can move posts"),
        help_text=_("Will be able to move posts to other threads."))
    can_merge_posts = forms.YesNoSwitch(label=_("Can merge posts"))
    can_approve_content = forms.YesNoSwitch(
        label=_("Can approve content"),
        help_text=_("Will be able to see and approve unapproved content."))
    can_report_content = forms.YesNoSwitch(label=_("Can report posts"))
    can_see_reports = forms.YesNoSwitch(label=_("Can see reports"))

    can_hide_events = forms.TypedChoiceField(label=_("Can hide events"),
                                             coerce=int,
                                             initial=0,
                                             choices=((0, _("No")),
                                                      (1, _("Hide events")),
                                                      (2, _("Delete events"))))
Esempio n. 21
0
class EditUserForm(UserBaseForm):
    new_password = forms.CharField(label=_("Change password to"),
                                   widget=forms.PasswordInput,
                                   required=False)

    is_avatar_locked = forms.YesNoSwitch(
        label=_("Lock avatar"),
        help_text=_("Setting this to yes will stop user from "
                    "changing his/her avatar, and will reset "
                    "his/her avatar to procedurally generated one."))
    avatar_lock_user_message = forms.CharField(
        label=_("User message"),
        help_text=_("Optional message for user explaining "
                    "why he/she is banned form changing avatar."),
        widget=forms.Textarea(attrs={'rows': 3}),
        required=False)
    avatar_lock_staff_message = forms.CharField(
        label=_("Staff message"),
        help_text=_("Optional message for forum team members explaining "
                    "why user is banned form changing avatar."),
        widget=forms.Textarea(attrs={'rows': 3}),
        required=False)

    signature = forms.CharField(label=_("Signature contents"),
                                widget=forms.Textarea(attrs={'rows': 3}),
                                required=False)
    is_signature_locked = forms.YesNoSwitch(
        label=_("Lock signature"),
        help_text=_("Setting this to yes will stop user from "
                    "making changes to his/her signature."))
    signature_lock_user_message = forms.CharField(
        label=_("User message"),
        help_text=_("Optional message to user explaining "
                    "why his/hers signature is locked."),
        widget=forms.Textarea(attrs={'rows': 3}),
        required=False)
    signature_lock_staff_message = forms.CharField(
        label=_("Staff message"),
        help_text=_("Optional message to team members explaining "
                    "why user signature is locked."),
        widget=forms.Textarea(attrs={'rows': 3}),
        required=False)

    is_hiding_presence = forms.YesNoSwitch(label=_("Hides presence"))
    limits_private_thread_invites_to = forms.TypedChoiceField(
        label=_("Who can add user to private threads"),
        coerce=int,
        choices=PRIVATE_THREAD_INVITES_LIMITS_CHOICES)

    subscribe_to_started_threads = forms.TypedChoiceField(
        label=_("Started threads"), coerce=int, choices=AUTO_SUBSCRIBE_CHOICES)
    subscribe_to_replied_threads = forms.TypedChoiceField(
        label=_("Replid threads"), coerce=int, choices=AUTO_SUBSCRIBE_CHOICES)

    class Meta:
        model = get_user_model()
        fields = [
            'username', 'email', 'title', 'is_avatar_locked',
            'avatar_lock_user_message', 'avatar_lock_staff_message',
            'signature', 'is_signature_locked', 'is_hiding_presence',
            'limits_private_thread_invites_to', 'signature_lock_user_message',
            'signature_lock_staff_message', 'subscribe_to_started_threads',
            'subscribe_to_replied_threads'
        ]

    def clean_signature(self):
        data = self.cleaned_data['signature']

        length_limit = settings.signature_length_max
        if len(data) > length_limit:
            raise forms.ValidationError(
                ungettext(
                    "Signature can't be longer than %(limit)s character.",
                    "Signature can't be longer than %(limit)s characters.",
                    length_limit) % {'limit': length_limit})

        return data
Esempio n. 22
0
class PermissionsForm(forms.Form):
    legend = _("Forum access")

    can_see = forms.YesNoSwitch(label=_("Can see forum"))
    can_browse = forms.YesNoSwitch(label=_("Can see forum contents"))
Esempio n. 23
0
class YesNoForm(forms.Form):
    test_field = forms.YesNoSwitch(label='Hello!')
Esempio n. 24
0
class LimitedPermissionsForm(forms.Form):
    legend = _("Warnings")

    can_see_other_users_warnings = forms.YesNoSwitch(label=_("Can see other users warnings"))
Esempio n. 25
0
class PermissionsForm(forms.Form):
    legend = _("Threads")

    can_see_all_threads = forms.TypedChoiceField(
        label=_("Can see threads"),
        coerce=int,
        initial=0,
        choices=((0, _("Started threads")), (1, _("All threads"))))
    can_start_threads = forms.YesNoSwitch(label=_("Can start threads"))
    can_reply_threads = forms.YesNoSwitch(label=_("Can reply to threads"))
    can_edit_threads = forms.TypedChoiceField(label=_("Can edit threads"),
                                              coerce=int,
                                              initial=0,
                                              choices=((0, _("No")),
                                                       (1, _("Own threads")),
                                                       (2, _("All threads"))))
    can_hide_own_threads = forms.TypedChoiceField(
        label=_("Can hide own threads"),
        help_text=_("Only threads started within time limit and "
                    "with no replies can be hidden."),
        coerce=int,
        initial=0,
        choices=((0, _("No")), (1, _("Hide threads")), (2,
                                                        _("Delete threads"))))
    thread_edit_time = forms.IntegerField(
        label=_("Time limit for own threads edits, in minutes"),
        help_text=_("Enter 0 to don't limit time for editing own threads."),
        initial=0,
        min_value=0)
    can_hide_threads = forms.TypedChoiceField(label=_("Can hide all threads"),
                                              coerce=int,
                                              initial=0,
                                              choices=((0, _("No")),
                                                       (1, _("Hide threads")),
                                                       (2,
                                                        _("Delete threads"))))
    can_edit_posts = forms.TypedChoiceField(label=_("Can edit posts"),
                                            coerce=int,
                                            initial=0,
                                            choices=((0, _("No")),
                                                     (1, _("Own posts")),
                                                     (2, _("All posts"))))
    can_hide_own_posts = forms.TypedChoiceField(
        label=_("Can hide own posts"),
        help_text=_("Only last posts to thread made within "
                    "edit time limit can be hidden."),
        coerce=int,
        initial=0,
        choices=((0, _("No")), (1, _("Hide posts")), (2, _("Delete posts"))))
    post_edit_time = forms.IntegerField(
        label=_("Time limit for own post edits, in minutes"),
        help_text=_("Enter 0 to don't limit time for editing own posts."),
        initial=0,
        min_value=0)
    can_hide_posts = forms.TypedChoiceField(label=_("Can hide all posts"),
                                            coerce=int,
                                            initial=0,
                                            choices=((0, _("No")),
                                                     (1, _("Hide posts")),
                                                     (2, _("Delete posts"))))
    can_protect_posts = forms.YesNoSwitch(
        label=_("Can protect posts"),
        help_text=_("Only users with this permission "
                    "can edit protected posts."))
    can_move_posts = forms.YesNoSwitch(label=_("Can move posts"))
    can_merge_posts = forms.YesNoSwitch(label=_("Can merge posts"))
    can_change_threads_labels = forms.TypedChoiceField(
        label=_("Can change threads labels"),
        coerce=int,
        initial=0,
        choices=((0, _("No")), (1, _("Own threads")), (2, _("All threads"))))
    can_pin_threads = forms.YesNoSwitch(label=_("Can pin threads"))
    can_close_threads = forms.YesNoSwitch(label=_("Can close threads"))
    can_move_threads = forms.YesNoSwitch(label=_("Can move threads"))
    can_merge_threads = forms.YesNoSwitch(label=_("Can merge threads"))
    can_split_threads = forms.YesNoSwitch(label=_("Can split threads"))
    can_review_moderated_content = forms.YesNoSwitch(
        label=_("Can review moderated content"),
        help_text=_("Will see and be able to accept moderated content."))
    can_report_content = forms.YesNoSwitch(label=_("Can report posts"))
    can_see_reports = forms.YesNoSwitch(label=_("Can see reports"))
    can_hide_events = forms.TypedChoiceField(label=_("Can hide events"),
                                             coerce=int,
                                             initial=0,
                                             choices=((0, _("No")),
                                                      (1, _("Hide events")),
                                                      (2, _("Delete events"))))
Esempio n. 26
0
class EditUserForm(UserBaseForm):
    new_password = forms.CharField(label=_("Change password to"),
                                   widget=forms.PasswordInput,
                                   required=False)

    is_avatar_locked = forms.YesNoSwitch(
        label=_("Lock avatar"),
        help_text=_("Setting this to yes will stop user from "
                    "changing his/her avatar, and will reset "
                    "his/her avatar to procedurally generated one."))
    avatar_lock_user_message = forms.CharField(
        label=_("User message"),
        help_text=_("Optional message for user explaining "
                    "why he/she is banned form changing avatar."),
        widget=forms.Textarea(attrs={'rows': 3}),
        required=False)
    avatar_lock_staff_message = forms.CharField(
        label=_("Staff message"),
        help_text=_("Optional message for forum team members explaining "
                    "why user is banned form changing avatar."),
        widget=forms.Textarea(attrs={'rows': 3}),
        required=False)

    signature = forms.CharField(label=_("Signature contents"),
                                widget=forms.Textarea(attrs={'rows': 3}),
                                required=False)
    is_signature_locked = forms.YesNoSwitch(
        label=_("Lock signature"),
        help_text=_("Setting this to yes will stop user from "
                    "making changes to his/her signature."))
    signature_lock_user_message = forms.CharField(
        label=_("User message"),
        help_text=_("Optional message to user explaining "
                    "why his/hers signature is locked."),
        widget=forms.Textarea(attrs={'rows': 3}),
        required=False)
    signature_lock_staff_message = forms.CharField(
        label=_("Staff message"),
        help_text=_("Optional message to team members explaining "
                    "why user signature is locked."),
        widget=forms.Textarea(attrs={'rows': 3}),
        required=False)

    class Meta:
        model = get_user_model()
        fields = [
            'username', 'email', 'title', 'is_avatar_locked',
            'avatar_lock_user_message', 'avatar_lock_staff_message',
            'signature', 'is_signature_locked', 'signature_lock_user_message',
            'signature_lock_staff_message'
        ]

    def clean_signature(self):
        data = self.cleaned_data['signature']

        length_limit = settings.signature_length_max
        if len(data) > length_limit:
            raise forms.ValidationError(
                ungettext(
                    "Signature can't be longer than %(limit)s character.",
                    "Signature can't be longer than %(limit)s characters.",
                    length_limit) % {'limit': length_limit})

        return data
Esempio n. 27
0
def create_yesno(setting, kwargs, extra):
    return forms.YesNoSwitch(**kwargs)
Esempio n. 28
0
class ThreadCloseForm(forms.Form):
    is_supporting = True
    legend = _("Close thread")
    template = "misago/posting/threadcloseform.html"

    is_closed = forms.YesNoSwitch(label=_("Close thread"), initial=0)
Esempio n. 29
0
from django.contrib.auth import get_user_model
from django.core.exceptions import PermissionDenied
from django.utils.translation import ugettext_lazy as _

from misago.acl import algebra
from misago.acl.decorators import return_boolean
from misago.acl.models import Role
from misago.core import forms

from misago.users.permissions.decorators import authenticated_only
"""
Admin Permissions Form
"""
CAN_BROWSE_USERS_LIST = forms.YesNoSwitch(label=_("Can browse users list"),
                                          initial=1)
CAN_SEE_USERS_ONLINE_LIST = forms.YesNoSwitch(
    label=_("Can see users online list"))
CAN_SEARCH_USERS = forms.YesNoSwitch(label=_("Can search user profiles"),
                                     initial=1)
CAN_SEE_USER_NAME_HISTORY = forms.YesNoSwitch(
    label=_("Can see other members name history"))
CAN_SEE_BAN_DETAILS = forms.YesNoSwitch(
    label=_("Can see members bans details"),
    help_text=_("Allows users with this permission to see user and "
                "staff ban messages."))


class LimitedPermissionsForm(forms.Form):
    legend = _("User profiles")

    can_browse_users_list = CAN_BROWSE_USERS_LIST
Esempio n. 30
0
class AnonymousPermissionsForm(forms.Form):
    legend = _("Attachments")

    can_download_other_users_attachments = forms.YesNoSwitch(
        label=_("Can download attachments"))