-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(surveys): setup views and forms
- Loading branch information
1 parent
64285d0
commit 5801747
Showing
5 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
from django import forms | ||
|
||
from lacommunaute.surveys.enums import ( | ||
DSPAvailability, | ||
DSPHousing, | ||
DSPJudicial, | ||
DSPLanguageSkills, | ||
DSPMobility, | ||
DSPResources, | ||
DSPRightsAccess, | ||
DSPWorkCapacity, | ||
) | ||
|
||
from .models import DSP | ||
|
||
|
||
class DSPForm(forms.ModelForm): | ||
work_capacity = forms.ChoiceField( | ||
widget=forms.RadioSelect, | ||
choices=DSPWorkCapacity.choices, | ||
label="Capacité à occuper un poste de travail", | ||
initial=None, | ||
required=True, | ||
) | ||
language_skills = forms.ChoiceField( | ||
widget=forms.RadioSelect, | ||
choices=DSPLanguageSkills.choices, | ||
label="Maîtrise de la langue française", | ||
initial=None, | ||
required=True, | ||
) | ||
housing = forms.ChoiceField( | ||
widget=forms.RadioSelect, | ||
choices=DSPHousing.choices, | ||
label="Logement", | ||
initial=None, | ||
required=True, | ||
) | ||
rights_access = forms.ChoiceField( | ||
widget=forms.RadioSelect, | ||
choices=DSPRightsAccess.choices, | ||
label="Accès aux droits", | ||
initial=None, | ||
required=True, | ||
) | ||
mobility = forms.ChoiceField( | ||
widget=forms.RadioSelect, | ||
choices=DSPMobility.choices, | ||
label="Mobilité", | ||
initial=None, | ||
required=True, | ||
) | ||
resources = forms.ChoiceField( | ||
widget=forms.RadioSelect, | ||
choices=DSPResources.choices, | ||
label="Ressources", | ||
initial=None, | ||
required=True, | ||
) | ||
judicial = forms.ChoiceField( | ||
widget=forms.RadioSelect, | ||
choices=DSPJudicial.choices, | ||
label="Situation judiciaire", | ||
initial=None, | ||
required=True, | ||
) | ||
availability = forms.ChoiceField( | ||
widget=forms.RadioSelect, | ||
choices=DSPAvailability.choices, | ||
label="Disponibilité", | ||
initial=None, | ||
required=True, | ||
) | ||
|
||
class Meta: | ||
model = DSP | ||
fields = [ | ||
"work_capacity", | ||
"language_skills", | ||
"housing", | ||
"rights_access", | ||
"mobility", | ||
"resources", | ||
"judicial", | ||
"availability", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.urls import path | ||
|
||
from lacommunaute.surveys import views | ||
|
||
|
||
app_name = "surveys" | ||
|
||
urlpatterns = [ | ||
path("dsp/create/", views.DSPCreateView.as_view(), name="dsp_create"), | ||
path("dsp/<int:pk>/", views.DSPDetailView.as_view(), name="dsp_detail"), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from django.contrib.auth.mixins import LoginRequiredMixin | ||
from django.urls import reverse_lazy | ||
from django.views.generic.detail import DetailView | ||
from django.views.generic.edit import CreateView | ||
|
||
from lacommunaute.surveys.forms import DSPForm | ||
from lacommunaute.surveys.models import DSP | ||
|
||
|
||
class DSPCreateView(LoginRequiredMixin, CreateView): | ||
model = DSP | ||
template_name = "surveys/dsp_form.html" | ||
form_class = DSPForm | ||
|
||
def get_recommendations(self): | ||
return { | ||
"Recommandations": "Parcours SIAE", | ||
"Logement": "lien vers la recherche de solutions de logement DORA", | ||
"Mobilité": "lien vers la recherche de solutions de mobilité DORA", | ||
} | ||
|
||
def get_success_url(self): | ||
return reverse_lazy("surveys:dsp_detail", kwargs={"pk": self.object.pk}) | ||
|
||
def form_valid(self, form): | ||
form.instance.user = self.request.user | ||
form.instance.recommendations = self.get_recommendations() | ||
return super().form_valid(form) | ||
|
||
|
||
class DSPDetailView(LoginRequiredMixin, DetailView): | ||
model = DSP | ||
template_name = "surveys/dsp_detail.html" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{% extends 'board_base.html' %} | ||
{% load i18n %} | ||
|
||
{% block title %}Diagnostic Socio Professionnel{{ block.super }}{% endblock %} | ||
{% block meta_description %}Recommandations{% endblock meta_description %}" | ||
|
||
{% block content %} | ||
|
||
<h1>Les recommandations suite à votre diagnostic</h1> | ||
|
||
{% for label, recommendation in object.recommendations.items %} | ||
<div class="row mt-3"> | ||
<div class="col-12"> | ||
<div class="card post-edit"> | ||
<div class="card-header"> | ||
<h3 class="m-0 h4 card-title">{{label}}</h3> | ||
</div> | ||
<div class="card-body"> | ||
{{ recommendation }} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endfor %} | ||
|
||
|
||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{% extends 'board_base.html' %} | ||
{% load i18n %} | ||
|
||
{% block title %}Diagnostic Socio Professionnel{{ block.super }}{% endblock %} | ||
{% block meta_description %}DSP{% endblock meta_description %}" | ||
|
||
{% block content %} | ||
|
||
<h1>Diagnostic socio-professionnel</h1> | ||
|
||
<form method="post"> | ||
{% csrf_token %} | ||
|
||
{% for field in form %} | ||
<div class="row mt-3"> | ||
<div class="col-12"> | ||
<div class="card post-edit"> | ||
<div class="card-header"> | ||
<h3 class="m-0 h4 card-title">{{ field.label_tag }}</h3> | ||
</div> | ||
<div class="card-body"> | ||
{{ field }} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endfor %} | ||
<input type="submit" class="btn btn-sm btn-secondary mt-3" value="Valider"> | ||
</form> | ||
|
||
{% endblock content %} |