Removed unused import, PEP8 cleanups

This commit is contained in:
Roberto Rosario
2011-08-12 02:13:23 -04:00
parent 09f1c2bd2f
commit 0a2591d58f
38 changed files with 295 additions and 142 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
# From: http://www.micahcarrick.com/django-email-authentication.html
from django.contrib.auth.models import User, check_password
from django.contrib.auth.models import User
from django.contrib.auth.backends import ModelBackend
class EmailAuthBackend(ModelBackend):
"""
Email Authentication Backend
Allows a user to sign in using an email/password pair rather than
a username/password pair.
"""
+5 -6
View File
@@ -51,7 +51,7 @@ class DetailForm(forms.ModelForm):
self.fields[field_name].widget = TextAreaDiv(
attrs=field.widget.attrs,
)
for field_name, field in self.fields.items():
self.fields[field_name].widget.attrs.update({'readonly': 'readonly'})
@@ -128,10 +128,10 @@ class EmailAuthenticationForm(AuthenticationForm):
Override the default authentication form to use email address
authentication
"""
email = forms.CharField(label=_(u'Email'), max_length=75,
email = forms.CharField(label=_(u'Email'), max_length=75,
widget=EmailInput()
)
def clean(self):
email = self.cleaned_data.get('email')
password = self.cleaned_data.get('password')
@@ -145,7 +145,7 @@ class EmailAuthenticationForm(AuthenticationForm):
self.check_for_test_cookie()
return self.cleaned_data
# Remove the inherited username field
# Remove the inherited username field
EmailAuthenticationForm.base_fields.keyOrder = ['email', 'password']
@@ -164,5 +164,4 @@ class ChangelogForm(forms.Form):
changelog_path = os.path.join(settings.PROJECT_ROOT, CHANGELOG_DIRECTORY, CHANGELOG_FILENAME)
fd = open(changelog_path)
self.fields['text'].initial = fd.read()
fd.close()
fd.close()
-6
View File
@@ -358,12 +358,6 @@ def validate_path(path):
return True
#def encapsulate(function):
# def wrapper():
# return function
# return wrapper
def encapsulate(function):
# Workaround Django ticket 15791
# Changeset 16045
+4 -11
View File
@@ -1,5 +1,3 @@
import os
from django.shortcuts import redirect
from django.utils.translation import ugettext_lazy as _
from django.http import HttpResponseRedirect
@@ -10,10 +8,8 @@ from django.contrib.contenttypes.models import ContentType
from django.core.urlresolvers import reverse
from django.utils.http import urlencode
from django.contrib.auth.views import login
from django.conf import settings
from django.utils.safestring import mark_safe
from common.forms import ChoiceForm, UserForm, UserForm_view
from common.forms import ChoiceForm, UserForm, UserForm_view, ChangelogForm
from common.forms import EmailAuthenticationForm
from common.conf.settings import LOGIN_METHOD
@@ -181,18 +177,15 @@ def login_view(request):
if LOGIN_METHOD == 'email':
kwargs['authentication_form'] = EmailAuthenticationForm
return login(request, **kwargs)
from common.forms import ChangelogForm
def changelog(request):
#changelog_widget = mark_safe(u'<form class="form"><div class="group"><textarea rows="10" cols="40" class="text_area">%s</textarea></div></form>' % changelog)
def changelog(request):
form = ChangelogForm()
return render_to_response(
'generic_detail.html', {
'form': form,
'title': _(u'Changelog'),
},
context_instance=RequestContext(request))
context_instance=RequestContext(request))
+5 -4
View File
@@ -4,8 +4,8 @@ from django.utils.translation import ugettext_lazy as _
from django.utils.safestring import mark_safe
from django import forms
from django.forms.util import flatatt
from django.utils.html import escape, conditional_escape
from django.utils.encoding import StrAndUnicode, force_unicode
from django.utils.html import conditional_escape
from django.utils.encoding import force_unicode
class PlainWidget(forms.widgets.Widget):
@@ -77,11 +77,12 @@ class TextAreaDiv(forms.widgets.Widget):
super(TextAreaDiv, self).__init__(default_attrs)
def render(self, name, value, attrs=None):
if value is None: value = ''
if value is None:
value = ''
final_attrs = self.build_attrs(attrs, name=name)
result = mark_safe(u'<div%s>%s</div>' % (flatatt(final_attrs),
conditional_escape(force_unicode(value))))
return mark_safe(result.replace('\n', '<br>'))