diff --git a/seminar/migrations/0073_copy_osoba_email_to_user_email.py b/seminar/migrations/0073_copy_osoba_email_to_user_email.py new file mode 100644 index 00000000..3b280209 --- /dev/null +++ b/seminar/migrations/0073_copy_osoba_email_to_user_email.py @@ -0,0 +1,22 @@ +# Generated by Django 2.2.9 on 2020-01-15 21:28 + +from django.db import migrations + +def copy_mails(apps, schema_editor): + Osoba = apps.get_model('seminar', 'Osoba') + + for o in Osoba.objects.all(): + if o.user is not None: + u = o.user + u.email = o.email + u.save() + +class Migration(migrations.Migration): + + dependencies = [ + ('seminar', '0072_auto_20191204_2257'), + ] + + operations = [ + migrations.RunPython(copy_mails, migrations.RunPython.noop) + ] diff --git a/seminar/models.py b/seminar/models.py index 7a16bc96..e65dcb67 100644 --- a/seminar/models.py +++ b/seminar/models.py @@ -130,6 +130,17 @@ class Osoba(SeminarModelBase): def __str__(self): return self.plne_jmeno() + # Overridujeme save Osoby, aby když si změní e-mail, aby se projevil i v + # Userovi (a tak se dal poslat mail s resetem hesla) + def save(self, *args, **kwargs): + if self.user is not None: + u = self.user + # U svatého tučňáka, prosím ať tohle funguje. + # (Takhle se kódit asi nemá...) + u.email = self.email + u.save() + super().save() + # # Mělo by být částečně vytaženo z Aesopa # viz https://ovvp.mff.cuni.cz/wiki/aesop/export-skol. diff --git a/seminar/views.py b/seminar/views.py index 065d6879..4a18739f 100644 --- a/seminar/views.py +++ b/seminar/views.py @@ -1296,6 +1296,7 @@ class LogoutView(auth_views.LogoutView): # Pavel: Vůbec nevím, proč to s _lazy funguje, ale bez toho to bylo rozbité. next_page = reverse_lazy('titulni_strana') +# "Chci resetovat heslo" class PasswordResetView(auth_views.PasswordResetView): #template_name = 'seminar/password_reset.html' # TODO: vlastní email_template_name a subject_template_name a html_email_template_name @@ -1303,14 +1304,17 @@ class PasswordResetView(auth_views.PasswordResetView): from_email = 'login@mam.mff.cuni.cz' # TODO: přepsat User-a :-( +# "Poslali jsme e-mail (pokud bylo kam))" class PasswordResetDoneView(auth_views.PasswordResetDoneView): #template_name = 'seminar/password_reset_done.html' pass +# "Vymysli si heslo" class PasswordResetConfirmView(auth_views.PasswordResetConfirmView): #template_name = 'seminar/password_confirm_done.html' success_url = reverse_lazy('reset_password_complete') +# "Heslo se asi změnilo." class PasswordResetCompleteView(auth_views.PasswordResetCompleteView): #template_name = 'seminar/password_complete_done.html' pass