mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-23 15:56:45 -04:00
Merge branch 'master' into primary-provider
Conflicts: tests/app/dao/test_provider_rates_dao.py
This commit is contained in:
@@ -129,9 +129,19 @@ class TemplateSchema(BaseTemplateSchema):
|
||||
raise ValidationError('Invalid template subject', 'subject')
|
||||
|
||||
|
||||
class TemplateHistorySchema(BaseTemplateSchema):
|
||||
class TemplateHistorySchema(BaseSchema):
|
||||
|
||||
created_by = field_for(models.Template, 'created_by', required=True)
|
||||
class Meta:
|
||||
# Use the base model class that the history class is created from
|
||||
model = models.Template
|
||||
# We have to use a method here because the relationship field on the
|
||||
# history object is not created.
|
||||
created_by = fields.Method("populate_created_by", dump_only=True)
|
||||
created_at = field_for(models.Template, 'created_at', format='%Y-%m-%d %H:%M:%S.%f')
|
||||
|
||||
def populate_created_by(self, data):
|
||||
usr = models.User.query.filter_by(id=data.created_by_id).one()
|
||||
return {'id': str(usr.id), 'name': usr.name, 'email_address': usr.email_address}
|
||||
|
||||
|
||||
class NotificationsStatisticsSchema(BaseSchema):
|
||||
@@ -149,6 +159,10 @@ class ApiKeySchema(BaseSchema):
|
||||
|
||||
|
||||
class JobSchema(BaseSchema):
|
||||
created_by_user = fields.Nested(UserSchema, attribute="created_by",
|
||||
dump_to="created_by", only=["id", "name"], dump_only=True)
|
||||
created_by = field_for(models.Job, 'created_by', required=True, load_only=True)
|
||||
|
||||
class Meta:
|
||||
model = models.Job
|
||||
|
||||
|
||||
Reference in New Issue
Block a user