mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-28 19:02:16 +00:00
Fix selectpickers disappearing on modal errors
This commit is contained in:
@@ -14,8 +14,10 @@ class Trainee(Profile, RevisionMixin):
|
|||||||
class Meta:
|
class Meta:
|
||||||
proxy = True
|
proxy = True
|
||||||
|
|
||||||
|
# TODO remove levels that the user has a qualification in
|
||||||
|
# FIXME use queryset
|
||||||
def started_levels(self):
|
def started_levels(self):
|
||||||
return [level for level in TrainingLevel.objects.all() if level.percentage_complete(self) > 0 and level.percentage_complete(self) < 100]
|
return [level for level in TrainingLevel.objects.all() if level.percentage_complete(self) > 0]
|
||||||
|
|
||||||
def level_qualifications(self, only_confirmed=False):
|
def level_qualifications(self, only_confirmed=False):
|
||||||
return self.levels.all().filter(confirmed_on__isnull=only_confirmed).select_related('level')
|
return self.levels.all().filter(confirmed_on__isnull=only_confirmed).select_related('level')
|
||||||
@@ -70,7 +72,7 @@ class TrainingItem(models.Model):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def user_has_qualification(item, user, depth):
|
def user_has_qualification(item, user, depth):
|
||||||
return user.qualifications_obtained.values('item', 'depth').filter(item=item, depth_gte=depth).exists()
|
return user.qualifications_obtained.values('item', 'depth').filter(item=item, depth__gte=depth).exists()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ["reference_number", "active", "category"]
|
unique_together = ["reference_number", "active", "category"]
|
||||||
|
|||||||
@@ -13,11 +13,17 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
<script src="{% static 'js/autocompleter.js' %}"></script>
|
|
||||||
<script src="{% static 'js/tooltip.js' %}"></script>
|
<script src="{% static 'js/tooltip.js' %}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<script src="{% static 'js/autocompleter.js' %}"></script>
|
||||||
|
<script>
|
||||||
|
//Has to be done here or the pickers disappear on modal error
|
||||||
|
$('document').ready(function(){
|
||||||
|
$(document).find(".selectpicker").selectpicker().each(function(){initPicker($(this))});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
<form role="form" action="{{ form.action|default:request.path }}" method="POST" id="add_record_form">
|
<form role="form" action="{{ form.action|default:request.path }}" method="POST" id="add_record_form">
|
||||||
{% include 'form_errors.html' %}
|
{% include 'form_errors.html' %}
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|||||||
@@ -13,14 +13,13 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
<script src="{% static 'js/autocompleter.js' %}"></script>
|
|
||||||
<script src="{% static 'js/tooltip.js' %}"></script>
|
<script src="{% static 'js/tooltip.js' %}"></script>
|
||||||
<script>
|
<script>
|
||||||
$('document').ready(function(){
|
$('document').ready(function(){
|
||||||
$('#add_record,#add_external').click(function (e) {
|
$('#add_record').click(function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var url = $(this).attr("href");
|
var url = $(this).attr("href");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
success: function(){
|
success: function(){
|
||||||
$link = $(this);
|
$link = $(this);
|
||||||
@@ -30,12 +29,12 @@
|
|||||||
modalobject = "";
|
modalobject = "";
|
||||||
$('#modal').load(url, function (e) {
|
$('#modal').load(url, function (e) {
|
||||||
$('#modal').modal();
|
$('#modal').modal();
|
||||||
$(".selectpicker").selectpicker().each(function(){initPicker($(this))});
|
//$(".selectpicker").selectpicker().each(function(){initPicker($(this))});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -53,14 +52,14 @@
|
|||||||
{% for qual in completed_levels %}
|
{% for qual in completed_levels %}
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<a href="{% url 'level_detail' qual.level.pk %}">{{ qual.level }}</a>
|
<a href="{% url 'level_detail' qual.level.pk %}">{{ qual.level }}</a>
|
||||||
{% if qual.confirmed_by is None %}
|
{% if qual.confirmed_on is None %}
|
||||||
{% if request.user.pk != object.pk and request.user.is_supervisor %}
|
{% if request.user.pk != object.pk and request.user.is_supervisor %}
|
||||||
<span class="badge badge-warning">Awaiting Confirmation</span> <a class="btn btn-info" href="{% url 'confirm_level' object.pk qual.level.pk %}">Confirm</a>
|
<span class="badge badge-warning">Awaiting Confirmation</span> <a class="btn btn-info" href="{% url 'confirm_level' object.pk qual.level.pk %}">Confirm</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<button class="btn btn-warning" disabled>Awaiting Confirmation</button>
|
<button class="btn btn-warning" disabled>Awaiting Confirmation</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<button class="btn btn-success active">Confirmed <small>by {{ qual.confirmed_by }}</small></button>
|
<button class="btn btn-success active">Confirmed <small>by {{ qual.confirmed_by|default:'System' }}</small></button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
@@ -84,4 +83,9 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col text-right">
|
||||||
|
{% include 'partials/last_edited.html' with target="trainee_history" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user