forked from voy/django-socialregistration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
68 lines (51 loc) · 2.13 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import django.dispatch
from django.db import models
from django.contrib.auth import authenticate
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
user_setup_complete = django.dispatch.Signal(providing_args=['graph'])
class FacebookProfile(models.Model):
user = models.ForeignKey(User)
site = models.ForeignKey(Site, default=Site.objects.get_current)
uid = models.CharField(max_length=255, blank=False, null=False)
def __unicode__(self):
if self.pk:
user = self.user
else:
user = u'<no-user>'
return u'%s: %s' % (user, self.uid)
def authenticate(self):
return authenticate(uid=self.uid)
class TwitterProfile(models.Model):
user = models.ForeignKey(User)
site = models.ForeignKey(Site, default=Site.objects.get_current)
twitter_id = models.PositiveIntegerField()
def __unicode__(self):
return u'%s: %s' % (self.user, self.twitter_id)
def authenticate(self):
return authenticate(twitter_id=self.twitter_id)
class OpenIDProfile(models.Model):
user = models.ForeignKey(User)
site = models.ForeignKey(Site, default=Site.objects.get_current)
identity = models.TextField()
def __unicode__(self):
return u'OpenID Profile for %s, via provider %s' % (self.user, self.identity)
def authenticate(self):
return authenticate(identity=self.identity)
class OpenIDStore(models.Model):
site = models.ForeignKey(Site, default=Site.objects.get_current)
server_url = models.CharField(max_length=255)
handle = models.CharField(max_length=255)
secret = models.TextField()
issued = models.IntegerField()
lifetime = models.IntegerField()
assoc_type = models.TextField()
def __unicode__(self):
return u'OpenID Store %s for %s' % (self.server_url, self.site)
class OpenIDNonce(models.Model):
server_url = models.CharField(max_length=255)
timestamp = models.IntegerField()
salt = models.CharField(max_length=255)
date_created = models.DateTimeField(auto_now_add=True)
def __unicode__(self):
return u'OpenID Nonce for %s' % self.server_url