models.py 1.37 KB
Newer Older
ichuang committed
1 2 3 4 5 6
"""
WE'RE USING MIGRATIONS!

If you make changes to this model, be sure to create an appropriate migration
file and check it in at the same time as your model changes. To do that,

7 8 9
1. Go to the edx-platform dir
2. ./manage.py lms schemamigration student --auto description_of_your_change
3. Add the migration file created in edx-platform/common/djangoapps/external_auth/migrations/
ichuang committed
10 11 12 13 14
"""

from django.db import models
from django.contrib.auth.models import User

Calen Pennington committed
15

ichuang committed
16
class ExternalAuthMap(models.Model):
17 18 19
    class Meta:
        unique_together = (('external_id', 'external_domain'), )
    external_id = models.CharField(max_length=255, db_index=True)
ichuang committed
20
    external_domain = models.CharField(max_length=255, db_index=True)
Calen Pennington committed
21
    external_credentials = models.TextField(blank=True)  # JSON dictionary
ichuang committed
22
    external_email = models.CharField(max_length=255, db_index=True)
Calen Pennington committed
23
    external_name = models.CharField(blank=True, max_length=255, db_index=True)
ichuang committed
24
    user = models.OneToOneField(User, unique=True, db_index=True, null=True)
Calen Pennington committed
25 26 27 28
    internal_password = models.CharField(blank=True, max_length=31)  	# randomly generated
    dtcreated = models.DateTimeField('creation date', auto_now_add=True)
    dtsignup = models.DateTimeField('signup date', null=True)		# set after signup

ichuang committed
29 30 31
    def __unicode__(self):
        s = "[%s] = (%s / %s)" % (self.external_id, self.external_name, self.external_email)
        return s