mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-18 05:52:15 +00:00
Fix selectpickers disappearing on modal errors
This commit is contained in:
@@ -14,8 +14,10 @@ class Trainee(Profile, RevisionMixin):
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
# TODO remove levels that the user has a qualification in
|
||||
# FIXME use queryset
|
||||
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):
|
||||
return self.levels.all().filter(confirmed_on__isnull=only_confirmed).select_related('level')
|
||||
@@ -70,7 +72,7 @@ class TrainingItem(models.Model):
|
||||
|
||||
@staticmethod
|
||||
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:
|
||||
unique_together = ["reference_number", "active", "category"]
|
||||
|
||||
@@ -13,11 +13,17 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
<script src="{% static 'js/autocompleter.js' %}"></script>
|
||||
<script src="{% static 'js/tooltip.js' %}"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% 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">
|
||||
{% include 'form_errors.html' %}
|
||||
{% csrf_token %}
|
||||
|
||||
@@ -13,14 +13,13 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
<script src="{% static 'js/autocompleter.js' %}"></script>
|
||||
<script src="{% static 'js/tooltip.js' %}"></script>
|
||||
<script>
|
||||
$('document').ready(function(){
|
||||
$('#add_record,#add_external').click(function (e) {
|
||||
e.preventDefault();
|
||||
var url = $(this).attr("href");
|
||||
$.ajax({
|
||||
$('#add_record').click(function (e) {
|
||||
e.preventDefault();
|
||||
var url = $(this).attr("href");
|
||||
$.ajax({
|
||||
url: url,
|
||||
success: function(){
|
||||
$link = $(this);
|
||||
@@ -30,12 +29,12 @@
|
||||
modalobject = "";
|
||||
$('#modal').load(url, function (e) {
|
||||
$('#modal').modal();
|
||||
$(".selectpicker").selectpicker().each(function(){initPicker($(this))});
|
||||
//$(".selectpicker").selectpicker().each(function(){initPicker($(this))});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -53,14 +52,14 @@
|
||||
{% for qual in completed_levels %}
|
||||
<li class="list-group-item">
|
||||
<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 %}
|
||||
<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 %}
|
||||
<button class="btn btn-warning" disabled>Awaiting Confirmation</button>
|
||||
{% endif %}
|
||||
{% 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 %}
|
||||
</li>
|
||||
{% empty %}
|
||||
@@ -84,4 +83,9 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col text-right">
|
||||
{% include 'partials/last_edited.html' with target="trainee_history" %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user