model save actions

master
Mustafa Yontar 4 years ago
parent e473ad4045
commit dbef52ed66
  1. 8
      models/User.py

@ -1,3 +1,4 @@
from flask_jwt_extended import current_user
from mongoengine import * from mongoengine import *
from internal_lib.EncryptedField import EncryptedStringField from internal_lib.EncryptedField import EncryptedStringField
@ -14,6 +15,7 @@ class User(Document):
'auto_create_index': True, 'auto_create_index': True,
'can_query': True, 'can_query': True,
"quyery": {}, "quyery": {},
'ignore_fields': ['password'],
'methods': [Methods.Get, Methods.List, Methods.Create], 'methods': [Methods.Get, Methods.List, Methods.Create],
"indexes": [ "indexes": [
('union'), ('union'),
@ -105,6 +107,12 @@ class User(Document):
user_group = ReferenceField(Group) user_group = ReferenceField(Group)
payment_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)

Loading…
Cancel
Save