Archived
Use Member as the Django User model, auth fixes
This commit is contained in:
1 parent
42e83727dd
commit
4e35307501
16 files changed
+117
-639
No files matched your search
+1
-22
@@ -1,16 +1,6 @@
|
||||
import django
|
||||
from django.db import models
|
||||
import tastypie
|
||||
from tastypie.models import ApiKey as tastypieApiKey
|
||||
import uuid
|
||||
import hmac
|
||||
|
||||
# TODO override ApiKeyAuthentication
|
||||
try:
|
||||
from hashlib import sha1
|
||||
except ImportError:
|
||||
import sha
|
||||
sha1 = sha.sha
|
||||
from tastypie.models import create_api_key
|
||||
|
||||
class BaseModel(models.Model):
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
@@ -18,18 +8,7 @@ class BaseModel(models.Model):
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
||||
class ApiKey(tastypieApiKey):
|
||||
user = models.OneToOneField('dusken.Member', related_name='api_key')
|
||||
|
||||
def create_api_key(sender, **kwargs):
|
||||
"""
|
||||
A signal for hooking up automatic ``ApiKey`` creation.
|
||||
"""
|
||||
if kwargs.get('created') is True:
|
||||
ApiKey.objects.create(user=kwargs.get('instance'))
|
||||
|
||||
class Member(django.contrib.auth.models.AbstractUser):
|
||||
def __unicode__(self):
|
||||
if len(self.first_name) + len(self.last_name) > 0:
|
||||
|
||||
Reference in new issue
Block a user