コード例 #1
0
def fpr_edit_rule(request, uuid=None):
    rule = None
    if request.method == 'POST':
        valid_submission = False
        if uuid:
            rule = ppModels.FormatPolicyRule.objects.get(pk=uuid)
            form = FPREditRule(request.POST)
            if form.is_valid():
                rule.enabled = False
                rule.lastmodified = strftime("%Y-%m-%d %H:%M:%S", gmtime())
                rule.save()
            
                # now make a new object and save form into that
                newrule = form.save(commit=False)
                newrule.lastmodified = strftime("%Y-%m-%d %H:%M:%S", gmtime())
                newrule.replaces = rule.pk
                newrule.command = request.POST['command']
                newrule.formatID = request.POST['formatID']
                newrule.save()
                valid_submission = True
                uuid = newrule.pk
        else:
            form = FPREditRule(request.POST)
            if form.is_valid():
                newrule = form.save(commit=False)
                newrule.command = request.POST['command']
                newrule.formatID = request.POST['formatID']
                newrule.save()
                uuid = newrule.pk
                valid_submission = True
        if valid_submission:
            url = reverse('components.preservation_planning.views.fpr_edit_rule', kwargs={'uuid': uuid})
            return HttpResponseRedirect(url)
    else:
        if uuid:
            rule = ppModels.FormatPolicyRule.objects.get(pk = uuid)
            form = FPREditRule(instance=rule)
        else:
            form = FPREditRule()    

    return render(request, 'main/edit_rule_fpr.html', locals())
コード例 #2
0
ファイル: views.py プロジェクト: bavc/archivematica
def fpr_edit_rule(request, uuid=None):
    rule = None
    if request.method == "POST":
        valid_submission = False
        if uuid:
            rule = ppModels.FormatPolicyRule.objects.get(pk=uuid)
            form = FPREditRule(request.POST)
            if form.is_valid():
                rule.enabled = False
                rule.lastmodified = strftime("%Y-%m-%d %H:%M:%S", gmtime())
                rule.save()

                # now make a new object and save form into that
                newrule = form.save(commit=False)
                newrule.lastmodified = strftime("%Y-%m-%d %H:%M:%S", gmtime())
                newrule.replaces = rule.pk
                newrule.command = request.POST["command"]
                newrule.formatID = request.POST["formatID"]
                newrule.save()
                valid_submission = True
                uuid = newrule.pk
        else:
            form = FPREditRule(request.POST)
            if form.is_valid():
                newrule = form.save(commit=False)
                newrule.command = request.POST["command"]
                newrule.formatID = request.POST["formatID"]
                newrule.save()
                uuid = newrule.pk
                valid_submission = True
        if valid_submission:
            url = reverse("components.preservation_planning.views.fpr_edit_rule", kwargs={"uuid": uuid})
            return HttpResponseRedirect(url)
    else:
        if uuid:
            rule = ppModels.FormatPolicyRule.objects.get(pk=uuid)
            form = FPREditRule(instance=rule)
        else:
            form = FPREditRule()

    return render(request, "main/edit_rule_fpr.html", locals())
コード例 #3
0
def fpr_edit_rule(request, uuid=None):
    rule = None
    if uuid is not None:
        rule = FormatPolicyRule.objects.get(pk=uuid)
    else:
        form = FPREditRule()
    
    if request.POST:
        form = FPREditRule(request.POST, instance=rule)
        if form.is_valid():
            newrule = form.save()
            newrule.save()
            valid_submission = True
            
    else:
        form =FPREditRule(instance=rule)
    
    accessFormats = getFormatIDs('access')
    preservationFormats = getFormatIDs('preservation')
    
    return render(request, 'main/edit_rule_fpr.html', locals())