mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Various small fixes for the reddit decouple
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% load naturaltimediff %}
|
||||
{% load installed %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
||||
@@ -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 %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user