2020-01-02 13:23:47 +00:00
|
|
|
from mongoengine import Document, StringField, DynamicField
|
2019-06-10 21:24:35 +00:00
|
|
|
|
2021-01-05 14:28:49 +00:00
|
|
|
from apiserver.database import Database, strict
|
|
|
|
from apiserver.database.model import DbModelMixin
|
|
|
|
from apiserver.database.model.base import GetMixin
|
|
|
|
from apiserver.database.model.company import Company
|
2019-06-10 21:24:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
class User(DbModelMixin, Document):
|
|
|
|
meta = {
|
2020-06-01 08:55:40 +00:00
|
|
|
"db_alias": Database.backend,
|
|
|
|
"strict": strict,
|
2019-06-10 21:24:35 +00:00
|
|
|
}
|
2020-06-01 08:55:40 +00:00
|
|
|
get_all_query_options = GetMixin.QueryParameterOptions(list_fields=("id",))
|
2019-06-10 21:24:35 +00:00
|
|
|
|
|
|
|
id = StringField(primary_key=True)
|
|
|
|
company = StringField(required=True, reference_field=Company)
|
|
|
|
name = StringField(required=True, user_set_allowed=True)
|
|
|
|
family_name = StringField(user_set_allowed=True)
|
|
|
|
given_name = StringField(user_set_allowed=True)
|
|
|
|
avatar = StringField()
|
2020-01-02 13:23:47 +00:00
|
|
|
preferences = DynamicField(default="", exclude_by_default=True)
|