summaryrefslogtreecommitdiffstats
path: root/engagements/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'engagements/forms.py')
-rw-r--r--engagements/forms.py42
1 files changed, 25 insertions, 17 deletions
diff --git a/engagements/forms.py b/engagements/forms.py
index 852ba74..ddd7aa0 100644
--- a/engagements/forms.py
+++ b/engagements/forms.py
@@ -248,22 +248,30 @@ class AssessmentCreateForm(forms.ModelForm):
class Meta:
model = Engagement
fields = ["proposed_start_date", "proposed_end_date", "officers", "engagement_type", "external_party"]
+ widgets = {
+ "proposed_start_date": forms.DateInput(
+ attrs={
+ "type": "date",
+ "class": "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50",
+ },
+ format="j M y H:i",
+ ),
+ "proposed_end_date": forms.DateInput(
+ attrs={
+ "type": "date",
+ "class": "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50",
+ },
+ format="j M y H:i",
+ ),
+ }
- def __init__(self, *args, **kwargs):
- # eng_type_id = kwargs.pop("eng_type_id", None)
- # entity_id = kwargs.pop("entity_id", None)
+ def __init__(self, *args, org, **kwargs):
super().__init__(*args, **kwargs)
- self.fields["proposed_start_date"].initial = "tosser"
- self.fields["engagement_type"].initial = "ASSESSMENT"
- # if eng_type_id is not None:
- # try:
- # engagement_type = EngagementType.objects.get(id=eng_type_id)
- # self.initial["engagement_type"] = engagement_type
- # except EngagementType.DoesNotExist:
- # raise ValidationError(f"EngagementType with id {eng_type_id} does not exist")
- # if entity_id is not None:
- # try:
- # entity = Organisation.objects.get(id=entity_id)
- # self.initial["external_party"] = entity
- # except Organisation.DoesNotExist:
- # raise ValidationError(f"Organisation with id {entity_id} does not exist")
+ entity = Organisation.objects.get(slug=org)
+ et = EngagementType.objects.get(name="ASSESSMENT")
+ self.initial["engagement_type"] = et.pk
+ self.initial["external_party"] = entity.pk
+ self.fields["engagement_type"].widget= forms.HiddenInput()
+ self.fields["engagement_type"].label = ""
+ self.fields["external_party"].widget= forms.HiddenInput()
+ self.fields["external_party"].label = ""