mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Merge branch 'master' into schedule-api-notification
This commit is contained in:
@@ -215,6 +215,21 @@ class Service(db.Model, Versioned):
|
||||
self.can_send_letters = LETTER_TYPE in [p.permission for p in self.permissions]
|
||||
self.can_send_international_sms = INTERNATIONAL_SMS_TYPE in [p.permission for p in self.permissions]
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, data):
|
||||
"""
|
||||
Assumption: data has been validated appropriately.
|
||||
|
||||
Returns a Service object based on the provided data. Deserialises created_by to created_by_id as marshmallow
|
||||
would.
|
||||
"""
|
||||
# validate json with marshmallow
|
||||
fields = data.copy()
|
||||
|
||||
fields['created_by_id'] = fields.pop('created_by')
|
||||
|
||||
return cls(**fields)
|
||||
|
||||
|
||||
class ServicePermission(db.Model):
|
||||
__tablename__ = "service_permissions"
|
||||
@@ -679,6 +694,7 @@ class Notification(db.Model):
|
||||
|
||||
id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||
to = db.Column(db.String, nullable=False)
|
||||
normalised_to = db.Column(db.String, nullable=True)
|
||||
job_id = db.Column(UUID(as_uuid=True), db.ForeignKey('jobs.id'), index=True, unique=False)
|
||||
job = db.relationship('Job', backref=db.backref('notifications', lazy='dynamic'))
|
||||
job_row_number = db.Column(db.Integer, nullable=True)
|
||||
|
||||
Reference in New Issue
Block a user