mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-30 03:42:15 +00:00
Compare commits
4 Commits
70d4c42676
...
046d0e461d
| Author | SHA1 | Date | |
|---|---|---|---|
|
046d0e461d
|
|||
|
b73b8401b6
|
|||
|
3fe388af26
|
|||
|
22dc83d595
|
@@ -124,8 +124,9 @@ class Command(BaseCommand):
|
||||
for child in root:
|
||||
depths = [("Training_Started", models.TrainingItemQualification.STARTED),
|
||||
("Training_Complete", models.TrainingItemQualification.COMPLETE),
|
||||
("Competency_Assessed", models.TrainingItemQualification.PASSED_OUT)]
|
||||
for depth, depth_index in depths:
|
||||
("Competency_Assessed", models.TrainingItemQualification.PASSED_OUT),]
|
||||
|
||||
for (depth, depth_index) in depths:
|
||||
if child.find('{}_Date'.format(depth)) is not None:
|
||||
if child.find('{}_Assessor_ID'.format(depth)) is None:
|
||||
print("Training Record #{} had no supervisor. Assigning System User.".format(child.find('ID').text))
|
||||
@@ -138,7 +139,6 @@ class Command(BaseCommand):
|
||||
continue
|
||||
try:
|
||||
obj, created = models.TrainingItemQualification.objects.update_or_create(
|
||||
pk=int(child.find('ID').text),
|
||||
item=models.TrainingItem.objects.get(pk=int(child.find('Training_Item_ID').text)),
|
||||
trainee=Profile.objects.get(pk=self.id_map[child.find('Member_ID').text]),
|
||||
depth=depth_index,
|
||||
@@ -154,7 +154,7 @@ class Command(BaseCommand):
|
||||
else:
|
||||
tally[0] += 1
|
||||
except IntegrityError: # Eh?
|
||||
print("Training Record #{} is duplicate. ಠ_ಠ".format(child.find('ID').text))
|
||||
print("Training Record #{} is probably duplicate. ಠ_ಠ".format(child.find('ID').text))
|
||||
except AttributeError:
|
||||
print(child.find('ID').text)
|
||||
|
||||
|
||||
23
training/migrations/0011_auto_20220102_1106.py
Normal file
23
training/migrations/0011_auto_20220102_1106.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.1.13 on 2022-01-02 11:06
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('training', '0010_auto_20211228_1144'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='traininglevelqualification',
|
||||
options={'ordering': ['-confirmed_on']},
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='traininglevelqualification',
|
||||
name='trainee',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, related_name='level_qualifications', to='training.trainee'),
|
||||
),
|
||||
]
|
||||
@@ -12,15 +12,14 @@ 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]
|
||||
return [level for level in TrainingLevel.objects.all() if level.percentage_complete(self) > 0 and level.pk not in self.level_qualifications.values_list('level', flat=True)]
|
||||
|
||||
@property
|
||||
def is_supervisor(self):
|
||||
return self.level_qualifications.all().exclude(confirmed_on=None).select_related('level') \
|
||||
.filter(level__gte=TrainingLevel.SUPERVISOR) \
|
||||
.filter(level__level__gte=TrainingLevel.SUPERVISOR) \
|
||||
.exclude(level__department=TrainingLevel.HAULAGE) \
|
||||
.exclude(level__department__isnull=True).exists()
|
||||
|
||||
@@ -109,6 +108,9 @@ class TrainingItemQualification(models.Model):
|
||||
else:
|
||||
return "info"
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('trainee_item_detail', kwargs={'pk': self.trainee.pk})
|
||||
|
||||
class Meta:
|
||||
unique_together = ["trainee", "item", "depth"]
|
||||
order_with_respect_to = 'item'
|
||||
@@ -249,3 +251,4 @@ class TrainingLevelQualification(models.Model, RevisionMixin):
|
||||
|
||||
class Meta:
|
||||
unique_together = ["trainee", "level"]
|
||||
ordering = ['-confirmed_on']
|
||||
|
||||
@@ -96,6 +96,9 @@
|
||||
<div class="card mb-3 d-none d-md-block">
|
||||
<h4 class="card-header">Users with this level</h4>
|
||||
<div class="card-body">
|
||||
{% for user in users_with %}
|
||||
{% user_level_if_present user object as level_qualification %}
|
||||
{% if forloop.first %}
|
||||
<table class="table table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -105,18 +108,19 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for user in users_with %}
|
||||
{% user_level_if_present user object as level_qualification %}
|
||||
<tr {% if not level_qualification.confirmed_on %}style="border-style: dashed; opacity: 80%"{%endif%}>
|
||||
<td><img src="{{user.profile_picture}}" style="width: 50px" class="img-thumbnail"/> {{user}}</td>
|
||||
<td>{% if level_qualification.confirmed_on %}<p class="card-text"><small>Qualified on {{ level_qualification.confirmed_on }}</small></p>{%else%}Unconfirmed{%endif%}</td>
|
||||
<td><a href="{% url 'profile_detail' user.pk %}" class="btn btn-primary btn-sm"><span class="fas fa-user"></span> View Profile</a></div></td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
Nobody here but us chickens... <span class="fas fa-egg text-warning"></span>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<tr {% if not level_qualification.confirmed_on %}style="border-style: dashed; opacity: 80%"{%endif%}>
|
||||
<td><img src="{{user.profile_picture}}" style="width: 50px" class="img-thumbnail"/> {{user}}</td>
|
||||
<td>{% if level_qualification.confirmed_on %}<p class="card-text"><small>Qualified on {{ level_qualification.confirmed_on }}</small></p>{%else%}Unconfirmed{%endif%}</td>
|
||||
<td><a href="{% url 'profile_detail' user.pk %}" class="btn btn-primary btn-sm"><span class="fas fa-user"></span> View Profile</a></div></td>
|
||||
</tr>
|
||||
{% if forloop.last %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
{% empty %}
|
||||
Nobody here but us chickens... <span class="fas fa-egg text-warning"></span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<td {% if object.is_driver %}class="table-success"{%endif%}>{{ object.is_driver|yesno|title }}</td>
|
||||
<td>{% for level in object|get_levels_of_depth:1 %}{% if forloop.first %}Yes {%endif%}{{ level.get_icon }}{%empty%}No{%endfor%}</td>
|
||||
<td {% if object.is_supervisor %}class="table-success"{%endif%}>{% for level in object|get_levels_of_depth:2 %}{% if forloop.first %}Yes {%endif%}{{ level.get_icon }}{%empty%}No{%endfor%}</td>
|
||||
<td>{{ object.num_qualifications }}</td>
|
||||
<td>{{ object.num_qualifications }} {% if forloop.first %} <span class="fas fa-crown text-warning"></span>{% endif %}</td>
|
||||
<td style="white-space: nowrap">
|
||||
<a class="btn btn-info" href="{% url 'trainee_detail' pk=object.pk %}"><span class="fas fa-eye"></span> View Training Record</a>
|
||||
<a href="{% url 'trainee_item_detail' pk=object.pk %}" class="btn btn-info"><span class="fas fa-info-circle"></span> View Detailed Record</a>
|
||||
|
||||
@@ -39,4 +39,4 @@ def get_supervisor(tech):
|
||||
|
||||
@register.filter
|
||||
def get_levels_of_depth(trainee, level):
|
||||
return trainee.level_qualifications.all().exclude(confirmed_on=None).select_related('level').filter(level__level=level)
|
||||
return trainee.level_qualifications.all().exclude(confirmed_on=None).exclude(level__department=models.TrainingLevel.HAULAGE).select_related('level').filter(level__level=level)
|
||||
|
||||
@@ -51,7 +51,8 @@ class TraineeItemDetail(generic.ListView):
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["page_title"] = "Detailed Training Record for {}".format(models.Trainee.objects.get(pk=self.kwargs['pk']))
|
||||
trainee = models.Trainee.objects.get(pk=self.kwargs['pk'])
|
||||
context["page_title"] = "Detailed Training Record for <a href='{}'>{}</a>".format(trainee.get_absolute_url(), trainee)
|
||||
return context
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user