示例#1
0
    def get_title(self):
        title = self.arguments['title']

        if not title:
            raise BadArgument("Title must not be empty.")

        return title
示例#2
0
 def get_element(self):
     try:
         element_pk = int(self.arguments['navigation_element'])
         return NavigationElement.objects.get(pk=element_pk)
     except (NavigationElement.DoesNotExist, ValueError):
         raise BadArgument("No navigation element found with ID '%s'." %
                           self.arguments['navigation_element'])
示例#3
0
 def get_event(self):
     try:
         event_pk = int(self.arguments['event'])
         return RegularEvent.objects.get(pk=event_pk)
     except (RegularEvent.DoesNotExist, ValueError):
         raise BadArgument("No event found with ID '%s'." %
                           self.arguments['event'])
示例#4
0
 def get_date(self):
     try:
         event_date = datetime.strptime(self.arguments['date'], '%Y%m%d')
         return event_date
     except ValueError:
         given = self.arguments['date']
         raise BadArgument("'%s' is not a valid date." % given)
示例#5
0
 def get_series(self):
     try:
         series_pk = int(self.arguments['series'])
         return SermonSeries.objects.get(pk=series_pk)
     except (SermonSeries.DoesNotExist, ValueError):
         raise BadArgument("No sermon series found with ID '%s'." %
                           self.arguments['series'])
示例#6
0
    def render(self, request, *args, **kwargs):
        element = self.get_element()
        try:
            self.move(element)
        except NavigationElement.DoesNotExist:
            raise BadArgument("Cannot move element.")

        return HttpResponse("Element moved.")
示例#7
0
    def get_parent(self):
        parent = self.arguments['parent']

        if not parent:
            return None

        try:
            return Page.objects.get(pk=parent)
        except (Page.DoesNotExist, ValueError):
            raise BadArgument("Page with ID '%s' not found." % parent)
示例#8
0
 def get_date(self, request, *args, **kwargs):
     date = request.GET['start_date']
     try:
         return datetime.strptime(date, '%Y%m%d').date()
     except ValueError:
         raise BadArgument("Invalid date '%s' provided." % date)