示例#1
0
文件: views.py 项目: jespersh/zamboni
def site_events(request, event_id=None):
    event = get_object_or_404(SiteEvent, pk=event_id) if event_id else None
    data = request.POST or None

    if event:
        form = SiteEventForm(data, instance=event)
    else:
        form = SiteEventForm(data)

    if request.method == "POST" and form.is_valid():
        form.save()
        return redirect("zadmin.site_events")
    pager = amo.utils.paginate(request, SiteEvent.objects.all(), 30)
    events = pager.object_list
    return jingo.render(request, "zadmin/site_events.html", {"form": form, "events": events})
示例#2
0
def site_events(request, event_id=None):
    event = get_object_or_404(SiteEvent, pk=event_id) if event_id else None
    data = request.POST or None

    if event:
        form = SiteEventForm(data, instance=event)
    else:
        form = SiteEventForm(data)

    if request.method == 'POST' and form.is_valid():
        form.save()
        return redirect('zadmin.site_events')
    pager = amo.utils.paginate(request, SiteEvent.objects.all(), 30)
    events = pager.object_list
    return render(request, 'zadmin/site_events.html', {
        'form': form, 'events': events})
示例#3
0
def site_events(request, event_id=None):
    event = get_object_or_404(SiteEvent, pk=event_id) if event_id else None
    data = request.POST or None

    if event:
        form = SiteEventForm(data, instance=event)
    else:
        form = SiteEventForm(data)

    if request.method == 'POST' and form.is_valid():
        form.save()
        return redirect('zadmin.site_events')
    pager = amo.utils.paginate(request, SiteEvent.objects.all(), 30)
    events = pager.object_list
    return render(request, 'zadmin/site_events.html', {
        'form': form, 'events': events})