Commit 1b87a3f8 authored by Bruno Martin's avatar Bruno Martin
Browse files

add missing course Material reference in models

parent bd82d032
......@@ -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):
......
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