Slight cleanup

This commit is contained in:
2022-01-08 17:24:28 +00:00
parent 1b32dc2db0
commit f15cfa8fce
4 changed files with 18 additions and 10 deletions

View File

@@ -1,7 +1,6 @@
{% extends 'base_training.html' %} {% extends 'base_training.html' %}
{% load markdown_tags %} {% load markdown_tags %}
{% load get_supervisor from tags %}
{% block content %} {% block content %}
{% if request.user.is_staff %} {% if request.user.is_staff %}

View File

@@ -33,11 +33,6 @@ def colour_from_depth(depth):
return models.TrainingItemQualification.get_colour_from_depth(depth) return models.TrainingItemQualification.get_colour_from_depth(depth)
@register.filter
def get_supervisor(tech):
return models.TrainingLevel.objects.get(department=tech.department, level=models.TrainingLevel.SUPERVISOR)
@register.filter @register.filter
def get_levels_of_depth(trainee, level): def get_levels_of_depth(trainee, level):
return trainee.level_qualifications.all().exclude(confirmed_on=None).exclude(level__department=models.TrainingLevel.HAULAGE).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)

View File

@@ -2,10 +2,18 @@ import pytest
from training import models from training import models
from RIGS.models import Profile from RIGS.models import Profile
@pytest.fixture @pytest.fixture
def trainee(db): def trainee(db):
trainee = Profile.objects.create(username="trainee", first_name="Train", last_name="EE", trainee = Profile.objects.create(username="trainee", first_name="Train", last_name="EE",
initials="TRN", initials="TRN",
email="trainee@example.com", is_active=True, is_approved=True) email="trainee@example.com", is_active=True, is_approved=True)
yield trainee yield trainee
trainee.delete() trainee.delete()
@pytest.fixture
def level(db):
level = models.TrainingLevel.objects.create(description="There is no description.", level=models.TrainingLevel.TECHNICIAN)
yield level
level.delete()

View File

@@ -12,8 +12,14 @@ from training import models
def test_add_qualification(admin_client, trainee, admin_user): def test_add_qualification(admin_client, trainee, admin_user):
url = reverse('add_qualification', kwargs={'pk': trainee.pk}) url = reverse('add_qualification', kwargs={'pk': trainee.pk})
date = (timezone.now() + datetime.timedelta(days=3)).strftime("%Y-%m-%d") date = (timezone.now() + datetime.timedelta(days=3)).strftime("%Y-%m-%d")
response = admin_client.post(url, {'date': date, 'trainee': trainee.pk, 'supervisor': trainee.pk }) response = admin_client.post(url, {'date': date, 'trainee': trainee.pk, 'supervisor': trainee.pk})
assertFormError(response, 'form', 'date', 'Qualification date may not be in the future') assertFormError(response, 'form', 'date', 'Qualification date may not be in the future')
assertFormError(response, 'form', 'supervisor', 'One may not supervise oneself...') assertFormError(response, 'form', 'supervisor', 'One may not supervise oneself...')
response = admin_client.post(url, {'date': date, 'trainee': trainee.pk, 'supervisor': admin_user.pk }) response = admin_client.post(url, {'date': date, 'trainee': trainee.pk, 'supervisor': admin_user.pk})
assertFormError(response, 'form', 'supervisor', 'Selected supervisor must actually *be* a supervisor...') assertFormError(response, 'form', 'supervisor', 'Selected supervisor must actually *be* a supervisor...')
def test_add_requirement(admin_client, level):
url = reverse('add_requirement', kwargs={'pk': level.pk})
response = admin_client.post(url)
assertContains(response, level.pk)