mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 14:10:00 +00:00
Clean up models.User.level helpers
This commit is contained in:
parent
95d2bff614
commit
752a5a1f95
|
@ -68,8 +68,8 @@ def handle_torrent_upload(upload_form, uploading_user=None, fromAPI=False):
|
||||||
torrent.remake = upload_form.is_remake.data
|
torrent.remake = upload_form.is_remake.data
|
||||||
torrent.complete = upload_form.is_complete.data
|
torrent.complete = upload_form.is_complete.data
|
||||||
# Copy trusted status from user if possible
|
# Copy trusted status from user if possible
|
||||||
torrent.trusted = (uploading_user.level >=
|
can_mark_trusted = uploading_user and uploading_user.is_trusted
|
||||||
models.UserLevelType.TRUSTED) if uploading_user else False
|
torrent.trusted = upload_form.is_trusted.data if can_mark_trusted else False
|
||||||
# Set category ids
|
# Set category ids
|
||||||
torrent.main_category_id, torrent.sub_category_id = \
|
torrent.main_category_id, torrent.sub_category_id = \
|
||||||
upload_form.category.parsed_data.get_category_ids()
|
upload_form.category.parsed_data.get_category_ids()
|
||||||
|
|
|
@ -382,15 +382,15 @@ class User(db.Model):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_admin(self):
|
def is_admin(self):
|
||||||
return self.level is UserLevelType.ADMIN or self.level is UserLevelType.SUPERADMIN
|
return self.level >= UserLevelType.ADMIN
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_superadmin(self):
|
def is_superadmin(self):
|
||||||
return self.level is UserLevelType.SUPERADMIN
|
return self.level == UserLevelType.SUPERADMIN
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_trusted(self):
|
def is_trusted(self):
|
||||||
return self.level is UserLevelType.TRUSTED
|
return self.level >= UserLevelType.TRUSTED
|
||||||
|
|
||||||
|
|
||||||
# class Session(db.Model):
|
# class Session(db.Model):
|
||||||
|
|
Loading…
Reference in a new issue