From 279948c3300eb8b51bccc6c88ff431bc12d5ff86 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Mon, 20 Dec 2010 12:43:02 +0000 Subject: [PATCH] Various small fixes for the reddit decouple --- reddit/forms.py | 4 ++-- reddit/urls.py | 3 +-- reddit/views.py | 7 ++++++- sso/forms.py | 4 ++-- templates/reddit/add_reddit_account.html | 2 +- templates/sso/lookup/user.html | 1 + templates/sso/profile.html | 2 +- urls.py | 2 +- 8 files changed, 15 insertions(+), 10 deletions(-) diff --git a/reddit/forms.py b/reddit/forms.py index 7ede80b..0733e89 100644 --- a/reddit/forms.py +++ b/reddit/forms.py @@ -3,10 +3,10 @@ from django import forms from django.contrib.auth.models import User from reddit.models import RedditAccount -class RedditAccountForm(forms.ModelForm): + +class RedditAccountForm(forms.Form): """ Basic Reddit account input form """ - user = forms.ModelChoiceField(queryset=User.objects.order_by('username')) username = forms.CharField(label = u'Reddit Username', max_length=64) def clean(self): diff --git a/reddit/urls.py b/reddit/urls.py index a06e0cd..57cc181 100644 --- a/reddit/urls.py +++ b/reddit/urls.py @@ -1,7 +1,6 @@ from django.conf.urls.defaults import * - -from sso import views +from reddit import views urlpatterns = patterns('', (r'^profile/add/reddit', views.reddit_add), diff --git a/reddit/views.py b/reddit/views.py index ceefdbd..f1c88a3 100644 --- a/reddit/views.py +++ b/reddit/views.py @@ -1,3 +1,8 @@ +from django.contrib.auth.decorators import login_required +from django.shortcuts import render_to_response, redirect +from django.template import RequestContext +from django.contrib import messages + from reddit.forms import RedditAccountForm from reddit.models import RedditAccount @@ -15,7 +20,7 @@ def reddit_add(request): acc.api_update() except RedditAccount.DoesNotExist: messages.add_message(request, messages.ERROR, "Error, user %s does not exist on Reddit" % acc.username ) - return render_to_response('sso/redditaccount.html', locals(), context_instance=RequestContext(request)) + return render_to_response('reddit/add_reddit_account.html', locals(), context_instance=RequestContext(request)) acc.save() messages.add_message(request, messages.INFO, "Reddit account %s successfully added." % acc.username) diff --git a/sso/forms.py b/sso/forms.py index c66c6fe..00b6ca9 100644 --- a/sso/forms.py +++ b/sso/forms.py @@ -118,10 +118,10 @@ class UserLookupForm(forms.Form): type = forms.ChoiceField(label = u'Search type', choices = choices) username = forms.CharField(label = u'User ID', max_length=64) - def __init__(self): + def __init__(self, *args, **kwargs): if installed('reddit'): self.choices.append((3, "Reddit ID")) - forms.Form.__init__(self) + forms.Form.__init__(self, *args, **kwargs) class APIPasswordForm(forms.Form): diff --git a/templates/reddit/add_reddit_account.html b/templates/reddit/add_reddit_account.html index 5d71a25..b17553f 100644 --- a/templates/reddit/add_reddit_account.html +++ b/templates/reddit/add_reddit_account.html @@ -7,7 +7,7 @@ corporation

Please note, you will be forever tied to this account and posts and comments made on this account will be checked on from time to time

-
+ {{ form.as_table }}
diff --git a/templates/sso/lookup/user.html b/templates/sso/lookup/user.html index 93d1a8d..69d377c 100644 --- a/templates/sso/lookup/user.html +++ b/templates/sso/lookup/user.html @@ -1,6 +1,7 @@ {% extends "base.html" %} {% load naturaltimediff %} +{% load installed %} {% block content %} diff --git a/templates/sso/profile.html b/templates/sso/profile.html index f8bd731..3469723 100644 --- a/templates/sso/profile.html +++ b/templates/sso/profile.html @@ -140,7 +140,7 @@ setup.

{% endif %}

-Add a Reddit account +Add a Reddit account

{% endif %} diff --git a/urls.py b/urls.py index 0134d44..ea8425e 100644 --- a/urls.py +++ b/urls.py @@ -24,6 +24,6 @@ urlpatterns = patterns('', if installed('reddit'): urlpatterns += patterns('', - ('', include('sso.urls')), + ('', include('reddit.urls')), )