コード例 #1
0
ファイル: views.py プロジェクト: hbcbh1999/treeio
def event_add(request, date=None, hour=12, response_format="html"):
    "Event add form"

    if request.POST:
        if not "cancel" in request.POST:
            event = Event()
            form = EventForm(request.user.get_profile(), date, hour, request.POST, instance=event)
            if form.is_valid():
                event = form.save()
                event.set_user_from_request(request)
                return HttpResponseRedirect(reverse("events_event_view", args=[event.id]))
        else:
            return HttpResponseRedirect(reverse("events"))
    else:
        form = EventForm(request.user.get_profile(), date, hour)

    return render_to_response(
        "events/event_add", {"form": form}, context_instance=RequestContext(request), response_format=response_format
    )
コード例 #2
0
ファイル: views.py プロジェクト: vovkd/treeio
def event_edit(request, event_id, response_format='html'):
    "Event edit"

    event = get_object_or_404(Event, pk=event_id)
    if not request.user.get_profile().has_permission(event, mode='w'):
        return user_denied(request,
                           message="You don't have access to this Event")

    if request.POST:
        if not 'cancel' in request.POST:
            form = EventForm(request.user.get_profile(),
                             None,
                             None,
                             request.POST,
                             instance=event)
            if form.is_valid():
                event = form.save()
                return HttpResponseRedirect(
                    reverse('events_event_view', args=[event.id]))
        else:
            return HttpResponseRedirect(reverse('events'))
    else:
        form = EventForm(request.user.get_profile(), instance=event)

    return render_to_response('events/event_edit', {
        'event': event,
        'form': form
    },
                              context_instance=RequestContext(request),
                              response_format=response_format)
コード例 #3
0
ファイル: views.py プロジェクト: BenoitNorrin/treeio
def event_edit(request, event_id, response_format='html'):
    "Event edit"
    
    event = get_object_or_404(Event, pk=event_id)
    if not request.user.get_profile().has_permission(event, mode='w'):
        return user_denied(request, message="You don't have access to this Event")
    
    if request.POST:
        if not 'cancel' in request.POST:
            form = EventForm(request.user.get_profile(), None, None, request.POST, instance=event)
            if form.is_valid():
                event = form.save()
                return HttpResponseRedirect(reverse('events_event_view', args=[event.id]))
        else:
            return HttpResponseRedirect(reverse('events'))
    else:
        form = EventForm(request.user.get_profile(), instance=event)
    
    return render_to_response('events/event_edit',
                              {'event': event,
                               'form': form},
                              context_instance=RequestContext(request), response_format=response_format)
コード例 #4
0
ファイル: views.py プロジェクト: vovkd/treeio
def event_add(request, date=None, hour=12, response_format='html'):
    "Event add form"

    if request.POST:
        if not 'cancel' in request.POST:
            event = Event()
            form = EventForm(request.user.get_profile(),
                             date,
                             hour,
                             request.POST,
                             instance=event)
            if form.is_valid():
                event = form.save()
                event.set_user_from_request(request)
                return HttpResponseRedirect(
                    reverse('events_event_view', args=[event.id]))
        else:
            return HttpResponseRedirect(reverse('events'))
    else:
        form = EventForm(request.user.get_profile(), date, hour)

    return render_to_response('events/event_add', {'form': form},
                              context_instance=RequestContext(request),
                              response_format=response_format)