|
|
|
@ -3,7 +3,7 @@ from mongoengine import * |
|
|
|
|
|
|
|
|
|
from internal_lib.EncryptedField import EncryptedStringField |
|
|
|
|
from models.EmbededDocuments import Descriptions |
|
|
|
|
from models.Group import Group |
|
|
|
|
from models.Group import Group, PaymentGroup |
|
|
|
|
from models.Union import Union |
|
|
|
|
from restapi import Methods |
|
|
|
|
|
|
|
|
@ -14,19 +14,20 @@ class User(Document): |
|
|
|
|
'index_cls': False, |
|
|
|
|
'auto_create_index': True, |
|
|
|
|
'can_query': True, |
|
|
|
|
'with_sub_docs': True, |
|
|
|
|
"quyery": {}, |
|
|
|
|
'ignore_fields': ['password'], |
|
|
|
|
'methods': [Methods.Get, Methods.List, Methods.Create], |
|
|
|
|
"indexes": [ |
|
|
|
|
('union'), |
|
|
|
|
('username','union'), |
|
|
|
|
('username', 'union'), |
|
|
|
|
('accept_date') |
|
|
|
|
] |
|
|
|
|
} |
|
|
|
|
union = ReferenceField(Union) |
|
|
|
|
member_no = LongField() |
|
|
|
|
username = StringField() |
|
|
|
|
photo = ImageField(thumbnail_size=(85,120)) |
|
|
|
|
photo = ImageField(thumbnail_size=(85, 120)) |
|
|
|
|
password = StringField() |
|
|
|
|
name = StringField() |
|
|
|
|
middle_name = StringField() |
|
|
|
@ -105,14 +106,16 @@ class User(Document): |
|
|
|
|
)) |
|
|
|
|
gnupg_fingerprint = StringField() |
|
|
|
|
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) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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): |
|
|
|
|
if current_user: |
|
|
|
|
self.union = current_user.union |
|
|
|
|
self.member_no = User.objects.filter(union=self.union).count() |
|
|
|
|
super(User, self).save(*args, **kwargs) |
|
|
|
|