mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-02-01 12:52:15 +00:00
Don't try and create existing level qualifications
This commit is contained in:
@@ -71,9 +71,9 @@ class TrainingItemQualification(models.Model):
|
|||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
super().save()
|
super().save()
|
||||||
for level in TrainingLevel.objects.all(): # Mm yes efficiency
|
for level in TrainingLevel.objects.all(): # Mm yes efficiency FIXME
|
||||||
if level.user_has_requirements(self.trainee):
|
if level.user_has_requirements(self.trainee):
|
||||||
level_qualification = TrainingLevelQualification.objects.create(trainee=self.trainee, level=level)
|
level_qualification = TrainingLevelQualification.objects.get_or_create(trainee=self.trainee, level=level)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ["trainee", "item", "depth"]
|
unique_together = ["trainee", "item", "depth"]
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<h2 class="col-12">Training Items</h2><br>
|
<h2 class="col-12">Training Items</h2><br>
|
||||||
<h3 class="col-12">Key: <span class="badge badge-warning">Training Started</span> <span class="badge badge-success">Training Complete</span> <span class="badge badge-info">Passed Out</span></h3>
|
<h3 class="col-12">Key: <span class="badge badge-warning">Training Started</span> <span class="badge badge-success">Training Complete</span> <span class="badge badge-info">Passed Out</span></h3>
|
||||||
<div class="card-columns">
|
<div class="card-deck">
|
||||||
{% for category in categories %}
|
{% for category in categories %}
|
||||||
<div class="card mb-3">
|
<div class="card mb-3">
|
||||||
<h3 class="card-header">{{ category }}</h3>
|
<h3 class="card-header">{{ category }}</h3>
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class TraineeDetail(views.ProfileDetail):
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(TraineeDetail, self).get_context_data(**kwargs)
|
context = super(TraineeDetail, self).get_context_data(**kwargs)
|
||||||
context["page_title"] = "{}'s Training Record".format(self.object)
|
context["page_title"] = "{}'s Training Record".format(self.object.first_name + " " + self.object.last_name)
|
||||||
context["levels"] = models.TrainingLevel.objects.all()
|
context["levels"] = models.TrainingLevel.objects.all()
|
||||||
context["categories"] = models.TrainingCategory.objects.all().prefetch_related('items')
|
context["categories"] = models.TrainingCategory.objects.all().prefetch_related('items')
|
||||||
choices = models.TrainingItemQualification.CHOICES
|
choices = models.TrainingItemQualification.CHOICES
|
||||||
|
|||||||
Reference in New Issue
Block a user