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

Merge branch 'develop' into 'master'

Set certificate template by default

See merge request !82
parents b59467bd e8c333a1
......@@ -6,6 +6,7 @@ from hashlib import sha1
from time import time
from courses.models import Course, CourseStudent, Forum
from courses.classes.models import Class
from courses.certification.models import CourseCertification, CertificateTemplate
......@@ -20,15 +21,29 @@ def course_student_created_or_updated(sender, created, instance: CourseStudent,
@receiver(post_save, sender=Course)
def course_created(sender, created, instance, **kwargs):
def course_created_or_updated(sender, created, instance, **kwargs):
if created:
c = Class.objects.create(, course=instance)
instance.default_class = c
forum = Forum.objects.create(, is_public=True, forum_type="course") = forum
for type_ in CertificateTemplate.TYPES:
ct = CertificateTemplate(course=instance, document_type=type_[0], name='Base ' +
for type_tuple in CertificateTemplate.TYPES:
type_name = type_tuple[0]
ct = CertificateTemplate(course=instance, document_type=type_name, name='Base ' +
if type_name == 'receipt':
instance.default_class.receipt_template = ct
elif type_name == 'certificate':
instance.default_class.certificate_template = ct
foruns = Forum.objects.filter(
if foruns:
......@@ -343,9 +343,6 @@ class Course(models.Model):
super(Course, self).save(*args, **kwargs)
if is_new:
c = Class.objects.create(, course=self)
self.default_class = c
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