Rebased migrations, all tests working.

This commit is contained in:
Nicholas Staples
2016-04-08 13:34:46 +01:00
parent 2abdad8d20
commit c4b316bde6
67 changed files with 392 additions and 1850 deletions

View File

@@ -91,12 +91,23 @@ class NotificationModelSchema(BaseSchema):
model = models.Notification
class TemplateSchema(BaseSchema):
class BaseTemplateSchema(BaseSchema):
class Meta:
model = models.Template
exclude = ("updated_at", "created_at", "service_id", "jobs")
class TemplateSchema(BaseTemplateSchema):
@validates_schema
def validate_type(self, data):
template_type = data.get('template_type')
if template_type and template_type == 'email':
subject = data.get('subject')
if not subject or subject.strip() == '':
raise ValidationError('Invalid template subject', 'subject')
class NotificationsStatisticsSchema(BaseSchema):
class Meta:
model = models.NotificationStatistics
@@ -140,7 +151,7 @@ class SmsNotificationSchema(NotificationSchema):
class EmailNotificationSchema(NotificationSchema):
to = fields.Str(required=True)
template = fields.Int(required=True)
template = fields.Str(required=True)
@validates('to')
def validate_to(self, value):
@@ -151,17 +162,17 @@ class EmailNotificationSchema(NotificationSchema):
class SmsTemplateNotificationSchema(SmsNotificationSchema):
template = fields.Int(required=True)
template = fields.Str(required=True)
job = fields.String()
class JobSmsTemplateNotificationSchema(SmsNotificationSchema):
template = fields.Int(required=True)
template = fields.Str(required=True)
job = fields.String(required=True)
class JobEmailTemplateNotificationSchema(EmailNotificationSchema):
template = fields.Int(required=True)
template = fields.Str(required=True)
job = fields.String(required=True)
@@ -220,8 +231,8 @@ class EmailDataSchema(ma.Schema):
class NotificationsFilterSchema(ma.Schema):
template_type = fields.Nested(TemplateSchema, only='template_type', many=True)
status = fields.Nested(NotificationModelSchema, only='status', many=True)
template_type = fields.Nested(BaseTemplateSchema, only=['template_type'], many=True)
status = fields.Nested(NotificationModelSchema, only=['status'], many=True)
page = fields.Int(required=False)
@pre_load