Exclude email, fix dates, don't check "Geburtsdatum" field
This commit is contained in:
parent
b0028a1685
commit
81351aa9fa
|
|
@ -44,6 +44,7 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
||||||
dueDate.start = dayjs(dueDate.start);
|
dueDate.start = dayjs(dueDate.start);
|
||||||
dueDate.end = dayjs(dueDate.end);
|
dueDate.end = dayjs(dueDate.end);
|
||||||
});
|
});
|
||||||
|
sortDueDates(cs.due_dates);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -202,7 +203,12 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
||||||
allDueDatesReturn.push(...cs.due_dates);
|
allDueDatesReturn.push(...cs.due_dates);
|
||||||
});
|
});
|
||||||
|
|
||||||
allDueDatesReturn.sort((a, b) => {
|
sortDueDates(allDueDatesReturn);
|
||||||
|
return allDueDatesReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sortDueDates(dueDates: DueDate[]) {
|
||||||
|
dueDates.sort((a, b) => {
|
||||||
const dateA = dayjs(a.end);
|
const dateA = dayjs(a.end);
|
||||||
const dateB = dayjs(b.end);
|
const dateB = dayjs(b.end);
|
||||||
|
|
||||||
|
|
@ -212,8 +218,6 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
||||||
|
|
||||||
return dateA.diff(dateB); // Otherwise, sort by the end date
|
return dateA.diff(dateB); // Otherwise, sort by the end date
|
||||||
});
|
});
|
||||||
|
|
||||||
return allDueDatesReturn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startUpload() {
|
async function startUpload() {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
("assignment", "0003_initial"),
|
("assignment", "0003_initial"),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
("assignment", "0004_alter_assignmentcompletion_additional_json_data"),
|
("assignment", "0004_alter_assignmentcompletion_additional_json_data"),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = []
|
dependencies = []
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import vbv_lernwelt.course.models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
("course", "0002_initial"),
|
("course", "0002_initial"),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,12 @@ class EdoniqUserExportTestCase(TestCase):
|
||||||
user2.save()
|
user2.save()
|
||||||
|
|
||||||
def test_fetch_course_session_users(self):
|
def test_fetch_course_session_users(self):
|
||||||
users = fetch_course_session_users([COURSE_TEST_ID])
|
users = fetch_course_session_users([COURSE_TEST_ID], excluded_domains=[])
|
||||||
self.assertEqual(len(users), 2)
|
self.assertEqual(len(users), 2)
|
||||||
|
|
||||||
def test_fetch_course_session_trainers(self):
|
def test_fetch_course_session_trainers(self):
|
||||||
users = fetch_course_session_users(
|
users = fetch_course_session_users(
|
||||||
[COURSE_TEST_ID], role=CourseSessionUser.Role.EXPERT
|
[COURSE_TEST_ID], role=CourseSessionUser.Role.EXPERT, excluded_domains=[]
|
||||||
)
|
)
|
||||||
self.assertEqual(len(users), 1)
|
self.assertEqual(len(users), 1)
|
||||||
|
|
||||||
|
|
@ -48,11 +48,13 @@ class EdoniqUserExportTestCase(TestCase):
|
||||||
user1 = User.objects.get(email="test-student1@example.com")
|
user1 = User.objects.get(email="test-student1@example.com")
|
||||||
user1.email = "some@eiger-versicherungen.ch"
|
user1.email = "some@eiger-versicherungen.ch"
|
||||||
user1.save()
|
user1.save()
|
||||||
users = fetch_course_session_users([COURSE_TEST_ID])
|
users = fetch_course_session_users(
|
||||||
|
[COURSE_TEST_ID], excluded_domains=["eiger-versicherungen.ch"]
|
||||||
|
)
|
||||||
self.assertEqual(len(users), 1)
|
self.assertEqual(len(users), 1)
|
||||||
|
|
||||||
def test_export_students_and_trainers(self):
|
def test_export_students_and_trainers(self):
|
||||||
users = fetch_course_session_all_users([COURSE_TEST_ID])
|
users = fetch_course_session_all_users([COURSE_TEST_ID], excluded_domains=[])
|
||||||
self.assertEqual(len(users), 3)
|
self.assertEqual(len(users), 3)
|
||||||
|
|
||||||
def test_deduplicates_users(self):
|
def test_deduplicates_users(self):
|
||||||
|
|
@ -64,13 +66,11 @@ class EdoniqUserExportTestCase(TestCase):
|
||||||
course_session=cs_zrh,
|
course_session=cs_zrh,
|
||||||
user=trainer1,
|
user=trainer1,
|
||||||
)
|
)
|
||||||
users = fetch_course_session_all_users([COURSE_TEST_ID])
|
users = fetch_course_session_all_users([COURSE_TEST_ID], excluded_domains=[])
|
||||||
for u in users:
|
|
||||||
print(u.edoniq_role, u.email)
|
|
||||||
self.assertEqual(len(users), 3)
|
self.assertEqual(len(users), 3)
|
||||||
|
|
||||||
def test_response_csv(self):
|
def test_response_csv(self):
|
||||||
users = fetch_course_session_users([COURSE_TEST_ID])
|
users = fetch_course_session_users([COURSE_TEST_ID], excluded_domains=[])
|
||||||
response = generate_export_response(users)
|
response = generate_export_response(users)
|
||||||
|
|
||||||
user_data = [
|
user_data = [
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ from itertools import chain
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from django.contrib.admin.views.decorators import staff_member_required
|
from django.contrib.admin.views.decorators import staff_member_required
|
||||||
from django.db.models import CharField, Value
|
from django.db.models import CharField, Q, Value
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
|
||||||
from vbv_lernwelt.core.models import User
|
from vbv_lernwelt.core.models import User
|
||||||
|
|
@ -12,6 +12,7 @@ from vbv_lernwelt.course.consts import COURSE_UK, COURSE_UK_FR, COURSE_UK_IT
|
||||||
from vbv_lernwelt.course.models import CourseSessionUser
|
from vbv_lernwelt.course.models import CourseSessionUser
|
||||||
|
|
||||||
UK_COURSE_IDS = [COURSE_UK, COURSE_UK_FR, COURSE_UK_IT]
|
UK_COURSE_IDS = [COURSE_UK, COURSE_UK_FR, COURSE_UK_IT]
|
||||||
|
DEFAULT_EXCLUDED_DOMAINS = ["eiger-versicherung.ch", "assurance.ch", "example.com"]
|
||||||
|
|
||||||
|
|
||||||
@staff_member_required
|
@staff_member_required
|
||||||
|
|
@ -34,30 +35,41 @@ def export_students_and_trainers(request):
|
||||||
return generate_export_response(course_session_users)
|
return generate_export_response(course_session_users)
|
||||||
|
|
||||||
|
|
||||||
def fetch_course_session_users(courses: List[int], role=CourseSessionUser.Role.MEMBER):
|
def fetch_course_session_users(
|
||||||
|
courses: List[int], role=CourseSessionUser.Role.MEMBER, excluded_domains=None
|
||||||
|
):
|
||||||
if role == CourseSessionUser.Role.EXPERT:
|
if role == CourseSessionUser.Role.EXPERT:
|
||||||
edoniq_role = "Trainer"
|
edoniq_role = "Trainer"
|
||||||
else:
|
else:
|
||||||
edoniq_role = "Lernende"
|
edoniq_role = "Lernende"
|
||||||
|
|
||||||
|
# exclude test users if required
|
||||||
|
if excluded_domains is None:
|
||||||
|
excluded_domains = DEFAULT_EXCLUDED_DOMAINS
|
||||||
|
|
||||||
|
exclude_q = Q()
|
||||||
|
for condition in excluded_domains:
|
||||||
|
exclude_q |= Q(email__contains=condition)
|
||||||
|
|
||||||
# if users should be exported per course session, remove the distinct() call
|
# if users should be exported per course session, remove the distinct() call
|
||||||
return (
|
return (
|
||||||
User.objects.filter(
|
User.objects.filter(
|
||||||
coursesessionuser__course_session__course__id__in=courses,
|
coursesessionuser__course_session__course__id__in=courses,
|
||||||
coursesessionuser__role=role,
|
coursesessionuser__role=role,
|
||||||
)
|
)
|
||||||
.exclude(email__contains="eiger-versicherungen.ch") # exclude test users
|
.exclude(exclude_q)
|
||||||
.exclude(email__contains="assurance.ch")
|
|
||||||
.order_by("email")
|
.order_by("email")
|
||||||
.annotate(edoniq_role=Value(edoniq_role, output_field=CharField()))
|
.annotate(edoniq_role=Value(edoniq_role, output_field=CharField()))
|
||||||
.distinct()
|
.distinct()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def fetch_course_session_all_users(courses: List[int]):
|
def fetch_course_session_all_users(courses: List[int], excluded_domains=None):
|
||||||
course_session_users = fetch_course_session_users(courses)
|
course_session_users = fetch_course_session_users(
|
||||||
|
courses, excluded_domains=excluded_domains
|
||||||
|
)
|
||||||
course_session_trainers = fetch_course_session_users(
|
course_session_trainers = fetch_course_session_users(
|
||||||
courses, role=CourseSessionUser.Role.EXPERT
|
courses, role=CourseSessionUser.Role.EXPERT, excluded_domains=excluded_domains
|
||||||
)
|
)
|
||||||
combined_queryset = chain(course_session_users, course_session_trainers)
|
combined_queryset = chain(course_session_users, course_session_trainers)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = []
|
dependencies = []
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import vbv_lernwelt.files.utils
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|
|
||||||
|
|
@ -508,7 +508,6 @@ def import_students_from_excel(filename: str):
|
||||||
"Sprache",
|
"Sprache",
|
||||||
"Durchführungen",
|
"Durchführungen",
|
||||||
"Lehrvertragsnummer",
|
"Lehrvertragsnummer",
|
||||||
"Geburtsdatum",
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
create_or_update_student(data)
|
create_or_update_student(data)
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -7,7 +7,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
("learnpath", "0001_initial"),
|
("learnpath", "0001_initial"),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue