mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 14:52:15 +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 django.contrib.auth.models import User
|
||||||
from reddit.models import RedditAccount
|
from reddit.models import RedditAccount
|
||||||
|
|
||||||
class RedditAccountForm(forms.ModelForm):
|
|
||||||
|
class RedditAccountForm(forms.Form):
|
||||||
""" Basic Reddit account input 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)
|
username = forms.CharField(label = u'Reddit Username', max_length=64)
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
from django.conf.urls.defaults import *
|
from django.conf.urls.defaults import *
|
||||||
|
from reddit import views
|
||||||
from sso import views
|
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
(r'^profile/add/reddit', views.reddit_add),
|
(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.forms import RedditAccountForm
|
||||||
from reddit.models import RedditAccount
|
from reddit.models import RedditAccount
|
||||||
|
|
||||||
@@ -15,7 +20,7 @@ def reddit_add(request):
|
|||||||
acc.api_update()
|
acc.api_update()
|
||||||
except RedditAccount.DoesNotExist:
|
except RedditAccount.DoesNotExist:
|
||||||
messages.add_message(request, messages.ERROR, "Error, user %s does not exist on Reddit" % acc.username )
|
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()
|
acc.save()
|
||||||
|
|
||||||
messages.add_message(request, messages.INFO, "Reddit account %s successfully added." % acc.username)
|
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)
|
type = forms.ChoiceField(label = u'Search type', choices = choices)
|
||||||
username = forms.CharField(label = u'User ID', max_length=64)
|
username = forms.CharField(label = u'User ID', max_length=64)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, *args, **kwargs):
|
||||||
if installed('reddit'):
|
if installed('reddit'):
|
||||||
self.choices.append((3, "Reddit ID"))
|
self.choices.append((3, "Reddit ID"))
|
||||||
forms.Form.__init__(self)
|
forms.Form.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
class APIPasswordForm(forms.Form):
|
class APIPasswordForm(forms.Form):
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
corporation</p>
|
corporation</p>
|
||||||
<p>Please note, you will be forever tied to this account and posts and comments made on this account will be checked
|
<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>
|
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>
|
<table>
|
||||||
{{ form.as_table }}
|
{{ form.as_table }}
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% load naturaltimediff %}
|
{% load naturaltimediff %}
|
||||||
|
{% load installed %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ setup.</p>
|
|||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<p>
|
<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>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user