from django import forms from datetime import date from .models import Routine, RoutineSkill, Plan class RoutineForm(forms.ModelForm): class Meta: model = Routine fields = ( "long_label", "short_label", "difficulty", "level", "active", "informations", ) widgets = { "long_label": forms.TextInput( attrs={"class": "form-control", "placeholder": "Routine's long name"} ), "short_label": forms.TextInput( attrs={"class": "form-control", "placeholder": "Routine's short name"} ), "informations": forms.Textarea( attrs={ "class": "form-control", "placeholder": "Informations about the psychological state of mind : context (why, where, …), possible consequencies, …", } ), "difficulty": forms.HiddenInput(), "level": forms.HiddenInput(), "active": forms.HiddenInput(), } class PlanForm(forms.ModelForm): """ Formulaire d'enregistrement d'un couple plan """ class Meta: model = Plan fields = ("date", "gymnast", "educative") widgets = { "gymnast": forms.HiddenInput(), "educative": forms.HiddenInput(), "date": forms.TextInput( attrs={ "class": "form-control datepicker", "placeholder": date.today().strftime("%Y-%m-%d"), "value": date.today().strftime("%Y-%m-%d"), } ), } gymnast_related = forms.CharField( widget=forms.TextInput( attrs={ "class": "form-control", "placeholder": "Searching gymnast…", "data-ref": "#id_gymnast", } ) ) educative_related = forms.CharField( widget=forms.TextInput( attrs={ "class": "form-control", "placeholder": "Searching skill…", "data-ref": "#id_skill", } ) )