Commit b0fdefee authored by Matheus Miranda's avatar Matheus Miranda
Browse files

Merge branch 'develop' into 'master'

Create a forum after creating a course

See merge request !41
parents b1acadc0 7fd3195b
......@@ -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