mirror of
https://github.com/fergalmoran/dss.git
synced 2026-01-06 00:44:16 +00:00
27 lines
843 B
Python
27 lines
843 B
Python
from tastypie.authorization import Authorization
|
|
from tastypie.exceptions import ImmediateHttpResponse
|
|
from tastypie.http import HttpBadRequest
|
|
|
|
from spa.api.v1.BackboneCompatibleResource import BackboneCompatibleResource
|
|
|
|
from spa.models import Show
|
|
from spa.models.show import ShowOverlapException
|
|
|
|
DATE_FORMAT = '%d/%m/%Y %H:%M:%S'
|
|
|
|
|
|
class ShowResource(BackboneCompatibleResource):
|
|
class Meta:
|
|
queryset = Show.objects.all()
|
|
authorization = Authorization()
|
|
resource_name = 'schedules'
|
|
|
|
def obj_create(self, bundle, **kwargs):
|
|
try:
|
|
return super(ShowResource, self).obj_create(bundle, **kwargs)
|
|
except ShowOverlapException:
|
|
raise ImmediateHttpResponse(
|
|
HttpBadRequest("This event overlaps with an existing event")
|
|
)
|
|
|