mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Make add_or_update_user more efficient with upsert
This commit is contained in:
parent
8d2f4ba32e
commit
d415c27a89
@ -137,23 +137,17 @@ class PermissionsCrafty:
|
|||||||
limit_user_creation,
|
limit_user_creation,
|
||||||
limit_role_creation,
|
limit_role_creation,
|
||||||
):
|
):
|
||||||
try:
|
# http://docs.peewee-orm.com/en/latest/peewee/querying.html#upsert
|
||||||
user_crafty = UserCrafty.select().where(UserCrafty.user_id == user_id).get()
|
|
||||||
user_crafty.permissions = permissions_mask
|
UserCrafty.replace(
|
||||||
user_crafty.limit_server_creation = limit_server_creation
|
{
|
||||||
user_crafty.limit_user_creation = limit_user_creation
|
UserCrafty.user_id: user_id,
|
||||||
user_crafty.limit_role_creation = limit_role_creation
|
UserCrafty.permissions: permissions_mask,
|
||||||
UserCrafty.save(user_crafty)
|
UserCrafty.limit_server_creation: limit_server_creation,
|
||||||
except:
|
UserCrafty.limit_user_creation: limit_user_creation,
|
||||||
UserCrafty.insert(
|
UserCrafty.limit_role_creation: limit_role_creation,
|
||||||
{
|
}
|
||||||
UserCrafty.user_id: user_id,
|
).execute()
|
||||||
UserCrafty.permissions: permissions_mask,
|
|
||||||
UserCrafty.limit_server_creation: limit_server_creation,
|
|
||||||
UserCrafty.limit_user_creation: limit_user_creation,
|
|
||||||
UserCrafty.limit_role_creation: limit_role_creation,
|
|
||||||
}
|
|
||||||
).execute()
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_created_quantity_list(user_id):
|
def get_created_quantity_list(user_id):
|
||||||
|
Loading…
Reference in New Issue
Block a user