Ejemplo n.º 1
0
def revision_add(request):
    user = request.user
    error = None
    if request.method == 'POST':
        add_form = RevisionAddForm(None, False, request.POST)
        if add_form.is_valid():
            post_info = add_form.cleaned_data
            resp, error = _add_new_revision(request, post_info, user)
            if not error:
                return resp
        else:
            error = '''Missing Requried Fields.
                       Return to previous page for drawing field to re-auto-filter'''
    else:
        add_form = RevisionAddForm(drawing_name=None, edit=False)

    context = {'form':add_form, 'drawing':None, 'is_edit':False, 
               'error':error, 'username':user}
    return render(request, 'tracking/revision_add.html', context)
Ejemplo n.º 2
0
def revision_edit(request, drawing_name, rev_no):
    user = request.user

    error = None
    dwg = None
    if request.method == 'POST':
        edit_form = RevisionAddForm(None, True, request.POST)
        if edit_form.is_valid():
            post_info = edit_form.cleaned_data
            new_rev, dwg, error = _update_revision_info(drawing_name, rev_no,
                                                        post_info, user)
            if new_rev:
                rev_no = new_rev

    else:
        edit_form = RevisionAddForm(drawing_name=drawing_name, edit=True)

    if not dwg:
        dwg = Drawing.objects.get(name=drawing_name)
    revision = Revision.objects.filter(drawing=dwg).get(number=rev_no)
    context = {'drawing':dwg, 'revision':revision, 'form':edit_form, 
               'is_edit':True, 'error':error, 'username':user}
    return render(request, 'tracking/revision_add.html', context)