|
@@ -6,18 +6,19 @@ from misago.forms import YesNoSwitch
|
|
|
from misago.acl.exceptions import ACLError403, ACLError404
|
|
|
|
|
|
def make_form(request, role, form):
|
|
|
- form.base_fields['can_destroy_user_older_than'] = forms.IntegerField(label=_("Maximum Age of destroyed account (in days)"),
|
|
|
- help_text=_("Enter zero to disable this check."),
|
|
|
- initial=0, min_value=0, required=False)
|
|
|
- form.base_fields['can_destroy_user_with_more_posts_than'] = forms.IntegerField(label=_("Maximum number of posts on destroyed account"),
|
|
|
- help_text=_("Enter zero to disable this check."),
|
|
|
- initial=0, min_value=0, required=False)
|
|
|
+ if role.special != 'guest':
|
|
|
+ form.base_fields['can_destroy_user_older_than'] = forms.IntegerField(label=_("Maximum Age of destroyed account (in days)"),
|
|
|
+ help_text=_("Enter zero to disable this check."),
|
|
|
+ initial=0, min_value=0, required=False)
|
|
|
+ form.base_fields['can_destroy_user_with_more_posts_than'] = forms.IntegerField(label=_("Maximum number of posts on destroyed account"),
|
|
|
+ help_text=_("Enter zero to disable this check."),
|
|
|
+ initial=0, min_value=0, required=False)
|
|
|
|
|
|
- form.fieldsets.append((
|
|
|
- _("Destroying User Accounts"),
|
|
|
- ('can_destroy_user_older_than',
|
|
|
- 'can_destroy_user_with_more_posts_than')
|
|
|
- ))
|
|
|
+ form.fieldsets.append((
|
|
|
+ _("Destroying User Accounts"),
|
|
|
+ ('can_destroy_user_older_than',
|
|
|
+ 'can_destroy_user_with_more_posts_than')
|
|
|
+ ))
|
|
|
|
|
|
|
|
|
class DestroyUserACL(BaseACL):
|
|
@@ -26,6 +27,9 @@ class DestroyUserACL(BaseACL):
|
|
|
or self.acl['can_destroy_user_with_more_posts_than']):
|
|
|
raise ACLError403(_("You can't destroy user accounts."))
|
|
|
|
|
|
+ if user.is_god() or user.is_team:
|
|
|
+ raise ACLError403(_("This user account is protected and cannot be destroyed."))
|
|
|
+
|
|
|
if self.acl['can_destroy_user_older_than']:
|
|
|
user_age = timezone.now() - user.join_date
|
|
|
if user_age.days > self.acl['can_destroy_user_older_than']:
|
|
@@ -44,17 +48,17 @@ class DestroyUserACL(BaseACL):
|
|
|
|
|
|
|
|
|
def build(acl, roles):
|
|
|
- acl.destroy_user = DestroyUserACL()
|
|
|
- acl.destroy_user.acl['can_destroy_user_older_than'] = 0
|
|
|
- acl.destroy_user.acl['can_destroy_user_with_more_posts_than'] = 0
|
|
|
+ acl.destroyusers = DestroyUserACL()
|
|
|
+ acl.destroyusers.acl['can_destroy_user_older_than'] = 0
|
|
|
+ acl.destroyusers.acl['can_destroy_user_with_more_posts_than'] = 0
|
|
|
|
|
|
for role in roles:
|
|
|
try:
|
|
|
if (role['can_destroy_user_older_than']
|
|
|
- and role['can_destroy_user_older_than'] > acl.destroy_user.acl['can_destroy_user_older_than']):
|
|
|
- acl.special.acl['can_destroy_user_older_than'] = role['can_destroy_user_older_than']
|
|
|
+ and role['can_destroy_user_older_than'] > acl.destroyusers.acl['can_destroy_user_older_than']):
|
|
|
+ acl.destroyusers.acl['can_destroy_user_older_than'] = role['can_destroy_user_older_than']
|
|
|
if (role['can_destroy_user_with_more_posts_than']
|
|
|
- and role['can_destroy_user_with_more_posts_than'] > acl.destroy_user.acl['can_destroy_user_with_more_posts_than']):
|
|
|
- acl.special.acl['can_destroy_user_with_more_posts_than'] = role['can_destroy_user_with_more_posts_than']
|
|
|
+ and role['can_destroy_user_with_more_posts_than'] > acl.destroyusers.acl['can_destroy_user_with_more_posts_than']):
|
|
|
+ acl.destroyusers.acl['can_destroy_user_with_more_posts_than'] = role['can_destroy_user_with_more_posts_than']
|
|
|
except KeyError:
|
|
|
pass
|