def clean_album_and_timeslot(self): album_id = self.params.get('AlbumId', None) timeslot_id = self.params.get('TimeslotId', None) if album_id and timeslot_id: raise BadRequest(message="There is AlbumId and TimeslotId. Should be only one.") if not timeslot_id and not album_id: raise ParameterExpected(parameter="AlbumId or TimeslotId") if album_id: try: self.album = self.caching.get_album(album_id) except ValueError: raise WrongParameter(parameter='AlbumId') except Albums.DoesNotExist: raise NotFound(message='There is no album with id %s.' % album_id) if timeslot_id: try: timeslot = self.caching.get_timeslot(timeslot_id) except ValueError: raise WrongParameter(parameter='TimeslotId') except TimeSlots.DoesNotExist: raise NotFound(message="There is no timeslot with id %s." % timeslot_id) else: self.album = timeslot.AlbumId
def _clean_episode(self): try: return Episodes.objects.get(EpisodeId=self.episode_id) except ValueError: raise WrongParameter(parameter='EpisodeId') except Episodes.DoesNotExist: raise NotFound( message='There is no episode with id %s' % self.episode_id)
def _clean_trailer(self): try: return Trailers.objects.get(TrailerId=self.trailer_id) except ValueError: raise WrongParameter(parameter='TrailerId') except Trailers.DoesNotExist: raise NotFound(message='There is no trailer with id %s' % self.trailer_id)
def clean(self): if not self.timeslot.is_current(): raise NoContent(message='Timeslot is no current') self.timeslot_videos = TimeSlotVideos.objects\ .filter(TimeSlotsId=self.timeslot)\ .order_by('Order') if not self.timeslot_videos: raise NotFound(message='There are no videos in timeslot %s' % self.timeslot)
def clean_episode(self): episode_id = self.params.get('EpisodeId', None) if not episode_id: ParameterExpected(parameter='EpisodeId') try: self.episode = self.caching.get_episode(episode_id) except ValueError: raise WrongParameter(parameter='EpisodeId') except Episodes.DoesNotExist: raise NotFound(message='There is no episode with id %s.' % episode_id)
def index(request): dashboard = Dashboard() chart_name = request.GET.get('chart', None) if chart_name: if chart_name not in Dashboard._chartList: context = NotFound(message='Unexpected chart %s' % chart_name).get_dict() response = HttpResponse(simplejson.dumps(context)) return response chart_factory = getattr(dashboard, chart_name) chart = chart_factory() return HttpResponse(simplejson.dumps(chart.toDict()), content_type="application/json") else: dashboard.charts = Dashboard._chartList dashboard = dashboard.toDict() return render_to_response('admin/pipture/dashboard.html', {'dashboard': dashboard}, context_instance=RequestContext(request))
def get_context_data(self): raise NotFound(message='Unknown method')