mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
FIX #502: Possibility to choose 'no selection' in session log form
Ref #501...may help/fix this...uncertain yet. Need to finish writing the relevant test!
This commit is contained in:
@@ -216,6 +216,8 @@ def button(type, url=None, pk=None, clazz="", icon=None, text="", id=None, style
|
|||||||
return {'submit': True, 'class': 'btn-info', 'icon': 'fa-search', 'text': 'Search', 'id': id, 'style': style}
|
return {'submit': True, 'class': 'btn-info', 'icon': 'fa-search', 'text': 'Search', 'id': id, 'style': style}
|
||||||
elif type == 'submit':
|
elif type == 'submit':
|
||||||
return {'submit': True, 'class': 'btn-primary', 'icon': 'fa-save', 'text': 'Save', 'id': id, 'style': style}
|
return {'submit': True, 'class': 'btn-primary', 'icon': 'fa-save', 'text': 'Save', 'id': id, 'style': style}
|
||||||
|
elif type == 'today':
|
||||||
|
return {'today': True, 'id': id}
|
||||||
return {'target': url, 'pk': pk, 'class': clazz, 'icon': icon, 'text': text, 'id': id, 'style': style}
|
return {'target': url, 'pk': pk, 'class': clazz, 'icon': icon, 'text': text, 'id': id, 'style': style}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -47,14 +47,16 @@ function initPicker(obj) {
|
|||||||
//log: 3,
|
//log: 3,
|
||||||
preprocessData: function (data) {
|
preprocessData: function (data) {
|
||||||
var i, l = data.length, array = [];
|
var i, l = data.length, array = [];
|
||||||
array.push({
|
if (!obj.data('noclear')) {
|
||||||
text: clearSelectionLabel,
|
array.push({
|
||||||
value: '',
|
text: clearSelectionLabel,
|
||||||
data:{
|
value: '',
|
||||||
update_url: '',
|
data:{
|
||||||
subtext:''
|
update_url: '',
|
||||||
}
|
subtext:''
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (l) {
|
if (l) {
|
||||||
for(i = 0; i < l; i++){
|
for(i = 0; i < l; i++){
|
||||||
@@ -71,11 +73,13 @@ function initPicker(obj) {
|
|||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
console.log(obj.data);
|
||||||
obj.prepend($("<option></option>")
|
if (!obj.data('noclear')) {
|
||||||
.attr("value",'')
|
obj.prepend($("<option></option>")
|
||||||
.text(clearSelectionLabel)
|
.attr("value",'')
|
||||||
.data('update_url','')); //Add "clear selection" option
|
.text(clearSelectionLabel)
|
||||||
|
.data('update_url','')); //Add "clear selection" option
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
obj.selectpicker().ajaxSelectPicker(options); //Initiaise selectPicker
|
obj.selectpicker().ajaxSelectPicker(options); //Initiaise selectPicker
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
<a href="{% url target pk %}" class="btn {{ class }}" {% if id %}id="{{id}}"{%endif%} {% if style %}style="{{style}}"{%endif%} {% if text == 'Print' %}target="_blank"{%endif%}><span class="fas {{ icon }} align-middle"></span> <span class="d-none d-sm-inline align-middle">{{ text }}</span></a>
|
<a href="{% url target pk %}" class="btn {{ class }}" {% if id %}id="{{id}}"{%endif%} {% if style %}style="{{style}}"{%endif%} {% if text == 'Print' %}target="_blank"{%endif%}><span class="fas {{ icon }} align-middle"></span> <span class="d-none d-sm-inline align-middle">{{ text }}</span></a>
|
||||||
{% elif copy %}
|
{% elif copy %}
|
||||||
<button class="btn btn-secondary btn-sm mr-1" data-clipboard-target="{{id}}" data-content="Copied to clipboard!"><span class="fas fa-copy"></span></button>
|
<button class="btn btn-secondary btn-sm mr-1" data-clipboard-target="{{id}}" data-content="Copied to clipboard!"><span class="fas fa-copy"></span></button>
|
||||||
|
{% elif today %}
|
||||||
|
<button class="btn btn-info col-sm-2" onclick="var date = new Date(); $('#{{id}}').val([date.getFullYear(), ('0' + (date.getMonth()+1)).slice(-2), ('0' + date.getDate()).slice(-2)].join('-'))" tabindex="-1" type="button">Today</button>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{% url target %}" class="btn {{ class }}" {% if id %}id="{{id}}"{%endif%} {% if style %}style="{{style}}"{%endif%}><span class="fas {{ icon }} align-middle"></span> <span class="d-none d-sm-inline align-middle">{{ text }}</span></a>
|
<a href="{% url target %}" class="btn {{ class }}" {% if id %}id="{{id}}"{%endif%} {% if style %}style="{{style}}"{%endif%}><span class="fas {{ icon }} align-middle"></span> <span class="d-none d-sm-inline align-middle">{{ text }}</span></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
{% render_field form.date|add_class:'form-control'|attr:'type="date"' value=training_date %}
|
{% render_field form.date|add_class:'form-control'|attr:'type="date"' value=training_date %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-info col-sm-2" onclick="var date = new Date(); $('#id_date').val([date.getFullYear(), ('0' + (date.getMonth()+1)).slice(-2), ('0' + date.getDate()).slice(-2)].join('-'))" tabindex="-1" type="button">Today</button>
|
{% button 'today' id='id_date' %}
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group form-row">
|
<div class="form-group form-row">
|
||||||
<label for="id_notes" class="col-sm-2 col-form-label">Notes</label>
|
<label for="id_notes" class="col-sm-2 col-form-label">Notes</label>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<label for="supervisor" class="col-sm-2 col-form-label">Supervisor</label>
|
<label for="supervisor" class="col-sm-2 col-form-label">Supervisor</label>
|
||||||
<select name="supervisor" id="supervisor_id" class="selectpicker col-sm-10" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials" required>
|
<select name="supervisor" id="supervisor_id" class="selectpicker col-sm-10" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials" required data-noclear="true">
|
||||||
{% if supervisor %}
|
{% if supervisor %}
|
||||||
<option value="{{form.supervisor.value}}" selected>{{ supervisor }}</option>
|
<option value="{{form.supervisor.value}}" selected>{{ supervisor }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -28,25 +28,26 @@
|
|||||||
{% include 'form_errors.html' %}
|
{% include 'form_errors.html' %}
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<h3>People</h3>
|
<h3>People</h3>
|
||||||
<div class="form-group row">
|
<div class="form-group row" id="supervisor_group">
|
||||||
{% include 'partials/supervisor_field.html' %}
|
{% include 'partials/supervisor_field.html' %}
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row" id="trainees_group">
|
||||||
<label for="trainees_id" class="col-sm-2">Select Attendees</label>
|
<label for="trainees_id" class="col-sm-2">Select Attendees</label>
|
||||||
<select multiple name="trainees" id="trainees_id" class="selectpicker col-sm-10" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
|
<select multiple name="trainees" id="trainees_id" class="selectpicker col-sm-10" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials" data-noclear="true">
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<h3>Training Items</h3>
|
<h3>Training Items</h3>
|
||||||
{% for depth in depths %}
|
{% for depth in depths %}
|
||||||
<div class="form-group row">
|
<div class="form-group row" id="{{depth.0}}">
|
||||||
<label for="selectpicker" class="col-sm-2 text-{% colour_from_depth depth.0 %} py-1">{{ depth.1 }} Items</label>
|
<label for="selectpicker" class="col-sm-2 text-{% colour_from_depth depth.0 %} py-1">{{ depth.1 }} Items</label>
|
||||||
<select multiple name="items_{{depth.0}}" id="items_{{depth.0}}_id" class="selectpicker col-sm-10 px-0" data-live-search="true" data-sourceurl="{% url 'api_secure' model='training_item' %}?fields=display_id,description&filters=active">
|
<select multiple name="items_{{depth.0}}" id="items_{{depth.0}}_id" class="selectpicker col-sm-10 px-0" data-live-search="true" data-sourceurl="{% url 'api_secure' model='training_item' %}?fields=display_id,description&filters=active" data-noclear="true">
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<h3>Session Information</h3>
|
<h3>Session Information</h3>
|
||||||
<div class="form-group">
|
<div class="form-group row">
|
||||||
{% include 'partials/form_field.html' with field=form.date %}
|
{% include 'partials/form_field.html' with field=form.date col='col-sm-6' %}
|
||||||
|
{% button 'today' id='id_date' %}
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{% include 'partials/form_field.html' with field=form.notes %}
|
{% include 'partials/form_field.html' with field=form.notes %}
|
||||||
|
|||||||
@@ -30,6 +30,15 @@ def training_item(db):
|
|||||||
training_item.delete()
|
training_item.delete()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def training_item_2(db):
|
||||||
|
training_category = models.TrainingCategory.objects.create(reference_number=2, name="Sound")
|
||||||
|
training_item = models.TrainingItem.objects.create(category=training_category, reference_number=1, description="Fundamentals of Audio")
|
||||||
|
yield training_item
|
||||||
|
training_category.delete()
|
||||||
|
training_item.delete()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def level(db):
|
def level(db):
|
||||||
level = models.TrainingLevel.objects.create(description="There is no description.", level=models.TrainingLevel.TECHNICIAN)
|
level = models.TrainingLevel.objects.create(description="There is no description.", level=models.TrainingLevel.TECHNICIAN)
|
||||||
|
|||||||
@@ -40,3 +40,42 @@ class AddQualification(FormPage):
|
|||||||
@property
|
@property
|
||||||
def success(self):
|
def success(self):
|
||||||
return 'add' not in self.driver.current_url
|
return 'add' not in self.driver.current_url
|
||||||
|
|
||||||
|
|
||||||
|
class SessionLog(FormPage):
|
||||||
|
URL_TEMPLATE = 'training/session_log'
|
||||||
|
|
||||||
|
_supervisor_selector = (By.CSS_SELECTOR, 'div#supervisor_group>div.bootstrap-select')
|
||||||
|
_trainees_selector = (By.CSS_SELECTOR, 'div#trainees_group>div.bootstrap-select')
|
||||||
|
_training_started_selector = (By.XPATH, '//div[1]/div/div/form/div[4]/div')
|
||||||
|
_training_complete_selector = (By.XPATH, '//div[1]/div/div/form/div[4]/div')
|
||||||
|
_competency_assessed_selector = (By.XPATH, '//div[1]/div/div/form/div[5]/div')
|
||||||
|
|
||||||
|
form_items = {
|
||||||
|
'date': (regions.DatePicker, (By.ID, 'id_date')),
|
||||||
|
'notes': (regions.TextBox, (By.ID, 'id_notes')),
|
||||||
|
}
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supervisor_selector(self):
|
||||||
|
return regions.BootstrapSelectElement(self, self.find_element(*self._supervisor_selector))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def trainees_selector(self):
|
||||||
|
return regions.BootstrapSelectElement(self, self.find_element(*self._trainees_selector))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def training_started_selector(self):
|
||||||
|
return regions.BootstrapSelectElement(self, self.find_element(*self._training_started_selector))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def training_complete_selector(self):
|
||||||
|
return regions.BootstrapSelectElement(self, self.find_element(*self._training_complete_selector))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def competency_assessed_selector(self):
|
||||||
|
return regions.BootstrapSelectElement(self, self.find_element(*self._competency_assessed_selector))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def success(self):
|
||||||
|
return 'log' not in self.driver.current_url
|
||||||
|
|||||||
@@ -12,6 +12,15 @@ from training import models
|
|||||||
from training.tests import pages
|
from training.tests import pages
|
||||||
|
|
||||||
|
|
||||||
|
def select_super(page, supervisor):
|
||||||
|
page.supervisor_selector.toggle()
|
||||||
|
assert page.supervisor_selector.is_open
|
||||||
|
page.supervisor_selector.search(supervisor.name[:-6])
|
||||||
|
time.sleep(2) # Slow down for javascript
|
||||||
|
assert page.supervisor_selector.options[0].selected
|
||||||
|
page.supervisor_selector.toggle()
|
||||||
|
|
||||||
|
|
||||||
def test_add_qualification(logged_in_browser, live_server, trainee, supervisor, training_item):
|
def test_add_qualification(logged_in_browser, live_server, trainee, supervisor, training_item):
|
||||||
page = pages.AddQualification(logged_in_browser.driver, live_server.url, pk=trainee.pk).open()
|
page = pages.AddQualification(logged_in_browser.driver, live_server.url, pk=trainee.pk).open()
|
||||||
# assert page.name in str(trainee)
|
# assert page.name in str(trainee)
|
||||||
@@ -30,12 +39,7 @@ def test_add_qualification(logged_in_browser, live_server, trainee, supervisor,
|
|||||||
assert page.item_selector.options[0].selected
|
assert page.item_selector.options[0].selected
|
||||||
page.item_selector.toggle()
|
page.item_selector.toggle()
|
||||||
|
|
||||||
page.supervisor_selector.toggle()
|
select_super(page, supervisor)
|
||||||
assert page.supervisor_selector.is_open
|
|
||||||
page.supervisor_selector.search(supervisor.name[:-6])
|
|
||||||
time.sleep(2) # Slow down for javascript
|
|
||||||
assert page.supervisor_selector.options[0].selected
|
|
||||||
page.supervisor_selector.toggle()
|
|
||||||
|
|
||||||
page.submit()
|
page.submit()
|
||||||
assert page.success
|
assert page.success
|
||||||
@@ -44,3 +48,32 @@ def test_add_qualification(logged_in_browser, live_server, trainee, supervisor,
|
|||||||
assert qualification.date == date
|
assert qualification.date == date
|
||||||
assert qualification.notes == "A note"
|
assert qualification.notes == "A note"
|
||||||
assert qualification.depth == models.TrainingItemQualification.STARTED
|
assert qualification.depth == models.TrainingItemQualification.STARTED
|
||||||
|
|
||||||
|
|
||||||
|
def test_session_log(logged_in_browser, live_server, trainee, supervisor, training_item, training_item_2):
|
||||||
|
page = pages.SessionLog(logged_in_browser.driver, live_server.url).open()
|
||||||
|
|
||||||
|
page.date = date = datetime.date(2001, 1, 10)
|
||||||
|
page.notes = note = "A general note"
|
||||||
|
|
||||||
|
time.sleep(2) # Slow down for javascript
|
||||||
|
|
||||||
|
select_super(page, supervisor)
|
||||||
|
|
||||||
|
page.trainees_selector.toggle()
|
||||||
|
assert page.trainees_selector.is_open
|
||||||
|
page.trainees_selector.search(trainee.first_name)
|
||||||
|
time.sleep(2) # Slow down for javascript
|
||||||
|
page.trainees_selector.set_option(trainee.name, True)
|
||||||
|
# assert page.trainees_selector.options[0].selected
|
||||||
|
page.trainees_selector.toggle()
|
||||||
|
|
||||||
|
page.training_started_selector.toggle()
|
||||||
|
assert page.training_started_selector.is_open
|
||||||
|
page.training_started_selector.search(training_item.description[:-2])
|
||||||
|
time.sleep(2) # Slow down for javascript
|
||||||
|
# assert page.training_started_selector.options[0].selected
|
||||||
|
page.training_started_selector.toggle()
|
||||||
|
|
||||||
|
page.submit()
|
||||||
|
assert page.success
|
||||||
|
|||||||
Reference in New Issue
Block a user