Machine switch

This commit is contained in:
2021-07-01 09:50:13 +01:00
parent b1646d556c
commit 458a734331
10 changed files with 137 additions and 19 deletions

View File

@@ -3,11 +3,30 @@ from django.shortcuts import render
from django.views import generic
from training import models
from users import views
class ItemList(generic.ListView):
template_name = "item_list.html"
model = models.TrainingItem
def get_context_data(self, **kwargs):
context = super(ItemList, self).get_context_data(**kwargs)
context["categories"] = models.TrainingCategory.objects.all()
context["page_title"] = "Training Items"
context["categories"] = models.TrainingCategory.objects.all()
return context
class TraineeDetail(views.ProfileDetail):
template_name = "trainee_detail.html"
model = models.Trainee
def get_context_data(self, **kwargs):
context = super(TraineeDetail, self).get_context_data(**kwargs)
context["page_title"] = "{}'s Training Record".format(self.object)
context["categories"] = models.TrainingCategory.objects.all()
choices = models.TrainingItemQualification.CHOICES
context["depths"] = choices
for i in [x for x,_ in choices]:
context[str(i)] = self.object.get_records_of_depth(i)
return context