Created
February 10, 2020 21:51
-
-
Save Theodore-Rose/30c613c1e7f2a3f1606f77ef6febc230 to your computer and use it in GitHub Desktop.
User model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@uc_schema_mixin | |
class User(UcDocument, BaseUcFlaskUserMixin): | |
email = LowercasingEmailField(unique=True) | |
password = StringField(max_length=255) | |
active = BooleanField(default=True) | |
confirmed_at = DateTimeField() | |
last_login_at = DateTimeField() | |
current_login_at = DateTimeField() | |
# The last time when this use was active. This is stored with millis accuracy but is | |
# computed with a lower accuracy (currently day). | |
last_active_at = DateTimeField() | |
last_login_ip = StringField(max_length=255) | |
current_login_ip = StringField(max_length=255) | |
login_count = IntField() | |
roles = ListField(ReferenceField(Role, dbref=False), default=[]) | |
consumer_app_device_token = EmbeddedDocumentField(DeviceToken) | |
agents_app_device_token = EmbeddedDocumentField(DeviceToken) | |
device_token = EmbeddedDocumentField(DeviceToken) | |
# lists of experiments that are force-{en,dis}abled for this user. | |
# Sticking an experiment in both lists should be impossible, but in case | |
# force disabling wins over force-enabling. | |
force_enabled_experiments = ListField(StringField()) | |
force_disabled_experiments = ListField(StringField()) | |
agent_profile = EmbeddedDocumentField(AgentProfile) | |
# This is the UserId of the NS that created this customer (if created via unconfirmed) | |
created_by = ObjectIdField() | |
# This is the channel by which the customer came to UC / a UC Agent | |
channel = EnumValueField(CustomerChannel) | |
channel_tag = StringField() # This allows finer-grained dimensioning by-channel | |
# Stores oauth information. See user.thrift for more details | |
oauth = EmbeddedDocumentField(OAuth) | |
# Stores user last_updated_at field for auditing and data port job | |
last_updated_at = DateTimeField() | |
def save(self, *args, **kwargs): | |
self.last_updated_at = datetime.utcnow() | |
super(User, self).save(*args, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment