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

    Required parameters:
        - name  =>  the unique name (abbreviation) of the rush to edit (as a string)

    """
    log_page_view(request, 'Edit Rush')
    rush = _get_rush_or_404(name)
    if request.method == 'POST':
        form = RushForm(request.POST, instance=rush)
        if form.is_valid():
            form.save()
            return _get_redirect_from_rush(rush)
    else:
        if 'visible' in request.GET and request.GET.get('visible') == 'true':
            rush.visible = True
            rush.save()
            return _get_redirect_from_rush(rush)
        if 'delete' in request.GET and request.GET.get('delete') == 'true':
            name = rush.title()
            rush.delete()
            log.info('%s (%s) deleted %s', request.user.username,
                     request.user.get_full_name(), name)
            return HttpResponseRedirect(reverse('rush_list'))
        form = RushForm(instance=rush)
    return render(request,
                  'rush/edit.html', {
                      'rush_name': name,
                      'form': form
                  },
                  context_instance=RequestContext(request))
Esempio n. 2
0
def edit(request, name):
    """Render and process a form for users to modify an existing rush.

    Required parameters:
        - name  =>  the unique name (abbreviation) of the rush to edit (as a string)

    """
    log_page_view(request, 'Edit Rush')
    rush = _get_rush_or_404(name)
    if request.method == 'POST':
        form = RushForm(request.POST, instance=rush)
        if form.is_valid():
            form.save()
            return _get_redirect_from_rush(rush)
    else:
        if 'visible' in request.GET and request.GET.get('visible') == 'true':
            rush.visible = True
            rush.save()
            return _get_redirect_from_rush(rush)
        if 'delete' in request.GET and request.GET.get('delete') == 'true':
            name = rush.title()
            rush.delete()
            log.info('%s (%s) deleted %s', request.user.username, request.user.get_full_name(), name)
            return HttpResponseRedirect(reverse('rush_list'))
        form = RushForm(instance=rush)
    return render(request, 'rush/edit.html', {'rush_name': name, 'form': form}, context_instance=RequestContext(request))
Esempio n. 3
0
def add(request):
    """Render and process a form for users to create new rushes."""
    log_page_view(request, 'Add Rush')
    if request.method == 'POST':
        form = RushForm(request.POST)
        if form.is_valid():
            rush = form.save()
            log.info('%s (%s) created %s', request.user.username, request.user.get_full_name(), rush.title())
            return HttpResponseRedirect(reverse('rush_list'))
    else:
        form = RushForm()
    return render(request, 'rush/create.html', {'form': form}, context_instance=RequestContext(request))
Esempio n. 4
0
def add(request):
    """Render and process a form for users to create new rushes."""
    log_page_view(request, 'Add Rush')
    if request.method == 'POST':
        form = RushForm(request.POST)
        if form.is_valid():
            rush = form.save()
            log.info('%s (%s) created %s', request.user.username,
                     request.user.get_full_name(), rush.title())
            return HttpResponseRedirect(reverse('rush_list'))
    else:
        form = RushForm()
    return render(request,
                  'rush/create.html', {'form': form},
                  context_instance=RequestContext(request))