Première migration django
This commit is contained in:
parent
15070a9db4
commit
3bc3f7cdd3
4 changed files with 124 additions and 18 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -99,3 +99,5 @@ $RECYCLE.BIN/
|
|||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
tpathtxt
|
||||
test.py
|
||||
|
|
|
@ -67,7 +67,8 @@ CAS_SERVER_URL = "https://cas.eleves.ens.fr/login" #SPI CAS
|
|||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'ENGINE': 'django.contrib.gis.db.backends.postgis',
|
||||
# 'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': 'experiens',
|
||||
'USER': 'experiens',
|
||||
'PASSWORD': 'experiens',
|
||||
|
|
98
monstage/migrations/0001_initial.py
Normal file
98
monstage/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,98 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.conf import settings
|
||||
import django.contrib.gis.db.models.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Lieu',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('name', models.CharField(max_length=250, verbose_name="Nom de l'institution d'accueil")),
|
||||
('ville', models.CharField(max_length=200, verbose_name='Ville, Pays')),
|
||||
('coord', django.contrib.gis.db.models.fields.PointField(srid=4326, verbose_name='Coordonn\xe9es', geography=True)),
|
||||
('type_lieu', models.CharField(default=b'universite', max_length=15, verbose_name="Type de structure d'accueil", choices=[(b'universite', 'Universit\xe9'), (b'entreprise', 'Entreprise'), (b'centrerecherche', 'Centre de recherche'), (b'administration', 'Administration'), (b'autre', 'Autre')])),
|
||||
],
|
||||
options={
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='LieuStage',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('avis_global', models.TextField(verbose_name='Ressenti global', blank=True)),
|
||||
('avis_lieudevie', models.TextField(verbose_name='Mon lieu de vie', blank=True)),
|
||||
('avis_lieustage', models.TextField(verbose_name='Le lieu du stage', blank=True)),
|
||||
('avis_pratique', models.TextField(verbose_name="S'installer / Conseils pratiques", blank=True)),
|
||||
('avis_visite', models.TextField(verbose_name='Que voir / que faire', blank=True)),
|
||||
('avis_anecdotes', models.TextField(verbose_name='Anecdotes', blank=True)),
|
||||
('lieu', models.ForeignKey(to='monstage.Lieu')),
|
||||
],
|
||||
options={
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Normalien',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('permanent_mail', models.CharField(max_length=200, verbose_name=b'Adresse e-mail permanente', blank=True)),
|
||||
('user', models.OneToOneField(related_name='profil', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Profil \xe9l\xe8ve',
|
||||
'verbose_name_plural': 'Profils \xe9l\xe8ves',
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Stage',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('published', models.BooleanField(default=False, verbose_name='Visible publiquement')),
|
||||
('type_stage', models.CharField(default=b'stage', max_length=5, verbose_name='Type', choices=[(b'stage', 'Stage')])),
|
||||
('start_date', models.DateField(null=True, verbose_name='Date de d\xe9but')),
|
||||
('end_date', models.DateField(null=True, verbose_name='Date de fin')),
|
||||
('sujet', models.CharField(max_length=500, verbose_name='Sujet')),
|
||||
('encadrants', models.CharField(max_length=500, verbose_name='Encadrants', blank=True)),
|
||||
('avis_encadrants', models.TextField(verbose_name='Avis sur les encadrants', blank=True)),
|
||||
('avis_equipe', models.TextField(verbose_name="Avis sur l'\xe9quipe", blank=True)),
|
||||
('avis_stage', models.TextField(verbose_name='Int\xe9r\xeat du stage', blank=True)),
|
||||
('avis_admin', models.TextField(verbose_name='Visa et administratif', blank=True)),
|
||||
('lieux', models.ManyToManyField(related_name='stages', through='monstage.LieuStage', to='monstage.Lieu')),
|
||||
('user', models.ForeignKey(related_name='stages', to='monstage.Normalien')),
|
||||
],
|
||||
options={
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='StageMatiere',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('name', models.CharField(max_length=30, verbose_name='Mati\xe8re')),
|
||||
('users', models.ManyToManyField(related_name='matieres', to='monstage.Stage')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Mati\xe8re des stages',
|
||||
'verbose_name_plural': 'Mati\xe8res des stages',
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='lieustage',
|
||||
name='stage',
|
||||
field=models.ForeignKey(to='monstage.Stage'),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
|
@ -1,3 +1,5 @@
|
|||
# coding: utf-8
|
||||
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
@ -16,6 +18,9 @@ TYPE_LIEU_CHOICES = (
|
|||
('autre', _(u"Autre")),
|
||||
)
|
||||
|
||||
def choices_length (choices):
|
||||
return reduce (lambda m, choice: max (m, len (choice[0])), choices, 0)
|
||||
|
||||
class Normalien(models.Model):
|
||||
user = models.OneToOneField(User, related_name = "profil")
|
||||
permanent_mail = models.CharField("Adresse e-mail permanente", max_length = 200, blank = True)
|
||||
|
@ -33,6 +38,19 @@ def create_user_profile(sender, user, created, **kwargs):
|
|||
Normalien.objects.get_or_create(user = user)
|
||||
cas_user_authenticated.connect(create_user_profile)
|
||||
|
||||
class Lieu(models.Model):
|
||||
name = models.CharField(_(u"Nom de l'institution d'accueil"), max_length = 250)
|
||||
ville = models.CharField(_(u"Ville, Pays"), max_length = 200)
|
||||
coord = geomodels.PointField(_(u"Coordonnées"), geography = True)
|
||||
objects = geomodels.GeoManager() # Requis par GeoDjango
|
||||
type_lieu = models.CharField( _(u"Type de structure d'accueil"),
|
||||
default = "universite",
|
||||
choices = TYPE_LIEU_CHOICES,
|
||||
max_length = choices_length (TYPE_LIEU_CHOICES))
|
||||
|
||||
def __unicode__(self):
|
||||
return u"%s (%s)" % (self.name, self.ville)
|
||||
|
||||
class Stage(models.Model):
|
||||
user = models.ForeignKey(Normalien, related_name = "stages")
|
||||
published = models.BooleanField(_("Visible publiquement"), default = False)
|
||||
|
@ -47,9 +65,9 @@ class Stage(models.Model):
|
|||
lieux = models.ManyToManyField(Lieu, related_name = "stages", through = "LieuStage")
|
||||
|
||||
# Avis
|
||||
avis_encadrants = models.TextField(_(u"Avis sur les encadrants", blank = True)
|
||||
avis_equipe = models.TextField(_(u"Avis sur l'équipe", blank = True)
|
||||
avis_stage = models.TextField(_(u"Intérêt du stage", blank = True)
|
||||
avis_encadrants = models.TextField(_(u"Avis sur les encadrants"), blank = True)
|
||||
avis_equipe = models.TextField(_(u"Avis sur l'équipe"), blank = True)
|
||||
avis_stage = models.TextField(_(u"Intérêt du stage"), blank = True)
|
||||
avis_admin = models.TextField(_(u"Visa et administratif"), blank = True)
|
||||
|
||||
def __unicode__(self):
|
||||
|
@ -58,7 +76,7 @@ class Stage(models.Model):
|
|||
|
||||
class StageMatiere(models.Model):
|
||||
name = models.CharField(_(u"Matière"), max_length = 30)
|
||||
users = models.ManyToManyField(stages, related_name = "matieres")
|
||||
users = models.ManyToManyField(Stage, related_name = "matieres")
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Matière des stages"
|
||||
|
@ -66,19 +84,6 @@ class StageMatiere(models.Model):
|
|||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
class Lieu(models.Model):
|
||||
name = models.CharField(_(u"Nom de l'institution d'accueil"), max_length = 250)
|
||||
ville = models.CharField(_(u"Ville, Pays"), max_length = 200)
|
||||
coord = geomodels.PointField(_(u"Coordonnées"), geography = True)
|
||||
objects = geomodels.GeoManager() # Requis par GeoDjango
|
||||
type_lieu = models.CharField( _(u"Type de structure d'accueil"),
|
||||
default = "universite",
|
||||
choices = TYPE_LIEU_CHOICES,
|
||||
max_length = choices_length (TYPE_LIEU_CHOICES))
|
||||
|
||||
def __unicode__(self):
|
||||
return u"%s (%s)" % (self.name, self.ville)
|
||||
|
||||
class LieuStage(models.Model):
|
||||
stage = models.ForeignKey(Stage)
|
||||
|
|
Loading…
Reference in a new issue