Esempio n. 1
0
def edit_event(request, id):
    """Render and process a form for users to modify an existing rush event.

    Required parameters:
        - id    =>  the unique ID of the rush event to edit (as an integer)

    """
    log_page_view(request, 'Edit Rush Event')
    event = get_object_or_404(RushEvent, id=id)
    if request.method == 'POST':
        form = RushEventForm(request.POST, instance=event)
        if form.is_valid():
            form.save()
            rush = event.rush
            rush.updated = datetime.now()
            rush.save()
            return _get_redirect_from_rush(rush)
    else:
        if 'delete' in request.GET and request.GET.get('delete') == 'true':
            log.info('%s (%s) deleted event \'%s\' from %s',
                     request.user.username, request.user.get_full_name(),
                     event.title, event.rush.title())
            event.delete()
            return _get_redirect_from_rush(event.rush)
        form = RushEventForm(instance=event)
    return render(request,
                  'rush/edit_event.html', {
                      'event_id': event.id,
                      'form': form
                  },
                  context_instance=RequestContext(request))
Esempio n. 2
0
def edit_event(request, id):
    """Render and process a form for users to modify an existing rush event.

    Required parameters:
        - id    =>  the unique ID of the rush event to edit (as an integer)

    """
    log_page_view(request, 'Edit Rush Event')
    event = get_object_or_404(RushEvent, id=id)
    if request.method == 'POST':
        form = RushEventForm(request.POST, instance=event)
        if form.is_valid():
            form.save()
            rush = event.rush
            rush.updated = datetime.now()
            rush.save()
            return _get_redirect_from_rush(rush)
    else:
        if 'delete' in request.GET and request.GET.get('delete') == 'true':
            log.info('%s (%s) deleted event \'%s\' from %s', request.user.username, request.user.get_full_name(),
                     event.title, event.rush.title())
            event.delete()
            return _get_redirect_from_rush(event.rush)
        form = RushEventForm(instance=event)
    return render(request, 'rush/edit_event.html', {'event_id': event.id, 'form': form},
                  context_instance=RequestContext(request))
Esempio n. 3
0
def add_event(request, name):
    """Render and process a form for users to create new rush events.

    Required parameters:
        - name  =>  the unique name (abbreviation) of the rush to which the new event should belong (as a string)

    """
    log_page_view(request, 'Add Rush Event')
    rush = _get_rush_or_404(name)
    if request.method == 'POST':
        form = RushEventForm(request.POST)
        if form.is_valid():
            event = form.save(commit=False)
            event.rush = rush
            event.save()
            rush.updated = datetime.now()
            rush.save()
            return _get_redirect_from_rush(rush)
    else:
        form = RushEventForm(initial={'rush': rush})
    return render(request,
                  'rush/add_event.html', {
                      'rush': rush,
                      'form': form
                  },
                  context_instance=RequestContext(request))
Esempio n. 4
0
def add_event(request, name):
    """Render and process a form for users to create new rush events.

    Required parameters:
        - name  =>  the unique name (abbreviation) of the rush to which the new event should belong (as a string)

    """
    log_page_view(request, 'Add Rush Event')
    rush = _get_rush_or_404(name)
    if request.method == 'POST':
        form = RushEventForm(request.POST)
        if form.is_valid():
            event = form.save(commit=False)
            event.rush = rush
            event.save()
            rush.updated = datetime.now()
            rush.save()
            return _get_redirect_from_rush(rush)
    else:
        form = RushEventForm(initial={'rush': rush})
    return render(request, 'rush/add_event.html', {'rush': rush, 'form': form}, context_instance=RequestContext(request))