Exemplo n.º 1
0
    def get(self):
        """
        Deliver an event as json or html.

        This method is included for the sake of
        completeness. Though unused, it might
        come in handy in a real-life situation.

        For example, you could request json from
        the eventMouseOver in fullcalendar, and
        display the description in a bubble, or
        request html from another app. For
        example,

        http://mydomain.com/jpycal/event/3001

        """
        # fetch the event
        e = Event.get_by_id(self.id)

        # format and deliver, based on expected output
        accept = self.request.META['HTTP_ACCEPT']
        if accept and accept == json_hdr:
            return HttpResponse(json.dumps(e.dict_()),
                                mimetype=json_hdr)
        else:
            return render_to_response('event.html', {'e':e})
Exemplo n.º 2
0
    def get(self):
        """
        Deliver an event as json or html.

        This method is included for the sake of
        completeness. Though unused, it might
        come in handy in a real-life situation.

        For example, you could request json from
        the eventMouseOver in fullcalendar, and
        display the description in a bubble, or
        request html from another app. For
        example,

        http://mydomain.com/jpycal/event/3001

        """
        # fetch the event
        e = Event.get_by_id(self.id)

        # format and deliver, based on expected output
        accept = self.request.META['HTTP_ACCEPT']
        if accept and accept == json_hdr:
            return HttpResponse(json.dumps(e.dict_()), mimetype=json_hdr)
        else:
            return render_to_response('event.html', {'e': e})
Exemplo n.º 3
0
    def put(self):
        """update an event"""
        f = self.f

        # fetch the event
        e = Event.get_by_id(self.id)

        # update and save
        e.start = f.has_key('start') and f['start'] or e.start
        e.end = f.has_key('end') and f['end'] or e.end
        if f.has_key('allDay'):
            e.allDay = f['allDay']
        e.title = f.has_key('title') and f['title'] or e.title
        e.description = f.has_key('description') and \
                            f['description'] or e.description
        e.put()

        # respond
        return HttpResponse('Event updated')
Exemplo n.º 4
0
    def put(self):
        """update an event"""
        f = self.f

        # fetch the event
        e = Event.get_by_id(self.id)

        # update and save
        e.start = f.has_key('start') and f['start'] or e.start
        e.end = f.has_key('end') and f['end'] or e.end
        if f.has_key('allDay'):
            e.allDay = f['allDay']
        e.title = f.has_key('title') and f['title'] or e.title
        e.description = f.has_key('description') and \
                            f['description'] or e.description
        e.put()

        # respond
        return HttpResponse('Event updated')