mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-18 21:48:49 -04:00
Work in progress, skeleton of the api created and testing started. Need to fix authentication tests.
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
from . import db
|
||||
|
||||
|
||||
def filter_null_value_fields(obj):
|
||||
return dict(
|
||||
filter(lambda x: x[1] is not None, obj.items())
|
||||
)
|
||||
|
||||
|
||||
class User(db.Model):
|
||||
__tablename__ = 'users'
|
||||
|
||||
@@ -9,6 +15,20 @@ class User(db.Model):
|
||||
created_at = db.Column(db.DateTime, index=False, unique=False, nullable=False)
|
||||
updated_at = db.Column(db.DateTime, index=False, unique=False, nullable=True)
|
||||
|
||||
# def serialize(self):
|
||||
# serialized = {
|
||||
# 'id': self.id,
|
||||
# 'name': self.name,
|
||||
# 'emailAddress': self.email_address,
|
||||
# 'locked': self.failed_login_count > current_app.config['MAX_FAILED_LOGIN_COUNT'],
|
||||
# 'createdAt': self.created_at.strftime(DATETIME_FORMAT),
|
||||
# 'updatedAt': self.updated_at.strftime(DATETIME_FORMAT),
|
||||
# 'role': self.role,
|
||||
# 'passwordChangedAt': self.password_changed_at.strftime(DATETIME_FORMAT),
|
||||
# 'failedLoginCount': self.failed_login_count
|
||||
# }
|
||||
# return filter_null_value_fields(serialized)
|
||||
|
||||
|
||||
user_to_service = db.Table(
|
||||
'user_to_service',
|
||||
@@ -29,15 +49,15 @@ class Service(db.Model):
|
||||
users = db.relationship('User', secondary=user_to_service, backref=db.backref('user_to_service', lazy='dynamic'))
|
||||
restricted = db.Column(db.Boolean, index=False, unique=False, nullable=False)
|
||||
|
||||
def serialize(self):
|
||||
serialized = {
|
||||
'id': self.id,
|
||||
'name': self.name,
|
||||
'createdAt': self.created_at.strftime(DATETIME_FORMAT),
|
||||
'active': self.active,
|
||||
'restricted': self.restricted,
|
||||
'limit': self.limit,
|
||||
'user': self.users.serialize()
|
||||
}
|
||||
# def serialize(self):
|
||||
# serialized = {
|
||||
# 'id': self.id,
|
||||
# 'name': self.name,
|
||||
# 'createdAt': self.created_at.strftime(DATETIME_FORMAT),
|
||||
# 'active': self.active,
|
||||
# 'restricted': self.restricted,
|
||||
# 'limit': self.limit,
|
||||
# 'user': self.users.serialize()
|
||||
# }
|
||||
|
||||
return filter_null_value_fields(serialized)
|
||||
# return filter_null_value_fields(serialized)
|
||||
|
||||
Reference in New Issue
Block a user