From 2a1bb57c74f9825d51bfae0c6d6651fdde2ef17c Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Sat, 19 Sep 2020 18:03:24 +0100 Subject: [PATCH] More fixes --- RIGS/templates/event_checklist_detail.html | 3 ++- RIGS/templates/event_checklist_form.html | 2 +- RIGS/templates/partials/event_status.html | 4 +++- RIGS/templates/rigboard.html | 16 ++++++++++++---- RIGS/templates/risk_assessment_detail.html | 13 +++---------- RIGS/templates/risk_assessment_form.html | 2 +- RIGS/tests/pages.py | 14 +++++--------- RIGS/tests/test_functional.py | 17 ++++------------- assets/templates/partials/asset_list_table.html | 2 +- templates/form_errors.html | 6 ++++-- 10 files changed, 36 insertions(+), 43 deletions(-) diff --git a/RIGS/templates/event_checklist_detail.html b/RIGS/templates/event_checklist_detail.html index e95ddc64..900148db 100644 --- a/RIGS/templates/event_checklist_detail.html +++ b/RIGS/templates/event_checklist_detail.html @@ -5,7 +5,7 @@ {% load yesnoi from filters %} {% block content %} -
+

Event Checklist for Event N{{ object.event.pk|stringformat:"05d" }} {{ object.event.name }}

@@ -225,6 +225,7 @@
+ View Event {{ object.review_string|safe }}
diff --git a/RIGS/templates/event_checklist_form.html b/RIGS/templates/event_checklist_form.html index bbfef295..c2c6b4dd 100644 --- a/RIGS/templates/event_checklist_form.html +++ b/RIGS/templates/event_checklist_form.html @@ -85,7 +85,7 @@ }); //Somewhat rudimentary way of ensuring people fill in completely (if it hits the database validation the whole table row disappears when the page reloads...) //the not is to avoid adding it to some of bootstrap-selects extra crap - $('#vehiclest,#crewmemberst').find("select,input").not(':input[type=search]').change(function () { + $('#vehiclest,#crewmemberst').on('change', 'select,input', function () { $(this).closest('tr').find("select,input").not(':input[type=search]').attr('required', 'true'); }); }); diff --git a/RIGS/templates/partials/event_status.html b/RIGS/templates/partials/event_status.html index f67275a0..3d53d114 100644 --- a/RIGS/templates/partials/event_status.html +++ b/RIGS/templates/partials/event_status.html @@ -2,7 +2,7 @@ Status: {{ event.get_status_display }} {% if event.is_rig %} {% if event.purchase_order %} - PO: {{ event.purchase_order }} + PO: {{ event.purchase_order }} {% elif event.authorised %} Authorisation: Complete {% else %} @@ -24,6 +24,8 @@ {% else %} Checklist: {% endif %} + {% else %} + Checklist: N/A {% endif %} {% if perms.RIGS.view_invoice %} {% if event.invoice %} diff --git a/RIGS/templates/rigboard.html b/RIGS/templates/rigboard.html index 83a86f97..f9ee0f45 100644 --- a/RIGS/templates/rigboard.html +++ b/RIGS/templates/rigboard.html @@ -4,11 +4,19 @@ {% block content %}

Rigboard

-{% if perms.RIGS.add_event %} -New -{% endif %} -

Key: ReadyAction RequiredNeeds MICCancelledNon-Rig

+
+
+ Key: ReadyAction RequiredNeeds MICCancelledNon-Rig +
+ +
+ {% if perms.RIGS.add_event %} + New + {% endif %} +
+
+ {% include 'event_table.html' %} {% endblock %} diff --git a/RIGS/templates/risk_assessment_detail.html b/RIGS/templates/risk_assessment_detail.html index 31e850d2..58397e75 100644 --- a/RIGS/templates/risk_assessment_detail.html +++ b/RIGS/templates/risk_assessment_detail.html @@ -4,15 +4,9 @@ {% load yesnoi from filters %} {% block content %} -
-
+
+

Risk Assessment for Event N{{ object.event.pk|stringformat:"05d" }} {{ object.event.name }}

-
-
- -
-
General
@@ -149,9 +143,8 @@
+ View Event {{ object.review_string|safe }} -
-
{% include 'partials/last_edited.html' with target="riskassessment_history" %}
diff --git a/RIGS/templates/risk_assessment_form.html b/RIGS/templates/risk_assessment_form.html index dcde1caa..5606834f 100644 --- a/RIGS/templates/risk_assessment_form.html +++ b/RIGS/templates/risk_assessment_form.html @@ -106,7 +106,7 @@ {% include 'partials/yes_no_radio.html' with formitem=form.safe_loading %} {% include 'partials/yes_no_radio.html' with formitem=form.safe_storage %} {% include 'partials/yes_no_radio.html' with formitem=form.area_outside_of_control %} - {% include 'partials/yes_no_radio.html' with formitem=form.barrier_required %} + {% include 'partials/yes_no_radio.html' with formitem=form.barrier_required %} {% include 'partials/yes_no_radio.html' with formitem=form.nonstandard_emergency_procedure %}
diff --git a/RIGS/tests/pages.py b/RIGS/tests/pages.py index e9fc39aa..c5b6562b 100644 --- a/RIGS/tests/pages.py +++ b/RIGS/tests/pages.py @@ -17,7 +17,7 @@ class Index(BasePage): class Rigboard(BasePage): URL_TEMPLATE = reverse('rigboard') - _add_item_selector = (By.CSS_SELECTOR, 'a.btn:nth-child(2)') + _add_item_selector = (By.XPATH, "//a[contains(@class, 'btn-success') and contains(., 'New')]") _event_row_locator = (By.ID, 'event_row') def add(self): @@ -86,11 +86,9 @@ class CreateEvent(FormPage): URL_TEMPLATE = reverse('event_create') _is_rig_selector = (By.ID, 'is_rig-selector') - _bottom_save_selector = (By.XPATH, '//*[@id="main"]/form/div/div[6]/div/button') _submit_locator = (By.XPATH, "//button[@type='submit' and contains(., 'Save')]") - # TODO The ID is now no longer on the highest level element on the selector, annoyingly - _person_selector_selector = (By.XPATH, '//*[@id="main"]/form/div/div[3]/div[1]/div[2]/div[1]/div/div/div[1]/div') - _venue_selector_selector = (By.XPATH, '//*[@id="main"]/form/div/div[3]/div[1]/div[2]/div[1]/div/div/div[1]/div') + _person_selector_selector = (By.XPATH, '//*[@id="id_person"]/..') + _venue_selector_selector = (By.XPATH, '//*[@id="id_venue"]/..') _mic_selector_selector = (By.XPATH, '//*[@id="form-hws"]/div[7]/div[1]/div/div') _add_person_selector = (By.XPATH, '//a[@data-target="#id_person" and contains(@href, "add")]') @@ -118,7 +116,7 @@ class CreateEvent(FormPage): } def select_event_type(self, type_name): - self.find_element(By.XPATH, '//button[.="' + type_name + '"]').click() + self.find_element(By.XPATH, '//button[.="{}"]'.format(type_name)).click() def item_row(self, ID): return rigs_regions.ItemRow(self, self.find_element(By.ID, "item-" + ID)) @@ -133,7 +131,7 @@ class CreateEvent(FormPage): @property def is_expanded(self): - return self.find_element(*self._bottom_save_selector).is_displayed() + return self.find_element(*self._submit_locator).is_displayed() @property def person_selector(self): @@ -164,7 +162,6 @@ class CreateEvent(FormPage): class DuplicateEvent(CreateEvent): URL_TEMPLATE = 'event/{event_id}/duplicate' - _submit_locator = (By.XPATH, '/html/body/div[1]/form/div/div[5]/div/button') @property def success(self): @@ -173,7 +170,6 @@ class DuplicateEvent(CreateEvent): class EditEvent(CreateEvent): URL_TEMPLATE = 'event/{event_id}/edit' - _submit_locator = (By.XPATH, '/html/body/div[1]/form/div/div[5]/div/button') @property def success(self): diff --git a/RIGS/tests/test_functional.py b/RIGS/tests/test_functional.py index 06e78d60..cb90b09c 100644 --- a/RIGS/tests/test_functional.py +++ b/RIGS/tests/test_functional.py @@ -190,7 +190,7 @@ class TestEventCreate(BaseRigboardTest): # Expected to fail self.page.submit() self.assertFalse(self.page.success) - self.assertIn("can't finish before it has started", self.page.errors["General form errors"][0]) + self.assertIn("Unless you've invented time travel, the event can't finish before it has started.", self.page.errors["End date"]) self.wait.until(animation_is_finished()) # Fix it @@ -200,7 +200,6 @@ class TestEventCreate(BaseRigboardTest): self.page.submit() self.assertTrue(self.page.success) - # TODO Seperated because of the way submit checks erroring def test_date_validation_2(self): self.select_event_type("Rig") @@ -209,7 +208,6 @@ class TestEventCreate(BaseRigboardTest): self.page.person_selector.toggle() self.assertFalse(self.page.person_selector.is_open) - self.page.name = "Test Date Validation" # end time before start self.page.start_date = datetime.date(2020, 1, 1) self.page.start_time = datetime.time(10, 00) @@ -218,7 +216,7 @@ class TestEventCreate(BaseRigboardTest): # Expected to fail self.page.submit() self.assertFalse(self.page.success) - self.assertIn("can't finish before it has started", self.page.errors["General form errors"][0]) + self.assertIn("Unless you've invented time travel, the event can't finish before it has started.", self.page.errors["End time"]) # Fix it self.page.end_time = datetime.time(23, 00) @@ -227,23 +225,16 @@ class TestEventCreate(BaseRigboardTest): self.page.submit() self.assertTrue(self.page.success) - def test_access_validation(self): + self.page = pages.CreateEvent(self.driver, self.live_server_url).open() self.select_event_type("Rig") - self.page.person_selector.search(self.client.name) - self.page.person_selector.set_option(self.client.name, True) - self.page.person_selector.toggle() - self.assertFalse(self.page.person_selector.is_open) - - self.page.name = "Access Validation Test" - self.page.start_date = datetime.date(2020, 1, 1) self.page.access_at = datetime.datetime(2020, 1, 5, 10) self.page.submit() self.assertFalse(self.page.success) self.assertTrue(self.page.errors is not None) - self.assertIn("access time cannot be after the event has started.", self.page.errors["General form errors"][0]) + self.assertIn("Regardless of what some clients might think, access time cannot be after the event has started.", self.page.errors["Access at"]) # Fix it self.page.access_at = datetime.datetime(2020, 1, 1, 10) diff --git a/assets/templates/partials/asset_list_table.html b/assets/templates/partials/asset_list_table.html index 8be8e148..de8f713d 100644 --- a/assets/templates/partials/asset_list_table.html +++ b/assets/templates/partials/asset_list_table.html @@ -11,7 +11,7 @@ {% for item in object_list %} - + {{ item.asset_id }} {{ item.description }} {{ item.category }} diff --git a/templates/form_errors.html b/templates/form_errors.html index 67751dd8..ed348790 100644 --- a/templates/form_errors.html +++ b/templates/form_errors.html @@ -5,8 +5,10 @@
{% with form|nice_errors as qq %} {% for error_name,desc in qq.items %} -
{{error_name}}
-
{{desc}}
+ +
{{error_name}}
+
{{desc}}
+
{% endfor %} {% endwith %}