|
@@ -7,36 +7,36 @@ from misago.acl.exceptions import ACLError403, ACLError404
|
|
|
|
|
|
def make_form(request, role, form):
|
|
|
if role.special != 'guest':
|
|
|
- form.base_fields['can_destroy_user_older_than'] = forms.IntegerField(label=_("Maximum Age of destroyed account (in days)"),
|
|
|
+ form.base_fields['can_destroy_user_newer_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"),
|
|
|
+ form.base_fields['can_destroy_users_with_less_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')
|
|
|
+ ('can_destroy_user_newer_than',
|
|
|
+ 'can_destroy_users_with_less_posts_than')
|
|
|
))
|
|
|
|
|
|
|
|
|
class DestroyUserACL(BaseACL):
|
|
|
def allow_destroy_user(self, user):
|
|
|
- if not (self.acl['can_destroy_user_older_than']
|
|
|
- or self.acl['can_destroy_user_with_more_posts_than']):
|
|
|
+ if not (self.acl['can_destroy_user_newer_than']
|
|
|
+ or self.acl['can_destroy_users_with_less_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']:
|
|
|
+ if self.acl['can_destroy_user_newer_than']:
|
|
|
user_age = timezone.now() - user.join_date
|
|
|
- if user_age.days > self.acl['can_destroy_user_older_than']:
|
|
|
+ if user_age.days > self.acl['can_destroy_user_newer_than']:
|
|
|
raise ACLError403(_("You can't destroy this user account. It's too old."))
|
|
|
|
|
|
- if (self.acl['can_destroy_user_with_more_posts_than']
|
|
|
- and user.posts > self.acl['can_destroy_user_with_more_posts_than']):
|
|
|
+ if (self.acl['can_destroy_users_with_less_posts_than']
|
|
|
+ and user.posts > self.acl['can_destroy_users_with_less_posts_than']):
|
|
|
raise ACLError403(_("You can't destroy this user account. Too many messages were posted from it."))
|
|
|
|
|
|
def can_destroy_user(self, user):
|
|
@@ -49,16 +49,16 @@ class DestroyUserACL(BaseACL):
|
|
|
|
|
|
def build(acl, roles):
|
|
|
acl.destroy_users = DestroyUserACL()
|
|
|
- acl.destroy_users.acl['can_destroy_user_older_than'] = 0
|
|
|
- acl.destroy_users.acl['can_destroy_user_with_more_posts_than'] = 0
|
|
|
+ acl.destroy_users.acl['can_destroy_user_newer_than'] = 0
|
|
|
+ acl.destroy_users.acl['can_destroy_users_with_less_posts_than'] = 0
|
|
|
|
|
|
for role in roles:
|
|
|
try:
|
|
|
- if (role['can_destroy_user_older_than']
|
|
|
- and role['can_destroy_user_older_than'] > acl.destroy_users.acl['can_destroy_user_older_than']):
|
|
|
- acl.destroy_users.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_users.acl['can_destroy_user_with_more_posts_than']):
|
|
|
- acl.destroy_users.acl['can_destroy_user_with_more_posts_than'] = role['can_destroy_user_with_more_posts_than']
|
|
|
+ if (role['can_destroy_user_newer_than']
|
|
|
+ and role['can_destroy_user_newer_than'] > acl.destroy_users.acl['can_destroy_user_newer_than']):
|
|
|
+ acl.destroy_users.acl['can_destroy_user_newer_than'] = role['can_destroy_user_newer_than']
|
|
|
+ if (role['can_destroy_users_with_less_posts_than']
|
|
|
+ and role['can_destroy_users_with_less_posts_than'] > acl.destroy_users.acl['can_destroy_users_with_less_posts_than']):
|
|
|
+ acl.destroy_users.acl['can_destroy_users_with_less_posts_than'] = role['can_destroy_users_with_less_posts_than']
|
|
|
except KeyError:
|
|
|
pass
|