fix: Use static() for script and style paths

Updates script and style paths to use Django's static() function
for better path resolution and management. This ensures that
the paths are correctly resolved relative to the static files
configuration, enhancing maintainability and reliability.
This commit is contained in:
Kumi 2024-11-21 07:47:17 +01:00
parent b6987bee69
commit 5dba14b378
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -78,7 +78,7 @@ class StatusCreateView(LoginRequiredMixin, CreateView):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
context["title"] = "Create Status" context["title"] = "Create Status"
context["subtitle"] = "How are you feeling today?" context["subtitle"] = "How are you feeling today?"
context["scripts"] = ["frontend/js/dropdown-to-buttons.js"] context["scripts"] = [static("frontend/js/dropdown-to-buttons.js")]
return context return context
def form_valid(self, form): def form_valid(self, form):
@ -110,7 +110,7 @@ class StatusEditView(LoginRequiredMixin, UpdateView):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
context["title"] = "Update Status" context["title"] = "Update Status"
context["subtitle"] = "Change a status you created before." context["subtitle"] = "Change a status you created before."
context["scripts"] = ["frontend/js/dropdown-to-buttons.js"] context["scripts"] = [static("frontend/js/dropdown-to-buttons.js")]
context["buttons"] = [ context["buttons"] = [
( (
reverse_lazy("mood:status_delete", kwargs={"id": self.kwargs["id"]}), reverse_lazy("mood:status_delete", kwargs={"id": self.kwargs["id"]}),
@ -268,12 +268,12 @@ class MoodEditView(LoginRequiredMixin, UpdateView):
context["title"] = "Edit Mood" context["title"] = "Edit Mood"
context["subtitle"] = "Make changes to the mood." context["subtitle"] = "Make changes to the mood."
context["scripts"] = [ context["scripts"] = [
"colorfield/jscolor/jscolor.js", static("colorfield/jscolor/jscolor.js"),
"colorfield/colorfield.js", static("colorfield/colorfield.js"),
"frontend/js/fontawesome-iconpicker.min.js", static("frontend/js/fontawesome-iconpicker.min.js"),
"frontend/js/iconpicker-loader.js", static("frontend/js/iconpicker-loader.js"),
] ]
context["styles"] = ["frontend/css/fontawesome-iconpicker.min.css"] context["styles"] = [static("frontend/css/fontawesome-iconpicker.min.css")]
return context return context
def get_object(self): def get_object(self):