mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-19 06:22:16 +00:00
Much template wrangling
This commit is contained in:
@@ -51,11 +51,11 @@ class Command(BaseCommand):
|
||||
|
||||
def setup_levels(self):
|
||||
items = self.items.copy()
|
||||
ta = models.TrainingLevel.objects.create(level=models.TrainingLevel.TA, description="Passion will hatred faithful evil suicide noble battle. Truth aversion gains grandeur noble. Dead play gains prejudice god ascetic grandeur zarathustra dead good. Faithful ultimate justice overcome love will mountains inexpedient.")
|
||||
ta = models.TrainingLevel.objects.create(level=models.TrainingLevel.TA, description="Passion will hatred faithful evil suicide noble battle. Truth aversion gains grandeur noble. Dead play gains prejudice god ascetic grandeur zarathustra dead good. Faithful ultimate justice overcome love will mountains inexpedient.", icon="address-card")
|
||||
self.levels.append(ta)
|
||||
tech_ccs = models.TrainingLevel.objects.create(level=models.TrainingLevel.TECHNICIAN, description="Technician Common Competencies. Spirit abstract endless insofar horror sexuality depths war decrepit against strong aversion revaluation free. Christianity reason joy sea law mountains transvaluation. Sea battle aversion dead ultimate morality self. Faithful morality.")
|
||||
tech_ccs = models.TrainingLevel.objects.create(level=models.TrainingLevel.TECHNICIAN, description="Technician Common Competencies. Spirit abstract endless insofar horror sexuality depths war decrepit against strong aversion revaluation free. Christianity reason joy sea law mountains transvaluation. Sea battle aversion dead ultimate morality self. Faithful morality.", icon="book-reader")
|
||||
tech_ccs.prerequisite_levels.add(ta)
|
||||
super_ccs = models.TrainingLevel.objects.create(level=models.TrainingLevel.SUPERVISOR, description="Depths disgust hope faith of against hatred will victorious. Law...")
|
||||
super_ccs = models.TrainingLevel.objects.create(level=models.TrainingLevel.SUPERVISOR, description="Depths disgust hope faith of against hatred will victorious. Law...", icon="user-graduate")
|
||||
for i in range(0, 5):
|
||||
if len(items) == 0:
|
||||
break
|
||||
@@ -65,10 +65,17 @@ class Command(BaseCommand):
|
||||
models.TrainingLevelRequirement.objects.create(level=tech_ccs, item=item, depth=random.choice(models.TrainingItemQualification.CHOICES)[0])
|
||||
else:
|
||||
models.TrainingLevelRequirement.objects.create(level=super_ccs, item=item, depth=random.choice(models.TrainingItemQualification.CHOICES)[0])
|
||||
icons = {
|
||||
models.TrainingLevel.SOUND: ('microphone', 'microphone-alt'),
|
||||
models.TrainingLevel.LIGHTING: ('lightbulb', 'traffic-light'),
|
||||
models.TrainingLevel.POWER: ('plug', 'bolt'),
|
||||
models.TrainingLevel.RIGGING: ('link', 'pallet'),
|
||||
models.TrainingLevel.HAULAGE: ('truck', 'route'),
|
||||
}
|
||||
for i,name in models.TrainingLevel.DEPARTMENTS:
|
||||
technician = models.TrainingLevel.objects.create(level=models.TrainingLevel.TECHNICIAN, department=i, description="Moral pinnacle derive ultimate war dead. Strong fearful joy contradict battle christian faithful enlightenment prejudice zarathustra moral.")
|
||||
technician = models.TrainingLevel.objects.create(level=models.TrainingLevel.TECHNICIAN, department=i, description="Moral pinnacle derive ultimate war dead. Strong fearful joy contradict battle christian faithful enlightenment prejudice zarathustra moral.", icon=icons[i][0])
|
||||
technician.prerequisite_levels.add(tech_ccs)
|
||||
supervisor = models.TrainingLevel.objects.create(level=models.TrainingLevel.SUPERVISOR, department=i, description="Spirit holiest merciful mountains inexpedient reason value. Suicide ultimate hope.")
|
||||
supervisor = models.TrainingLevel.objects.create(level=models.TrainingLevel.SUPERVISOR, department=i, description="Spirit holiest merciful mountains inexpedient reason value. Suicide ultimate hope.", icon=icons[i][1])
|
||||
supervisor.prerequisite_levels.add(super_ccs, technician)
|
||||
|
||||
for i in range(0, 30):
|
||||
@@ -87,7 +94,7 @@ class Command(BaseCommand):
|
||||
supervisor = models.Profile.objects.create(username="supervisor", first_name="Super", last_name="Visor",
|
||||
initials="SV",
|
||||
email="supervisor@example.com", is_active=True,
|
||||
is_staff=True)
|
||||
is_staff=True, is_approved=True)
|
||||
supervisor.set_password('supervisor')
|
||||
supervisor.save()
|
||||
models.TrainingLevelQualification.objects.create(trainee=supervisor, level=models.TrainingLevel.objects.filter(level__gte=models.TrainingLevel.SUPERVISOR).exclude(department=models.TrainingLevel.HAULAGE).exclude(department__isnull=True).first(), confirmed_on=timezone.now())
|
||||
|
||||
@@ -42,8 +42,6 @@ class Trainee(Profile, RevisionMixin):
|
||||
def get_absolute_url(self):
|
||||
return reverse('trainee_detail', kwargs={'pk': self.pk})
|
||||
|
||||
# Items
|
||||
|
||||
|
||||
class TrainingCategory(models.Model):
|
||||
reference_number = models.CharField(max_length=3)
|
||||
@@ -134,12 +132,16 @@ class TrainingLevel(models.Model, RevisionMixin):
|
||||
(TECHNICIAN, 'Technician'),
|
||||
(SUPERVISOR, 'Supervisor'),
|
||||
)
|
||||
SOUND = 0
|
||||
LIGHTING = 1
|
||||
POWER = 2
|
||||
RIGGING = 3
|
||||
HAULAGE = 4
|
||||
DEPARTMENTS = (
|
||||
(0, 'Sound'),
|
||||
(1, 'Lighting'),
|
||||
(2, 'Power'),
|
||||
(3, 'Rigging'),
|
||||
(SOUND, 'Sound'),
|
||||
(LIGHTING, 'Lighting'),
|
||||
(POWER, 'Power'),
|
||||
(RIGGING, 'Rigging'),
|
||||
(HAULAGE, 'Haulage'),
|
||||
)
|
||||
department = models.IntegerField(choices=DEPARTMENTS, null=True) # N.B. Technical Assistant does not have a department
|
||||
@@ -147,16 +149,17 @@ 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)
|
||||
|
||||
def get_department_colour(self):
|
||||
if self.department == 0:
|
||||
@property
|
||||
def department_colour(self):
|
||||
if self.department == self.SOUND:
|
||||
return "info"
|
||||
elif self.department == 1:
|
||||
elif self.department == self.LIGHTING:
|
||||
return "dark"
|
||||
elif self.department == 2:
|
||||
elif self.department == self.POWER:
|
||||
return "danger"
|
||||
elif self.department == 3:
|
||||
elif self.department == self.RIGGING:
|
||||
return "warning"
|
||||
elif self.department == 4:
|
||||
elif self.department == self.HAULAGE:
|
||||
return "light"
|
||||
else:
|
||||
return "primary"
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
{% extends 'base_training.html' %}
|
||||
{% load colour_from_level from tags %}
|
||||
|
||||
{% block css %}
|
||||
<style>
|
||||
.level-1::after {
|
||||
content: "";
|
||||
position: relative;
|
||||
position: relative;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: 2px;
|
||||
@@ -38,9 +37,9 @@
|
||||
<div class="col-6">
|
||||
{% endif %}
|
||||
<div class="{% if forloop.first %}level-1 row{% elif forloop.counter == 2 %}level-2 row{%endif%}">
|
||||
<div class="card my-3">
|
||||
<div class="card my-3 border-{{level.department_colour}}">
|
||||
<h3 class="card-header"><a href="{% url 'level_detail' level.pk %}">{{ level }}</a></h3>
|
||||
<div class="card-body bg-{% colour_from_level level %}">
|
||||
<div class="card-body">
|
||||
<p>{{ level.description }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
5
training/templates/partials/add_qualification.html
Normal file
5
training/templates/partials/add_qualification.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{% if request.user.is_supervisor or perms.training.add_trainingitemqualification %}
|
||||
<a type="button" class="btn btn-success" href="{% url 'add_qualification' object.pk %}" id="add_record">
|
||||
<span class="fas fa-plus"></span> Add New Training Record
|
||||
</a>
|
||||
{% endif %}
|
||||
@@ -45,9 +45,7 @@
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-sm-12 text-right">
|
||||
<a type="button" class="btn btn-success" href="{% url 'edit_record' object.pk %}" id="add_record">
|
||||
<span class="fas fa-plus"></span> Add New Training Record
|
||||
</a>
|
||||
{% include 'partials/add_qualification.html' %}
|
||||
<a href="{% url 'trainee_item_detail' object.pk %}" class="btn btn-info"><span class="fas fa-info-circle"></span> View Detailed Record</a><br/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -26,7 +26,3 @@ def percentage_complete(level, user):
|
||||
@register.simple_tag
|
||||
def colour_from_depth(depth):
|
||||
return models.TrainingItemQualification.get_colour_from_depth(depth)
|
||||
|
||||
@register.simple_tag
|
||||
def colour_from_level(level):
|
||||
return level.get_department_colour()
|
||||
|
||||
@@ -6,19 +6,19 @@ from PyRIGS.decorators import permission_required_with_403
|
||||
from training import views
|
||||
|
||||
urlpatterns = [
|
||||
path('items/', views.ItemList.as_view(), name='item_list'),
|
||||
path('trainee/list/', views.TraineeList.as_view(), name='trainee_list'),
|
||||
path('items/', login_required(views.ItemList.as_view()), name='item_list'),
|
||||
path('trainee/list/', login_required(views.TraineeList.as_view()), name='trainee_list'),
|
||||
path('trainee/', login_required(views.TraineeDetail.as_view()), name='trainee_detail'),
|
||||
path('trainee/<int:pk>/',
|
||||
permission_required_with_403('RIGS.view_profile')(views.TraineeDetail.as_view()),
|
||||
name='trainee_detail'),
|
||||
path('trainee/<int:pk>/edit/', views.AddQualification.as_view(),
|
||||
name='edit_record'),
|
||||
path('session/', views.SessionLog.as_view(), name='session_log'),
|
||||
path('levels/', views.LevelList.as_view(), name='level_list'),
|
||||
path('level/<int:pk>/', views.LevelDetail.as_view(), name='level_detail'),
|
||||
path('level/<int:pk>/add_requirement/', views.AddLevelRequirement.as_view(), name='add_requirement'),
|
||||
path('level/remove_requirement/<int:pk>/', views.RemoveRequirement.as_view(), name='remove_requirement'),
|
||||
path('trainee/<int:pk>/level/<int:level_pk>/confirm', views.ConfirmLevel.as_view(), name='confirm_level'),
|
||||
path('trainee/<int:pk>/item_record', views.TraineeItemDetail.as_view(), name='trainee_item_detail'),
|
||||
path('trainee/<int:pk>/add_qualification/', login_required(views.AddQualification.as_view()),
|
||||
name='add_qualification'),
|
||||
path('session/', login_required(views.SessionLog.as_view()), name='session_log'),
|
||||
path('levels/', login_required(views.LevelList.as_view()), name='level_list'),
|
||||
path('level/<int:pk>/', login_required(views.LevelDetail.as_view()), name='level_detail'),
|
||||
path('level/<int:pk>/add_requirement/', login_required(views.AddLevelRequirement.as_view()), name='add_requirement'),
|
||||
path('level/remove_requirement/<int:pk>/', login_required(views.RemoveRequirement.as_view()), name='remove_requirement'),
|
||||
path('trainee/<int:pk>/level/<int:level_pk>/confirm', login_required(views.ConfirmLevel.as_view()), name='confirm_level'),
|
||||
path('trainee/<int:pk>/item_record', login_required(views.TraineeItemDetail.as_view()), name='trainee_item_detail'),
|
||||
]
|
||||
|
||||
@@ -61,7 +61,7 @@ class LevelDetail(generic.DetailView):
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["page_title"] = "Training Level {} <span class='badge badge-{} badge-pill'><span class='fas fa-{}'></span></span>".format(self.object, self.object.get_department_colour(), self.object.icon)
|
||||
context["page_title"] = "Training Level {} <span class='badge badge-{} badge-pill'><span class='fas fa-{}'></span></span>".format(self.object, self.object.department_colour, self.object.icon)
|
||||
context["users_with"] = map(lambda qual: qual.trainee, models.TrainingLevelQualification.objects.filter(level=self.object))
|
||||
return context
|
||||
|
||||
|
||||
Reference in New Issue
Block a user