Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SCODOC_R6A06
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Milleville
SCODOC_R6A06
Commits
01dcd8cc
Commit
01dcd8cc
authored
3 years ago
by
Emmanuel Viennet
Browse files
Options
Downloads
Patches
Plain Diff
Migration: tolère dates logs aberrantes, et élimine relations manquantes dans entreprises
parent
30e7fd51
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
scodoc.py
+23
-7
23 additions, 7 deletions
scodoc.py
tools/import_scodoc7_dept.py
+7
-1
7 additions, 1 deletion
tools/import_scodoc7_dept.py
with
30 additions
and
8 deletions
scodoc.py
+
23
−
7
View file @
01dcd8cc
...
...
@@ -278,13 +278,29 @@ def user_role(username, dept_acronym=None, add_role_name=None, remove_role_name=
db
.
session
.
commit
()
def
abort_if_false
(
ctx
,
param
,
value
):
if
not
value
:
ctx
.
abort
()
@app.cli.command
()
@click.option
(
"
--yes
"
,
is_flag
=
True
,
callback
=
abort_if_false
,
expose_value
=
False
,
prompt
=
f
"""
Attention: Cela va effacer toutes les données du département
(étudiants, notes, formations, etc)
Voulez-vous vraiment continuer ?
"""
,
)
@click.argument
(
"
dept
"
)
def
delete_dept
(
dept
):
# delete-dept
"""
Delete existing departement
"""
from
app.scodoc
import
notesdb
as
ndb
from
app.scodoc
import
sco_dept
if
False
:
click
.
confirm
(
f
"""
Attention: Cela va effacer toutes les données du département
{
dept
}
(étudiants, notes, formations, etc)
...
...
This diff is collapsed.
Click to expand it.
tools/import_scodoc7_dept.py
+
7
−
1
View file @
01dcd8cc
...
...
@@ -170,6 +170,11 @@ def import_scodoc7_dept(dept_id: str, dept_db_uri=None):
logging
.
info
(
f
"
connecting to database
{
dept_db_uri
}
"
)
cnx
=
psycopg2
.
connect
(
dept_db_uri
)
cursor
=
cnx
.
cursor
(
cursor_factory
=
ndb
.
ScoDocCursor
)
# FIX : des dates aberrantes (dans le futur) peuvent tenir en SQL mais pas en Python
cursor
.
execute
(
"""
UPDATE scolar_events SET event_date=
'
2021-09-30
'
WHERE event_date >
'
2200-01-01
'"""
)
cnx
.
commit
()
# Create dept:
dept
=
models
.
Departement
(
acronym
=
dept_id
,
description
=
"
migré de ScoDoc7
"
)
db
.
session
.
add
(
dept
)
...
...
@@ -374,6 +379,8 @@ def convert_object(
new_ref
=
id_from_scodoc7
[
old_ref
]
elif
(
not
is_table
)
and
table_name
in
{
"
scolog
"
,
"
entreprise_correspondant
"
,
"
entreprise_contact
"
,
"
etud_annotations
"
,
"
notes_notes_log
"
,
"
scolar_news
"
,
...
...
@@ -389,7 +396,6 @@ def convert_object(
new_ref
=
None
elif
is_table
and
table_name
in
{
"
notes_semset_formsemestre
"
,
"
entreprise_contact
"
,
}:
# pour anciennes installs où des relations n'avait pas été déclarées clés étrangères
# eg: notes_semset_formsemestre.semset_id n'était pas une clé
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment