diff options
Diffstat (limited to '')
-rw-r--r-- | ctrack/organisations/templates/organisations/organisation_detail.html | 29 | ||||
-rw-r--r-- | ctrack/register/forms.py | 49 | ||||
-rw-r--r-- | ctrack/register/templates/register/engagementevent_form.html | 32 | ||||
-rw-r--r-- | ctrack/register/urls.py | 10 | ||||
-rw-r--r-- | ctrack/register/views.py | 18 |
5 files changed, 135 insertions, 3 deletions
diff --git a/ctrack/organisations/templates/organisations/organisation_detail.html b/ctrack/organisations/templates/organisations/organisation_detail.html index 2479f50..29d188c 100644 --- a/ctrack/organisations/templates/organisations/organisation_detail.html +++ b/ctrack/organisations/templates/organisations/organisation_detail.html @@ -95,6 +95,35 @@ </div> </div> </div> + <div class="row"> + <div class="col-md-12 my-2"> + <div class="card bg-light"> + <div class="card-body"> + <div class="card-title">OES Engagements<a href="#" class="btn btn-primary btn-sm float-right">Add + new...</a></div> + <div class="table table-responsive"> + <table class="table"> + {% if engagement_events|length > 0 %} + {% for event in engagement_events %} + <tr> + <td><a href="{% url "caf:ass_detail" ass.id %}">{{ ass.name }}</a></td> + <td>{{ ass.description }}<br> + <a href="{% url "caf:detail" ass.caf.pk %}" class="small"> + {{ ass.caf }} + </a> <span class="text-muted"> | <a href="#" class="small">Edit System</a></span> + </td> + </tr> + {% endfor %} + {% else %} + <a class="btn btn-primary" href="{% url "caf:create_from_org" object.slug %}" role="button">Add + new...</a> + {% endif %} + </table> + </div> + </div> + </div> + </div> + </div> <div class="row"> <div class="col-12 mt-3"> <h4>Addresses</h4> diff --git a/ctrack/register/forms.py b/ctrack/register/forms.py new file mode 100644 index 0000000..021414d --- /dev/null +++ b/ctrack/register/forms.py @@ -0,0 +1,49 @@ +from crispy_forms.helper import FormHelper +from crispy_forms.layout import Button, ButtonHolder, Layout, Submit +from django import forms +from django.urls import reverse + +from ctrack.register.models import EngagementEvent + + +class EngagementEventCreateForm(forms.ModelForm): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + cancel_redirect = reverse("core:home") + self.helper = FormHelper(self) + self.helper.layout = Layout( + "type", + "short_description", + "participants", + "user", + "date", + "end_date", + "document_link", + "response_date_requested", + "response_received", + "related_caf", + "comments", + ButtonHolder( + Submit("submit", "Submit", css_class="btn-primary"), + Button( + "cancel", + "Cancel", + onclick=f"location.href='{cancel_redirect}';", + css_class="btn-danger", + ), + ), + ) + + def save(self, commit=True): + ee = super().save(commit=False) + if commit: + ee.save() + return ee + + class Meta: + model = EngagementEvent + fields = "__all__" + widgets = { + "date": forms.DateTimeInput(attrs={"type": "date"}), + "end_date": forms.DateTimeInput(attrs={"type": "date"}), + } diff --git a/ctrack/register/templates/register/engagementevent_form.html b/ctrack/register/templates/register/engagementevent_form.html new file mode 100644 index 0000000..972ad52 --- /dev/null +++ b/ctrack/register/templates/register/engagementevent_form.html @@ -0,0 +1,32 @@ +{% extends "base.html" %} + +{% block title %} + Register a new OES event +{% endblock title %} + +{% load crispy_forms_tags %} + +{% block content %} + <div class="container mt-3"> + <div class="row"> + <div class="col-md-12 pl-0 my-2"> + <h4>Register a new OES event</h4> + </div> + </div> + <div class="row"> + <div class="col-md-7 pt-2 border bg-light"> + {% crispy form %} + </div> + <div class="col-sm-5"> + <div class="card" style="width: 18rem;"> + <div class="card-body"> + <h5 class="card-title">Help on Engagement Events</h5> + <p class="card-text">An organisation is the parent/operating company. There is probably advice and + proper definitions for this somewhere. Maybe if you click the link below, it will take you there?</p> + <a href="#" class="btn btn-primary">Go somewhere</a> + </div> + </div> + </div> + </div> + </div> +{% endblock content %} diff --git a/ctrack/register/urls.py b/ctrack/register/urls.py index 567ef2f..4d9c219 100644 --- a/ctrack/register/urls.py +++ b/ctrack/register/urls.py @@ -1,3 +1,11 @@ -#from django.urls import path +from django.urls import path + +from ctrack.register.views import EngagementEventCreate app_name = "register" + +urlpatterns = [ + path( + "engagement-event/create/", view=EngagementEventCreate.as_view(), name="create" + ), +] diff --git a/ctrack/register/views.py b/ctrack/register/views.py index 01a38ba..deae422 100644 --- a/ctrack/register/views.py +++ b/ctrack/register/views.py @@ -1,3 +1,17 @@ -#from django.shortcuts import render +from django.contrib.auth.mixins import LoginRequiredMixin +from django.http import HttpResponseRedirect +from django.urls import reverse, reverse_lazy +from django.views.generic import FormView -# Create your views here. +from ctrack.register.forms import EngagementEventCreateForm + + +class EngagementEventCreate(LoginRequiredMixin, FormView): + fields = "__all__" + form_class = EngagementEventCreateForm + template_name = "register/engagementevent_form.html" + success_url = reverse_lazy("organisations:list") + + def form_valid(self, form): + form.save() + return HttpResponseRedirect(reverse("organisations:list")) |