Exemple #1
0
def edit_meeting(request, meeting_id,
    template_name="schedule_tests/meetings/edit.html"):
    meeting = get_object_or_404(ClubMeeting, id = meeting_id)
 
    if request.method == 'POST':
        form = MeetingForm(request.POST, instance = meeting)
        if form.is_valid():
            event = EventRelation.objects.get_events_for_object(meeting, inherit=False)[0]
            event.start = form.cleaned_data['start']
            event.end = form.cleaned_data['end']
            event.title = form.cleaned_data['place']
            event.save()
            
            meeting = form.save(commit=False)
            meeting.save()
            
            return HttpResponseRedirect(reverse('show_meeting', args=(meeting.id,)))
        # if invalid, it gets displayed below
    else:
        form = MeetingForm(instance = meeting)
 
    return render_to_response(template_name, {
        'form': form,
        'meeting': meeting,
    }, context_instance=RequestContext(request))
Exemple #2
0
def create_meeting(request, club_id,
                   template_name="schedule_tests/meetings/new.html"):

    club = get_object_or_404(Club, id = club_id)
 
    if request.method == 'POST':
        form = MeetingForm(request.POST)
        if form.is_valid():
            calendar = Calendar.objects.get_calendar_for_object(club)
            
            meeting = form.save(commit=False)
            meeting.club = club
            meeting.calendar = calendar
            meeting.creator = request.user
            meeting.title = meeting.place
            meeting.save()
            
            return HttpResponseRedirect(reverse('show_meeting', args=(meeting.id,)))
        # if invalid, it gets displayed below
    else:
        form = MeetingForm(initial = {'club': club, 'start': datetime.datetime.now(), 'end': datetime.datetime.now()})
 
    return render_to_response(template_name, {
            'form': form,
            'club': club
        }, context_instance=RequestContext(request))