コード例 #1
0
ファイル: views.py プロジェクト: ThibaultR/BlueHive
def event_edit(request, event_id):
    if request.method == 'POST':
        form = EventForm(request.POST, instance=get_object_or_404(Event, pk=event_id))
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('BlueHive:event_overview'))
        else:
            print form.errors
            return render(request, 'BlueHive/event/event_edit.html', {'form': form})
    else:
        form = EventForm(instance=get_object_or_404(Event, pk=event_id))
        args = {}
        args.update(csrf(request))

        args['form'] = form
        args['event_id'] = event_id
        return render_to_response('BlueHive/event/event_edit.html', args)
コード例 #2
0
ファイル: views.py プロジェクト: ThibaultR/BlueHive
def event_add(request):
    if request.POST:
        form = EventForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/event/overview')
        else:
            return render(request, 'BlueHive/event/event_add.html', {'form': form})
    else:
        form = EventForm(initial={'location': 'LTU Lulea'})

    args = {}
    args.update(csrf(request))
    args['form'] = form
    args['user'] = request.user

    return render_to_response('BlueHive/event/event_add.html', args)