mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-02-24 15:18:24 +00:00
Compare commits
7 Commits
dependabot
...
dff5ac2308
| Author | SHA1 | Date | |
|---|---|---|---|
| dff5ac2308 | |||
| a3729fa930 | |||
| 458a734331 | |||
| b1646d556c | |||
| f8624d3b7a | |||
| f6836fdab6 | |||
| b3949f2903 |
@@ -61,6 +61,7 @@ INSTALLED_APPS = (
|
|||||||
'users',
|
'users',
|
||||||
'RIGS',
|
'RIGS',
|
||||||
'assets',
|
'assets',
|
||||||
|
'training',
|
||||||
|
|
||||||
'debug_toolbar',
|
'debug_toolbar',
|
||||||
'registration',
|
'registration',
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ urlpatterns = [
|
|||||||
path('', include('versioning.urls')),
|
path('', include('versioning.urls')),
|
||||||
path('', include('RIGS.urls')),
|
path('', include('RIGS.urls')),
|
||||||
path('assets/', include('assets.urls')),
|
path('assets/', include('assets.urls')),
|
||||||
|
path('training/', include('training.urls')),
|
||||||
|
|
||||||
path('', login_required(views.Index.as_view()), name='index'),
|
path('', login_required(views.Index.as_view()), name='index'),
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from django.views.decorators.clickjacking import xframe_options_exempt
|
|||||||
|
|
||||||
from RIGS import models
|
from RIGS import models
|
||||||
from assets import models as asset_models
|
from assets import models as asset_models
|
||||||
|
from training import models as training_models
|
||||||
|
|
||||||
|
|
||||||
def is_ajax(request):
|
def is_ajax(request):
|
||||||
@@ -38,7 +39,8 @@ class SecureAPIRequest(generic.View):
|
|||||||
'organisation': models.Organisation,
|
'organisation': models.Organisation,
|
||||||
'profile': models.Profile,
|
'profile': models.Profile,
|
||||||
'event': models.Event,
|
'event': models.Event,
|
||||||
'supplier': asset_models.Supplier
|
'supplier': asset_models.Supplier,
|
||||||
|
'training_item': training_models.TrainingItem,
|
||||||
}
|
}
|
||||||
|
|
||||||
perms = {
|
perms = {
|
||||||
@@ -47,7 +49,8 @@ class SecureAPIRequest(generic.View):
|
|||||||
'organisation': 'RIGS.view_organisation',
|
'organisation': 'RIGS.view_organisation',
|
||||||
'profile': 'RIGS.view_profile',
|
'profile': 'RIGS.view_profile',
|
||||||
'event': None,
|
'event': None,
|
||||||
'supplier': None
|
'supplier': None,
|
||||||
|
'training_item': None, # TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from reversion.admin import VersionAdmin
|
|||||||
from RIGS import models
|
from RIGS import models
|
||||||
from users import forms as user_forms
|
from users import forms as user_forms
|
||||||
|
|
||||||
# Register your models here.
|
|
||||||
admin.site.register(models.VatRate, VersionAdmin)
|
admin.site.register(models.VatRate, VersionAdmin)
|
||||||
admin.site.register(models.Event, VersionAdmin)
|
admin.site.register(models.Event, VersionAdmin)
|
||||||
admin.site.register(models.EventItem, VersionAdmin)
|
admin.site.register(models.EventItem, VersionAdmin)
|
||||||
|
|||||||
@@ -12,3 +12,4 @@ class Command(BaseCommand):
|
|||||||
call_command('generateSampleUserData')
|
call_command('generateSampleUserData')
|
||||||
call_command('generateSampleRIGSData')
|
call_command('generateSampleRIGSData')
|
||||||
call_command('generateSampleAssetsData')
|
call_command('generateSampleAssetsData')
|
||||||
|
call_command('generateSampleTrainingData')
|
||||||
|
|||||||
BIN
RIGS/static/imgs/assets.jpg
Normal file
BIN
RIGS/static/imgs/assets.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
BIN
RIGS/static/imgs/rigs.jpg
Normal file
BIN
RIGS/static/imgs/rigs.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 278 KiB |
BIN
RIGS/static/imgs/tappytaptap.gif
Normal file
BIN
RIGS/static/imgs/tappytaptap.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.3 MiB |
BIN
RIGS/static/imgs/training.jpg
Normal file
BIN
RIGS/static/imgs/training.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 852 KiB |
@@ -72,7 +72,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% include 'item_modal.html' %}
|
{% include 'partials/item_modal.html' %}
|
||||||
<form class="itemised_form" role="form" method="POST">
|
<form class="itemised_form" role="form" method="POST">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -326,7 +326,7 @@
|
|||||||
|
|
||||||
<div class="form-group" data-toggle="tooltip" title="The purchase order number (for external clients)">
|
<div class="form-group" data-toggle="tooltip" title="The purchase order number (for external clients)">
|
||||||
<label for="{{ form.purchase_order.id_for_label }}"
|
<label for="{{ form.purchase_order.id_for_label }}"
|
||||||
class="col-sm-4 col-form-label">{{ form.purchase_order.label }}</label>
|
class="col-sm-4 col-fitem_tableorm-label">{{ form.purchase_order.label }}</label>
|
||||||
|
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
{% render_field form.purchase_order class+="form-control" %}
|
{% render_field form.purchase_order class+="form-control" %}
|
||||||
@@ -348,7 +348,7 @@
|
|||||||
{% render_field form.notes class+="form-control" %}
|
{% render_field form.notes class+="form-control" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% include 'item_table.html' %}
|
{% include 'partials/item_table.html' %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
{% with object=event auth=True %}
|
{% with object=event auth=True %}
|
||||||
{% include 'item_table.html' %}
|
{% include 'partials/item_table.html' %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -78,7 +78,7 @@
|
|||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
{% with object.event as object %}
|
{% with object.event as object %}
|
||||||
{% include 'item_table.html' %}
|
{% include 'partials/item_table.html' %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{% extends 'base_rigs.html' %}
|
{% extends 'base_rigs.html' %}
|
||||||
{% load humanize %}
|
{% load humanize %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
{% block title %}RIGS{% endblock %}
|
{% block title %}RIGS{% endblock %}
|
||||||
|
|
||||||
@@ -7,8 +8,9 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<h1 class="col-sm-12 pb-3">R<small class="text-muted">ig</small> I<small class="text-muted">nformation</small> G<small class="text-muted">athering</small> S<small class="text-muted">ystem</small></h1>
|
<h1 class="col-sm-12 pb-3">R<small class="text-muted">ig</small> I<small class="text-muted">nformation</small> G<small class="text-muted">athering</small> S<small class="text-muted">ystem</small></h1>
|
||||||
<h2 class="col-sm-12 pb-3">Welcome back {{ user.get_full_name }}, there {%if rig_count == 1 %}is one rig coming up{%else%}are {{ rig_count|apnumber }} rigs coming up.{%endif%}</h2>
|
<h2 class="col-sm-12 pb-3">Welcome back {{ user.get_full_name }}, there {%if rig_count == 1 %}is one rig coming up{%else%}are {{ rig_count|apnumber }} rigs coming up.{%endif%}</h2>
|
||||||
<div class="col-sm mb-3">
|
<div class="col-sm-4 mb-3">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
<img class="card-img-top" src="{% static 'imgs/rigs.jpg' %}" alt="" style="height: 150px; object-fit: cover;">
|
||||||
<h4 class="card-header">Rigboard</h4>
|
<h4 class="card-header">Rigboard</h4>
|
||||||
<div class="list-group list-group-flush">
|
<div class="list-group list-group-flush">
|
||||||
<a class="list-group-item list-group-item-action" href="{% url 'rigboard' %}"><span class="fas fa-list align-middle"></span><span class="align-middle"> Rigboard</span></a>
|
<a class="list-group-item list-group-item-action" href="{% url 'rigboard' %}"><span class="fas fa-list align-middle"></span><span class="align-middle"> Rigboard</span></a>
|
||||||
@@ -17,6 +19,12 @@
|
|||||||
<a class="list-group-item list-group-item-action" href="{% url 'event_create' %}"><span class="fas fa-plus align-middle"></span><span class="align-middle"> New Event</span></a>
|
<a class="list-group-item list-group-item-action" href="{% url 'event_create' %}"><span class="fas fa-plus align-middle"></span><span class="align-middle"> New Event</span></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-4 mb-3">
|
||||||
|
<div class="card">
|
||||||
|
{% now "m-d" as todays_date %}
|
||||||
|
<img class="card-img-top" src="{% if todays_date == '04-01' %}{% static 'imgs/tappytaptap.gif' %}{%else%}{% static 'imgs/assets.jpg' %}{%endif%}" alt="" style="height: 150px; object-fit: cover;">
|
||||||
<h4 class="card-header">Asset Database</h4>
|
<h4 class="card-header">Asset Database</h4>
|
||||||
<div class="list-group list-group-flush">
|
<div class="list-group list-group-flush">
|
||||||
<a class="list-group-item list-group-item-action" href="{% url 'asset_index' %}"><span class="fas fa-tag align-middle"></span><span class="align-middle"> Asset List</span></a>
|
<a class="list-group-item list-group-item-action" href="{% url 'asset_index' %}"><span class="fas fa-tag align-middle"></span><span class="align-middle"> Asset List</span></a>
|
||||||
@@ -28,6 +36,21 @@
|
|||||||
<a class="list-group-item list-group-item-action" href="{% url 'supplier_create' %}"><span class="fas fa-plus align-middle"></span><span class="align-middle"> New Supplier</span></a>
|
<a class="list-group-item list-group-item-action" href="{% url 'supplier_create' %}"><span class="fas fa-plus align-middle"></span><span class="align-middle"> New Supplier</span></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-4 mb-3">
|
||||||
|
<div class="card">
|
||||||
|
<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="{% url 'session_log' %}"><span class="fas fa-plus align-middle"></span><span class="align-middle"> Log Training Session</span></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm mb-3">
|
||||||
|
<div class="card">
|
||||||
<h4 class="card-header">Quick Links</h4>
|
<h4 class="card-header">Quick Links</h4>
|
||||||
<div class="list-group list-group-flush">
|
<div class="list-group list-group-flush">
|
||||||
<a class="list-group-item list-group-item-action" href="https://forum.nottinghamtec.co.uk" target="_blank" rel="noopener noreferrer"><span class="fas fa-comment-alt text-info align-middle"></span><span class="align-middle"> TEC Forum</span></a>
|
<a class="list-group-item list-group-item-action" href="https://forum.nottinghamtec.co.uk" target="_blank" rel="noopener noreferrer"><span class="fas fa-comment-alt text-info align-middle"></span><span class="align-middle"> TEC Forum</span></a>
|
||||||
|
|||||||
0
training/__init__.py
Normal file
0
training/__init__.py
Normal file
8
training/admin.py
Normal file
8
training/admin.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
from training import models
|
||||||
|
from reversion.admin import VersionAdmin
|
||||||
|
|
||||||
|
#admin.site.register(models.Trainee, VersionAdmin)
|
||||||
|
admin.site.register(models.TrainingLevel, VersionAdmin)
|
||||||
|
admin.site.register(models.TrainingCategory, VersionAdmin)
|
||||||
|
admin.site.register(models.TrainingItem, VersionAdmin)
|
||||||
5
training/apps.py
Normal file
5
training/apps.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class TrainingConfig(AppConfig):
|
||||||
|
name = 'training'
|
||||||
20
training/forms.py
Normal file
20
training/forms.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
from django import forms
|
||||||
|
|
||||||
|
from training import models
|
||||||
|
from RIGS.models import Profile
|
||||||
|
|
||||||
|
class SessionLogForm(forms.Form):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class QualificationForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = models.TrainingItemQualification
|
||||||
|
fields = '__all__'
|
||||||
|
# exclude = ['trainee']
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
pk = kwargs.pop('pk', None)
|
||||||
|
super(QualificationForm, self).__init__(*args, **kwargs)
|
||||||
|
self.fields['trainee'].initial = Profile.objects.get(pk=pk)
|
||||||
|
|
||||||
0
training/management/commands/__init__.py
Normal file
0
training/management/commands/__init__.py
Normal file
45
training/management/commands/generateSampleTrainingData.py
Normal file
45
training/management/commands/generateSampleTrainingData.py
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import datetime
|
||||||
|
import random
|
||||||
|
|
||||||
|
from django.contrib.auth.models import Group, Permission
|
||||||
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
|
from django.db import transaction
|
||||||
|
from django.utils import timezone
|
||||||
|
from reversion import revisions as reversion
|
||||||
|
|
||||||
|
from training import models
|
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
help = 'Adds sample data to use for testing'
|
||||||
|
can_import_settings = True
|
||||||
|
|
||||||
|
categories = []
|
||||||
|
items = []
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
if not (settings.DEBUG or settings.STAGING):
|
||||||
|
raise CommandError('You cannot run this command in production')
|
||||||
|
|
||||||
|
random.seed('otherwise it is done by time, which could lead to inconsistant tests')
|
||||||
|
|
||||||
|
with transaction.atomic():
|
||||||
|
self.setup_categories()
|
||||||
|
self.setup_items()
|
||||||
|
|
||||||
|
def setup_categories(self):
|
||||||
|
names = [(1, "Basic"), (2, "Sound"), (3, "Lighting"), (4, "Rigging"), (5, "Power"), (6, "Haulage")]
|
||||||
|
|
||||||
|
for i, name in names:
|
||||||
|
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", "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), reference_number=random.randint(0, 100), name=name)
|
||||||
|
self.items.append(item)
|
||||||
80
training/migrations/0001_initial.py
Normal file
80
training/migrations/0001_initial.py
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
# Generated by Django 3.1.5 on 2021-07-05 22:01
|
||||||
|
|
||||||
|
import RIGS.models
|
||||||
|
import django.contrib.auth.models
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RIGS', '0041_auto_20210302_1204'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='TrainingCategory',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('reference_number', models.CharField(max_length=3)),
|
||||||
|
('name', models.CharField(max_length=50)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='TrainingItem',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('reference_number', models.CharField(max_length=3)),
|
||||||
|
('name', models.CharField(max_length=50)),
|
||||||
|
('category', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, related_name='items', to='training.trainingcategory')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='TrainingLevel',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('department', models.CharField(max_length=50, null=True)),
|
||||||
|
('level', models.IntegerField(choices=[(0, 'Technical Assistant'), (1, 'Technician'), (2, 'Supervisor')])),
|
||||||
|
],
|
||||||
|
bases=(models.Model, RIGS.models.RevisionMixin),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Trainee',
|
||||||
|
fields=[
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'proxy': True,
|
||||||
|
'indexes': [],
|
||||||
|
'constraints': [],
|
||||||
|
},
|
||||||
|
bases=('RIGS.profile',),
|
||||||
|
managers=[
|
||||||
|
('objects', django.contrib.auth.models.UserManager()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='TrainingLevelQualification',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('confirmed_on', models.DateTimeField()),
|
||||||
|
('confirmed_by', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, related_name='confirmer', to='training.trainee')),
|
||||||
|
('level', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, to='training.traininglevel')),
|
||||||
|
('trainee', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, related_name='levels', to='training.trainee')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='TrainingItemQualification',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('depth', models.IntegerField(choices=[(0, 'Training Started'), (1, 'Training Complete'), (2, 'Passed Out')])),
|
||||||
|
('date', models.DateField()),
|
||||||
|
('notes', models.TextField(blank=True)),
|
||||||
|
('item', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, to='training.trainingitem')),
|
||||||
|
('supervisor', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, related_name='qualifications_granted', to='training.trainee')),
|
||||||
|
('trainee', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, related_name='qualifications_obtained', to='training.trainee')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
0
training/migrations/__init__.py
Normal file
0
training/migrations/__init__.py
Normal file
64
training/models.py
Normal file
64
training/models.py
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
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
|
||||||
|
class Trainee(Profile):
|
||||||
|
class Meta:
|
||||||
|
proxy = True
|
||||||
|
|
||||||
|
def get_records_of_depth(self, depth):
|
||||||
|
return self.qualifications_obtained.filter(depth=depth)
|
||||||
|
|
||||||
|
# Items
|
||||||
|
class TrainingCategory(models.Model):
|
||||||
|
reference_number = models.CharField(max_length=3)
|
||||||
|
name = models.CharField(max_length=50)
|
||||||
|
|
||||||
|
|
||||||
|
class TrainingItem(models.Model):
|
||||||
|
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.reference_number, self.reference_number, self.name)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO Validation that dates cannot be in the future
|
||||||
|
class TrainingItemQualification(models.Model):
|
||||||
|
STARTED = 0
|
||||||
|
COMPLETE = 1
|
||||||
|
PASSED_OUT = 2
|
||||||
|
CHOICES = (
|
||||||
|
(STARTED, 'Training Started'),
|
||||||
|
(COMPLETE, 'Training Complete'),
|
||||||
|
(PASSED_OUT, 'Passed Out'),
|
||||||
|
)
|
||||||
|
item = models.ForeignKey('TrainingItem', on_delete=models.RESTRICT)
|
||||||
|
trainee = models.ForeignKey('Trainee', related_name='qualifications_obtained', on_delete=models.RESTRICT)
|
||||||
|
depth = models.IntegerField(choices=CHOICES)
|
||||||
|
date = models.DateField()
|
||||||
|
# TODO Remember that some training is external. Support for making an organisation the trainer?
|
||||||
|
supervisor = models.ForeignKey('Trainee', related_name='qualifications_granted', on_delete=models.RESTRICT)
|
||||||
|
notes = models.TextField(blank=True)
|
||||||
|
|
||||||
|
|
||||||
|
# Levels
|
||||||
|
# FIXME Common Competencies...
|
||||||
|
class TrainingLevel(models.Model, RevisionMixin):
|
||||||
|
CHOICES = (
|
||||||
|
(0, 'Technical Assistant'),
|
||||||
|
(1, 'Technician'),
|
||||||
|
(2, 'Supervisor'),
|
||||||
|
)
|
||||||
|
department = models.CharField(max_length=50, null=True) # N.B. Technical Assistant does not have a department
|
||||||
|
level = models.IntegerField(choices=CHOICES)
|
||||||
|
|
||||||
|
|
||||||
|
class TrainingLevelQualification(models.Model):
|
||||||
|
trainee = models.ForeignKey('Trainee', related_name='levels', on_delete=models.RESTRICT)
|
||||||
|
level = models.ForeignKey('TrainingLevel', on_delete=models.RESTRICT)
|
||||||
|
confirmed_on = models.DateTimeField()
|
||||||
|
confirmed_by = models.ForeignKey('Trainee', related_name='confirmer', on_delete=models.RESTRICT)
|
||||||
57
training/templates/edit_training_record.html
Normal file
57
training/templates/edit_training_record.html
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
{% extends 'base_rigs.html' %}
|
||||||
|
|
||||||
|
{% load static %}
|
||||||
|
{% load widget_tweaks %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{{ block.super }}
|
||||||
|
<link rel="stylesheet" type="text/css" href="{% static 'css/selects.css' %}"/>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block preload_js %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script src="{% static 'js/selects.js' %}"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script src="{% static 'js/autocompleter.js' %}"></script>
|
||||||
|
<script src="{% static 'js/tooltip.js' %}"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% if form.errors %}
|
||||||
|
{% include 'form_errors.html' %}
|
||||||
|
{% endif %}
|
||||||
|
<form id="item-form" action="{{ form.action|default:request.path }}" method="post">{% csrf_token %}
|
||||||
|
{% render_field form.trainee|attr:'hidden' value=form.trainee.initial %}
|
||||||
|
<div class="form-group form-row">
|
||||||
|
<label for="item_id" class="col-sm-2 col-form-label">Item</label>
|
||||||
|
<select name="item" id="item_id" class="form-control selectpicker custom-select col-sm-10" data-live-search="true" data-sourceurl="{% url 'api_secure' model='training_item' %}" required>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group form-row">
|
||||||
|
<label for="depth" class="col-sm-2 col-form-label">Depth</label>
|
||||||
|
{% render_field form.depth|add_class:'form-control custom-select selectpicker col-sm' %}
|
||||||
|
</div>
|
||||||
|
<div class="form-group form-row">
|
||||||
|
<label for="selectpicker" class="col-sm-2 col-form-label">Supervisor</label>
|
||||||
|
<select name="supervisor" id="supervisor_id" class="form-control selectpicker custom-select col-sm-10" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials" required>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group form-row">
|
||||||
|
<label for="date" class="col-sm-2 col-form-label">Training Date</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
{% render_field form.date|add_class:'form-control'|attr:'type="date"' %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group form-row">
|
||||||
|
<label for="item_description" class="col-sm-2 col-form-label">Notes</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<textarea type="text" placeholder="Notes" class="form-control"
|
||||||
|
id="notes" rows="3"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<input type="submit" class="btn btn-primary">
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
||||||
18
training/templates/item_list.html
Normal file
18
training/templates/item_list.html
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{% extends 'base_rigs.html' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="row">
|
||||||
|
{% for category in categories %}
|
||||||
|
<div class="col">
|
||||||
|
<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 %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
54
training/templates/session_log_form.html
Normal file
54
training/templates/session_log_form.html
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
{% extends 'base_rigs.html' %}
|
||||||
|
|
||||||
|
{% load static %}
|
||||||
|
{% load button from filters %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{{ block.super }}
|
||||||
|
<link rel="stylesheet" type="text/css" href="{% static 'css/selects.css' %}"/>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block preload_js %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script src="{% static 'js/selects.js' %}"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script src="{% static 'js/autocompleter.js' %}"></script>
|
||||||
|
<script src="{% static 'js/interaction.js' %}"></script>
|
||||||
|
<script src="{% static 'js/tooltip.js' %}"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<form class="form">
|
||||||
|
<h3>People</h3>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="selectpicker">Select Supervisor</label>
|
||||||
|
<select name="supervisor" id="supervisor_id" class="form-control selectpicker custom-select" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="selectpicker">Select Attendees</label>
|
||||||
|
<select multiple name="attendees" id="attendees_id" class="form-control selectpicker custom-select" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<h3>Training Items</h3>
|
||||||
|
<div class="row">
|
||||||
|
{% for depth in depths %}
|
||||||
|
<div class="col">
|
||||||
|
<h4>{{ depth.1 }}</h4>
|
||||||
|
<select multiple name="{{ depth.0 }}" id="{{ depth.0 }}_id" class="form-control selectpicker custom-select" data-live-search="true" data-sourceurl="{% url 'api_secure' model='training_item' %}">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-12 text-right my-3">
|
||||||
|
{% button 'submit' %}
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
34
training/templates/trainee_detail.html
Normal file
34
training/templates/trainee_detail.html
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
{% extends 'base_rigs.html' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<button type="button" class="btn btn-success btn-sm item-add"
|
||||||
|
data-toggle="modal"
|
||||||
|
data-target="#record_modal">
|
||||||
|
<i class="fas fa-plus"></i> Add New Training Record
|
||||||
|
</button>
|
||||||
|
<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 %}
|
||||||
18
training/urls.py
Normal file
18
training/urls.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
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'),
|
||||||
|
path('trainee/<int:pk>/edit/', views.AddQualification.as_view(),
|
||||||
|
name='edit_record'),
|
||||||
|
path('session/', views.SessionLog.as_view(), name='session_log'),
|
||||||
|
]
|
||||||
68
training/views.py
Normal file
68
training/views.py
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
from django.urls import reverse_lazy
|
||||||
|
from django.views import generic
|
||||||
|
from PyRIGS.views import OEmbedView, is_ajax
|
||||||
|
from training import models, forms
|
||||||
|
|
||||||
|
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["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
|
||||||
|
|
||||||
|
|
||||||
|
class SessionLog(generic.FormView):
|
||||||
|
template_name = "session_log_form.html"
|
||||||
|
form_class = forms.SessionLogForm
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super(SessionLog, self).get_context_data(**kwargs)
|
||||||
|
context["page_title"] = "Log New Training Session"
|
||||||
|
context["depths"] = models.TrainingItemQualification.CHOICES
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class AddQualification(generic.CreateView):
|
||||||
|
template_name = "edit_training_record.html"
|
||||||
|
model = models.TrainingItemQualification
|
||||||
|
form_class = forms.QualificationForm
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super(AddQualification, self).get_context_data(**kwargs)
|
||||||
|
# context["page_title"] = "Edit {}'s Training Record".format(self.object)
|
||||||
|
context["depths"] = models.TrainingItemQualification.CHOICES
|
||||||
|
if is_ajax(self.request):
|
||||||
|
context['override'] = "base_ajax.html"
|
||||||
|
else:
|
||||||
|
context['override'] = 'base_rigs.html' # TODO
|
||||||
|
return context
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy('trainee_detail')
|
||||||
|
|
||||||
|
def get_form_kwargs(self):
|
||||||
|
kwargs = super(AddQualification, self).get_form_kwargs()
|
||||||
|
kwargs['pk'] = self.kwargs['pk']
|
||||||
|
return kwargs
|
||||||
Reference in New Issue
Block a user