mirror of
https://github.com/pinry/pinry.git
synced 2025-11-14 17:05:50 +01:00
Expose a gravatar hash for account via the Rest API
This commit is contained in:
@@ -2,12 +2,17 @@ from tastypie.resources import ModelResource
|
|||||||
from tastypie import fields
|
from tastypie import fields
|
||||||
from tastypie.authorization import DjangoAuthorization
|
from tastypie.authorization import DjangoAuthorization
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
from pinry.core.models import User
|
||||||
|
|
||||||
from pinry.pins.models import Pin
|
from pinry.pins.models import Pin
|
||||||
|
|
||||||
|
|
||||||
class UserResource(ModelResource):
|
class UserResource(ModelResource):
|
||||||
|
gravatar = fields.CharField()
|
||||||
|
|
||||||
|
def dehydrate_gravatar(self, bundle):
|
||||||
|
return bundle.obj.gravatar
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
queryset = User.objects.all()
|
queryset = User.objects.all()
|
||||||
resource_name = 'user'
|
resource_name = 'user'
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import hashlib
|
||||||
|
from django.contrib.auth.models import User as BaseUser
|
||||||
|
|
||||||
|
class User(BaseUser):
|
||||||
|
@property
|
||||||
|
def gravatar(self):
|
||||||
|
return hashlib.md5(self.email).hexdigest()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
proxy = True
|
||||||
Reference in New Issue
Block a user