1
0
Fork 0
mirror of https://gitlab.com/SIGBUS/nyaa.git synced 2024-12-22 14:49:59 +00:00

Clean up models.User.level helpers

This commit is contained in:
TheAMM 2017-05-20 21:56:22 +03:00
parent 95d2bff614
commit 752a5a1f95
2 changed files with 5 additions and 5 deletions

View file

@ -68,8 +68,8 @@ def handle_torrent_upload(upload_form, uploading_user=None, fromAPI=False):
torrent.remake = upload_form.is_remake.data
torrent.complete = upload_form.is_complete.data
# Copy trusted status from user if possible
torrent.trusted = (uploading_user.level >=
models.UserLevelType.TRUSTED) if uploading_user else False
can_mark_trusted = uploading_user and uploading_user.is_trusted
torrent.trusted = upload_form.is_trusted.data if can_mark_trusted else False
# Set category ids
torrent.main_category_id, torrent.sub_category_id = \
upload_form.category.parsed_data.get_category_ids()

View file

@ -382,15 +382,15 @@ class User(db.Model):
@property
def is_admin(self):
return self.level is UserLevelType.ADMIN or self.level is UserLevelType.SUPERADMIN
return self.level >= UserLevelType.ADMIN
@property
def is_superadmin(self):
return self.level is UserLevelType.SUPERADMIN
return self.level == UserLevelType.SUPERADMIN
@property
def is_trusted(self):
return self.level is UserLevelType.TRUSTED
return self.level >= UserLevelType.TRUSTED
# class Session(db.Model):