|
|
@ -3,7 +3,7 @@ from mongoengine import * |
|
|
|
|
|
|
|
|
|
|
|
from internal_lib.EncryptedField import EncryptedStringField |
|
|
|
from internal_lib.EncryptedField import EncryptedStringField |
|
|
|
from models.EmbededDocuments import Descriptions |
|
|
|
from models.EmbededDocuments import Descriptions |
|
|
|
from models.Group import Group |
|
|
|
from models.Group import Group, PaymentGroup |
|
|
|
from models.Union import Union |
|
|
|
from models.Union import Union |
|
|
|
from restapi import Methods |
|
|
|
from restapi import Methods |
|
|
|
|
|
|
|
|
|
|
@ -14,6 +14,7 @@ class User(Document): |
|
|
|
'index_cls': False, |
|
|
|
'index_cls': False, |
|
|
|
'auto_create_index': True, |
|
|
|
'auto_create_index': True, |
|
|
|
'can_query': True, |
|
|
|
'can_query': True, |
|
|
|
|
|
|
|
'with_sub_docs': True, |
|
|
|
"quyery": {}, |
|
|
|
"quyery": {}, |
|
|
|
'ignore_fields': ['password'], |
|
|
|
'ignore_fields': ['password'], |
|
|
|
'methods': [Methods.Get, Methods.List, Methods.Create], |
|
|
|
'methods': [Methods.Get, Methods.List, Methods.Create], |
|
|
@ -105,14 +106,16 @@ class User(Document): |
|
|
|
)) |
|
|
|
)) |
|
|
|
gnupg_fingerprint = StringField() |
|
|
|
gnupg_fingerprint = StringField() |
|
|
|
user_group = ReferenceField(Group) |
|
|
|
user_group = ReferenceField(Group) |
|
|
|
payment_group = ReferenceField(Group) |
|
|
|
payment_group = ReferenceField(PaymentGroup) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __unicode__(self): |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
return ' '.join([self.name, self.middle_name, self.last_name]) |
|
|
|
|
|
|
|
except: |
|
|
|
|
|
|
|
return str(self.id) |
|
|
|
|
|
|
|
|
|
|
|
def save(self, *args, **kwargs): |
|
|
|
def save(self, *args, **kwargs): |
|
|
|
|
|
|
|
if current_user: |
|
|
|
self.union = current_user.union |
|
|
|
self.union = current_user.union |
|
|
|
self.member_no = User.objects.filter(union=self.union).count() + 1 |
|
|
|
self.member_no = User.objects.filter(union=self.union).count() |
|
|
|
super(User, self).save(*args, **kwargs) |
|
|
|
super(User, self).save(*args, **kwargs) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|