Esempio n. 1
0
def home(request):
    if request.method == 'POST' and request.is_ajax:
        form = EventForm(request.POST)
        status = {'status' : 'success'}

        if form.is_valid():
            title = form.cleaned_data['title']
            start = form.cleaned_data['start']
            end = form.cleaned_data['end']
            allDay = form.cleaned_data['allDay']

            event = CalendarEvents(title=title, start=start, end=end, allDay=allDay)
            event.save()

            status['message'] = 'Success!  Your event has been added to the calendar'

        else:
            status['status'] = 'fail'
            status['errors'] = dict(form.errors.items())
            status['message'] = 'Oops! Looks like the tubes got clogged'

        json_response = simplejson.dumps(status)
        return HttpResponse(json_response, mimetype='application/json')

    else:
        form = EventForm
    return render_to_response('core/home.html', {'form': form}, context_instance=RequestContext(request))
Esempio n. 2
0
from core.models import CalendarEvents

e1 = CalendarEvents(title="Test", start="1325923200", end="1325944800", allDay=False)
e2 = CalendarEvents(title="Test2", start="1326412800", end="1326585600", allDay=True)
e3 = CalendarEvents(title="Test3", start="1327881600", end="1327968000", allDay=True)
e1.save()
e2.save()
e3.save()