diff --git a/package-lock.json b/package-lock.json index 24528b69..2b73da2d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "PyRIGS", "version": "1.0.0", "license": "Custom", "dependencies": { diff --git a/training/management/commands/generateSampleTrainingData.py b/training/management/commands/generateSampleTrainingData.py index 8b92452d..d89cd724 100644 --- a/training/management/commands/generateSampleTrainingData.py +++ b/training/management/commands/generateSampleTrainingData.py @@ -143,6 +143,11 @@ class Command(BaseCommand): "Bin Diving", "Wiki Editing"] + descriptions = ["Physical training concentrates on mechanistic goals: training programs in this area develop specific motor skills, agility, strength or physical fitness, often with an intention of peaking at a particular time.", + "In military use, training means gaining the physical ability to perform and survive in combat, and learn the many skills needed in a time of war. These include how to use a variety of weapons, outdoor survival skills, and how to survive being captured by the enemy, among many others. See military education and training.", + "For psychological or physiological reasons, people who believe it may be beneficial to them can choose to practice relaxation training, or autogenic training, in an attempt to increase their ability to relax or deal with stress. While some studies have indicated relaxation training is useful for some medical conditions, autogenic training has limited results or has been the result of few studies.", + "Some occupations are inherently hazardous, and require a minimum level of competence before the practitioners can perform the work at an acceptable level of safety to themselves or others in the vicinity. Occupational diving, rescue, firefighting and operation of certain types of machinery and vehicles may require assessment and certification of a minimum acceptable competence before the person is allowed to practice as a licensed instructor."] + for i, name in enumerate(names): category = random.choice(self.categories) previous_item = models.TrainingItem.objects.filter(category=category).last() @@ -150,7 +155,7 @@ class Command(BaseCommand): number = previous_item.reference_number + 1 else: number = 0 - item = models.TrainingItem.objects.create(category=category, reference_number=number, description=name) + item = models.TrainingItem.objects.create(category=category, reference_number=number, name=name, description=random.choice(descriptions)) self.items.append(item) def setup_levels(self): diff --git a/training/migrations/0006_rename_description_trainingitem_name.py b/training/migrations/0006_rename_description_trainingitem_name.py new file mode 100644 index 00000000..5976da1c --- /dev/null +++ b/training/migrations/0006_rename_description_trainingitem_name.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.18 on 2023-02-19 14:02 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('training', '0005_auto_20220223_1535'), + ] + + operations = [ + migrations.RenameField( + model_name='trainingitem', + old_name='description', + new_name='name', + ), + ] diff --git a/training/migrations/0007_trainingitem_description.py b/training/migrations/0007_trainingitem_description.py new file mode 100644 index 00000000..4a087668 --- /dev/null +++ b/training/migrations/0007_trainingitem_description.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.18 on 2023-02-19 14:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('training', '0006_rename_description_trainingitem_name'), + ] + + operations = [ + migrations.AddField( + model_name='trainingitem', + name='description', + field=models.TextField(blank=True), + ), + ] diff --git a/training/models.py b/training/models.py index db36c7ed..9f6fddc8 100644 --- a/training/models.py +++ b/training/models.py @@ -85,7 +85,7 @@ class TrainingItemManager(QueryablePropertiesManager): def search(self, query=None): qs = self.get_queryset() if query is not None: - or_lookup = (Q(description__icontains=query) | Q(display_id=query)) + or_lookup = (Q(name__icontains=query) | Q(description__icontains=query) | Q(display_id=query)) qs = qs.filter(or_lookup).distinct() # distinct() is often necessary with Q lookups return qs @@ -94,16 +94,13 @@ class TrainingItemManager(QueryablePropertiesManager): class TrainingItem(models.Model): reference_number = models.IntegerField() category = models.ForeignKey('TrainingCategory', related_name='items', on_delete=models.CASCADE) - description = models.CharField(max_length=50) + name = models.CharField(max_length=50) + description = models.TextField(blank=True) active = models.BooleanField(default=True) prerequisites = models.ManyToManyField('self', symmetrical=False, blank=True) objects = TrainingItemManager() - @property - def name(self): - return str(self) - @queryable_property def display_id(self): return f"{self.category.reference_number}.{self.reference_number}" @@ -121,7 +118,7 @@ class TrainingItem(models.Model): return models.Q() def __str__(self): - name = f"{self.display_id} {self.description}" + name = f"{self.display_id} {self.name}" if not self.active: name += " (inactive)" return name @@ -149,7 +146,7 @@ class TrainingItemQualificationManager(QueryablePropertiesManager): def search(self, query=None): qs = self.get_queryset().select_related('item', 'supervisor', 'item__category') if query is not None: - or_lookup = (Q(item__description__icontains=query) | Q(supervisor__first_name__icontains=query) | Q(supervisor__last_name__icontains=query) | Q(item__category__name__icontains=query) | Q(item__display_id=query)) + or_lookup = (Q(item__name__icontains=query) | Q(supervisor__first_name__icontains=query) | Q(supervisor__last_name__icontains=query) | Q(item__category__name__icontains=query) | Q(item__display_id=query)) try: or_lookup = Q(item__category__reference_number=int(query)) | or_lookup diff --git a/training/templates/item_list.html b/training/templates/item_list.html index 556c550b..bcd63050 100644 --- a/training/templates/item_list.html +++ b/training/templates/item_list.html @@ -13,7 +13,8 @@
Passed Out Prerequisites:
@@ -24,7 +25,6 @@