aboutsummaryrefslogtreecommitdiffstats
path: root/pyblackbird_cc/resources/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyblackbird_cc/resources/views.py')
-rw-r--r--pyblackbird_cc/resources/views.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/pyblackbird_cc/resources/views.py b/pyblackbird_cc/resources/views.py
index c1d7672..e96e701 100644
--- a/pyblackbird_cc/resources/views.py
+++ b/pyblackbird_cc/resources/views.py
@@ -15,6 +15,7 @@ from django.shortcuts import render
from . import services
from .forms import ResourceCreateForm
+from .forms import ResourceUpdateMetadataForm
from .models import PDFPageSnapshot
from .models import PDFResource
from .models import Resource
@@ -357,3 +358,25 @@ def hx_download_button(request):
"resources/hx_download_button.html",
{"pdf_url": _extract_metadata_from_resource(res).pdf_url},
)
+
+
+@login_required
+def update_resource_metadata(request, pk): # Change resource_id to pk
+ resource = get_object_or_404(Resource, pk=pk)
+
+ if request.method == "POST":
+ form = ResourceUpdateMetadataForm(request.POST, instance=resource)
+ if form.is_valid():
+ form.save()
+ return redirect(
+ "resources:resource_detail",
+ resource_id=resource.pk,
+ ) # Use pk instead of resource_id
+ else:
+ form = ResourceUpdateMetadataForm(instance=resource)
+
+ return render(
+ request,
+ "resources/resource_metadata_update.html",
+ {"form": form, "resource": resource},
+ )