mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 22:12:24 +01:00
Allow auto-approval for all users that aren't banned
This commit is contained in:
parent
0488b129fc
commit
41477980df
@ -118,7 +118,7 @@ def check_for_ban():
|
||||
if current_user.rank == models.UserRank.BANNED:
|
||||
current_user.rank = models.UserRank.MEMBER
|
||||
models.db.session.commit()
|
||||
elif current_user.ban or current_user.rank == models.UserRank.BANNED:
|
||||
elif current_user.is_banned:
|
||||
if current_user.ban:
|
||||
flash(gettext("Banned:") + " " + current_user.ban.message, "danger")
|
||||
else:
|
||||
|
@ -1066,7 +1066,7 @@ class PackageRelease(db.Model):
|
||||
return True
|
||||
|
||||
def check_perm(self, user, perm):
|
||||
if not user.is_authenticated:
|
||||
if not user.is_authenticated or user.is_banned:
|
||||
return False
|
||||
|
||||
if type(perm) == str:
|
||||
@ -1092,9 +1092,7 @@ class PackageRelease(db.Model):
|
||||
|
||||
return count > 0
|
||||
elif perm == Permission.APPROVE_RELEASE:
|
||||
return user.rank.at_least(UserRank.APPROVER) or \
|
||||
(is_maintainer and user.rank.at_least(
|
||||
UserRank.MEMBER if self.approved else UserRank.NEW_MEMBER))
|
||||
return is_maintainer or user.rank.at_least(UserRank.APPROVER)
|
||||
else:
|
||||
raise Exception("Permission {} is not related to releases".format(perm.name))
|
||||
|
||||
|
@ -192,6 +192,10 @@ class User(db.Model, UserMixin):
|
||||
|
||||
ban = db.relationship("UserBan", foreign_keys="UserBan.user_id", back_populates="user", uselist=False)
|
||||
|
||||
@property
|
||||
def is_banned(self):
|
||||
return (self.ban and not self.ban.has_expired) or self.rank == UserRank.BANNED
|
||||
|
||||
def get_dict(self):
|
||||
from app.utils.flask import abs_url_for
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user