--- /dev/null
+# -*- encoding: utf-8 -*-
+from django import forms
+from models import *
+
+class PersonneForm(forms.ModelForm):
+ class Meta:
+ model = Personne
+ fields = ('nom', 'prenom', 'courriel', 'genre')
+
+class ChercheurForm(forms.ModelForm):
+ class Meta:
+ model = Chercheur
+ fields = ('pays', 'discipline', 'groupes')
--- /dev/null
+# -*- encoding: utf-8 -*-
+from django.db import models
+from auf_references_client.models import Discipline, Pays
+
+GENRE_CHOICES = (('H', 'Homme'), ('F', 'Femme'))
+class Personne(models.Model):
+
+ id = models.AutoField(primary_key=True)
+ salutation = models.CharField(max_length=128, null = True, blank = True)
+ nom = models.CharField(max_length=255)
+ prenom = models.CharField(max_length=128, verbose_name = 'Prénom')
+ courriel = models.CharField(max_length=128, blank = True)
+ fonction = models.CharField(max_length=128, null = True, blank = True)
+ sousfonction = models.CharField(max_length=128, null = True, blank = True,
+ verbose_name = 'Sous-fonction')
+ mobile = models.CharField(max_length=32, null = True, blank = True,
+ verbose_name = 'Numéro de téléphone portable ')
+ genre = models.CharField(max_length=1, choices=GENRE_CHOICES)
+ commentaire = models.TextField(verbose_name = 'Commentaires', null = True,
+ blank = True)
+ actif = models.BooleanField(editable = False)
+
+ def __unicode__(self):
+ return u"%s %s, %s" % (self.prenom, self.nom, self.courriel)
+
+ class Meta:
+ ordering = ["prenom", "nom"]
+
+class Chercheur(models.Model):
+ id = models.AutoField(primary_key=True, db_column='id')
+ personne = models.ForeignKey('Personne')
+ discipline = models.ForeignKey(Discipline)
+ pays = models.ForeignKey(Pays)
+ groupes = models.ManyToManyField('Groupe', through='ChercheurGroupe')
+ actif = models.BooleanField(editable = False)
+
+
+class Groupe(models.Model):
+ id = models.AutoField(primary_key=True, db_column='id')
+ nom = models.CharField(max_length=255, db_column='nom')
+ actif = models.BooleanField(editable = False, db_column='actif')
+
+ def __unicode__(self):
+ return u"%s" % (self.nom)
+
+class ChercheurGroupe(models.Model):
+ chercheur = models.ForeignKey('Chercheur')
+ groupe = models.ForeignKey('Groupe')
+ date_inscription = models.DateField(auto_now=True)
--- /dev/null
+"""
+This file demonstrates two different styles of tests (one doctest and one
+unittest). These will both pass when you run "manage.py test".
+
+Replace these with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+class SimpleTest(TestCase):
+ def test_basic_addition(self):
+ """
+ Tests that 1 + 1 always equals 2.
+ """
+ self.failUnlessEqual(1 + 1, 2)
+
+__test__ = {"doctest": """
+Another way to test that 1 + 1 is equal to 2.
+
+>>> 1 + 1 == 2
+True
+"""}
+
--- /dev/null
+# Create your views here.
+from django.shortcuts import render_to_response
+from django.template import Context, RequestContext
+from forms import *
+
+from auf_references_client.models import Discipline, TypeImplantation
+from models import Personne
+
+def inscription(request):
+ if request.method == 'POST':
+ personne_form = PersonneForm (request.POST, prefix="personne")
+ chercheur_form = ChercheurForm (request.POST, prefix="chercheur")
+ if personne_form.is_valid():
+ if chercheur_form.is_valid():
+ p = personne_form.save()
+ c = chercheur_form.save(commit=False)
+ c.personne = p
+ c.save()
+ else:
+ personne_form = PersonneForm(prefix="personne")
+ chercheur_form = ChercheurForm(prefix="chercheur")
+
+ variables = { 'personne_form': personne_form,
+ 'chercheur_form': chercheur_form,
+ }
+
+ return render_to_response ("chercheurs/inscription.html", \
+ Context (variables),
+ context_instance = RequestContext(request))
from auf_savoirs_en_partage.settings import *
+
+DEBUG=True
+TEMPLATE_DEBUG=DEBUG
'django_roa',
'timezones',
'savoirs',
+ 'chercheurs',
)
TEMPLATE_LOADERS = (
--- /dev/null
+erreur 500
--- /dev/null
+{% extends "container_base.html" %}
+
+{% block contenu %}
+<form method="post">
+ <h2>Informations générales</h2>
+ {% with personne_form as form %}
+ {% include "table_form.html" %}
+ {% endwith %}
+ {% with chercheur_form as form %}
+ {% include "table_form.html" %}
+ {% endwith %}
+ <p class="Nav">
+ <input type="submit" name="Submit" value="Inscription" class="bouton" />
+ </p>
+</form>
+{% endblock %}
--- /dev/null
+{% extends "container_base.html" %}
+
+{% block contenu %}
+{% for d in disciplines %}
+<li>{{d}}</li>
+{% endfor %}
+
+<hr />
+
+{% for p in personnes %}
+<li>{{p}}</li>
+{% endfor %}
+
+
+{% endblock %}
--- /dev/null
+<tr>
+ {% if field.is_hidden %}
+ {{ field }}
+ {% else %}
+ <td{{ field.row_attrs }} class="required" style="width: 150px;">
+ {{ field.label_tag }}
+ {% if field.errors %}
+ {{ field.errors }}
+ {% endif %}
+ </td><td>
+ {{ field }}
+ </td>
+ {% endif %}
+</tr>
--- /dev/null
+{% for field in form %}
+{% include "render_field.html" %}
+{% endfor %}
--- /dev/null
+<table class="DMAJ">
+ {% include "render_form.html" %}
+</table>
(r'^json/get/$', 'savoirs.views.json_get'),
(r'^json/set/$', 'savoirs.views.json_set'),
+
+ (r'^chercheurs/inscription/$', 'chercheurs.views.inscription'),
)
if settings.DEBUG: