Commit dd80e024 authored by Virgilio Santos's avatar Virgilio Santos
Browse files

certificate: fix CourseCertification creation signal

parent 70976c3d
...@@ -10,14 +10,13 @@ from courses.certification.models import CourseCertification, CertificateTemplat ...@@ -10,14 +10,13 @@ from courses.certification.models import CourseCertification, CertificateTemplat
@receiver(post_save, sender=CourseStudent) @receiver(post_save, sender=CourseStudent)
def course_student_created_or_updated(sender, created, instance, **kwargs): def course_student_created_or_updated(sender, created, instance: CourseStudent, **kwargs):
if created: if created:
link_hash = ub64(sha1(str(time()) + instance.user.last_name.encode('utf-8')).digest()[0:6]) link_hash = ub64(sha1((str(time()) + instance.user.last_name).encode('utf-8')).digest()[0:6])
receipt = CourseCertification(course_student=instance, receipt = CourseCertification(course_student=instance,
course=instance.course, type=CourseCertification.TYPES[0][0],
type=CourseCertification.TYPES[0][0], is_valid=True, link_hash=link_hash.decode())
is_valid=True, link_hash=link_hash.decode())
receipt.save() receipt.save()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment