Example #1
0
def EntryTypeEdit(request, guid):
    entrytype = get_object_or_404(EntryType, guid=guid, user=request.user)
    if request.method == "POST":
        f = EntryTypeModelForm(request.POST or None, request.FILES, instance=entrytype)
        if f.is_valid():
            f.save()
            messages.add_message(request, messages.INFO, "Media successfully changed.")
            return redirect("Replica:EditEntryType", guid=instance.guid)
    else:
        f = EntryTypeModelForm(instance=entrytype)
    ctx = {"form": f, "entrytype": entrytype, "adding": False}
    return render(request, "replica/dashboard/edit-entrytype.html", ctx)
Example #2
0
def EntryTypeNew(request):
    instance = EntryType(user=request.user)
    if request.method == "POST":
        f = EntryTypeModelForm(request.POST or None, request.FILES, instance=instance)
        if f.is_valid():
            f.save()
            messages.add_message(request, messages.INFO, "EntryType Added.")
            return redirect("Replica:EditEntryType", guid=instance.guid)
    else:
        f = EntryTypeModelForm(instance=instance)
    ctx = {"form": f, "adding": True}
    return render(request, "replica/dashboard/edit-entrytype.html", ctx)