Browse Source

Cleaned up attachments permissions. #29

Rafał Pitoń 11 years ago
parent
commit
e953339f1d

+ 5 - 4
misago/acl/permissions/privatethreads.py

@@ -91,10 +91,9 @@ def cleanup(acl, perms, forums):
                               'can_make_polls': False,
                               'can_vote_in_polls': False,
                               'can_see_poll_votes': False,
-                              'can_see_attachments': True,
                               'can_upload_attachments': False,
                               'can_download_attachments': True,
-                              'attachment_size': 100,
+                              'attachment_size': 300,
                               'attachment_limit': 3,
                               'can_approve': False,
                               'can_edit_labels': False,
@@ -124,9 +123,11 @@ def cleanup(acl, perms, forums):
                 acl.threads.acl[forum]['can_upload_attachments'] = True
             if perm['can_download_attachments_in_private_threads']:
                 acl.threads.acl[forum]['can_download_attachments'] = True
-            if perm['private_thread_attachment_size']:
+            if (perm['private_thread_attachment_size'] > acl.threads.acl[forum]['attachment_size']
+                    and acl.threads.acl[forum]['attachment_size'] != 0):
                 acl.threads.acl[forum]['attachment_size'] = perm['private_thread_attachment_size']
-            if perm['private_thread_attachments_limit']:
+            if (perm['private_thread_attachments_limit'] > acl.threads.acl[forum]['attachment_limit']
+                    and acl.threads.acl[forum]['attachment_limit'] != 0):
                 acl.threads.acl[forum]['attachment_limit'] = perm['private_thread_attachments_limit']
             if perm['can_invite_ignoring']:
                 acl.threads.acl[forum]['can_invite_ignoring'] = True

+ 2 - 5
misago/acl/permissions/threads.py

@@ -51,8 +51,6 @@ def make_forum_form(request, role, form):
                                                             widget=YesNoSwitch, initial=False, required=False)
     form.base_fields['can_vote_in_polls'] = forms.BooleanField(label=_("Can vote in polls"),
                                                                widget=YesNoSwitch, initial=False, required=False)
-    form.base_fields['can_see_attachments'] = forms.BooleanField(label=_("Can see attachments"),
-                                                                 widget=YesNoSwitch, initial=False, required=False)
     form.base_fields['can_upload_attachments'] = forms.BooleanField(label=_("Can upload attachments"),
                                                                     widget=YesNoSwitch, initial=False, required=False)
     form.base_fields['can_download_attachments'] = forms.BooleanField(label=_("Can download attachments"),
@@ -135,8 +133,8 @@ def make_forum_form(request, role, form):
                           ))
     form.fieldsets.append((
                            _("Attachments"),
-                           ('can_see_attachments', 'can_upload_attachments',
-                            'can_download_attachments', 'attachment_size', 'attachment_limit')
+                           ('can_upload_attachments', 'can_download_attachments',
+                            'attachment_size', 'attachment_limit')
                           ))
     form.fieldsets.append((
                            _("Moderation"),
@@ -772,7 +770,6 @@ def build_forums(acl, perms, forums, forum_roles):
                      'can_see_votes': False,
                      'can_make_polls': False,
                      'can_vote_in_polls': False,
-                     'can_see_attachments': False,
                      'can_upload_attachments': False,
                      'can_download_attachments': False,
                      'attachment_size': 100,

+ 3 - 4
misago/fixtures/forumsroles.py

@@ -23,11 +23,10 @@ def load():
                         'can_see_poll_votes': True,
                         'can_edit_polls': 0,
                         'can_delete_polls': 2,
-                        'can_see_attachments': True,
                         'can_upload_attachments': True,
                         'can_download_attachments': True,
                         'attachment_size': 5000,
-                        'attachment_limit': 15,
+                        'attachment_limit': 12,
                         'can_approve': True,
                         'can_change_prefixes': True,
                         'can_see_changelog': True,
@@ -64,8 +63,8 @@ def load():
                         'can_delete_polls': 1,
                         'can_upload_attachments': True,
                         'can_download_attachments': True,
-                        'attachment_size': 100,
-                        'attachment_limit': 3,
+                        'attachment_size': 500,
+                        'attachment_limit': 4,
                        }
     role.save(force_insert=True)
 

+ 6 - 6
misago/fixtures/userroles.py

@@ -32,7 +32,7 @@ def load():
                         'forums': {3: 1, 5: 1, 6: 1},
                        }
     role.save(force_insert=True)
-    
+
     role = Role(name=_("Moderator").message, _special='mod', protected=True)
     role.permissions = {
                         'name_changes_allowed': 3,
@@ -49,8 +49,8 @@ def load():
                         'can_use_private_threads': True,
                         'can_start_private_threads': True,
                         'can_upload_attachments_in_private_threads': True,
-                        'private_thread_attachment_size': 0,
-                        'private_thread_attachments_limit': 0,
+                        'private_thread_attachment_size': 500,
+                        'private_thread_attachments_limit': 4,
                         'can_invite_ignoring': True,
                         'private_threads_mod': True,
                         'can_delete_checkpoints': 1,
@@ -59,7 +59,7 @@ def load():
                         'forums': {3: 1, 5: 1, 6: 1},
                        }
     role.save(force_insert=True)
-    
+
     role = Role(name=_("Registered").message, _special='registered')
     role.permissions = {
                         'name_changes_allowed': 2,
@@ -71,14 +71,14 @@ def load():
                         'can_start_private_threads': True,
                         'can_upload_attachments_in_private_threads': False,
                         'private_thread_attachment_size': 100,
-                        'private_thread_attachments_limit': 30,
+                        'private_thread_attachments_limit': 3,
                         'can_invite_ignoring': False,
                         'private_threads_mod': False,
                         'can_report_content': True,
                         'forums': {4: 3, 5: 3, 6: 3},
                        }
     role.save(force_insert=True)
-    
+
     role = Role(name=_("Guest").message, _special='guest')
     role.permissions = {
                         'can_search_forums': True,