More fixes

This commit is contained in:
2020-09-19 18:03:24 +01:00
parent 77c82efce6
commit 2a1bb57c74
10 changed files with 36 additions and 43 deletions

View File

@@ -5,7 +5,7 @@
{% load yesnoi from filters %}
{% block content %}
<div class="row my-3 py-3">
<div class="row py-3">
<div class="col-12">
<h3>Event Checklist for Event N{{ object.event.pk|stringformat:"05d" }} {{ object.event.name }}</h3>
<div class="row">
@@ -225,6 +225,7 @@
<div class="col-12 text-right">
<a href="{% url 'ec_edit' object.pk %}" class="btn btn-warning my-3"><span class="fas fa-edit"></span> <span
class="hidden-xs">Edit</span></a>
<a href="{% url 'event_detail' object.event.pk %}" class="btn btn-primary"><span class="fas fa-eye"></span> View Event</a>
{{ object.review_string|safe }}
</div>
<div class="col-12 text-right">

View File

@@ -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');
});
});

View File

@@ -2,7 +2,7 @@
<span class="badge badge-{% if event.confirmed %}success{% elif event.cancelled %}dark{% else %}warning{% endif %}">Status: {{ event.get_status_display }}</span>
{% if event.is_rig %}
{% if event.purchase_order %}
<span class="badge badge-success">PO: {{ event.purchase_order }}</i></span>
<span class="badge badge-success">PO: {{ event.purchase_order }}</span>
{% elif event.authorised %}
<span class="badge badge-success">Authorisation: Complete <span class="fas fa-check"></span></span>
{% else %}
@@ -24,6 +24,8 @@
{% else %}
<span class="badge badge-danger">Checklist: <span class="fas fa-times"></span></span>
{% endif %}
{% else %}
<span class="badge badge-secondary">Checklist: N/A</span>
{% endif %}
{% if perms.RIGS.view_invoice %}
{% if event.invoice %}

View File

@@ -4,11 +4,19 @@
{% block content %}
<h1>Rigboard</h1>
{% if perms.RIGS.add_event %}
<a href="{% url 'event_create' %}" class="btn btn-success my-3 float-right">New <i class="fas fa-plus"></i></a>
{% endif %}
<p>Key: <span class="badge badge-success mr-1">Ready</span><span class="badge badge-warning mr-1">Action Required</span><span class="badge badge-danger mr-1">Needs MIC</span><span class="badge badge-secondary mr-1">Cancelled</span><span class="badge badge-info">Non-Rig</span></p>
<div class="row align-items-center justify-content-between py-2">
<div class="col-sm-12 col-md">
Key: <span class="table-success mr-1 px-2">Ready</span><span class="table-warning mr-1 px-2">Action Required</span><span class="table-danger mr-1 px-2">Needs MIC</span><span class="table-secondary mr-1 px-2">Cancelled</span><span class="table-info px-2">Non-Rig</span>
</div>
<div class="col text-right">
{% if perms.RIGS.add_event %}
<a href="{% url 'event_create' %}" class="btn btn-success">New <i class="fas fa-plus"></i></a>
{% endif %}
</div>
</div>
{% include 'event_table.html' %}
{% endblock %}

View File

@@ -4,15 +4,9 @@
{% load yesnoi from filters %}
{% block content %}
<div class="row my-3 py-3">
<div class="col-sm-12">
<div class="row py-3">
<div class="col-12">
<h3>Risk Assessment for Event N{{ object.event.pk|stringformat:"05d" }} {{ object.event.name }}</h3>
<div class="row">
<div class="col-12 text-right">
<a href="{% url 'ra_edit' object.pk %}" class="btn btn-warning my-3"><span class="fas fa-edit"></span> <span
class="hidden-xs">Edit</span></a>
</div>
</div>
<div class="card card-default mb-3">
<div class="card-header">General</div>
<div class="card-body">
@@ -149,9 +143,8 @@
<div class="col-12 text-right">
<a href="{% url 'ra_edit' object.pk %}" class="btn btn-warning my-3"><span class="fas fa-edit"></span> <span
class="hidden-xs">Edit</span></a>
<a href="{% url 'event_detail' object.event.pk %}" class="btn btn-primary"><span class="fas fa-eye"></span> View Event</a>
{{ object.review_string|safe }}
</div>
<div class="col-12 text-right">
{% include 'partials/last_edited.html' with target="riskassessment_history" %}
</div>
</div>

View File

@@ -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 %}
</div>
</div>

View File

@@ -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):

View File

@@ -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)

View File

@@ -11,7 +11,7 @@
</thead>
<tbody id="asset_table_body">
{% for item in object_list %}
<tr class="{{ item.status.display_class|default:'' }} assetRow">
<tr class="table-{{ item.status.display_class|default:'' }} assetRow">
<th scope="row"><a class="assetID" href="{% url 'asset_detail' item.asset_id %}">{{ item.asset_id }}</a></th>
<td class="assetDesc"><span class="text-truncate d-inline-block">{{ item.description }}</span></td>
<td class="assetCategory">{{ item.category }}</td>

View File

@@ -5,8 +5,10 @@
<dl class="row">
{% with form|nice_errors as qq %}
{% for error_name,desc in qq.items %}
<dt class="col-4">{{error_name}}</dt>
<dd class="col-8">{{desc}}</dd>
<span>
<dt class="col-4">{{error_name}}</dt>
<dd class="col-8">{{desc}}</dd>
</span>
{% endfor %}
{% endwith %}
</dl>