'detailed' flag on GET /service/<uuid>

if passed in, returns the service object with additional statistics
dictionary, which will be used in the admin app to populate dashboard
components. A new schema has been created for this to avoid clashing/
causing confusion with the existing schema, which is already used
for PUT/POST as well, and this schema can be easily tailored to
reduce ambiguity and lazy-loading
This commit is contained in:
Leo Hemsted
2016-07-18 12:03:44 +01:00
parent a355f3e544
commit 2d1babf2bb
5 changed files with 131 additions and 8 deletions

View File

@@ -123,6 +123,23 @@ class ServiceSchema(BaseSchema):
raise ValidationError('Only alphanumeric characters allowed')
class DetailedServiceSchema(BaseSchema):
statistics = fields.Dict()
class Meta:
model = models.Service
exclude = (
'api_keys',
'templates',
'users',
'created_by',
'jobs',
'template_statistics',
'service_provider_stats',
'service_notification_stats'
)
class NotificationModelSchema(BaseSchema):
class Meta:
model = models.Notification
@@ -486,6 +503,7 @@ user_schema = UserSchema()
user_schema_load_json = UserSchema(load_json=True)
service_schema = ServiceSchema()
service_schema_load_json = ServiceSchema(load_json=True)
detailed_service_schema = DetailedServiceSchema()
template_schema = TemplateSchema()
template_schema_load_json = TemplateSchema(load_json=True)
api_key_schema = ApiKeySchema()