Beispiel #1
0
def update(request, bug):
    
    if request.method == 'POST':
        bugUpdateForm = BugUpdateForm(instance=bug, data=request.POST)
        bugnoteForm = BugnoteForm(prefix='note', data=request.POST)
        if bugUpdateForm.is_valid():
            bug = bugUpdateForm.save(commit=True)
            request.user.message_set.create(
                message=_('bug #%(bug_id)s updated' % {'bug_id': bug.id,}))
            if bugnoteForm.is_valid():
                bugnote = bugnoteForm.save(commit=False)
                bugnote.bug, bugnote.reporter = bug, request.user
                bugnote.save()
                request.user.message_set.create(
                    message=_('bugnote #%(bugnote_id)s added' %
                        {'bugnote_id': bugnote.id,}))
            return HttpResponseRedirect(bug.get_absolute_url())

    else:
        bugUpdateForm = BugUpdateForm(instance=bug)
        bugnoteForm = BugnoteForm(prefix='note')
    
    return direct_to_template(request, 'picket/bug_update.html',
        {'bug': bug, 'bug_update_form': bugUpdateForm,
            'bugnote_form': bugnoteForm,})
Beispiel #2
0
def annotate(request, bug):
    """
    @todo: handle bugnotes access rights
    """
    
    if request.method == 'POST':
        bugnoteForm = BugnoteForm(request.POST)
        if bugnoteForm.is_valid():
            bugnote = bugnoteForm.save(commit=False)
            bugnote.bug, bugnote.reporter = bug, request.user
            bugnote.save()
            request.user.message_set.create(message=_('Bugnote filed'))
            return HttpResponseRedirect(bugnote.get_absolute_url())
        else:
            return direct_to_template(request, 'picket/bugnote_form.html',
                {'bugnote_form': bugnoteForm, 'bug': bug,})
    else:
        return HttpResponseRedirect(bug.get_absolute_url())