mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 11:04:20 +00:00
pedagogy: import results from old uv guide
This commit is contained in:
parent
e7b8ddb631
commit
d18f0aa829
18
migrate.py
18
migrate.py
@ -77,7 +77,7 @@ from forum.models import (
|
||||
ForumMessageMeta,
|
||||
ForumUserInfo,
|
||||
)
|
||||
from pedagogy.models import UV, UVComment
|
||||
from pedagogy.models import UV, UVComment, UVResult
|
||||
|
||||
db = MySQLdb.connect(**settings.OLD_MYSQL_INFOS)
|
||||
start = datetime.datetime.now()
|
||||
@ -1643,6 +1643,22 @@ def migrate_pedagogy():
|
||||
publish_date=comment["date"],
|
||||
).save()
|
||||
|
||||
print("Migrating UV Results")
|
||||
cur.execute("SELECT * FROM pedag_resultat")
|
||||
|
||||
for result in cur:
|
||||
author = User.objects.filter(id=comment["id_utilisateur"]).first()
|
||||
uv = UV.objects.filter(id=comment["id_uv"]).first()
|
||||
if not author or not uv:
|
||||
continue
|
||||
UVResult(
|
||||
id=result["id_resultat"],
|
||||
uv=uv,
|
||||
user=author,
|
||||
grade=result["note"],
|
||||
semester=result["semestre"],
|
||||
).save()
|
||||
|
||||
|
||||
def main():
|
||||
print("Start at %s" % start)
|
||||
|
Loading…
Reference in New Issue
Block a user