From dbef52ed669ef7c55b96a4c83f3cb147599d7784 Mon Sep 17 00:00:00 2001 From: Mustafa Yontar Date: Sun, 31 Jan 2021 02:02:14 +0300 Subject: [PATCH] model save actions --- models/User.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/models/User.py b/models/User.py index e88e6f4..f8f820a 100644 --- a/models/User.py +++ b/models/User.py @@ -1,3 +1,4 @@ +from flask_jwt_extended import current_user from mongoengine import * from internal_lib.EncryptedField import EncryptedStringField @@ -14,6 +15,7 @@ class User(Document): 'auto_create_index': True, 'can_query': True, "quyery": {}, + 'ignore_fields': ['password'], 'methods': [Methods.Get, Methods.List, Methods.Create], "indexes": [ ('union'), @@ -105,6 +107,12 @@ class User(Document): user_group = ReferenceField(Group) payment_group = ReferenceField(Group) + def save(self,*args, **kwargs): + self.union = current_user.union + self.member_no = User.objects.filter(union=self.union).count() + 1 + super(User, self).save(*args, **kwargs) + +