summaryrefslogtreecommitdiffstats
path: root/engagements/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'engagements/views.py')
-rw-r--r--engagements/views.py29
1 files changed, 26 insertions, 3 deletions
diff --git a/engagements/views.py b/engagements/views.py
index ae1abfd..2257a98 100644
--- a/engagements/views.py
+++ b/engagements/views.py
@@ -1,8 +1,11 @@
from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import LoginRequiredMixin
from django.db.models import Q
+from django.http import HttpResponse
from django.shortcuts import get_object_or_404, redirect, render
-from django.views.generic import ListView
+from django.template.loader import render_to_string
+from django.urls import reverse_lazy
+from django.views.generic import CreateView, ListView
from instruments.models import SubInstrument
@@ -12,8 +15,15 @@ from .forms import (
EngagementEffortRegulationCreateForm,
EngagementEffortReportingCreateForm,
EngagementEffortTravelCreateForm,
+ EngagementStrategyCreateForm,
)
-from .models import Engagement, EngagementEffort, EngagementType, Organisation
+from .models import Engagement, EngagementEffort, EngagementStrategy, EngagementType, Organisation
+
+
+def effort_detail(request, effort_id):
+ effort = get_object_or_404(EngagementEffort, id=effort_id)
+ html = render_to_string("engagements/snippets/effort_detail.html", {"effort": effort})
+ return HttpResponse(html)
class RegulatedEntitiesView(LoginRequiredMixin, ListView):
@@ -40,7 +50,7 @@ def htmx_effort_planned(request, effid):
else:
effort.is_planned = True
effort.save()
- return render(request, "engagements/snippets/effort_summary_panel.html", {"e" : effort})
+ return render(request, "engagements/snippets/effort_summary_panel.html", {"e": effort})
@login_required
@@ -147,6 +157,12 @@ def engagement_create(request, slug, reg=None):
ef.external_party = Organisation.objects.get(slug=slug)
ef.save()
return redirect("engagements:plan_for_org", orgslug=slug)
+ else:
+ return render(
+ request,
+ "engagements/engagement_form.html",
+ {"form": form, "title": f"Create Engagement for {slug}", "errors": form.errors},
+ )
else:
if reg:
form = EngagementCreateForm(
@@ -180,3 +196,10 @@ def engagement_create(request, slug, reg=None):
"engagements/engagement_form.html",
{"form": form, "title": "Add New Engagement"},
)
+
+
+class CreateEngagementStrategy(LoginRequiredMixin, CreateView):
+ model = EngagementStrategy
+ form_class = EngagementStrategyCreateForm
+ template_name = "engagements/engagement_strategy_form.html"
+ success_url = reverse_lazy("engagements:home")