Newer
Older
from django.db import models
from django.contrib.auth.models import User
from django.utils.timezone import now
from django.core.urlresolvers import reverse
identifier = models.CharField(max_length=200, unique=True,
help_text="A URL identifier. Alphanumeric with dashes, "
"no spaces.",
db_index=True)
git_source = models.CharField(max_length=200, blank=True,
help_text="A Git URL from which to pull course updates.")
xmpp_id = models.CharField(max_length=200, blank=True,
help_text="An XMPP ID")
active_git_commit_sha = models.CharField(max_length=200, null=True)
participants = models.ManyToManyField(User,
through='Participation')
def __unicode__(self):
return self.identifier
def get_absolute_url(self):
return reverse("course.views.course_page", args=(self.identifier,))
class role:
instructor = "instructor"
teaching_assistant = "ta"
student = "student"
ROLE_CHOICES = (
(role.instructor, "Instructor"),
(role.teaching_assistant, "Teaching Assistant"),
(role.student, "Student"),
requested = "requested"
email_confirmed = "email_confirmed"
active = "active"
dropped = "dropped"
STATUS_CHOICES = (
(participation_status.requested, "Requested"),
(participation_status.email_confirmed, "Email confirmed"),
(participation_status.active, "Active"),
(participation_status.dropped, "Dropped"),
)
class Participation(models.Model):
user = models.ForeignKey(User)
course = models.ForeignKey(Course)
enroll_time = models.DateTimeField(default=now)
role = models.CharField(max_length=50,
choices=ROLE_CHOICES)
status = models.CharField(max_length=50,
choices=STATUS_CHOICES)
registration_key = models.CharField(max_length=50)
#time_factor = models.DecimalField(max_digits=10, decimal_places=2)
class InstantFlowRequest(models.Model):
course = models.ForeignKey(Course)
flow_id = models.CharField(max_length=200)
start_time = models.DateTimeField(default=now)
end_time = models.DateTimeField()
class flow_visit_state:
in_progress = "in_progress"
expired = "expired"
completed = "completed"
participation = models.ForeignKey(Participation)
active_git_commit_sha = models.CharField(max_length=200)
start_time = models.DateTimeField(default=now)
state = models.CharField(max_length=50)
flow_visit = models.ForeignKey(FlowVisit)
page_id = models.CharField(max_length=200)
visit_time = models.DateTimeField(default=now)
answer_time = models.DateTimeField(default=now)
answer_value = models.CharField(max_length=200)
points = models.DecimalField(max_digits=10, decimal_places=2)
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# {{{ sync commands
class sync_commands:
update = "update"
SYNC_COMMAND_CHOICES = (
(sync_commands.update, "Update"),
)
class sync_command_status:
waiting = "waiting"
running = "running"
error = "error"
success = "success"
class sync_commands:
update = "update"
class SyncCommand(models.Model):
course = models.ForeignKey(Course)
command = models.CharField(max_length=200,
choices=SYNC_COMMAND_CHOICES)
command_timestamp = models.DateTimeField(default=now)
status = models.CharField(max_length=200)
status_timestamp = models.DateTimeField(default=now)
message = models.CharField(max_length=2000)
# }}}