mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-18 14:02:15 +00:00
Revamp level list for better grouping
This commit is contained in:
@@ -225,17 +225,16 @@ class Command(BaseCommand):
|
||||
|
||||
for child in root:
|
||||
try:
|
||||
if child.find('Training_x0020_Level_x0020_ID') is None:
|
||||
print('Training Level Qualification #{} does not qualify in any level. How?'.format(child.find('ID').text))
|
||||
trainee = Profile.objects.get(pk=self.id_map[child.find('Member_x0020_ID').text]) if child.find('Member_x0020_ID') is not None else False
|
||||
level = models.TrainingLevel.objects.get(pk=int(child.find('Training_x0020_Level_x0020_ID').text)) if child.find('Training_x0020_Level_x0020_ID') is not None else False
|
||||
|
||||
if trainee and level:
|
||||
obj, created = models.TrainingLevelQualification.objects.update_or_create(pk=int(child.find('ID').text),
|
||||
trainee=trainee,
|
||||
level=level)
|
||||
else:
|
||||
print('Training Level Qualification #{} failed to import. Trainee: {} and Level: {}'.format(child.find('ID').text, trainee, level))
|
||||
continue
|
||||
if child.find('Member_x0020_ID') is None:
|
||||
print('Training Level Qualification #{} does not qualify anyone. How?!'.format(child.find('ID').text))
|
||||
continue
|
||||
obj, created = models.TrainingLevelQualification.objects.update_or_create(
|
||||
pk=int(child.find('ID').text),
|
||||
trainee=Profile.objects.get(pk=self.id_map[child.find('Member_x0020_ID').text]),
|
||||
level=models.TrainingLevel.objects.get(pk=int(child.find('Training_x0020_Level_x0020_ID').text))
|
||||
)
|
||||
|
||||
if child.find('Date_x0020_Level_x0020_Awarded') is not None:
|
||||
obj.confirmed_on = make_aware(datetime.datetime.strptime(child.find('Date_x0020_Level_x0020_Awarded').text.split('T')[0], "%Y-%m-%d"))
|
||||
|
||||
17
training/migrations/0002_alter_traininglevel_options.py
Normal file
17
training/migrations/0002_alter_traininglevel_options.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# Generated by Django 3.2.11 on 2022-01-05 12:06
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('training', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='traininglevel',
|
||||
options={'ordering': ['department', 'level']},
|
||||
),
|
||||
]
|
||||
@@ -152,6 +152,9 @@ class TrainingLevel(models.Model, RevisionMixin):
|
||||
prerequisite_levels = models.ManyToManyField('self', related_name='prerequisites', symmetrical=False, blank=True)
|
||||
icon = models.CharField(null=True, blank=True, max_length=20)
|
||||
|
||||
class Meta:
|
||||
ordering = ["department", "level"]
|
||||
|
||||
@property
|
||||
def department_colour(self):
|
||||
if self.department == self.SOUND:
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
{% load get_supervisor from tags %}
|
||||
|
||||
{% block content %}
|
||||
{% if request.user.is_staff %}
|
||||
<div class="alert alert-info" role="alert">
|
||||
<p>Please Note:</p>
|
||||
<ul>
|
||||
@@ -13,10 +14,17 @@
|
||||
</ul>
|
||||
<sup>Correct as of 3rd September 2021, check the Training Policy.</sup>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% for level in object_list %}
|
||||
<div class="card mb-2">
|
||||
<div class="card-header"><a href="{{level.get_absolute_url}}">{{level}}</a></div>
|
||||
<div class="card-body">{{level.description|markdown}}</div>
|
||||
{% ifchanged level.department %}
|
||||
{% if not forloop.first %}</div>{% endif %}
|
||||
<div class="card-group">
|
||||
{% endifchanged %}
|
||||
<div class="card mb-2 border-{{level.department_colour}}">
|
||||
<div class="card-body">
|
||||
<h3 class="card-title"><a href="{{level.get_absolute_url}}">{{level}}</a></h2>
|
||||
{{level.description|markdown}}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user