From 8635941d39aa7353ef72eecd7e914270a558488b Mon Sep 17 00:00:00 2001 From: Gregory Trullemans Date: Wed, 11 Oct 2023 14:56:32 +0200 Subject: [PATCH] Remove Injury and InjuryLocation models --- jarvis/followup/admin.py | 64 +++++----- jarvis/followup/forms.py | 116 +++++++++--------- ...061_delete_injury_delete_injurylocation.py | 19 +++ jarvis/followup/models.py | 116 +++++++++--------- jarvis/followup/views.py | 4 +- jarvis/people/views.py | 6 +- 6 files changed, 172 insertions(+), 153 deletions(-) create mode 100644 jarvis/followup/migrations/0061_delete_injury_delete_injurylocation.py diff --git a/jarvis/followup/admin.py b/jarvis/followup/admin.py index 7e2b866..a482849 100644 --- a/jarvis/followup/admin.py +++ b/jarvis/followup/admin.py @@ -11,13 +11,13 @@ from .models import ( Note, Point, Chrono, - Injury, + # Injury, WellBeing, Intensity, HeightWeight, LearnedSkill, ChronoDetails, - InjuryLocation, + # InjuryLocation, GymnastHasRoutine, SeasonInformation, NumberOfRoutineDone, @@ -91,38 +91,38 @@ class PointAdmin(admin.ModelAdmin): autocomplete_fields = ("gymnast", "event") -class InjuryLocationAdmin(admin.ModelAdmin): - model = InjuryLocation +# class InjuryLocationAdmin(admin.ModelAdmin): +# model = InjuryLocation - list_display = ("label",) - fields = ("label",) - search_fields = ("label",) +# list_display = ("label",) +# fields = ("label",) +# search_fields = ("label",) -class InjuryAdmin(admin.ModelAdmin): - model = Injury +# class InjuryAdmin(admin.ModelAdmin): +# model = Injury - fields = ( - "date", - "gymnast", - "skill", - "location", - "body_side", - "mechanism", - "nb_week_off", - "informations", - ) # educative - readonly_fields = ("season", "week_number", "created_at", "updated_at") - list_display = ("date", "gymnast", "skill") # educative - list_filter = ( - ("gymnast", RelatedDropdownFilter), - ("location", RelatedDropdownFilter), - ("body_side", DropdownFilter), - ("mechanism", DropdownFilter), - ) - date_hierarchy = "date" - search_fields = ("date", "gymnast") # educative - autocomplete_fields = ("gymnast", "skill") +# fields = ( +# "date", +# "gymnast", +# "skill", +# "location", +# "body_side", +# "mechanism", +# "nb_week_off", +# "informations", +# ) # educative +# readonly_fields = ("season", "week_number", "created_at", "updated_at") +# list_display = ("date", "gymnast", "skill") # educative +# list_filter = ( +# ("gymnast", RelatedDropdownFilter), +# ("location", RelatedDropdownFilter), +# ("body_side", DropdownFilter), +# ("mechanism", DropdownFilter), +# ) +# date_hierarchy = "date" +# search_fields = ("date", "gymnast") # educative +# autocomplete_fields = ("gymnast", "skill") class WellBeingAdmin(admin.ModelAdmin): @@ -298,13 +298,13 @@ admin.site.register(Plan, PlanAdmin) admin.site.register(Note, NoteAdmin) admin.site.register(Point, PointAdmin) admin.site.register(Chrono, ChronoAdmin) -admin.site.register(Injury, InjuryAdmin) +# admin.site.register(Injury, InjuryAdmin) admin.site.register(WellBeing, WellBeingAdmin) admin.site.register(Intensity, IntensityAdmin) admin.site.register(LearnedSkill, LearnedSkillAdmin) admin.site.register(HeightWeight, HeightWeightAdmin) admin.site.register(ChronoDetails, ChronoDetailsAdmin) -admin.site.register(InjuryLocation, InjuryLocationAdmin) +# admin.site.register(InjuryLocation, InjuryLocationAdmin) admin.site.register(SeasonInformation, SeasonInformationAdmin) admin.site.register(GymnastHasRoutine, GymnastHasRoutineAdmin) admin.site.register(NumberOfRoutineDone, NumberOfRoutineDoneAdmin) diff --git a/jarvis/followup/forms.py b/jarvis/followup/forms.py index 79cfdd3..855364c 100644 --- a/jarvis/followup/forms.py +++ b/jarvis/followup/forms.py @@ -7,7 +7,7 @@ from .models import ( Note, Point, Chrono, - Injury, + # Injury, WellBeing, Intensity, HeightWeight, @@ -181,65 +181,65 @@ class ScoreForm(forms.ModelForm): ) -class InjuryForm(forms.ModelForm): - class Meta: - model = Injury - fields = ( - "gymnast", - "date", - "mechanism", - "injury_type", - "location", - "body_side", - "nb_week_off", - "informations", - ) - widgets = { - "date": forms.DateInput( - attrs={ - "class": "form-control datepicker", - "placeholder": date.today().strftime("%Y-%m-%d"), - "value": date.today().strftime("%Y-%m-%d"), - } - ), - "gymnast": forms.HiddenInput(), - "skill": forms.HiddenInput(), - "injury_type": forms.Select(attrs={"class": "form-control selectpicker"}), - "mechanism": forms.Select(attrs={"class": "form-control selectpicker"}), - "location": forms.Select(attrs={"class": "form-control selectpicker"}), - "body_side": forms.Select(attrs={"class": "form-control selectpicker"}), - "nb_week_off": forms.NumberInput( - attrs={"class": "form-control", "placeholder": "xx"} - ), - "informations": forms.Textarea( - attrs={ - "class": "form-control", - "placeholder": "Informations about injury: context (why, where, …), consequencies, re-education exercices, …", # pylint: disable=line-too-long - } - ), - } +# class InjuryForm(forms.ModelForm): +# class Meta: +# model = Injury +# fields = ( +# "gymnast", +# "date", +# "mechanism", +# "injury_type", +# "location", +# "body_side", +# "nb_week_off", +# "informations", +# ) +# widgets = { +# "date": forms.DateInput( +# attrs={ +# "class": "form-control datepicker", +# "placeholder": date.today().strftime("%Y-%m-%d"), +# "value": date.today().strftime("%Y-%m-%d"), +# } +# ), +# "gymnast": forms.HiddenInput(), +# "skill": forms.HiddenInput(), +# "injury_type": forms.Select(attrs={"class": "form-control selectpicker"}), +# "mechanism": forms.Select(attrs={"class": "form-control selectpicker"}), +# "location": forms.Select(attrs={"class": "form-control selectpicker"}), +# "body_side": forms.Select(attrs={"class": "form-control selectpicker"}), +# "nb_week_off": forms.NumberInput( +# attrs={"class": "form-control", "placeholder": "xx"} +# ), +# "informations": forms.Textarea( +# attrs={ +# "class": "form-control", +# "placeholder": "Informations about injury: context (why, where, …), consequencies, re-education exercices, …", # pylint: disable=line-too-long +# } +# ), +# } - gymnast_related = forms.CharField( - required=False, - widget=forms.TextInput( - attrs={ - "class": "form-control", - "placeholder": "Searching gymnast…", - "data-ref": "#id_gymnast", - } - ), - ) +# gymnast_related = forms.CharField( +# required=False, +# widget=forms.TextInput( +# attrs={ +# "class": "form-control", +# "placeholder": "Searching gymnast…", +# "data-ref": "#id_gymnast", +# } +# ), +# ) - skill_related = forms.CharField( - required=False, - widget=forms.TextInput( - attrs={ - "class": "form-control", - "placeholder": "Searching skill…", - "data-ref": "#id_skill", - } - ), - ) +# skill_related = forms.CharField( +# required=False, +# widget=forms.TextInput( +# attrs={ +# "class": "form-control", +# "placeholder": "Searching skill…", +# "data-ref": "#id_skill", +# } +# ), +# ) class WellBeingForm(forms.ModelForm): diff --git a/jarvis/followup/migrations/0061_delete_injury_delete_injurylocation.py b/jarvis/followup/migrations/0061_delete_injury_delete_injurylocation.py new file mode 100644 index 0000000..75e7f10 --- /dev/null +++ b/jarvis/followup/migrations/0061_delete_injury_delete_injurylocation.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2 on 2023-10-11 12:56 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("followup", "0060_alter_injury_injury_type_alter_injury_location_and_more"), + ] + + operations = [ + migrations.DeleteModel( + name="Injury", + ), + migrations.DeleteModel( + name="InjuryLocation", + ), + ] diff --git a/jarvis/followup/models.py b/jarvis/followup/models.py index ee7ad0a..1c2ec06 100644 --- a/jarvis/followup/models.py +++ b/jarvis/followup/models.py @@ -162,73 +162,73 @@ class ChronoDetails(models.Model): value = models.DecimalField(max_digits=5, decimal_places=3) -class InjuryLocation(models.Model): - """ - Classe représentant les localisations de blessures - """ +# class InjuryLocation(models.Model): +# """ +# Classe représentant les localisations de blessures +# """ - class Meta: - verbose_name = "Injury Location" - verbose_name_plural = "Injury Locations" +# class Meta: +# verbose_name = "Injury Location" +# verbose_name_plural = "Injury Locations" - label = models.CharField(max_length=100, null=False, blank=False) +# label = models.CharField(max_length=100, null=False, blank=False) - def __str__(self): - return f"{self.label}" +# def __str__(self): +# return f"{self.label}" -class Injury(Markdownizable, Seasonisable): - """ - La classe `Injury` permet d'indiquer qu'un gymnaste a eu un blessure, en liaison avec un - skill ou non. - """ +# class Injury(Markdownizable, Seasonisable): +# """ +# La classe `Injury` permet d'indiquer qu'un gymnaste a eu un blessure, en liaison avec un +# skill ou non. +# """ - class Meta: - verbose_name = "Injury" - verbose_name_plural = "Injuries" - # unique_together = ("gymnast", "skill", "date") +# class Meta: +# verbose_name = "Injury" +# verbose_name_plural = "Injuries" +# # unique_together = ("gymnast", "skill", "date") - gymnast = models.ForeignKey( - Gymnast, - verbose_name="Gymnast", - related_name="injuries", - on_delete=models.CASCADE, - ) - skill = models.ForeignKey( - "objective.Skill", - verbose_name="Skill", - related_name="injuries", - on_delete=models.SET_NULL, - default=None, - blank=True, - null=True, - ) - location = models.ForeignKey( - InjuryLocation, - verbose_name="Location", - related_name="injuries", - on_delete=models.CASCADE, - ) - injury_type = models.SmallIntegerField( - choices=INJURY_TYPE_CHOICE, verbose_name="Injury type" - ) - body_side = models.PositiveSmallIntegerField( - choices=INJURY_BODY_SIDE_CHOICE, verbose_name="Body side" - ) - mechanism = models.PositiveSmallIntegerField( - choices=INJURY_MECHANISM_CHOICE, verbose_name="Injury mechanism" - ) - nb_week_off = models.SmallIntegerField( - blank=True, null=True, verbose_name="# week off" - ) - created_at = models.DateTimeField(auto_now_add=True) - updated_at = models.DateTimeField(auto_now=True) +# gymnast = models.ForeignKey( +# Gymnast, +# verbose_name="Gymnast", +# related_name="injuries", +# on_delete=models.CASCADE, +# ) +# skill = models.ForeignKey( +# "objective.Skill", +# verbose_name="Skill", +# related_name="injuries", +# on_delete=models.SET_NULL, +# default=None, +# blank=True, +# null=True, +# ) +# location = models.ForeignKey( +# InjuryLocation, +# verbose_name="Location", +# related_name="injuries", +# on_delete=models.CASCADE, +# ) +# injury_type = models.SmallIntegerField( +# choices=INJURY_TYPE_CHOICE, verbose_name="Injury type" +# ) +# body_side = models.PositiveSmallIntegerField( +# choices=INJURY_BODY_SIDE_CHOICE, verbose_name="Body side" +# ) +# mechanism = models.PositiveSmallIntegerField( +# choices=INJURY_MECHANISM_CHOICE, verbose_name="Injury mechanism" +# ) +# nb_week_off = models.SmallIntegerField( +# blank=True, null=True, verbose_name="# week off" +# ) +# created_at = models.DateTimeField(auto_now_add=True) +# updated_at = models.DateTimeField(auto_now=True) - def __str__(self): - return f"{self.gymnast} ({self.date})" +# def __str__(self): +# return f"{self.gymnast} ({self.date})" - def timeline_representation(self): - return f"
  • {self.date:%d %b %Y} - Accident ({self.skill}): {self.nb_week_off} (weeks off)
  • " +# def timeline_representation(self): +# return f"
  • {self.date:%d %b %Y} - Accident ({self.skill}): {self.nb_week_off} (weeks off)
  • " class LearnedSkill(Seasonisable): diff --git a/jarvis/followup/views.py b/jarvis/followup/views.py index 68ffbcb..e485ff2 100644 --- a/jarvis/followup/views.py +++ b/jarvis/followup/views.py @@ -19,7 +19,7 @@ from .models import ( Note, Point, Chrono, - Injury, + # Injury, WellBeing, Intensity, LearnedSkill, @@ -35,7 +35,7 @@ from .forms import ( NoteForm, ScoreForm, ChronoForm, - InjuryForm, + # InjuryForm, WellBeingForm, IntensityForm, HeightWeightForm, diff --git a/jarvis/people/views.py b/jarvis/people/views.py index 4eb7339..60dec2b 100644 --- a/jarvis/people/views.py +++ b/jarvis/people/views.py @@ -35,7 +35,7 @@ from jarvis.followup.models import ( Skill, Point, Chrono, - Injury, + # Injury, WellBeing, Intensity, LearnedSkill, @@ -287,7 +287,7 @@ def gymnast_display_injury(request, gymnast_id): Args: gymnast_id (int) identifiant du gymnast """ - injuries_list = Injury.objects.filter(gymnast=gymnast_id) + injuries_list = None # Injury.objects.filter(gymnast=gymnast_id) context = {"injuries_list": injuries_list, "gymnast_id": gymnast_id} return render(request, "gymnasts/list_injury.html", context) @@ -301,7 +301,7 @@ def gymnast_display_physiological(request, gymnast_id): Args: gymnast_id (int) identifiant du gymnast """ - injuries_list = Injury.objects.filter(gymnast=gymnast_id).order_by("date") + injuries_list = None # Injury.objects.filter(gymnast=gymnast_id).order_by("date") wellbeing_list = WellBeing.objects.filter(gymnast=gymnast_id).order_by("date") height_weight_list = HeightWeight.objects.filter(gymnast=gymnast_id).order_by( "date"