Skip to content

Commit

Permalink
Improved SocialApp admin (long tokens) (closes #470)
Browse files Browse the repository at this point in the history
  • Loading branch information
pennersr committed Mar 8, 2014
1 parent 6a50b53 commit 93c799f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
18 changes: 15 additions & 3 deletions allauth/socialaccount/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.contrib import admin
from django import forms

from .models import SocialApp, SocialAccount, SocialToken

Expand All @@ -8,7 +9,18 @@
User = get_user_model()


class SocialAppForm(forms.ModelForm):
class Meta:
model = SocialApp
widgets = {
'client_id': forms.TextInput(attrs={'size': '100'}),
'key': forms.TextInput(attrs={'size': '100'}),
'secret': forms.TextInput(attrs={'size': '100'})
}


class SocialAppAdmin(admin.ModelAdmin):
form = SocialAppForm
list_display = ('name', 'provider',)
filter_horizontal = ('sites',)

Expand All @@ -17,9 +29,9 @@ class SocialAccountAdmin(admin.ModelAdmin):
search_fields = ['user__emailaddress__email'] + \
list(map(lambda a: 'user__' + a,
filter(lambda a: a and hasattr(User(), a),
[app_settings.USER_MODEL_USERNAME_FIELD,
'first_name',
'last_name'])))
[app_settings.USER_MODEL_USERNAME_FIELD,
'first_name',
'last_name'])))
raw_id_fields = ('user',)
list_display = ('user', 'uid', 'provider')
list_filter = ('provider',)
Expand Down
6 changes: 3 additions & 3 deletions allauth/socialaccount/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class SocialApp(models.Model):
name = models.CharField(max_length=40)
client_id = models.CharField(max_length=100,
help_text='App ID, or consumer key')
key = models.CharField(max_length=100,
blank=True,
help_text='Key (Stack Exchange only)')
secret = models.CharField(max_length=100,
help_text='API secret, client secret, or'
' consumer secret')
key = models.CharField(max_length=100,
blank=True,
help_text='Key (Stack Exchange only)')
# Most apps can be used across multiple domains, therefore we use
# a ManyToManyField. Note that Facebook requires an app per domain
# (unless the domains share a common base name).
Expand Down

0 comments on commit 93c799f

Please sign in to comment.