Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
MOOC packages by hacklab
django-courses
Commits
b0fdefee
Commit
b0fdefee
authored
Apr 09, 2021
by
Matheus Miranda
Browse files
Merge branch 'develop' into 'master'
Create a forum after creating a course See merge request
!41
parents
b1acadc0
7fd3195b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
courses/certification/signals.py
courses/certification/signals.py
+5
-3
No files found.
courses/certification/signals.py
View file @
b0fdefee
...
...
@@ -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
(
title
=
instance
.
name
,
is_public
=
True
,
forum_type
=
"course"
)
instance
.
forum
=
forum
instance
.
save
()
for
type_
in
CertificateTemplate
.
TYPES
:
ct
=
CertificateTemplate
(
course
=
instance
,
document_type
=
type_
[
0
])
ct
.
save
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment