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
1b87a3f8
Commit
1b87a3f8
authored
Apr 29, 2019
by
Bruno Martin
Browse files
add missing course Material reference in models
parent
bd82d032
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
+16
-14
courses/models.py
courses/models.py
+16
-14
No files found.
courses/models.py
View file @
1b87a3f8
...
...
@@ -18,6 +18,7 @@ from .utils import hash_name
from
.videos.models
import
Video
from
.notes.models
import
Note
from
.course_material.models
import
CourseMaterial
import
re
...
...
@@ -334,14 +335,14 @@ class Course(models.Model):
return
iter
(
professors
)
def
is_course_assistant
(
self
,
user
):
if
user
.
is_anonymous
()
:
if
user
.
is_anonymous
:
return
False
return
self
.
get_professor_role
(
user
)
==
'assistant'
# return role =='assistant', 'coordinator'] or user.is_superuser
def
is_assistant_or_coordinator
(
self
,
user
):
if
user
.
is_anonymous
()
:
if
user
.
is_anonymous
:
return
False
if
user
.
is_staff
or
user
.
is_superuser
:
...
...
@@ -396,18 +397,19 @@ class CourseStudent(models.Model):
def
save
(
self
,
*
args
,
**
kwargs
):
super
(
CourseStudent
,
self
).
save
(
*
args
,
**
kwargs
)
try
:
receipt
=
CourseCertification
.
objects
.
get
(
course_student
=
self
)
except
CourseCertification
.
DoesNotExist
:
from
base64
import
urlsafe_b64encode
as
ub64
from
hashlib
import
sha1
from
time
import
time
h
=
ub64
(
sha1
(
str
(
time
())
+
self
.
user
.
last_name
.
encode
(
'utf-8'
)).
digest
()[
0
:
6
])
receipt
=
CourseCertification
(
course_student
=
self
,
course
=
self
.
course
,
type
=
CourseCertification
.
TYPES
[
0
][
0
],
is_valid
=
True
,
link_hash
=
h
)
receipt
.
save
()
# TODO Move this to Course Certification app, couse this app must not depend on Course Certification.
# try:
# receipt = CourseCertification.objects.get(course_student=self)
# except CourseCertification.DoesNotExist:
# from base64 import urlsafe_b64encode as ub64
# from hashlib import sha1
# from time import time
# h = ub64(sha1(str(time()) + self.user.last_name.encode('utf-8')).digest()[0:6])
# receipt = CourseCertification(course_student=self,
# course=self.course,
# type=CourseCertification.TYPES[0][0],
# is_valid=True, link_hash=h)
# receipt.save()
@
property
def
units_done
(
self
):
...
...
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