Esempio n. 1
0
def add_user_event(request):
    if request.POST:
        form = UserEventForm(data=request.POST, prefix="user")
        if form.is_valid():
            when = form.save()
            who = Who(user=request.user, event=when.event)
            who.save()
            j = when.to_fullcalendar_dict(lambda when:True, "my_user")
            return HttpResponse(json.dumps(j))
        else:
            return False
Esempio n. 2
0
    def save(self, when=None): 
        if self.is_valid(): 
            f = self.cleaned_data 
            event = self._build_event(when)
            event.force_display=self.cleaned_data['force_display']
            event.subject_modality = SubjectModality.objects.filter( 
                subject=f['subject']).filter(type=f['modality']).get() 
            event.save() 
            event.places.clear()
            event.places.add(f['place']) 
            who = self._build_classgroup(when)
            who.event = event
            who.save()

            # add teacher
            contributor = self.cleaned_data['contributor']
            if contributor is not None:
                teacher = Who(user=contributor, is_contributor=True, event=event)
                teacher.save()
            when = self._build_when(when)
            when.event = event
            when.save()
            return when
        return False