Various small fixes for the reddit decouple

This commit is contained in:
2010-12-20 12:43:02 +00:00
parent cc4f986edb
commit 279948c330
8 changed files with 15 additions and 10 deletions

View File

@@ -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):

View File

@@ -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),

View File

@@ -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)

View File

@@ -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):

View File

@@ -7,7 +7,7 @@
corporation</p>
<p>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</p>
<form action="{% url sso.views.reddit_add %}" method="post">
<form action="{% url reddit.views.reddit_add %}" method="post">
<table>
{{ form.as_table }}
</table>

View File

@@ -1,6 +1,7 @@
{% extends "base.html" %}
{% load naturaltimediff %}
{% load installed %}
{% block content %}

View File

@@ -140,7 +140,7 @@ setup.</p>
</table>
{% endif %}
<p>
<a href="{% url sso.views.reddit_add %}">Add a Reddit account</a>
<a href="{% url reddit.views.reddit_add %}">Add a Reddit account</a>
</p>
{% endif %}

View File

@@ -24,6 +24,6 @@ urlpatterns = patterns('',
if installed('reddit'):
urlpatterns += patterns('',
('', include('sso.urls')),
('', include('reddit.urls')),
)