aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMR Lemon <matt@matthewlemon>2020-05-12 16:31:12 +0100
committerMR Lemon <matt@matthewlemon>2020-05-12 16:31:12 +0100
commit4201470c63c9719ca90710847985fc548ad9e6b9 (patch)
tree583ef880a7d7775a79f10511399165a8fca54670
parentdade2f791d101d1fd582782c50d76fcb95ba5596 (diff)
basic population of IGP data
-rw-r--r--ctrack/assessments/admin.py12
-rw-r--r--ctrack/assessments/migrations/0004_achievementlevel_igp.py32
-rw-r--r--ctrack/assessments/migrations/0005_auto_20200512_1438.py27
-rw-r--r--ctrack/assessments/models.py21
-rw-r--r--ctrack/assessments/tests/factories.py18
-rw-r--r--ctrack/organisations/management/commands/populate_db.py32
-rw-r--r--utility/fix_line_endings.md1
-rw-r--r--utility/truncate_script.sql2
8 files changed, 136 insertions, 9 deletions
diff --git a/ctrack/assessments/admin.py b/ctrack/assessments/admin.py
index 10c19d0..869b542 100644
--- a/ctrack/assessments/admin.py
+++ b/ctrack/assessments/admin.py
@@ -1,7 +1,7 @@
from django.contrib import admin
from ctrack.assessments.models import CAFAssessment, CAFObjective, CAFPrinciple, CAFContributingOutcome, \
- CAFAssessmentOutcomeScore
+ CAFAssessmentOutcomeScore, IGP, AchievementLevel
class CAFAssessmentAdmin(admin.ModelAdmin):
@@ -24,8 +24,18 @@ class CAFAssessmentOutcomeScoreAdmin(admin.ModelAdmin):
model = CAFAssessmentOutcomeScore
+class IGPAdmin(admin.ModelAdmin):
+ model = IGP
+
+
+class AchievementLevelAdmin(admin.ModelAdmin):
+ model = AchievementLevel
+
+
admin.site.register(CAFAssessment, CAFAssessmentAdmin)
admin.site.register(CAFObjective, CAFObjectiveAdmin)
admin.site.register(CAFPrinciple, CAFPrincipleAdmin)
admin.site.register(CAFContributingOutcome, CAFContributingOutcomeAdmin)
admin.site.register(CAFAssessmentOutcomeScore, CAFAssessmentOutcomeScoreAdmin)
+admin.site.register(IGP, IGPAdmin)
+admin.site.register(AchievementLevel, AchievementLevelAdmin)
diff --git a/ctrack/assessments/migrations/0004_achievementlevel_igp.py b/ctrack/assessments/migrations/0004_achievementlevel_igp.py
new file mode 100644
index 0000000..581a115
--- /dev/null
+++ b/ctrack/assessments/migrations/0004_achievementlevel_igp.py
@@ -0,0 +1,32 @@
+# Generated by Django 3.0.5 on 2020-05-12 14:00
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('assessments', '0003_cafassessment_completer'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='AchievementLevel',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('descriptor', models.CharField(max_length=50)),
+ ('color_description', models.CharField(max_length=100)),
+ ('color_hex', models.CharField(max_length=8)),
+ ],
+ ),
+ migrations.CreateModel(
+ name='IGP',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('descriptive_text', models.CharField(max_length=2000)),
+ ('achievement_level', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assessments.AchievementLevel')),
+ ('contributing_outcome', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assessments.CAFContributingOutcome')),
+ ],
+ ),
+ ]
diff --git a/ctrack/assessments/migrations/0005_auto_20200512_1438.py b/ctrack/assessments/migrations/0005_auto_20200512_1438.py
new file mode 100644
index 0000000..31a741a
--- /dev/null
+++ b/ctrack/assessments/migrations/0005_auto_20200512_1438.py
@@ -0,0 +1,27 @@
+# Generated by Django 3.0.5 on 2020-05-12 14:38
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('assessments', '0004_achievementlevel_igp'),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name='igp',
+ options={'verbose_name': 'IGP'},
+ ),
+ migrations.RenameField(
+ model_name='achievementlevel',
+ old_name='color_description',
+ new_name='colour_description',
+ ),
+ migrations.RenameField(
+ model_name='achievementlevel',
+ old_name='color_hex',
+ new_name='colour_hex',
+ ),
+ ]
diff --git a/ctrack/assessments/models.py b/ctrack/assessments/models.py
index db8c8e1..d3cd4dd 100644
--- a/ctrack/assessments/models.py
+++ b/ctrack/assessments/models.py
@@ -5,9 +5,6 @@ from ctrack.organisations.models import Person
class CAFAssessment(models.Model):
- """
- These are carried out by an OES as result in, or are associated with a CAF.
- """
caf = models.ForeignKey(CAF, on_delete=models.CASCADE)
completer = models.ForeignKey(Person, on_delete=models.CASCADE)
comments = models.TextField(max_length=500)
@@ -96,3 +93,21 @@ class CAFAssessmentOutcomeScore(models.Model):
def __str__(self):
return f"{self.caf_contributing_outcome} | {self.caf_assessment} | {self.assessment_score}"
+
+
+class AchievementLevel(models.Model):
+ descriptor = models.CharField(max_length=50)
+ colour_description = models.CharField(max_length=100)
+ colour_hex = models.CharField(max_length=8) # CSS hex code or simple word descriptor
+
+ def __str__(self):
+ return f"{self.descriptor}"
+
+
+class IGP(models.Model):
+ achievement_level = models.ForeignKey(AchievementLevel, on_delete=models.CASCADE)
+ contributing_outcome = models.ForeignKey(CAFContributingOutcome, on_delete=models.CASCADE)
+ descriptive_text = models.CharField(max_length=2000)
+
+ class Meta:
+ verbose_name = "IGP"
diff --git a/ctrack/assessments/tests/factories.py b/ctrack/assessments/tests/factories.py
index c8e26ec..21b2286 100644
--- a/ctrack/assessments/tests/factories.py
+++ b/ctrack/assessments/tests/factories.py
@@ -1,7 +1,17 @@
-# Factories for populating the CAF assessment data
-
import factory
+from factory import Faker
+
+from ctrack.assessments.models import AchievementLevel
+
+
+class AchievementLevelFactory(factory.DjangoModelFactory):
+ descriptor = Faker("text", max_nb_chars=30, ext_word_list=None)
+ colour_description = Faker("text", max_nb_chars=30, ext_word_list=None)
+ colour_hex = Faker("text", max_nb_chars=30, ext_word_list=None)
+
+ class Meta:
+ model = AchievementLevel
-# class CAFSelfAssessmentFactory(factory.DjangoModelFactory):
-# caf = factory.SubFactory("ctrack.caf.tests.factories.CAF")
+class IGPFactory(factory.DjangoModelFactory):
+ achievement_level = factory.SubFactory(AchievementLevelFactory)
diff --git a/ctrack/organisations/management/commands/populate_db.py b/ctrack/organisations/management/commands/populate_db.py
index bb963e3..1b10520 100644
--- a/ctrack/organisations/management/commands/populate_db.py
+++ b/ctrack/organisations/management/commands/populate_db.py
@@ -3,9 +3,10 @@ from random import randint, choice
from django.core.management import BaseCommand
from django.core.management import CommandParser
+from faker import Faker
from ctrack.assessments.models import CAFAssessment, CAFObjective, CAFPrinciple, CAFContributingOutcome, \
- CAFAssessmentOutcomeScore
+ CAFAssessmentOutcomeScore, AchievementLevel, IGP
from ctrack.caf.models import CAF
from ctrack.caf.tests.factories import (
GradingFactory,
@@ -567,6 +568,35 @@ class Command(BaseCommand):
)
]
+ achievement_levels = [
+ AchievementLevel.objects.create(
+ descriptor="Not Achieved",
+ colour_description="Red",
+ colour_hex="#000001"
+ ),
+ AchievementLevel.objects.create(
+ descriptor="Partially Achieved",
+ colour_description="Amber",
+ colour_hex="#000002"
+ ),
+ AchievementLevel.objects.create(
+ descriptor="Achieved",
+ colour_description="Green",
+ colour_hex="#000003"
+ )
+ ]
+
+ for al in achievement_levels:
+ for co in cos:
+ for igp in range(2):
+ dtext_fake = Faker()
+ fake_txt = f"IGP {igp}/{al.descriptor}/{co.designation}: {dtext_fake.paragraph()}"
+ IGP.objects.create(
+ achievement_level=al,
+ contributing_outcome=co,
+ descriptive_text=fake_txt
+ )
+
# We want to create a CAF with a bunch of scoring now...
_caf2 = CAF.objects.get(pk=1)
diff --git a/utility/fix_line_endings.md b/utility/fix_line_endings.md
new file mode 100644
index 0000000..c037df4
--- /dev/null
+++ b/utility/fix_line_endings.md
@@ -0,0 +1 @@
+`sed -i 's/\r$//' path/to/file`
diff --git a/utility/truncate_script.sql b/utility/truncate_script.sql
index e444c01..864b99f 100644
--- a/utility/truncate_script.sql
+++ b/utility/truncate_script.sql
@@ -17,4 +17,6 @@ TRUNCATE TABLE assessments_cafobjective RESTART IDENTITY CASCADE;
TRUNCATE TABLE assessments_cafprinciple RESTART IDENTITY CASCADE;
TRUNCATE TABLE assessments_cafselfassessment RESTART IDENTITY CASCADE;
TRUNCATE TABLE assessments_cafselfassessmentoutcomescore RESTART IDENTITY CASCADE;
+TRUNCATE TABLE assessments_achievementlevel RESTART IDENTITY CASCADE;
+TRUNCATE TABLE assessments_igp RESTART IDENTITY CASCADE;
DELETE FROM users_user WHERE username != 'mrlemon';