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

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

        return title
Exemple #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'])
Exemple #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'])
Exemple #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)
Exemple #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'])
Exemple #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.")
Exemple #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)
Exemple #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)