Commit dc7e16bf authored by Glaucia S. Santos's avatar Glaucia S. Santos Committed by Matheus Miranda
Browse files

Create a forum after creating a course

parent e8d75c73
......@@ -5,13 +5,12 @@ from base64 import urlsafe_b64encode as ub64
from hashlib import sha1
from time import time
from courses.models import Course, CourseStudent
from courses.models import Course, CourseStudent, Forum
from courses.certification.models import CourseCertification, CertificateTemplate
@receiver(post_save, sender=CourseStudent)
def course_student_created_or_updated(sender, created, instance: CourseStudent, **kwargs):
if created:
link_hash = ub64(sha1((str(time()) + instance.user.last_name).encode('utf-8')).digest()[0:6])
receipt = CourseCertification(course_student=instance,
......@@ -22,8 +21,11 @@ def course_student_created_or_updated(sender, created, instance: CourseStudent,
@receiver(post_save, sender=Course)
def course_created(sender, created, instance, **kwargs):
if created:
forum = Forum.objects.create(, is_public=True, forum_type="course") = forum
for type_ in CertificateTemplate.TYPES:
ct = CertificateTemplate(course=instance, document_type=type_[0])
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