Commit 9853c632 by Calen Pennington Committed by ichuang

Remove circular dependencies that connect student.models and django_comment_client

Includes removal of "from django_comment_client.models import Role" from common/djangoapps/student/models.py

Conflicts:

	common/djangoapps/student/models.py
parent ec94f732
......@@ -49,7 +49,6 @@ from django.db.models.signals import post_save
from django.dispatch import receiver
import comment_client as cc
from django_comment_client.models import Role
log = logging.getLogger(__name__)
......@@ -280,16 +279,6 @@ class CourseEnrollmentAllowed(models.Model):
return "[CourseEnrollmentAllowed] %s: %s (%s)" % (self.email, self.course_id, self.created)
@receiver(post_save, sender=CourseEnrollment)
def assign_default_role(sender, instance, **kwargs):
if instance.user.is_staff:
role = Role.objects.get_or_create(course_id=instance.course_id, name="Moderator")[0]
else:
role = Role.objects.get_or_create(course_id=instance.course_id, name="Student")[0]
logging.info("assign_default_role: adding %s as %s" % (instance.user, role))
instance.user.roles.add(role)
#cache_relation(User.profile)
#### Helper methods for use from python manage.py shell.
......
......@@ -2,6 +2,10 @@ import logging
from django.db import models
from django.contrib.auth.models import User
from django.dispatch import receiver
from django.db.models.signals import post_save
from student.models import CourseEnrollment
from courseware.courses import get_course_by_id
......@@ -45,3 +49,14 @@ class Permission(models.Model):
def __unicode__(self):
return self.name
@receiver(post_save, sender=CourseEnrollment)
def assign_default_role(sender, instance, **kwargs):
if instance.user.is_staff:
role = Role.objects.get_or_create(course_id=instance.course_id, name="Moderator")[0]
else:
role = Role.objects.get_or_create(course_id=instance.course_id, name="Student")[0]
logging.info("assign_default_role: adding %s as %s" % (instance.user, role))
instance.user.roles.add(role)
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