class User(db.Document): email = db.EmailField(unique=True) password = db.StringField(default=True) active = db.BooleanField(default=True) is_superuser = db.BooleanField(default=False) is_staff = db.BooleanField(default=False) last_login = db.DateTimeField(default=datetime.datetime.now()) date_joined = db.DateTimeField(default=datetime.datetime.now()) authenticated = db.BooleanField(default=False) def set_password(self, password): self.password = flask_bcrypt.generate_password_hash(password) def check_password(self, password): return flask_bcrypt.check_password_hash(self.password, password) def is_anonymous(self): return not self.authenticated def is_active(self): return self.active def is_authenticated(self): return self.authenticated def get_id(self): return self.id
class User(db.Document): username = db.StringField() password = db.BinaryField() email = db.EmailField() point = db.IntField(default=500) win = db.IntField(default=0) lose = db.IntField(default=0) isBot = db.BooleanField(default=False) created_at = db.DateTimeField(default=datetime.datetime.utcnow) def set_password(self, password): self.password = bcrypt.generate_password_hash(password) def check_password(self,password): return bcrypt.check_password_hash(pw_hash=self.password,password=password) @staticmethod def is_authenticated(): return True @staticmethod def is_active(): return True @staticmethod def is_anonymous(): return False def get_id(self): return self.username
class UserDetails(db.Document): name = db.StringField(required=True) email = db.EmailField(required=True) user_id = db.StringField(required=True) profile_pic = db.StringField() bio = db.StringField() verified = db.BooleanField() def to_json(self): return { "name": self.name, "email": self.email, "user_id": self.user_id } # @app.route('/add', methods=['POST']) # def add_user(): # user = User(name=request.form.get('name'), # email=request.form.get('email')) # try: # user.save() # except : # return "error" # return user.to_json() # @app.route('/get', methods=["GET"]) # def get_user(): # user = User.objects(email="*****@*****.**") # if not user: # return jsonify({'error': 'data not found'}) # else: # return user.to_json()
class User(UserMixin, BaseDocument): email = db.EmailField(verbose_name='email', required=True) username = db.StringField(verbose_name='username', required=True) password_hash = db.StringField(verbose_name='password', required=True) @property def password(self): raise AttributeError('password is not a readable attribute') @password.setter def password(self, password): self.password_hash = generate_password_hash(password) def verify_password(self, password): return check_password_hash(self.password_hash, password) def generate_auth_token(self, expiration): s = Serializer(current_app.config['SECRET_KEY'], expires_in=expiration) return s.dumps({'id': str(self.id)}) @staticmethod def verify_auth_token(token): s = Serializer(current_app.config['SECRET_KEY']) try: data = s.loads(token) except: return None return User.objects.get_or_404(id=ObjectId(data['id'])) def __repr__(self): return '<User %r>' % self.username
class Report(db.Document, PositionMixin, SerializableMixin): """A user submitted report""" created_at = db.DateTimeField(default=datetime.datetime.now) name = db.StringField(max_length=255) email = db.EmailField() telephone = db.StringField(max_length=255) address = db.StringField(max_length=255) between_streets = db.StringField(max_length=255) city = db.StringField(max_length=255) province = db.StringField(max_length=255) noise_type = db.StringField(max_length=255) severity = db.IntField(default=0, choices=[1, 2, 3, 4, 5]) comment = db.StringField(max_length=500) sound = db.StringField() def as_dict(self): """Report instance as dictionary. Overloads SerializableMixin.as_dict() for including noise_type_s, which is the noise_type as a human readable string. """ d = super().as_dict() d["noise_type_s"] = NOISE_TYPE_TO_STR.get(self.noise_type) return d
class User(db.Document): username = db.StringField(db_field="user_name", required=True, unique=True) password = db.StringField(db_field="password", required=True) email = db.EmailField(db_field="email", required=True, unique=True) first_name = db.StringField(db_field="first_name", max_length=50) last_name = db.StringField(db_field="last_name", max_length=50) created_at = db.IntField(db_field="created_at", default=utc_now_ts()) bio = db.StringField(db_field="bio", max_length=160) # confirm user email after register email_confirmed = db.BooleanField(db_field="email_confirmed", default=False) # the files will be changed and need confirm change_configuration = db.DictField(db_field="change_config") avatar = db.StringField(db_field="avatar", default=None) @classmethod def pre_save(cls, sender, document, **kwargs): document.username = document.username.lower() document.email = document.email.lower() def profile_imgsrc(self, size): if self.avatar: return url_for('static', filename=os.path.join( 'images', 'user', '%s.%s.%s.png' % (self.id, self.avatar, size))) else: return url_for('static', filename=os.path.join('images', 'user', 'no-profile.%s.png' % (size))) meta = {'indexes': ['username', 'email', '-created_at']}
class User(db.Document): username = db.StringField(max_length=20, unique=True, required=True) email = db.EmailField(unique=True, required=True) password = db.StringField(required=True) #reports = db.ListField(db.EmbeddedDocumentField(Report)) #ReferenceField(Report) reports = db.DictField()
class User(db.Document): name: db.StringField(default=True) email = db.EmailField(unique=True) password = db.StringField(default=True) active = db.BooleanField(default=True) isAdmin = db.BooleanField(default=False) timestamp = db.DateTimeField(default=datetime.datetime.now())
class Course(db.Document): courseName = db.StringField() courseID = db.StringField() profEmail = db.EmailField() # Students in the course students = db.ListField(db.ReferenceField('Profile'), null=True)
class User(UserMixin, db.Document): name = db.StringField(max_length=80, verbose_name="Name", help_text="Basically, who are you?") email = db.EmailField(max_length=255, unique=True, verbose_name="Email contact", help_text="Please, check your email") description = db.StringField(max_length=1024, verbose_name="Description", help_text="Tell us more about you") password = db.StringField(max_length=255, verbose_name="Password", help_text="Secret password") active = db.BooleanField(default=True) confirmed_at = db.DateTimeField() roles = db.ListField(db.ReferenceField(Role), default=[]) renderfields = ("name", "email", "description", "teams") renderfieldsaslist = ("teams") badge = "teams" def __str__(self): if (self.name): return ("%s" % self.name) else: return ("%s" % self.email) @property def teams(self): return Team.objects.filter(members__user=self)
class Account(db.Document): # Sign-in email = db.EmailField(required=True, primary_key=True) password = db.StringField(required=True) # Relationships team = db.ReferenceField('Team') profile = db.ReferenceField('Profile') # Core Info (Extra Credit) first_name = db.StringField(required=True) last_name = db.StringField(required=True) fsuid = db.StringField() signin = db.DateTimeField(null=True) # Admin status is_admin = db.BooleanField(null=True) def set_password(self, password): self.password = generate_password_hash(password) def check_password(self, password): return check_password_hash(self.password, password) def __repr__(self): return '<Account %r>' % self.email
class Account(db.Document): # Sign-in email = db.EmailField(required=True, primary_key=True) password = db.StringField(required=True) # Relationships team = db.ReferenceField('Team') # Core Info (Extra Credit) first_name = db.StringField(required=True) last_name = db.StringField(required=True) fsuid = db.StringField() signin = db.DateTimeField(null=True) # Admin status is_admin = db.BooleanField(null=True) def set_password(self, password): self.password = generate_password_hash(password) def check_password(self, password): return check_password_hash(self.password, password) def __repr__(self): return '<Account %r>' % self.email def __str__(self): return self.first_name + " " + self.last_name def clean(self): """ Make sure self.email is always lowercase. This function is automatically called on self.save() """ self.email = self.email.lower()
class StoresDB(db.Document): """""" store_id = db.StringField(required=True) store_name = db.StringField(db_field='sn', max_length=30, required=True, unique=True) description = db.StringField(db_field='d', max_length=900, required=True) url_prefix = db.URLField(db_field='up', required=True, unique=True) tag_name = db.StringField(db_field='tn', required=True) query = db.DictField(db_field='q', required=True) predefined_store = db.BooleanField(db_field='ps', default=False) mall = db.ReferenceField(MallDB, reverse_delete_rule=CASCADE) user = db.ReferenceField(UserDB, reverse_delete_rule=CASCADE) user_email = db.EmailField(db_field='ue') creation_date = db.DateTimeField(db_field='cd', default=time_now()) @classmethod def pre_save(cls, sender, document, **kwargs): """""" document.store_name = document.store_name.title() document.url_prefix = document.url_prefix.lower() document.tag_name = document.tag_name.lower() meta = { 'indexes': ['store_name', 'url_prefix', 'store_id', 'predefined_store'] }
class UserAccount(db.EmbeddedDocument): """""" created_at = db.DateTimeField(default=datetime.datetime.utcnow, required=True) # login related email = db.EmailField(required=True, unique=True) mobile_number = db.StringField() is_email_verified = db.BooleanField(default=False) _password = db.StringField(max_length=256) activate_key_expire_date = db.DateTimeField() # password @property def password(self): return self._password @password.setter def password(self, password): self._password = bcrypt.generate_password_hash(password).decode( 'utf-8') print(self._password) def check_password(self, password): if self.password is None: return False return bcrypt.check_password_hash(self.password, password) def to_json(self): return dict(created_at=str(self.created_at), email=self.email)
class Course(db.Document): name = db.StringField(required=True) professor_name = db.StringField(null=False) professor_email = db.EmailField(null=False) division = db.IntField(required=True) @property def num_students(self): return Account.objects(courses__contains=self).count() def __repr__(self): if self.professor_name: return '<Course %r - %r>' % (self.name, self.professor_name) else: return '<Course %r>' % self.name def __str__(self): if self.professor_name: return self.name + " - " + self.professor_name else: return self.name def clean(self): """ Make sure self.email is always lowercase. This function is automatically called on self.save() """ if self.professor_email: self.professor_email = self.professor_email.lower()
class User(db.Document, UserMixin): username = db.StringField(required=True) first_name = db.StringField(max_length=25) last_name = db.StringField(max_length=25) email = db.EmailField(max_length=35) password = db.StringField(max_length=255) roles = db.ListField(db.ReferenceField(Role), default=[]) def is_authenticated(self): return True def is_active(self): return True def is_anonymous(self): return False def get_id(self): return unicode(self.id) def __unicode__(self): return self.id def __repr__(self): return '<User %r>' % (self.username)
class User(db.Document): user_id = db.IntField(min_value=0, max_value=9001) created_at = db.DateTimeField(default=datetime.datetime.now, required=True) email = db.EmailField(max_length=255, required=True) username = db.StringField(max_length=255, required=True) #slug = db.StringField(max_length=255, required=True)#???? hashed_pass = db.StringField(max_length=255, required=True) meta = { #To declare admin users 'allow_inheritance': True } def is_authenticated(self): return True def is_active(self): return True def is_anonymous(self): return False def get_id(self): try: return unicode(self.username) except NameError: return normalize_from_unicode(self.username)
class User(db.Document): """The database uses mongoEngine and when called saves the user's details to the database""" username = db.StringField(db_field="u", required=True, unique=True) password = db.StringField(db_field="p", required=True) email = db.EmailField(db_field="e", required=True, unique=True) first_name = db.StringField(db_field="fn", max_length=50) last_name = db.StringField(db_field="ln", max_length=50) created = db.IntField(db_field="c", default=time_stamp()) bio = db.StringField(db_field="b", max_length=150) email_confirmed = db.BooleanField(db_field="ec", default=False) change_configuration = db.DictField(db_field="cc") profile_image = db.StringField(db_field="pi", default=None) def profile_image_src(self, size): """profile_image_src(str) -> return img path The profile function allows the user of the application to fetch the path of the desired image which will then be rendered to by the application :param size: Takes a string relating to the size of image """ if self.profile_image: return join_path( STATIC_IMAGE_URL, 'users', "{}.{}.{}.png".format(self.id, self.profile_image, size)).replace("\\", '/') return join_path(STATIC_IMAGE_URL, "users", "no_profile.jpg").replace("\\", '/') meta = {"indexes": ["username", "email", "-created"]}
class Worker(db.Document): email = db.EmailField(required=True) first_name = db.StringField(max_length=50) last_name = db.StringField(max_length=50) dob = db.StringField() identification = db.StringField() phone = db.IntField() availibility = db.BooleanField()
class User(db.Document): login = db.StringField(required=True, max_length=50) password = db.StringField(required=True, max_length=255) email = db.EmailField(required=True, max_length=50) bitcoin_wallet = db.StringField(max_length=50) avatar = db.StringField() date = db.DateTimeField(default=datetime.now) balance = db.IntField(default=0)
class UserLogins(db.Document): name = db.StringField(required=True) email = db.EmailField(required=True) password = db.StringField(required=True) token = db.ListField() signup_time = db.DateTimeField(required=True) def to_json(self): return {"name": self.name, "email": self.email}
class Shop(db.Document): name = db.StringField(required=True) slug = db.StringField() nit = db.StringField(required=True, unique=True) email = db.EmailField(required=True, unique=True) phone = db.IntField(required=True, unique=True) address = db.DictField() shipping = db.DictField() categories = db.ReferenceField(Category)
class User(db.Document): email = db.EmailField(required=True, unique=True) password = db.StringField(required=True, min_length=6) movies = db.ListField(db.ReferenceField('Movie', reverse_delete_rule=db.PULL)) def generate_password(self): self.password = generate_password_hash(self.password).decode('utf8') def check_password(self, password): return check_password_hash(self.password, password)
class Restaurant(db.Document): profile_picture = db.StringField( verbose_name=u'Profile Picture', default='https://s3.amazonaws.com/foodtruckfinder45/fast-food.png') name = db.StringField(verbose_name=u'Name', max_length=100, required=True) email = db.EmailField(verbose_name=u'Email', max_length=100, required=True, unique=True) pwd = db.StringField(verbose_name='Password', max_length=100, required=True) cuisine = db.StringField( verbose_name=u'Cuisine', max_length=100, required=True, ) isOpen = db.BooleanField(verbose_name=u'Open', default=False) hours = db.IntField(verbose_name=u'Hours', default=0) lat = db.DecimalField(verbose_name=u'Lat', default=0.00, precision=9) lng = db.DecimalField(verbose_name=u'Lng', default=0.00, precision=9) menu = db.ListField(db.DictField(verbose_name=u'Menu')) def __unicode__(self): return self.email def __init__(self, *args, **kwargs): super(Restaurant, self).__init__(*args, **kwargs) def set_password(self, password): self.pwd = generate_password_hash( password, method=current_app.config['PROJECT_PASSWORD_HASH_METHOD']) def check_password(self, password): return check_password_hash(self.pwd, password) def get_token(self): serializer = TimedSerializer(current_app.config['SECRET_KEY']) token = serializer.dumps(self.email) return token def check_token_password(self, token): serializer = TimedSerializer(current_app.config['SECRET_KEY']) full_token = '"' + self.email + '".' + token return serializer.loads(full_token, max_age=1800) def change_password(self, new_password): self.set_password(new_password)
class User(db.Document): """User class for mongodb document.""" user_id = db.StringField(primary_key=True) email = db.EmailField(unique=True, required=True) username = db.StringField(unique=True, required=True) password = db.StringField(default=True, required=True) mentor = db.StringField(default='admin') role = db.StringField(default='s', choices=ROLES) register_t = db.DateTimeField(default=datetime.datetime.now()) expire_t = db.DateTimeField(default=datetime.datetime.now()) last_active_t = db.DateTimeField(default=datetime.datetime.now()) game_status = db.StringField(default='')
class User(db.Document): uid = db.StringField(required=True, unique=True, default=lambda: uid_generator()) email = db.EmailField(required=True, unique=True) password = db.StringField(required=True) authorization = db.EmbeddedDocumentField(UserAuthorization, default=UserAuthorization) profile = db.EmbeddedDocumentField(UserProfile, default=UserProfile) activity = db.EmbeddedDocumentField(UserActivity, default=UserActivity) meta = {'indexes': ['email', 'uid'], 'ordering': ['-activity.created']} def hash_token(self, token): return pwd_context.encrypt(token) def verify_token(self, token): for db_token in self.activity.valid_tokens: if (pwd_context.verify(token, db_token)): return True return False def remove_token(self, token): for db_token in self.activity.valid_tokens: if (pwd_context.verify(token, db_token)): self.activity.valid_tokens.remove(db_token) return True return False def hash_password(self, password): self.password = pwd_context.encrypt(password) def verify_password(self, password): return pwd_context.verify(password, self.password) def generate_auth_token(self, expiration=600): # s = Serializer(app.config['SECRET_KEY'], expires_in=expiration) s = Serializer(SECRET_KEY, expires_in=expiration) return s.dumps({'uid': str(self.uid)}) @staticmethod def verify_auth_token(token): s = Serializer(SECRET_KEY) try: data = s.loads(token) except SignatureExpired: return None # valid token, but expired except BadSignature: return None # invalid token user = User.objects.filter(uid=data['uid']).first() return user
class Whitelist(db.Document): """A database model to hold an entry on the Whitelist. Only users that are on the Whitelist may make accounts with Eventum. Once they authenticate with the whitelisted email, a :class:`~app.models.User` object is made, but the whitelist entry remains, but is marked redeemed. :ivar date_created: :class:`mongoengine.fields.DateTimeField` - The date that the whitelist entry was created. :ivar date_modified: :class:`mongoengine.fields.DateTimeField` - The date when the whitelist entry was last modified. :ivar email: :class:`mongoengine.fields.EmailField` - The email to be whitelisted. :ivar user_type: :class:`mongoengine.fields.StringField` - The user type to associate with the email address. :ivar redeemed: :class:`mongoengine.fields.BooleanField` - True if the user has authenticated with this email and made an account on Eventum. """ date_created = db.DateTimeField(required=True, default=now) date_modified = db.DateTimeField(required=True, default=now) email = db.EmailField(required=True, unique=True) user_type = db.StringField(default='editor', regex=USER_TYPE_REGEX) redeemed = db.BooleanField(required=True, default=False) # MongoEngine ORM metadata meta = {'indexes': ['email']} def clean(self): """Called by Mongoengine on every ``.save()`` to the object. Updates ``date_modified``. """ self.date_modified = now() def __repr__(self): """The representation of this Whitelist entry. :returns: The entry's details. :rtype: str """ return 'Whitelist(email={}, user_type={}, redeemed={})'.fomrat( self.email, self.user_type, self.redeemed) def __unicode__(self): """This Whitelist entry, as a unicode string. :returns: The whitelisted email :rtype: str """ return 'Whitelist<%r>' % self.email
class Tracker(db.Document): _id = db.ObjectIdField() tracker_name = db.StringField() root_url = db.StringField() search_text = db.StringField() min_price = db.IntField() max_price = db.IntField() notify_email = db.EmailField() notify_every = db.IntField() notify_unit = db.StringField() notify_interval = db.IntField(validation=valid_notify_interval) last_notified_date = db.DateTimeField() def __repr__(self): return '<Tracker {}>'.format(self.tracker_name)
class Author(Document): username = db.StringField(max_length=32, required=True) email = db.EmailField(default=None) name = db.StringField(default=None) @property def json(self): return json.loads(self.to_json()) meta = {'collection': 'authors'} def clean(self): if Author.objects(email=self.email).count() > 0: raise ValidationError('(Error) Documento ya existe.') abort(500)
class Officer(db.Document): firstName = db.StringField(max_length=255, required=True) lastName = db.StringField(max_length=255, required=True) employeeNum = db.IntField() email = db.EmailField() address1 = db.StringField(max_length=255, required=False) address2 = db.StringField(max_length=255, required=False) city = db.StringField(max_length=255, required=False) state = db.StringField(max_length=255, required=False) zip = db.StringField(max_length=255, required=False) phone = db.StringField(max_length=255, required=False) rank = db.StringField(max_length=255, required=False) active = db.BooleanField(required=True) armed = db.BooleanField(required=True) customerID = db.StringField(max_length=255, required=True)