diff --git a/templates/objectives/skills/details.html b/templates/objectives/skills/details.html
index ffa616bf50..72dcd08097 100644
--- a/templates/objectives/skills/details.html
+++ b/templates/objectives/skills/details.html
@@ -88,15 +88,15 @@
diff --git a/ultron/objective/forms.py b/ultron/objective/forms.py
index a65d9bf774..0ddb363334 100644
--- a/ultron/objective/forms.py
+++ b/ultron/objective/forms.py
@@ -1,11 +1,28 @@
from django import forms
from .models import (
+ Skill,
Routine,
RoutineSkill
)
+class SkillForm(forms.ModelForm):
+ class Meta:
+ model = Skill
+ fields = (
+ "informations",
+ )
+ widgets = {
+ "informations": forms.Textarea(
+ attrs={
+ "class": "form-control",
+ "placeholder": "Informations about the skill : attention point, methodology, biomecanics, …", # pylint: disable=line-too-long
+ }
+ ),
+ }
+
+
class RoutineForm(forms.ModelForm):
class Meta:
model = Routine
diff --git a/ultron/objective/urls.py b/ultron/objective/urls.py
index b3e646eef9..b053a640b7 100644
--- a/ultron/objective/urls.py
+++ b/ultron/objective/urls.py
@@ -11,6 +11,11 @@ urlpatterns = [
path(r"skill/lookup/", views.skill_lookup, name="skill_lookup"),
path(r"skill/search/", views.skill_listing, name="skill_search"),
path(r"skill//", views.skill_details, name="skill_details"),
+ path(
+ r"skill//edit/",
+ views.skill_create_or_update,
+ name="skill_update"
+ ),
path(r"skill//tree/", views.skill_tree, name="skill_tree"),
path(
r"skill/prerequisiteless/",
diff --git a/ultron/objective/views.py b/ultron/objective/views.py
index 03b610aec0..9d9d7d569a 100644
--- a/ultron/objective/views.py
+++ b/ultron/objective/views.py
@@ -8,6 +8,7 @@ from django.urls import reverse
from ultron.people.models import Gymnast
from .forms import (
+ SkillForm,
RoutineForm,
RoutineSkillForm,
)
@@ -138,6 +139,34 @@ def skill_details(request, skill_id):
return render(request, "objectives/skills/details.html", context)
+@login_required
+@require_http_methods(["GET", "POST"])
+def skill_create_or_update(request, skill_id=None):
+ """Création ou modification d'un saut.
+
+ Args:
+ skill_id (int): identifiant d'un object de classe .
+ """
+
+ if skill_id:
+ skill = get_object_or_404(Skill, pk=skill_id)
+ else:
+ skill = None
+
+ if request.method == "POST":
+ form = SkillForm(request.POST, instance=skill)
+
+ if form.is_valid():
+ skill = form.save()
+ return HttpResponseRedirect(reverse("skill_details", args=(skill.pk,)))
+ else:
+ return render(request, "objectives/skill/create.html", {"form": form})
+
+ form = SkillForm(instance=skill)
+ context = {"form": form, "skill_id": skill_id}
+ return render(request, "objectives/skills/create.html", context)
+
+
@login_required
@require_http_methods(["GET"])
def routine_listing(request, gymnast_id=None):