1
0
forked from ScoDoc/ScoDoc

Ménage: supprime ancien code entreprises

This commit is contained in:
Emmanuel Viennet 2022-03-27 23:00:26 +02:00
parent 5998f97fde
commit ca286288bc
9 changed files with 0 additions and 2389 deletions

View File

@ -293,7 +293,6 @@ def delete_dept(dept_id: int):
"create temp table formsemestres_temp as select id from notes_formsemestre where dept_id = %(dept_id)s", "create temp table formsemestres_temp as select id from notes_formsemestre where dept_id = %(dept_id)s",
"create temp table moduleimpls_temp as select id from notes_moduleimpl where formsemestre_id in (select id from formsemestres_temp)", "create temp table moduleimpls_temp as select id from notes_moduleimpl where formsemestre_id in (select id from formsemestres_temp)",
"create temp table formations_temp as select id from notes_formations where dept_id = %(dept_id)s", "create temp table formations_temp as select id from notes_formations where dept_id = %(dept_id)s",
"create temp table entreprises_temp as select id from entreprises where dept_id = %(dept_id)s",
"create temp table tags_temp as select id from notes_tags where dept_id = %(dept_id)s", "create temp table tags_temp as select id from notes_tags where dept_id = %(dept_id)s",
] ]
for r in reqs: for r in reqs:
@ -345,13 +344,9 @@ def delete_dept(dept_id: int):
"delete from notes_formsemestre where dept_id = %(dept_id)s", "delete from notes_formsemestre where dept_id = %(dept_id)s",
"delete from scolar_news where dept_id = %(dept_id)s", "delete from scolar_news where dept_id = %(dept_id)s",
"delete from notes_semset where dept_id = %(dept_id)s", "delete from notes_semset where dept_id = %(dept_id)s",
"delete from entreprise_contact where entreprise_id in (select id from entreprises_temp) ",
"delete from entreprise_correspondant where entreprise_id in (select id from entreprises_temp) ",
"delete from entreprises where dept_id = %(dept_id)s",
"delete from notes_formations where dept_id = %(dept_id)s", "delete from notes_formations where dept_id = %(dept_id)s",
"delete from departement where id = %(dept_id)s", "delete from departement where id = %(dept_id)s",
"drop table tags_temp", "drop table tags_temp",
"drop table entreprises_temp",
"drop table formations_temp", "drop table formations_temp",
"drop table moduleimpls_temp", "drop table moduleimpls_temp",
"drop table etudids_temp", "drop table etudids_temp",

View File

@ -1,324 +0,0 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Gestion scolarite IUT
#
# Copyright (c) 1999 - 2022 Emmanuel Viennet. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Emmanuel Viennet emmanuel.viennet@viennet.net
#
##############################################################################
"""Fonctions sur les entreprises
"""
# codes anciens déplacés de ZEntreprise
import datetime
from operator import itemgetter
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.notesdb import ScoDocCursor, EditableTable, DateISOtoDMY, DateDMYtoISO
def _format_nom(nom):
"formatte nom (filtre en entree db) d'une entreprise"
if not nom:
return nom
return nom[0].upper() + nom[1:]
class EntreprisesEditor(EditableTable):
def delete(self, cnx, oid):
"delete correspondants and contacts, then self"
# first, delete all correspondants and contacts
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor.execute(
"delete from entreprise_contact where entreprise_id=%(entreprise_id)s",
{"entreprise_id": oid},
)
cursor.execute(
"delete from entreprise_correspondant where entreprise_id=%(entreprise_id)s",
{"entreprise_id": oid},
)
cnx.commit()
EditableTable.delete(self, cnx, oid)
def list(
self,
cnx,
args={},
operator="and",
test="=",
sortkey=None,
sort_on_contact=False,
limit="",
offset="",
):
# list, then sort on date of last contact
R = EditableTable.list(
self,
cnx,
args=args,
operator=operator,
test=test,
sortkey=sortkey,
limit=limit,
offset=offset,
)
if sort_on_contact:
for r in R:
c = do_entreprise_contact_list(
args={"entreprise_id": r["entreprise_id"]},
disable_formatting=True,
)
if c:
r["date"] = max([x["date"] or datetime.date.min for x in c])
else:
r["date"] = datetime.date.min
# sort
R.sort(key=itemgetter("date"))
for r in R:
r["date"] = DateISOtoDMY(r["date"])
return R
def list_by_etud(
self, cnx, args={}, sort_on_contact=False, disable_formatting=False
):
"cherche rentreprise ayant eu contact avec etudiant"
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor.execute(
"select E.*, I.nom as etud_nom, I.prenom as etud_prenom, C.date from entreprises E, entreprise_contact C, identite I where C.entreprise_id = E.entreprise_id and C.etudid = I.etudid and I.nom ~* %(etud_nom)s ORDER BY E.nom",
args,
)
_, res = [x[0] for x in cursor.description], cursor.dictfetchall()
R = []
for r in res:
r["etud_prenom"] = r["etud_prenom"] or ""
d = {}
for key in r:
v = r[key]
# format value
if not disable_formatting and key in self.output_formators:
v = self.output_formators[key](v)
d[key] = v
R.append(d)
# sort
if sort_on_contact:
R.sort(key=lambda x: (x["date"] or datetime.date.min))
for r in R:
r["date"] = DateISOtoDMY(r["date"] or datetime.date.min)
return R
_entreprisesEditor = EntreprisesEditor(
"entreprises",
"entreprise_id",
(
"entreprise_id",
"nom",
"adresse",
"ville",
"codepostal",
"pays",
"contact_origine",
"secteur",
"privee",
"localisation",
"qualite_relation",
"plus10salaries",
"note",
"date_creation",
),
filter_dept=True,
sortkey="nom",
input_formators={
"nom": _format_nom,
"plus10salaries": bool,
},
)
# ----------- Correspondants
_entreprise_correspEditor = EditableTable(
"entreprise_correspondant",
"entreprise_corresp_id",
(
"entreprise_corresp_id",
"entreprise_id",
"civilite",
"nom",
"prenom",
"fonction",
"phone1",
"phone2",
"mobile",
"fax",
"mail1",
"mail2",
"note",
),
sortkey="nom",
)
# ----------- Contacts
_entreprise_contactEditor = EditableTable(
"entreprise_contact",
"entreprise_contact_id",
(
"entreprise_contact_id",
"date",
"type_contact",
"entreprise_id",
"entreprise_corresp_id",
"etudid",
"description",
"enseignant",
),
sortkey="date",
output_formators={"date": DateISOtoDMY},
input_formators={"date": DateDMYtoISO},
)
def do_entreprise_create(args):
"entreprise_create"
cnx = ndb.GetDBConnexion()
r = _entreprisesEditor.create(cnx, args)
return r
def do_entreprise_delete(oid):
"entreprise_delete"
cnx = ndb.GetDBConnexion()
_entreprisesEditor.delete(cnx, oid)
def do_entreprise_list(**kw):
"entreprise_list"
cnx = ndb.GetDBConnexion()
return _entreprisesEditor.list(cnx, **kw)
def do_entreprise_list_by_etud(**kw):
"entreprise_list_by_etud"
cnx = ndb.GetDBConnexion()
return _entreprisesEditor.list_by_etud(cnx, **kw)
def do_entreprise_edit(*args, **kw):
"entreprise_edit"
cnx = ndb.GetDBConnexion()
_entreprisesEditor.edit(cnx, *args, **kw)
def do_entreprise_correspondant_create(args):
"entreprise_correspondant_create"
cnx = ndb.GetDBConnexion()
r = _entreprise_correspEditor.create(cnx, args)
return r
def do_entreprise_correspondant_delete(oid):
"entreprise_correspondant_delete"
cnx = ndb.GetDBConnexion()
_entreprise_correspEditor.delete(cnx, oid)
def do_entreprise_correspondant_list(**kw):
"entreprise_correspondant_list"
cnx = ndb.GetDBConnexion()
return _entreprise_correspEditor.list(cnx, **kw)
def do_entreprise_correspondant_edit(*args, **kw):
"entreprise_correspondant_edit"
cnx = ndb.GetDBConnexion()
_entreprise_correspEditor.edit(cnx, *args, **kw)
def do_entreprise_correspondant_listnames(args={}):
"-> liste des noms des correspondants (pour affichage menu)"
C = do_entreprise_correspondant_list(args=args)
return [(x["prenom"] + " " + x["nom"], str(x["entreprise_corresp_id"])) for x in C]
def do_entreprise_contact_delete(oid):
"entreprise_contact_delete"
cnx = ndb.GetDBConnexion()
_entreprise_contactEditor.delete(cnx, oid)
def do_entreprise_contact_list(**kw):
"entreprise_contact_list"
cnx = ndb.GetDBConnexion()
return _entreprise_contactEditor.list(cnx, **kw)
def do_entreprise_contact_edit(*args, **kw):
"entreprise_contact_edit"
cnx = ndb.GetDBConnexion()
_entreprise_contactEditor.edit(cnx, *args, **kw)
def do_entreprise_contact_create(args):
"entreprise_contact_create"
cnx = ndb.GetDBConnexion()
r = _entreprise_contactEditor.create(cnx, args)
return r
def do_entreprise_check_etudiant(etudiant):
"""Si etudiant est vide, ou un ETUDID valide, ou un nom unique,
retourne (1, ETUDID).
Sinon, retourne (0, 'message explicatif')
"""
etudiant = etudiant.strip().translate(
str.maketrans("", "", "'()")
) # suppress parens and quote from name
if not etudiant:
return 1, None
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor.execute(
"select etudid, nom, prenom from identite where upper(nom) ~ upper(%(etudiant)s) or etudid=%(etudiant)s",
{"etudiant": etudiant},
)
r = cursor.fetchall()
if len(r) < 1:
return 0, 'Aucun etudiant ne correspond à "%s"' % etudiant
elif len(r) > 10:
return (
0,
"<b>%d etudiants</b> correspondent à ce nom (utilisez le code)" % len(r),
)
elif len(r) > 1:
e = ['<ul class="entreprise_etud_list">']
for x in r:
e.append(
"<li>%s %s (code %s)</li>" % ((x[1]).upper(), x[2] or "", x[0].strip())
)
e.append("</ul>")
return (
0,
"Les étudiants suivants correspondent: préciser le nom complet ou le code\n"
+ "\n".join(e),
)
else: # une seule reponse !
return 1, r[0][0].strip()

View File

@ -449,7 +449,6 @@ _adresseEditor = ndb.EditableTable(
"telephonemobile", "telephonemobile",
"fax", "fax",
"typeadresse", "typeadresse",
"entreprise_id",
"description", "description",
), ),
convert_null_outputs_to_empty=True, convert_null_outputs_to_empty=True,

View File

@ -2362,29 +2362,6 @@ td.fvs_tit_chk {
font-weight: bold; font-weight: bold;
} }
/* ----- Entreprises ------- */
table.entreprise_list, table.corr_list, table.contact_list {
width : 100%;
border-width: 0px;
/* border-style: solid; */
border-spacing: 0px 0px;
padding: 0px;
margin-left: 0px;
}
table.entreprise_list td.nbcorr a, table.entreprise_list td.nbcontact a, table.contact_list td.etudnom a, table.contact_list td a {
color: navy;
text-decoration: underline;
}
tr.entreprise_list_even, tr.corr_list_even, tr.contact_list_even {
background-color: rgb(85%,85%,95%);
}
tr.entreprise_list_odd, tr.corr_list_odd, tr.contact_list_odd {
background-color: rgb(90%,90%, 90%);
}
span.table_nav_mid { span.table_nav_mid {
flex-grow: 1; /* Set the middle element to grow and stretch */ flex-grow: 1; /* Set the middle element to grow and stretch */
} }
@ -2398,82 +2375,6 @@ div.table_nav {
justify-content: space-between; justify-content: space-between;
} }
td.entreprise_descr, td.corr_descr, td.contact_descr {
padding-left: 2em;
}
td.entreprise_descr_link {
padding-left: 2em;
white-space: nowrap;
}
td.entreprise_descr_name { white-space: nowrap; }
a.entreprise_delete { color: black; text-decoration: underline; }
a.entreprise_delete:visited { color: black; }
a.entreprise_edit {
text-decoration: underline;
color : rgb(0,0,204);
font-weight: normal;
}
a.entreprise_edit:visited { color : rgb(0,0,204); }
a.entreprise_edit:hover {
color: rgb(153,51,51);
text-decoration: underline;
}
p.entreprise_create { padding-top: 2em; }
a.entreprise_create { color : black; font-weight: bold; }
a.entreprise_create:visited { color : black; }
table.entreprise_list_title {
width: 100%;
border-top: 1px solid rgb(51,102,204);
border-spacing: 0px 0px;
padding: 0px;
}
tr.entreprise_list_title {
background-color: rgb(229,236,249);
font-weight: bold;
}
td.entreprise_list_title {
padding-left: 1em;
}
td.entreprise_list_title_res {
font-weight: normal;
text-align : right;
}
h2.entreprise {
color: rgb(6,102,18);
border: 1px solid blue;
}
h2.entreprise_contact:before {
content: url(/ScoDoc/static/icons/contact_img.png);
vertical-align: -80%;
padding-right: 1em;
}
h2.entreprise_correspondant:before {
content: url(/ScoDoc/static/icons/correspondant_img.png);
vertical-align: -80%;
padding-right: 1em;
}
h2.entreprise_new:before {
content: url(/ScoDoc/static/icons/entreprise_img.png);
vertical-align: -80%;
padding-right: 2em;
}
p.entreprise_warning, p.gtr_warning, p.gtr_interdit, p.gtr_devel {
color: red;
font-style: italic;
margin-top: -1em;
}
P.entreprise_warning:before {
content: url(/ScoDoc/static/icons/warning_img.png);
vertical-align: -80%;
}
P.gtr_interdit:before { P.gtr_interdit:before {
content: url(/ScoDoc/static/icons/interdit_img.png); content: url(/ScoDoc/static/icons/interdit_img.png);
vertical-align: -80%; vertical-align: -80%;
@ -2482,9 +2383,6 @@ P.gtr_devel:before {
content: url(/ScoDoc/static/icons/devel_img.png); content: url(/ScoDoc/static/icons/devel_img.png);
vertical-align: -80%; vertical-align: -80%;
} }
div.entreprise-insidebar {
border: 1px solid blue;
}
/* ---- Sortable tables --- */ /* ---- Sortable tables --- */
/* Sortable tables */ /* Sortable tables */

File diff suppressed because it is too large Load Diff

View File

@ -1665,7 +1665,6 @@ def etudident_delete(etudid, dialog_confirmed=False):
"notes_moduleimpl_inscription", "notes_moduleimpl_inscription",
"notes_formsemestre_inscription", "notes_formsemestre_inscription",
"group_membership", "group_membership",
"entreprise_contact",
"etud_annotations", "etud_annotations",
"scolog", "scolog",
"admissions", "admissions",

View File

@ -53,7 +53,6 @@ tables = (
"billet_absence", "billet_absence",
"scolog", "scolog",
"etud_annotations", "etud_annotations",
"entreprise_contact",
"notes_formsemestre_inscription", "notes_formsemestre_inscription",
"notes_moduleimpl_inscription", "notes_moduleimpl_inscription",
"notes_notes", "notes_notes",

View File

@ -1,683 +0,0 @@
-- Creation des tables pour gestion notes ScoDoc 7 (OBSOLETE !)
-- E. Viennet, Sep 2005
-- creation de la base: utiliser le script config/create_dept.sh
--
-- ou pour tester: en tant qu'utilisateur postgres
-- createuser --pwprompt scogea
-- createdb -E UTF-8 -O scogea SCOGEA "scolarite GEA"
--
--
-- generation des id
CREATE SEQUENCE serial;
CREATE SEQUENCE notes_idgen;
CREATE FUNCTION notes_newid( text ) returns text as '
select $1 || to_char( nextval(''notes_idgen''), ''FM999999999'' )
as result;
' language SQL;
CREATE SEQUENCE notes_idgen2;
CREATE FUNCTION notes_newid2( text ) returns text as '
select $1 || to_char( nextval(''notes_idgen2''), ''FM999999999'' )
as result;
' language SQL;
CREATE SEQUENCE notes_idgen_etud;
CREATE FUNCTION notes_newid_etud( text ) returns text as '
select $1 || to_char( nextval(''notes_idgen_etud''), ''FM999999999'' )
as result;
' language SQL;
-- Fonction pour anonymisation:
-- inspirée par https://www.simononsoftware.com/random-string-in-postgresql/
CREATE FUNCTION random_text_md5( integer ) returns text
LANGUAGE SQL
AS $$
select upper( substring( (SELECT string_agg(md5(random()::TEXT), '')
FROM generate_series(
1,
CEIL($1 / 32.)::integer)
), 1, $1) );
$$;
-- Preferences
CREATE TABLE sco_prefs (
pref_id text DEFAULT notes_newid('PREF'::text) UNIQUE NOT NULL,
name text NOT NULL,
value text,
formsemestre_id text default NULL,
UNIQUE(name,formsemestre_id)
) WITH OIDS;
CREATE TABLE identite (
etudid text DEFAULT notes_newid_etud('EID'::text) UNIQUE NOT NULL,
nom text,
prenom text,
civilite text NOT NULL CHECK (civilite IN ('M', 'F', 'X')),
date_naissance date, -- new: date en texte
lieu_naissance text,
dept_naissance text,
nationalite text,
statut text, -- NULL ou 'SALARIE'
foto text, -- deprecated
photo_filename text,
code_nip text UNIQUE, -- code NIP Apogee (may be null)
code_ine text UNIQUE, -- code INE Apogee (may be null)
nom_usuel text, -- optionnel (si present, affiché à la place du nom)
boursier text -- 'O' (capital o) si boursier
) WITH OIDS;
CREATE TABLE adresse (
adresse_id text DEFAULT notes_newid_etud('ADR'::text) NOT NULL,
etudid text NOT NULL,
email text, -- email institutionnel
emailperso text, -- email personnel (exterieur)
domicile text,
codepostaldomicile text,
villedomicile text,
paysdomicile text,
telephone text,
telephonemobile text,
fax text,
typeadresse text DEFAULT 'domicile'::text NOT NULL,
entreprise_id integer,
description text
) WITH OIDS;
CREATE TABLE admissions (
adm_id text DEFAULT notes_newid_etud('ADM'::text) NOT NULL,
etudid text NOT NULL,
annee integer,
bac text,
specialite text,
annee_bac integer,
math real,
physique real,
anglais real,
francais real,
rang integer, -- dans les voeux du candidat (inconnu avec APB)
qualite real,
rapporteur text,
decision text,
score real,
commentaire text,
nomlycee text,
villelycee text,
codepostallycee text,
codelycee text,
debouche text, -- OBSOLETE UNUSED situation APRES etre passe par chez nous (texte libre)
type_admission text, -- 'APB', 'APC-PC', 'CEF', 'Direct', '?' (autre)
boursier_prec integer default NULL, -- etait boursier dans le cycle precedent (lycee) ?
classement integer default NULL, -- classement par le jury d'admission (1 à N), global (pas celui d'APB si il y a des groupes)
apb_groupe text, -- code du groupe APB
apb_classement_gr integer default NULL -- classement (1..Ngr) par le jury dans le groupe APB
) WITH OIDS;
CREATE TABLE itemsuivi (
itemsuivi_id text DEFAULT notes_newid('SUI'::text) PRIMARY KEY,
etudid text NOT NULL,
item_date date DEFAULT now(), -- date de l'observation
situation text -- situation à cette date (champ libre)
) WITH OIDS;
CREATE TABLE itemsuivi_tags (
tag_id text DEFAULT notes_newid('TG') PRIMARY KEY,
title text UNIQUE NOT NULL
) WITH OIDS;
CREATE TABLE itemsuivi_tags_assoc (
tag_id text REFERENCES itemsuivi_tags(tag_id) ON DELETE CASCADE,
itemsuivi_id text REFERENCES itemsuivi(itemsuivi_id) ON DELETE CASCADE,
PRIMARY KEY (tag_id, itemsuivi_id)
) WITH OIDS;
CREATE TABLE absences (
etudid text NOT NULL,
jour date, -- jour de l'absence
estabs boolean, -- vrai si absent
estjust boolean, -- vrai si justifie
matin boolean, -- vrai si concerne le matin, faux si apres midi
description text, -- "raison" de l'absence
entry_date timestamp with time zone DEFAULT now(),
moduleimpl_id text -- moduleimpid concerne (optionnel)
) WITH OIDS;
CREATE TABLE absences_notifications (
etudid text NOT NULL,
notification_date timestamp with time zone DEFAULT now(),
email text NOT NULL,
nbabs integer,
nbabsjust integer,
formsemestre_id text -- semestre concerne par cette notification
) WITH OIDS;
CREATE SEQUENCE notes_idgen_billets;
CREATE FUNCTION notes_newid_billet( text ) returns text as '
select $1 || to_char( nextval(''notes_idgen_billets''), ''FM999999999'' )
as result;
' language SQL;
CREATE TABLE billet_absence (
billet_id text DEFAULT notes_newid_billet('B'::text) NOT NULL,
etudid text NOT NULL,
abs_begin timestamp with time zone,
abs_end timestamp with time zone,
description text, -- "raison" de l'absence
etat integer default 0, -- 0 new, 1 processed
entry_date timestamp with time zone DEFAULT now(),
justified integer default 0 -- 1 si l'absence pourrait etre justifiée
) WITH OIDS;
-- --- Log des actions (journal modif etudiants)
CREATE TABLE scolog (
date timestamp without time zone DEFAULT now(),
authenticated_user text,
remote_addr text,
remote_host text,
method text,
etudid character(32),
msg text
) WITH OIDS;
CREATE TABLE etud_annotations (
id integer DEFAULT nextval('serial'::text) NOT NULL,
date timestamp without time zone DEFAULT now(),
etudid character(32),
author text, -- now unused
comment text,
zope_authenticated_user text, -- should be author
zope_remote_addr text
) WITH OIDS;
-- ------------ Nouvelle gestion des absences ------------
-- CREATE SEQUENCE abs_idgen;
-- CREATE FUNCTION abs_newid( text ) returns text as '
-- select $1 || to_char( nextval(''abs_idgen''), ''FM999999999'' )
-- as result;
-- ' language SQL;
-- CREATE TABLE abs_absences (
-- absid text default abs_newid('AB') PRIMARY KEY,
-- etudid character(32),
-- abs_begin timestamp with time zone,
-- abs_end timestamp with time zone
-- ) WITH OIDS;
-- CREATE TABLE abs_presences (
-- absid text default abs_newid('PR') PRIMARY KEY,
-- etudid character(32),
-- abs_begin timestamp with time zone,
-- abs_end timestamp with time zone
-- ) WITH OIDS;
-- CREATE TABLE abs_justifs (
-- absid text default abs_newid('JU') PRIMARY KEY,
-- etudid character(32),
-- abs_begin timestamp with time zone,
-- abs_end timestamp with time zone,
-- category text,
-- description text
-- ) WITH OIDS;
-- ------------ ENTREPRISES ------------
CREATE TABLE entreprises (
entreprise_id serial NOT NULL,
nom text,
adresse text,
ville text,
codepostal text,
pays text,
contact_origine text,
secteur text,
note text,
privee text,
localisation text,
qualite_relation integer, -- -1 inconnue, 0, 25, 50, 75, 100
plus10salaries integer,
date_creation timestamp without time zone DEFAULT now()
) WITH OIDS;
CREATE TABLE entreprise_correspondant (
entreprise_corresp_id serial NOT NULL,
nom text,
prenom text,
fonction text,
phone1 text,
phone2 text,
mobile text,
mail1 text,
mail2 text,
note text,
entreprise_id integer,
civilite text,
fax text
) WITH OIDS;
--
--
CREATE TABLE entreprise_contact (
entreprise_contact_id serial NOT NULL,
date date,
type_contact text,
entreprise_id integer,
entreprise_corresp_id integer,
etudid text,
description text,
enseignant text
) WITH OIDS;
-- ------------ NOTES ------------
-- Description generique d'un module (eg infos du PPN)
CREATE SEQUENCE notes_idgen_fcod;
CREATE FUNCTION notes_newid_fcod( text ) returns text as '
select $1 || to_char( nextval(''notes_idgen_fcod''), ''FM999999999'' )
as result;
' language SQL;
CREATE TABLE notes_formations (
formation_id text default notes_newid('FORM') PRIMARY KEY,
acronyme text NOT NULL, -- 'DUT R&T', 'LPSQRT', ...
titre text NOT NULL, -- titre complet
titre_officiel text NOT NULL, -- "DUT Gestion des Entreprises et Admininistration"
version integer default 1, -- version de la formation
formation_code text default notes_newid_fcod('FCOD') NOT NULL,
type_parcours int DEFAULT 0, -- 0 DUT, 100 Lic Pro
code_specialite text default NULL,
UNIQUE(acronyme,titre,version)
) WITH OIDS;
CREATE TABLE notes_ue (
ue_id text default notes_newid('UE') PRIMARY KEY,
formation_id text REFERENCES notes_formations(formation_id),
acronyme text NOT NULL,
numero int, -- ordre de presentation
titre text,
type int DEFAULT 0, -- 0 normal ("fondamentale"), 1 "sport", 2 "projet et stage (LP)", 4 "élective"
ue_code text default notes_newid_fcod('UCOD') NOT NULL,
ects real, -- nombre de credits ECTS
is_external integer default 0, -- si UE effectuee dans le cursus d'un autre etablissement
code_apogee text, -- id de l'element pedagogique Apogee correspondant
coefficient real -- coef UE, utilise seulement si l'option use_ue_coefs est activée
) WITH OIDS;
CREATE TABLE notes_matieres (
matiere_id text default notes_newid('MAT') PRIMARY KEY,
ue_id text REFERENCES notes_ue(ue_id),
titre text,
numero int, -- ordre de presentation
UNIQUE(ue_id,titre)
) WITH OIDS;
CREATE TABLE notes_semestres (
-- une bete table 1,2,3,...,8 pour l'instant fera l'affaire...
semestre_id int PRIMARY KEY
) WITH OIDS;
INSERT INTO notes_semestres (semestre_id) VALUES (-1); -- denote qu'il n'y a pas de semestres dans ce diplome
INSERT INTO notes_semestres (semestre_id) VALUES (1);
INSERT INTO notes_semestres (semestre_id) VALUES (2);
INSERT INTO notes_semestres (semestre_id) VALUES (3);
INSERT INTO notes_semestres (semestre_id) VALUES (4);
INSERT INTO notes_semestres (semestre_id) VALUES (5);
INSERT INTO notes_semestres (semestre_id) VALUES (6);
INSERT INTO notes_semestres (semestre_id) VALUES (7);
INSERT INTO notes_semestres (semestre_id) VALUES (8);
CREATE TABLE notes_modules (
module_id text default notes_newid('MOD') PRIMARY KEY,
titre text,
code text NOT NULL,
heures_cours real,
heures_td real,
heures_tp real,
coefficient real, -- coef PPN
ue_id text REFERENCES notes_ue(ue_id),
formation_id text REFERENCES notes_formations(formation_id),
matiere_id text REFERENCES notes_matieres(matiere_id),
semestre_id integer REFERENCES notes_semestres(semestre_id),
numero int, -- ordre de presentation
abbrev text, -- nom court
ects real, -- nombre de credits ECTS (NON UTILISES)
code_apogee text, -- id de l'element pedagogique Apogee correspondant
module_type int -- NULL ou 0:defaut, 1: malus (NOTES_MALUS)
) WITH OIDS;
CREATE TABLE notes_tags (
tag_id text default notes_newid('TAG') PRIMARY KEY,
title text UNIQUE NOT NULL
) WITH OIDS;
CREATE TABLE notes_modules_tags (
tag_id text REFERENCES notes_tags(tag_id) ON DELETE CASCADE,
module_id text REFERENCES notes_modules(module_id) ON DELETE CASCADE,
PRIMARY KEY (tag_id, module_id)
) WITH OIDS;
-- Mise en oeuvre d'un semestre de formation
CREATE TABLE notes_formsemestre (
formsemestre_id text default notes_newid('SEM') PRIMARY KEY,
formation_id text REFERENCES notes_formations(formation_id),
semestre_id int REFERENCES notes_semestres(semestre_id),
titre text,
date_debut date,
date_fin date,
-- responsable_id text,
-- gestion_absence integer default 1, -- XXX obsolete
-- bul_show_decision integer default 1, -- XXX obsolete
-- bul_show_uevalid integer default 1, -- XXX obsolete
etat integer default 1, -- 1 ouvert, 0 ferme (verrouille)
-- nomgroupetd text default 'TD', -- XXX obsolete
-- nomgroupetp text default 'TP', -- XXX obsolete
-- nomgroupeta text default 'langues', -- XXX obsolete
-- bul_show_codemodules integer default 1, -- XXX obsolete
-- bul_show_rangs integer default 1, -- XXX obsolete
-- bul_show_ue_rangs integer default 1, -- XXX obsolete
-- bul_show_mod_rangs integer default 1, -- XXX obsolete
gestion_compensation integer default 0, -- gestion compensation sem DUT
bul_hide_xml integer default 0, -- ne publie pas le bulletin XML
gestion_semestrielle integer default 0, -- semestres decales (pour gestion jurys)
bul_bgcolor text default 'white', -- couleur fond bulletins HTML
modalite text, -- FI, FC, APP, ''
resp_can_edit integer default 0, -- autorise resp. a modifier semestre
resp_can_change_ens integer default 1, -- autorise resp. a modifier slt les enseignants
ens_can_edit_eval int default 0, -- autorise les ens a creer des evals
elt_sem_apo text, -- code element semestre Apogee, eg VRTW1 ou V2INCS4,V2INLS4
elt_annee_apo text -- code element annee Apogee, eg VRT1A ou V2INLA,V2INCA
) WITH OIDS;
-- id des utilisateurs responsables (aka directeurs des etudes) du semestre:
CREATE TABLE notes_formsemestre_responsables (
formsemestre_id text REFERENCES notes_formsemestre(formsemestre_id) ON DELETE CASCADE,
responsable_id text NOT NULL,
UNIQUE(formsemestre_id, responsable_id)
) WITH OIDS;
-- Etape Apogee associes au semestre:
CREATE TABLE notes_formsemestre_etapes (
formsemestre_id text REFERENCES notes_formsemestre(formsemestre_id) ON DELETE CASCADE,
etape_apo text NOT NULL
) WITH OIDS;
CREATE TABLE notes_form_modalites (
form_modalite_id text default notes_newid('Md') PRIMARY KEY,
modalite text, -- la clef dans notes_formsemestre
titre text, -- le nom complet de la modalite pour les documents scodoc
numero SERIAL -- integer, ordre de presentation
);
INSERT INTO notes_form_modalites (modalite, titre) VALUES ('', 'Autres formations');
INSERT INTO notes_form_modalites (modalite, titre) VALUES ('FI', 'Formation Initiale');
INSERT INTO notes_form_modalites (modalite, titre) VALUES ('FC', 'Formation Continue');
INSERT INTO notes_form_modalites (modalite, titre) VALUES ('FAP', 'Apprentissage');
INSERT INTO notes_form_modalites (modalite, titre) VALUES ('DEC', 'Formation Décalées');
INSERT INTO notes_form_modalites (modalite, titre) VALUES ('LIC', 'Licence');
INSERT INTO notes_form_modalites (modalite, titre) VALUES ('CP', 'Contrats de Professionnalisation');
INSERT INTO notes_form_modalites (modalite, titre) VALUES ('EXT', 'Extérieur');
-- semsets
CREATE TABLE notes_semset (
semset_id text default notes_newid('NSS') PRIMARY KEY,
title text,
annee_scolaire int default NULL, -- 2016
sem_id int default NULL -- periode: 0 (année), 1 (Simpair), 2 (Spair)
) WITH OIDS;
CREATE TABLE notes_semset_formsemestre (
formsemestre_id text REFERENCES notes_formsemestre(formsemestre_id) ON DELETE CASCADE,
semset_id text REFERENCES notes_semset (semset_id) ON DELETE CASCADE,
PRIMARY KEY (formsemestre_id, semset_id)
) WITH OIDS;
-- Coef des UE capitalisees arrivant dans ce semestre:
CREATE TABLE notes_formsemestre_uecoef (
formsemestre_uecoef_id text default notes_newid('SEM') PRIMARY KEY,
formsemestre_id text REFERENCES notes_formsemestre(formsemestre_id),
ue_id text REFERENCES notes_ue(ue_id),
coefficient real NOT NULL,
UNIQUE(formsemestre_id, ue_id)
) WITH OIDS;
-- Formules utilisateurs pour calcul moyenne UE
CREATE TABLE notes_formsemestre_ue_computation_expr (
notes_formsemestre_ue_computation_expr_id text default notes_newid('UEXPR') PRIMARY KEY,
formsemestre_id text REFERENCES notes_formsemestre(formsemestre_id),
ue_id text REFERENCES notes_ue(ue_id),
computation_expr text, -- formule de calcul moyenne
UNIQUE(formsemestre_id, ue_id)
) WITH OIDS;
-- Menu custom associe au semestre
CREATE TABLE notes_formsemestre_custommenu (
custommenu_id text default notes_newid('CMENU') PRIMARY KEY,
formsemestre_id text REFERENCES notes_formsemestre(formsemestre_id),
title text,
url text,
idx integer default 0 -- rang dans le menu
) WITH OIDS;
-- Mise en oeuvre d'un module pour une annee/semestre
CREATE TABLE notes_moduleimpl (
moduleimpl_id text default notes_newid('MIP') PRIMARY KEY,
module_id text REFERENCES notes_modules(module_id),
formsemestre_id text REFERENCES notes_formsemestre(formsemestre_id),
responsable_id text,
computation_expr text, -- formule de calcul moyenne
UNIQUE(module_id,formsemestre_id) -- ajoute
) WITH OIDS;
-- Enseignants (chargés de TD ou TP) d'un moduleimpl
CREATE TABLE notes_modules_enseignants (
modules_enseignants_id text default notes_newid('ENS') PRIMARY KEY,
moduleimpl_id text REFERENCES notes_moduleimpl(moduleimpl_id),
ens_id text -- est le user_name de sco_users (de la base SCOUSERS)
) WITH OIDS;
-- Inscription a un semestre de formation
CREATE TABLE notes_formsemestre_inscription (
formsemestre_inscription_id text default notes_newid2('SI') PRIMARY KEY,
etudid text REFERENCES identite(etudid),
formsemestre_id text REFERENCES notes_formsemestre(formsemestre_id),
etat text, -- I inscrit, D demission en cours de semestre, DEF si "defaillant"
etape text, -- etape apogee d'inscription (experimental 2020)
UNIQUE(formsemestre_id, etudid)
) WITH OIDS;
-- Inscription a un module (etudiants,moduleimpl)
CREATE TABLE notes_moduleimpl_inscription (
moduleimpl_inscription_id text default notes_newid2('MI') PRIMARY KEY,
moduleimpl_id text REFERENCES notes_moduleimpl(moduleimpl_id),
etudid text REFERENCES identite(etudid),
UNIQUE( moduleimpl_id, etudid)
) WITH OIDS;
CREATE TABLE partition(
partition_id text default notes_newid2('P') PRIMARY KEY,
formsemestre_id text REFERENCES notes_formsemestre(formsemestre_id),
partition_name text, -- "TD", "TP", ... (NULL for 'all')
compute_ranks integer default 1, -- calcul rang etudiants dans les groupes (currently unused)
numero SERIAL, -- ordre de presentation
bul_show_rank integer default 0,
show_in_lists integer default 1, -- montre dans les noms de groupes
UNIQUE(formsemestre_id,partition_name)
) WITH OIDS;
CREATE TABLE group_descr (
group_id text default notes_newid2('G') PRIMARY KEY,
partition_id text REFERENCES partition(partition_id),
group_name text, -- "A", "C2", ... (NULL for 'all')
UNIQUE(partition_id, group_name)
) WITH OIDS;
CREATE TABLE group_membership(
group_membership_id text default notes_newid2('GM') PRIMARY KEY,
etudid text REFERENCES identite(etudid),
group_id text REFERENCES group_descr(group_id),
UNIQUE(etudid, group_id)
) WITH OIDS;
-- Evaluations (controles, examens, ...)
CREATE TABLE notes_evaluation (
evaluation_id text default notes_newid('EVAL') PRIMARY KEY,
moduleimpl_id text REFERENCES notes_moduleimpl(moduleimpl_id),
jour date,
heure_debut time,
heure_fin time,
description text,
note_max real,
coefficient real,
visibulletin integer default 1,
publish_incomplete integer default 0, -- prise en compte meme si incomplete
evaluation_type integer default 0, -- type d'evaluation: 0 normale, 1 rattrapage
numero int -- ordre de presentation (le plus petit numero est normalement la plus ancienne eval)
) WITH OIDS;
-- Les notes...
CREATE TABLE notes_notes (
etudid text REFERENCES identite(etudid),
evaluation_id text REFERENCES notes_evaluation(evaluation_id),
value real, -- null si absent, voir valeurs speciales dans notes_table.py
UNIQUE(etudid,evaluation_id),
-- infos sur saisie de cette note:
comment text,
date timestamp default now(),
uid text
) WITH OIDS;
CREATE INDEX notes_notes_evaluation_id_idx ON notes_notes (evaluation_id);
-- Historique des modifs sur notes (anciennes entrees de notes_notes)
CREATE TABLE notes_notes_log (
id SERIAL PRIMARY KEY,
etudid text REFERENCES identite(etudid),
evaluation_id text, -- REFERENCES notes_evaluation(evaluation_id),
value real,
comment text,
date timestamp,
uid text
-- pas de foreign key, sinon bug lors supression notes (et on
-- veut garder le log)
-- FOREIGN KEY (etudid,evaluation_id) REFERENCES notes_notes(etudid,evaluation_id)
) WITH OIDS;
---------------------------------------------------------------------
-- Parcours d'un etudiant
--
-- etat: INSCRIPTION inscr. de l'etud dans ce semestre
-- DEM l'etud demissionne EN COURS DE SEMESTRE
-- DIPLOME en fin semestre, attribution du diplome correspondant
-- (ou plutot, validation du semestre)
-- AUT_RED en fin semestre, autorise a redoubler ce semestre
-- EXCLUS exclus (== non autorise a redoubler)
-- VALID_SEM obtention semestre après jury terminal
-- VALID_UE obtention UE après jury terminal
-- ECHEC_SEM echec a ce semestre
-- UTIL_COMPENSATION utilise formsemestre_id pour compenser et valider
-- comp_formsemestre_id
CREATE TABLE scolar_events (
event_id text default notes_newid('EVT') PRIMARY KEY,
etudid text,
event_date timestamp default now(),
formsemestre_id text REFERENCES notes_formsemestre(formsemestre_id),
ue_id text REFERENCES notes_ue(ue_id),
event_type text, -- 'CREATION', 'INSCRIPTION', 'DEMISSION',
-- 'AUT_RED', 'EXCLUS', 'VALID_UE', 'VALID_SEM'
-- 'ECHEC_SEM'
-- 'UTIL_COMPENSATION'
comp_formsemestre_id text REFERENCES notes_formsemestre(formsemestre_id)
-- semestre compense par formsemestre_id
) WITH OIDS;
-- Stockage des codes d'etat apres jury
CREATE SEQUENCE notes_idgen_svalid;
CREATE FUNCTION notes_newidsvalid( text ) returns text as '
select $1 || to_char( nextval(''notes_idgen_svalid''), ''FM999999999'' )
as result;
' language SQL;
CREATE TABLE scolar_formsemestre_validation (
formsemestre_validation_id text default notes_newidsvalid('VAL') PRIMARY KEY,
etudid text NOT NULL,
formsemestre_id text REFERENCES notes_formsemestre(formsemestre_id), -- anciennement (<2015-03-17) NULL si external
ue_id text REFERENCES notes_ue(ue_id), -- NULL si validation de semestre
code text NOT NULL,
assidu integer, -- NULL pour les UE, 0|1 pour les semestres
event_date timestamp default now(),
compense_formsemestre_id text, -- null sauf si compense un semestre
moy_ue real, -- moyenne UE capitalisee (/20, NULL si non calculee)
semestre_id int, -- (normalement NULL) indice du semestre, utile seulement pour UE "antérieures" et si la formation définit des UE utilisées dans plusieurs semestres (cas R&T IUTV v2)
is_external integer default 0, -- si UE validée dans le cursus d'un autre etablissement
UNIQUE(etudid,formsemestre_id,ue_id) -- une seule decision
) WITH OIDS;
CREATE TABLE scolar_autorisation_inscription (
autorisation_inscription_id text default notes_newidsvalid('AUT') PRIMARY KEY,
etudid text NOT NULL,
formation_code text NOT NULL,
semestre_id int REFERENCES notes_semestres(semestre_id), -- semestre ou on peut s'inscrire
date timestamp default now(),
origin_formsemestre_id text REFERENCES notes_formsemestre(formsemestre_id)
) WITH OIDS;
---------------------------------------------------------------------
-- NOUVELLES (pour page d'accueil et flux rss associe)
--
CREATE TABLE scolar_news (
news_id text default notes_newid('NEWS') PRIMARY KEY,
date timestamp default now(),
authenticated_user text,
type text, -- 'INSCR', 'NOTES', 'FORM', 'SEM', 'MISC'
object text, -- moduleimpl_id, formation_id, formsemestre_id,
text text, -- free text
url text -- optional URL
) WITH OIDS;
-- Appreciations sur bulletins
CREATE TABLE notes_appreciations (
id integer DEFAULT nextval('serial'::text) NOT NULL,
date timestamp without time zone DEFAULT now(),
etudid text REFERENCES identite(etudid),
formsemestre_id text REFERENCES notes_formsemestre(formsemestre_id),
author text,
comment text,
zope_authenticated_user text,
zope_remote_addr text
) WITH OIDS;
CREATE OR REPLACE FUNCTION truncate_tables(username IN VARCHAR) RETURNS void AS $$
DECLARE
statements CURSOR FOR
SELECT tablename FROM pg_tables
WHERE tableowner = username AND schemaname = 'public'
AND tablename <> 'notes_semestres'
AND tablename <> 'notes_form_modalites';
BEGIN
FOR stmt IN statements LOOP
EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;';
END LOOP;
END;
$$ LANGUAGE plpgsql;

View File

@ -92,27 +92,6 @@ ANONYMIZED_FIELDS = {
"admissions.nomlycee": anonymize_name, "admissions.nomlycee": anonymize_name,
"billet_absence.description": anonymize_null, "billet_absence.description": anonymize_null,
"etud_annotations.comment": anonymize_name, "etud_annotations.comment": anonymize_name,
# "entreprises.nom": anonymize_name,
# "entreprises.adresse": anonymize_null,
# "entreprises.ville": anonymize_null,
# "entreprises.codepostal": anonymize_null,
# "entreprises.pays": anonymize_null,
# "entreprises.contact_origine": anonymize_null,
# "entreprises.secteur": anonymize_null,
# "entreprises.note": anonymize_null,
# "entreprises.privee": anonymize_null,
# "entreprises.localisation": anonymize_null,
# "entreprise_correspondant.nom": anonymize_name,
# "entreprise_correspondant.prenom": anonymize_name,
# "entreprise_correspondant.phone1": anonymize_null,
# "entreprise_correspondant.phone2": anonymize_null,
# "entreprise_correspondant.mobile": anonymize_null,
# "entreprise_correspondant.mail1": anonymize_null,
# "entreprise_correspondant.mail2": anonymize_null,
# "entreprise_correspondant.note": anonymize_null,
# "entreprise_correspondant.fax": anonymize_null,
# "entreprise_contact.description": anonymize_null,
# "entreprise_contact.enseignant": anonymize_null,
"notes_appreciations.comment": anonymize_name, "notes_appreciations.comment": anonymize_name,
} }