Fix error when trying to load detailed item list

This commit is contained in:
2022-01-20 10:31:08 +00:00
parent ce83ae6dd1
commit f9e38338dc
2 changed files with 12 additions and 4 deletions

View File

@@ -96,14 +96,14 @@ class TrainingItemQualification(models.Model, RevisionMixin):
# TODO Maximum depth - some things stop at Complete and you can't be passed out in them # TODO Maximum depth - some things stop at Complete and you can't be passed out in them
def __str__(self): def __str__(self):
return "{} in {} on {}".format(self.get_depth_display(), self.item, self.date.strftime("%b %d %Y")) return f"{self.get_depth_display()} in {self.item} on {self.date.strftime('%b %d %Y')}"
@property @property
def activity_feed_string(self): def activity_feed_string(self):
return str("{} in {}".format(self.get_depth_display(), self.item)) return f"{self.get_depth_display()} in {self.item}"
@classmethod @classmethod
def get_colour_from_depth(cls, obj, depth): def get_colour_from_depth(cls, depth):
if depth == 0: if depth == 0:
return "warning" return "warning"
if depth == 1: if depth == 1:
@@ -238,7 +238,8 @@ class TrainingLevelRequirement(models.Model, RevisionMixin):
reversion_hide = True reversion_hide = True
def __str__(self): def __str__(self):
return "{} in {}".format(TrainingItemQualification.CHOICES[self.depth][1], self.item) depth = TrainingItemQualification.CHOICES[self.depth][1]
return f"{depth} in {self.item}"
class Meta: class Meta:
unique_together = ["level", "item"] unique_together = ["level", "item"]

View File

@@ -36,3 +36,10 @@ def test_trainee_detail(admin_client, trainee, admin_user):
assertNotContains(response, "Your") assertNotContains(response, "Your")
name = trainee.first_name + " " + trainee.last_name name = trainee.first_name + " " + trainee.last_name
assertContains(response, f"{name}'s Training Record") assertContains(response, f"{name}'s Training Record")
def test_trainee_item_detail(admin_client, trainee):
url = reverse('trainee_item_detail', kwargs={'pk': trainee.pk})
response = admin_client.get(url)
assert response.status_code == 200
assertContains(response, "Nothing found")