pedagogy: import results from old uv guide

This commit is contained in:
Antoine Bartuccio 2019-06-18 17:43:13 +02:00
parent e7b8ddb631
commit d18f0aa829
Signed by: klmp200
GPG Key ID: E7245548C53F904B

View File

@ -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)