models.py 1.46 KB
Newer Older
1 2
import logging

3 4
from django.contrib.auth.models import User
from django.db import models
5
from xmodule_django.models import CourseKeyField
6

7 8
log = logging.getLogger(__name__)

Calen Pennington committed
9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
class CourseUserGroup(models.Model):
    """
    This model represents groups of users in a course.  Groups may have different types,
    which may be treated specially.  For example, a user can be in at most one cohort per
    course, and cohorts are used to split up the forums by group.
    """
    class Meta:
        unique_together = (('name', 'course_id'), )

    name = models.CharField(max_length=255,
                            help_text=("What is the name of this group?  "
                                       "Must be unique within a course."))
    users = models.ManyToManyField(User, db_index=True, related_name='course_groups',
                                   help_text="Who is in this group?")

    # Note: groups associated with particular runs of a course.  E.g. Fall 2012 and Spring
    # 2013 versions of 6.00x will have separate groups.
27
    course_id = CourseKeyField(max_length=255, db_index=True,
28 29 30 31
                                 help_text="Which course is this group associated with?")

    # For now, only have group type 'cohort', but adding a type field to support
    # things like 'question_discussion', 'friends', 'off-line-class', etc
32 33
    COHORT = 'cohort'
    GROUP_TYPE_CHOICES = ((COHORT, 'Cohort'),)
34
    group_type = models.CharField(max_length=20, choices=GROUP_TYPE_CHOICES)