mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 21:42:14 +00:00
Machine switch
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
<img class="card-img-top" src="{% static 'imgs/training.jpg' %}" alt="" style="height: 150px; object-fit: cover;">
|
||||
<h4 class="card-header">Training Database</h4>
|
||||
<div class="list-group list-group-flush">
|
||||
<a class="list-group-item list-group-item-action" href="{% url 'trainee_detail' %}"><span class="fas fa-file-signature align-middle"></span><span class="align-middle"> My Training Record</span></a>
|
||||
<a class="list-group-item list-group-item-action" href="{% url 'item_list' %}"><span class="fas fa-eye align-middle"></span><span class="align-middle"> View Training Items</span></a>
|
||||
<a class="list-group-item list-group-item-action" href=""><span class="fas fa-plus align-middle"></span><span class="align-middle"> Log Training Session</span></a>
|
||||
</div>
|
||||
|
||||
@@ -33,13 +33,13 @@ class Command(BaseCommand):
|
||||
names = [(1, "Basic"), (2, "Sound"), (3, "Lighting"), (4, "Rigging"), (5, "Power"), (6, "Haulage")]
|
||||
|
||||
for i, name in names:
|
||||
category = models.TrainingCategory.objects.create(number=i, name=name)
|
||||
category = models.TrainingCategory.objects.create(reference_number=i, name=name)
|
||||
category.save()
|
||||
self.categories.append(category)
|
||||
|
||||
def setup_items(self):
|
||||
names = ["Motorised Power Towers", "Catering", "Forgetting Cables", "Gazebo Construction", "Balanced Audio", "Unbalanced Audio"]
|
||||
names = ["Motorised Power Towers", "Catering", "Forgetting Cables", "Gazebo Construction", "Balanced Audio", "Unbalanced Audio", "BBQ/Bin Interactions", "Pushing Boxes", "How Not To Die", "Setting up projectors", "Basketing truss", "First Aid", "Digging Trenches", "Avoiding Bin Lorries", "Getting cherry pickers stuck in mud", "Crashing the Van"]
|
||||
|
||||
for i,name in enumerate(names):
|
||||
item = models.TrainingItem.objects.create(category=random.choice(self.categories), number=random.randint(0, 100), name=name)
|
||||
item = models.TrainingItem.objects.create(category=random.choice(self.categories), reference_number=random.randint(0, 100), name=name)
|
||||
self.items.append(item)
|
||||
|
||||
19
training/migrations/0003_auto_20210630_1624.py
Normal file
19
training/migrations/0003_auto_20210630_1624.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 3.1.5 on 2021-06-30 15:24
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('training', '0002_auto_20210630_1514'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='trainingitem',
|
||||
name='category',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, related_name='items', to='training.trainingcategory'),
|
||||
),
|
||||
]
|
||||
23
training/migrations/0004_auto_20210630_1641.py
Normal file
23
training/migrations/0004_auto_20210630_1641.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.1.5 on 2021-06-30 15:41
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('training', '0003_auto_20210630_1624'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='trainingcategory',
|
||||
old_name='number',
|
||||
new_name='reference_number',
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='trainingitem',
|
||||
old_name='number',
|
||||
new_name='reference_number',
|
||||
),
|
||||
]
|
||||
@@ -4,23 +4,26 @@ from RIGS.models import RevisionMixin, Profile
|
||||
from reversion import revisions as reversion
|
||||
|
||||
# 'shim' overtop the profile model to neatly contain all training related fields etc
|
||||
@reversion.register
|
||||
class Trainee(Profile):
|
||||
pass
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
def get_records_of_depth(self, depth):
|
||||
return self.training_items.filter(depth=depth)
|
||||
|
||||
# Items
|
||||
class TrainingCategory(models.Model):
|
||||
number = models.CharField(max_length=3)
|
||||
reference_number = models.CharField(max_length=3)
|
||||
name = models.CharField(max_length=50)
|
||||
|
||||
|
||||
class TrainingItem(models.Model):
|
||||
category = models.ForeignKey('TrainingCategory', related_name='category', on_delete=models.RESTRICT)
|
||||
number = models.CharField(max_length=3)
|
||||
reference_number = models.CharField(max_length=3)
|
||||
category = models.ForeignKey('TrainingCategory', related_name='items', on_delete=models.RESTRICT)
|
||||
name = models.CharField(max_length=50)
|
||||
|
||||
def __str__(self):
|
||||
return "{}.{} {}".format(self.category.number, self.number, self.name)
|
||||
return "{}.{} {}".format(self.category.reference_number, self.reference_number, self.name)
|
||||
|
||||
|
||||
# TODO Validation that dates cannot be in the future
|
||||
@@ -34,24 +37,23 @@ class TrainingItemQualification(models.Model):
|
||||
(PASSED_OUT, 'Passed Out'),
|
||||
)
|
||||
item = models.ForeignKey('TrainingItem', on_delete=models.RESTRICT)
|
||||
trainee = models.ForeignKey('Trainee', related_name='items', on_delete=models.RESTRICT)
|
||||
trainee = models.ForeignKey('Trainee', related_name='training_items', on_delete=models.RESTRICT)
|
||||
depth = models.IntegerField(choices=CHOICES)
|
||||
date = models.DateTimeField()
|
||||
# TODO Remember that some training is external. Support for making an organisation the trainer?
|
||||
supervisor = models.ForeignKey('Trainee', related_name='training_started', on_delete=models.RESTRICT)
|
||||
notes = models.TextField()
|
||||
|
||||
|
||||
# Levels
|
||||
# FIXME Common Competencies...
|
||||
class TrainingLevel(models.Model, RevisionMixin):
|
||||
ASSISTANT = 0
|
||||
TECHNICIAN = 1
|
||||
SUPERVISOR = 2
|
||||
CHOICES = (
|
||||
(ASSISTANT, 'Technical Assistant'),
|
||||
(TECHNICIAN, 'Technician'),
|
||||
(SUPERVISOR, 'Supervisor'),
|
||||
(0, 'Technical Assistant'),
|
||||
(1, 'Technician'),
|
||||
(2, 'Supervisor'),
|
||||
)
|
||||
department = models.CharField(max_length=50, null=True) # Technical Assistant does not have a department
|
||||
department = models.CharField(max_length=50, null=True) # N.B. Technical Assistant does not have a department
|
||||
level = models.IntegerField(choices=CHOICES)
|
||||
|
||||
|
||||
|
||||
@@ -4,8 +4,13 @@
|
||||
<div class="row">
|
||||
{% for category in categories %}
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
<div class="card mb-3">
|
||||
<h4 class="card-header">{{ category.name }}</h4>
|
||||
<div class="list-group list-group-flush">
|
||||
{% for item in category.items.all %}
|
||||
<li class="list-group-item">{{ item }}</li>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
12
training/templates/session_log_form.html
Normal file
12
training/templates/session_log_form.html
Normal file
@@ -0,0 +1,12 @@
|
||||
{% extends 'base_rigs.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<h1>Log New Training Session</h1>
|
||||
<div class="form-group">
|
||||
<label for="selectpicker">Select Attendees</label>
|
||||
<select name="attendees" id="attendees_id" class="form-control selectpicker" data-live-search="true">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
29
training/templates/trainee_detail.html
Normal file
29
training/templates/trainee_detail.html
Normal file
@@ -0,0 +1,29 @@
|
||||
{% extends 'base_rigs.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row mb-3">
|
||||
<h2 class="col-12">Training Levels</h2>
|
||||
<p>{{ user.name }} is a...<br></p>
|
||||
<div class="col">
|
||||
<h2><div class="badge badge-success">Sound Supervisor <span class="fas fa-volume-up"></span></div><h2>
|
||||
<h3><div class="badge badge-danger">Power Technician <span class="fas fa-plug"></span></div></h3>
|
||||
<h4><div class="badge badge-primary">Technical Assistant <span class="fas fa-wrench"></span></div></h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<h2 class="col-12">Training Items</h2><br>
|
||||
{% for category in categories %}
|
||||
<div class="col-md-3">
|
||||
<div class="card mb-3">
|
||||
<h3 class="card-header">{{ category.name }}</h3>
|
||||
<div class="list-group list-group-flush">
|
||||
{% for depth in depths %}
|
||||
<li class="list-group-item {% if depth.0 == 0 %}list-group-item-warning{%elif depth.0 == 1%}list-group-item-success{%else%}list-group-item-info{%endif%}">{{depth.1}}</li>
|
||||
<li class="list-group-item">Dummy Item</li>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -1,7 +1,15 @@
|
||||
from django.urls import path
|
||||
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from PyRIGS.decorators import permission_required_with_403
|
||||
|
||||
from training import views
|
||||
|
||||
urlpatterns = [
|
||||
path('items/', views.ItemList.as_view(), name='item_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'),
|
||||
]
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user