Adding the core applications code to the repository
This commit is contained in:
0
sujets/__init__.py
Normal file
0
sujets/__init__.py
Normal file
BIN
sujets/__pycache__/__init__.cpython-35.pyc
Normal file
BIN
sujets/__pycache__/__init__.cpython-35.pyc
Normal file
Binary file not shown.
BIN
sujets/__pycache__/admin.cpython-35.pyc
Normal file
BIN
sujets/__pycache__/admin.cpython-35.pyc
Normal file
Binary file not shown.
BIN
sujets/__pycache__/models.cpython-35.pyc
Normal file
BIN
sujets/__pycache__/models.cpython-35.pyc
Normal file
Binary file not shown.
BIN
sujets/__pycache__/tests.cpython-35.pyc
Normal file
BIN
sujets/__pycache__/tests.cpython-35.pyc
Normal file
Binary file not shown.
BIN
sujets/__pycache__/urls.cpython-35.pyc
Normal file
BIN
sujets/__pycache__/urls.cpython-35.pyc
Normal file
Binary file not shown.
BIN
sujets/__pycache__/views.cpython-35.pyc
Normal file
BIN
sujets/__pycache__/views.cpython-35.pyc
Normal file
Binary file not shown.
14
sujets/admin.py
Normal file
14
sujets/admin.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import Sujet
|
||||
|
||||
|
||||
@admin.register(Sujet)
|
||||
class SujetAdmin(admin.ModelAdmin):
|
||||
|
||||
fieldsets = [
|
||||
('Identité', {'fields': [('nom', 'prenom'), 'genre']}),
|
||||
('Informations', {'fields': ['age', ]}),
|
||||
]
|
||||
|
||||
|
||||
5
sujets/apps.py
Normal file
5
sujets/apps.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class SujetsConfig(AppConfig):
|
||||
name = 'sujets'
|
||||
46
sujets/migrations/0001_initial.py
Normal file
46
sujets/migrations/0001_initial.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.7 on 2016-08-04 10:21
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Personne',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('genre', models.CharField(choices=[('M', 'Homme'), ('Mme', 'Femme')], default='M', max_length=3)),
|
||||
('nom', models.CharField(blank=True, max_length=32)),
|
||||
('prenom', models.CharField(blank=True, max_length=32)),
|
||||
('surnom', models.CharField(blank=True, max_length=64)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Sujet',
|
||||
fields=[
|
||||
('personne_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='sujets.Personne')),
|
||||
('premiere_rencontre', models.DateField(default=django.utils.timezone.now)),
|
||||
('age', models.SmallIntegerField(blank=True, null=True)),
|
||||
('lien_familial', models.NullBooleanField(verbose_name='Lien Familial')),
|
||||
('parcours_de_vie', models.CharField(choices=[('Familial', 'Parcours familial'), ('Institutionnel', 'Parcours institutionnel'), ('Non renseigné', 'Ne sait pas')], default='Non renseigné', max_length=64)),
|
||||
('prob_psychiatrie', models.NullBooleanField(verbose_name='Psychiatrie')),
|
||||
('prob_administratif', models.NullBooleanField(verbose_name='Administratif')),
|
||||
('prob_addiction', models.NullBooleanField(verbose_name='Addiction')),
|
||||
('prob_somatique', models.NullBooleanField(verbose_name='Somatique')),
|
||||
('habitation', models.CharField(choices=[('Sans Abri', 'Sans abri'), ('Hébergement', 'Hébergé'), ('Logement', 'Logé'), ('Mal logé', 'Mal logé'), ('Non renseigné', 'Ne sait pas')], default='Non renseigné', max_length=64, verbose_name="Type d'habitat")),
|
||||
('ressources', models.CharField(choices=[('AAH', 'AAH'), ('RSA', 'RSA'), ('Pas de ressources', 'Aucune'), ('Pôle Emploi', 'Pôle emploi'), ('Autres', 'Autres ressources'), ('Non renseigné', 'Ne sait pas')], default='Non renseigné', max_length=64, verbose_name='Ressources')),
|
||||
('connu_siao', models.NullBooleanField(verbose_name='Connu du SIAO ?')),
|
||||
],
|
||||
bases=('sujets.personne',),
|
||||
),
|
||||
]
|
||||
0
sujets/migrations/__init__.py
Normal file
0
sujets/migrations/__init__.py
Normal file
BIN
sujets/migrations/__pycache__/0001_initial.cpython-35.pyc
Normal file
BIN
sujets/migrations/__pycache__/0001_initial.cpython-35.pyc
Normal file
Binary file not shown.
BIN
sujets/migrations/__pycache__/__init__.cpython-35.pyc
Normal file
BIN
sujets/migrations/__pycache__/__init__.cpython-35.pyc
Normal file
Binary file not shown.
124
sujets/models.py
Normal file
124
sujets/models.py
Normal file
@@ -0,0 +1,124 @@
|
||||
from django.utils import timezone
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
|
||||
class Personne(models.Model):
|
||||
""" Modèle de base d'une personne
|
||||
- genre
|
||||
- nom
|
||||
- prénom
|
||||
"""
|
||||
|
||||
HOMME = 'M'
|
||||
FEMME = 'Mme'
|
||||
GENRE_CHOICES = (
|
||||
(HOMME, 'Homme'),
|
||||
(FEMME, 'Femme'),
|
||||
)
|
||||
genre = models.CharField(max_length=3,
|
||||
choices=GENRE_CHOICES,
|
||||
default=HOMME)
|
||||
nom = models.CharField(max_length=32, blank=True)
|
||||
prenom = models.CharField(max_length=32, blank=True)
|
||||
surnom = models.CharField(max_length=64, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
string = '%s ' % self.genre
|
||||
if self.nom: string += '%s ' % self.nom
|
||||
if self.surnom: string += '"%s" ' % self.surnom
|
||||
if self.prenom: string += '%s' % self.prenom
|
||||
return string
|
||||
|
||||
def clean(self):
|
||||
if not any([self.nom, self.prenom, self.surnom]):
|
||||
raise ValidationError(_("Vous devez remplir au moins un nom, prénom ou surnom"))
|
||||
return super().clean()
|
||||
|
||||
# Item: Parcours institutionnel
|
||||
PARCOURS_INSTITUTIONNEL = "Institutionnel"
|
||||
PARCOURS_FAMILIAL = "Familial"
|
||||
PARCOURS_NR = "Non renseigné"
|
||||
PARCOURS_DE_VIE_CHOICES = (
|
||||
(PARCOURS_FAMILIAL, "Parcours familial"),
|
||||
(PARCOURS_INSTITUTIONNEL, "Parcours institutionnel"),
|
||||
(PARCOURS_NR, "Ne sait pas"),
|
||||
)
|
||||
|
||||
#Item: Type d'habitation
|
||||
HABITATION_SANS = "Sans Abri"
|
||||
HABITATION_LOGEMENT = "Logement"
|
||||
HABITATION_TIERS = "Hébergement"
|
||||
HABITATION_MAL_LOGEMENT = "Mal logé"
|
||||
HABITATION_NR = "Non renseigné"
|
||||
HABITATION_CHOICES = (
|
||||
(HABITATION_SANS, "Sans abri"),
|
||||
(HABITATION_TIERS, "Hébergé"),
|
||||
(HABITATION_LOGEMENT, "Logé"),
|
||||
(HABITATION_MAL_LOGEMENT, "Mal logé"),
|
||||
(HABITATION_NR, "Ne sait pas"),
|
||||
)
|
||||
|
||||
#Item: Ressources
|
||||
RESSOURCES_RSA = "RSA"
|
||||
RESSOURCES_AAH = "AAH"
|
||||
RESSOURCES_POLE_EMPLOI = "Pôle Emploi"
|
||||
RESSOURCES_AUTRES = "Autres"
|
||||
RESSOURCES_SANS = "Pas de ressources"
|
||||
RESSOURCES_NR = "Non renseigné"
|
||||
RESSOURCES_CHOICES = (
|
||||
(RESSOURCES_AAH, "AAH"),
|
||||
(RESSOURCES_RSA, "RSA"),
|
||||
(RESSOURCES_SANS, "Aucune"),
|
||||
(RESSOURCES_POLE_EMPLOI, "Pôle emploi"),
|
||||
(RESSOURCES_AUTRES, "Autres ressources"),
|
||||
(RESSOURCES_NR, "Ne sait pas")
|
||||
)
|
||||
|
||||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Sujet(Personne):
|
||||
""" Personne faisant l'objet d'un suivi par la maraude
|
||||
|
||||
"""
|
||||
# referent = models.ForeignKey("utilisateurs.Professionnel", related_name="suivis")
|
||||
|
||||
premiere_rencontre = models.DateField(default=timezone.now)
|
||||
age = models.SmallIntegerField(blank=True, null=True)
|
||||
|
||||
lien_familial = models.NullBooleanField("Lien Familial")
|
||||
parcours_de_vie = models.CharField(max_length=64,
|
||||
choices=PARCOURS_DE_VIE_CHOICES,
|
||||
default=PARCOURS_NR)
|
||||
|
||||
# Problématiques
|
||||
prob_psychiatrie = models.NullBooleanField("Psychiatrie")
|
||||
prob_administratif = models.NullBooleanField("Administratif")
|
||||
prob_addiction = models.NullBooleanField("Addiction")
|
||||
prob_somatique = models.NullBooleanField("Somatique")
|
||||
|
||||
# Logement
|
||||
habitation = models.CharField("Type d'habitat", max_length=64,
|
||||
choices=HABITATION_CHOICES,
|
||||
default=HABITATION_NR)
|
||||
ressources = models.CharField("Ressources", max_length=64,
|
||||
choices=RESSOURCES_CHOICES,
|
||||
default=RESSOURCES_NR)
|
||||
connu_siao = models.NullBooleanField("Connu du SIAO ?")
|
||||
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Sujet"
|
||||
permissions = (
|
||||
('view_sujets', "Accès à l'application 'sujets'"),
|
||||
)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('suivis:details', kwargs={'pk': self.id})
|
||||
6
sujets/templates/sujets/base.html
Normal file
6
sujets/templates/sujets/base.html
Normal file
@@ -0,0 +1,6 @@
|
||||
{% extends "base_site.html" %}
|
||||
|
||||
{% block title %}{% endblock %}
|
||||
|
||||
{% block page_header %}{% endblock %}
|
||||
|
||||
2
sujets/templates/sujets/sujet_create.html
Normal file
2
sujets/templates/sujets/sujet_create.html
Normal file
@@ -0,0 +1,2 @@
|
||||
{% include "sujets/sujet_create_inner.html" %}
|
||||
|
||||
8
sujets/templates/sujets/sujet_create_inner.html
Normal file
8
sujets/templates/sujets/sujet_create_inner.html
Normal file
@@ -0,0 +1,8 @@
|
||||
{% load bootstrap3 %}
|
||||
<div class="row"><div class="col-md-12">
|
||||
<form class="form-horizontal" action="{% url "sujets:create" %}" method="post">{% csrf_token %}
|
||||
{% bootstrap_form form layout="horizontal"%}
|
||||
{% bootstrap_button "Ajouter un sujet" button_type="submit" button_class="btn btn-primary" %}
|
||||
{% if next %}<input type="text" hidden=True name="next" value="{{ next }}" />{%endif%}
|
||||
</form>
|
||||
</div></div>
|
||||
1
sujets/templates/sujets/sujet_details.html
Normal file
1
sujets/templates/sujets/sujet_details.html
Normal file
@@ -0,0 +1 @@
|
||||
{% include 'sujets/sujet_details_inner.html' %}
|
||||
76
sujets/templates/sujets/sujet_details_inner.html
Normal file
76
sujets/templates/sujets/sujet_details_inner.html
Normal file
@@ -0,0 +1,76 @@
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-center">
|
||||
<div class="alert alert-info">
|
||||
<p>Première rencontre le {{sujet.premiere_rencontre}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-md-offset-4">
|
||||
<a href="{% url "sujets:update" pk=sujet.id %}" class="btn btn-primary">Mettre à jour</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
État-civil
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p>Nom : {{ sujet.nom|default:'?' }}</p>
|
||||
<p>Prénom : {{ sujet.prenom|default:'?' }}</p>
|
||||
<p>Sexe : {{ sujet.genre }}</p>
|
||||
<p>Âge : {{ sujet.age|default:'?' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Problématiques
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p>Psychiatrique : {{ sujet.prob_psychiatrie }}</p>
|
||||
<p>Administratif : {{ sujet.prob_administratif }}</p>
|
||||
<p>Addiction : {{ sujet.prob_addiction }}</p>
|
||||
<p>Somatique : {{ sujet.prob_somatique }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!- Hébergement ->
|
||||
<div class="col-md-4">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Habitation
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<h4></h4>
|
||||
<p>Type : {{ sujet.habitation }}</p>
|
||||
<p>Connu du SIAO : {{ sujet.connu_siao }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!- Ressources ->
|
||||
<div class="col-md-4">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Ressources
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p>{{ sujet.ressources }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!- Parcours de vie ->
|
||||
<div class="col-md-4">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Parcours de vie
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p>Parcours : {{ sujet.parcours_de_vie }}</p>
|
||||
<p>Lien familial : {{ sujet.lien_familial }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!- row ->
|
||||
|
||||
|
||||
19
sujets/templates/sujets/sujet_liste.html
Normal file
19
sujets/templates/sujets/sujet_liste.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<div class="panel panel-default">
|
||||
<!-- Default panel contents -->
|
||||
<div class="panel-heading">Sujets connus</div>
|
||||
<div class="panel-body">
|
||||
<p>Voici la liste des sujets rencontrés dans le cadre des maraudes</p>
|
||||
</div>
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>Nom</th>
|
||||
<th>Vu le</th>
|
||||
</tr>
|
||||
{% for sujet in object_list %}
|
||||
<tr>
|
||||
<td><a href="{% url 'suivi:details' sujet.pk %}">{{sujet}}</a></td>
|
||||
<td>ToDo</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
2
sujets/templates/sujets/sujet_update.html
Normal file
2
sujets/templates/sujets/sujet_update.html
Normal file
@@ -0,0 +1,2 @@
|
||||
{% include 'sujets/sujet_update_inner.html' %}
|
||||
|
||||
60
sujets/templates/sujets/sujet_update_inner.html
Normal file
60
sujets/templates/sujets/sujet_update_inner.html
Normal file
@@ -0,0 +1,60 @@
|
||||
{% load bootstrap3 %}
|
||||
<form action="" method="post">{% csrf_token %}
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-sd-6">
|
||||
<div class="well text-center">
|
||||
<div class="form-inline">
|
||||
{% bootstrap_field form.nom layout="inline" %}
|
||||
{% bootstrap_field form.surnom layout="inline" %}
|
||||
{% bootstrap_field form.prenom layout="inline" %}
|
||||
</div><div class="form-inline"><hr />
|
||||
{% bootstrap_field form.genre layout="inline" %}
|
||||
{% bootstrap_field form.age layout="inline" %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-sd-6">
|
||||
<div class="well well-sm">
|
||||
{% bootstrap_field form.premiere_rencontre %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-sm-6">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Situation sociale</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-horizontal">
|
||||
{% bootstrap_field form.habitation layout="horizontal" label_class="col-md-6" field_class="col-md-6" %}
|
||||
{% bootstrap_field form.connu_siao layout="horizontal" label_class="col-md-6" field_class="col-md-6" %}
|
||||
{% bootstrap_field form.ressources layout="horizontal" label_class="col-md-6" field_class="col-md-6" %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-sm-6">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Problématiques</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-horizontal">
|
||||
{% bootstrap_field form.prob_addiction layout="horizontal" label_class="col-md-4" field_class="col-md-6" %}
|
||||
{% bootstrap_field form.prob_psychiatrie layout="horizontal" label_class="col-md-4" field_class="col-md-6" %}
|
||||
{% bootstrap_field form.prob_administratif layout="horizontal" label_class="col-md-4" field_class="col-md-6" %}
|
||||
{% bootstrap_field form.prob_somatique layout="horizontal" label_class="col-md-4" field_class="col-md-6" %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-sm-6">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Parcours de vie</div>
|
||||
<div class="panel-body">
|
||||
{% bootstrap_field form.parcours_de_vie %}
|
||||
{% bootstrap_field form.lien_familial %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% bootstrap_button "Enregistrer" button_type="submit" %}
|
||||
</form>
|
||||
3
sujets/tests.py
Normal file
3
sujets/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
10
sujets/urls.py
Normal file
10
sujets/urls.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from django.conf.urls import url
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'(?P<pk>[0-9]+)/$', views.SujetDetailsView.as_view(), name="details"),
|
||||
url(r'(?P<pk>[0-9]+)/update/$', views.SujetUpdateView.as_view(), name="update"),
|
||||
url(r'liste/$', views.SujetListView.as_view(), name="liste"),
|
||||
url(r'create/$', views.SujetCreateView.as_view(), name="create"),
|
||||
]
|
||||
65
sujets/views.py
Normal file
65
sujets/views.py
Normal file
@@ -0,0 +1,65 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
from django.views import generic
|
||||
from website import views
|
||||
|
||||
from .models import Sujet
|
||||
|
||||
from django.forms import ModelForm
|
||||
|
||||
# Create your views here.
|
||||
|
||||
class SujetsView(views.WebsiteProtectedMixin):
|
||||
title = "Sujets"
|
||||
|
||||
def get_active_app(self):
|
||||
return super().get_active_app(app_name='suivi')
|
||||
|
||||
|
||||
|
||||
class SujetDetailsView(SujetsView, generic.DetailView):
|
||||
template_name = "sujets/sujet_details.html"
|
||||
model = Sujet
|
||||
|
||||
|
||||
|
||||
class SujetListView(SujetsView, generic.ListView):
|
||||
model = Sujet
|
||||
template_name = "sujets/sujet_liste.html"
|
||||
|
||||
|
||||
|
||||
class SujetUpdateView(SujetsView, generic.edit.UpdateView):
|
||||
template_name = "sujets/sujet_update.html"
|
||||
model = Sujet
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
|
||||
class SujetCreateForm(ModelForm):
|
||||
class Meta:
|
||||
model = Sujet
|
||||
fields = ['nom', 'surnom', 'prenom', 'genre', 'premiere_rencontre']
|
||||
|
||||
|
||||
|
||||
class SujetCreateView(SujetsView, generic.edit.CreateView, views.AjaxTemplateMixin):
|
||||
template_name = "sujets/sujet_create.html"
|
||||
form_class = SujetCreateForm
|
||||
|
||||
title = "Création : Sujet"
|
||||
header = "Ajouter un sujet"
|
||||
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
if 'next' in self.request.POST:
|
||||
self.success_url = self.request.POST["next"]
|
||||
return super().post(self, request, *args, **kwargs)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
try:
|
||||
context['next'] = self.request.GET['next']
|
||||
except:
|
||||
context['next'] = None
|
||||
return context
|
||||
Reference in New Issue
Block a user