You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Adunatio/models/User.py

119 lines
3.1 KiB

from flask_jwt_extended import current_user
4 years ago
from mongoengine import *
from internal_lib.EncryptedField import EncryptedStringField
from models.EmbededDocuments import Descriptions
from models.Group import Group
from models.Union import Union
from restapi import Methods
4 years ago
class User(Document):
meta = {
'index_background': True,
'index_cls': False,
'auto_create_index': True,
'can_query': True,
"quyery": {},
'ignore_fields': ['password'],
'methods': [Methods.Get, Methods.List, Methods.Create],
"indexes": [
('union'),
('username','union'),
('accept_date')
]
}
4 years ago
union = ReferenceField(Union)
member_no = LongField()
username = StringField()
photo = ImageField(thumbnail_size=(85,120))
password = StringField()
name = StringField()
middle_name = StringField()
last_name = StringField()
gov_id = EncryptedStringField()
mother_name = EncryptedStringField()
father_name = EncryptedStringField()
email = EncryptedStringField()
place_of_birth = EncryptedStringField()
date_of_birth = EncryptedStringField()
telephone = EncryptedStringField()
job = StringField()
address = EncryptedStringField()
accept_date = DateTimeField()
dismissal_date = DateTimeField()
descriptions = ListField(EmbeddedDocumentField(Descriptions))
gender = StringField(choices=(
'Man',
'Women',
'Agender',
'Androgyne',
'Androgynous',
'Bigender',
'Cis',
'Cisgender',
'Cis Female',
'Cis Male',
'Cis Man',
'Cis Woman',
'Cisgender Female',
'Cisgender Male',
'Cisgender Man',
'Cisgender Woman',
'Female to Male',
'FTM',
'Gender Fluid',
'Gender Nonconforming',
'Gender Questioning',
'Gender Variant',
'Genderqueer',
'Intersex',
'Male to Female',
'MTF',
'Neither',
'Neutrois',
'Non-binary',
'Other',
'Pangender',
'Trans',
'Trans*',
'Trans Female',
'Trans* Female',
'Trans Male',
'Trans* Male',
'Trans Man',
'Trans* Man',
'Trans Person',
'Trans* Person',
'Trans Woman',
'Trans* Woman',
'Transfeminine',
'Transgender',
'Transgender Female',
'Transgender Male',
'Transgender Man',
'Transgender Person',
'Transgender Woman',
'Transmasculine',
'Transsexual',
'Transsexual Female',
'Transsexual Male',
'Transsexual Man',
'Transsexual Person',
'Transsexual Woman',
'Two-Spirit'
))
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)
4 years ago