PEP8 cleanups

This commit is contained in:
Roberto Rosario
2011-04-08 01:31:39 -04:00
parent 61fb876a81
commit 1b6806f7d1
13 changed files with 173 additions and 167 deletions

View File

@@ -1,16 +1,16 @@
from django import forms
from django import forms
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _
from django.db import models
from common.utils import return_attrib
class DetailSelectMultiple(forms.widgets.SelectMultiple):
def __init__(self, queryset=None, *args, **kwargs):
self.queryset = queryset
super(DetailSelectMultiple, self).__init__(*args, **kwargs)
def render(self, name, value, attrs=None, choices=()):
if value is None:
value = ''
@@ -30,7 +30,7 @@ class DetailSelectMultiple(forms.widgets.SelectMultiple):
if self.choices[0] != (u'', u'---------') and value != []:
options = [(index, string) for index, string in \
self.choices]
if options:
for index, string in options:
if self.queryset:
@@ -110,7 +110,7 @@ class GenericAssignRemoveForm(forms.Form):
left_list = forms.ModelMultipleChoiceField(required=False, queryset=None)
right_list = forms.ModelMultipleChoiceField(required=False, queryset=None)
class FilterForm(forms.Form):
def __init__(self, list_filters, *args, **kwargs):
super(FilterForm, self).__init__(*args, **kwargs)

View File

@@ -1,11 +1,13 @@
from re import compile
from django.http import HttpResponseRedirect
from django.conf import settings
from re import compile
EXEMPT_URLS = [compile(settings.LOGIN_URL.lstrip('/'))]
if hasattr(settings, 'LOGIN_EXEMPT_URLS'):
EXEMPT_URLS += [compile(expr) for expr in settings.LOGIN_EXEMPT_URLS]
class LoginRequiredMiddleware:
"""
Middleware that requires a user to be authenticated to view any page other
@@ -28,4 +30,3 @@ class LoginRequiredMiddleware:
path = request.path_info.lstrip('/')
if not any(m.match(path) for m in EXEMPT_URLS):
return HttpResponseRedirect(settings.LOGIN_URL)

View File

@@ -1,6 +1,7 @@
# Aliasing it for the sake of page size.
from django.utils.html import strip_spaces_between_tags as short
class SpacelessMiddleware(object):
def process_response(self, request, response):
if 'text/html' in response['Content-Type']:

View File

@@ -5,10 +5,12 @@ from navigation.api import model_list_columns
register = Library()
@register.filter
def object_property(value, arg):
return return_attrib(value, arg)
@register.filter
def get_model_list_columns(obj):
for key, value in model_list_columns.items():

View File

@@ -2,7 +2,7 @@ from django.template import Library
register = Library()
@register.filter
def make_non_breakable(value):
return value.replace(u'-', u'\u2011')

View File

@@ -3,6 +3,7 @@ from django.conf import settings
register = Library()
@register.simple_tag
def project_name():
return settings.PROJECT_TITLE

View File

@@ -11,8 +11,8 @@ class SettingsNode(Node):
def __init__(self, format_string, var_name):
self.format_string = format_string
self.var_name = var_name
def render(self, context):
#context[self.var_name] = settings(self.format_string)
context[self.var_name] = getattr(settings, self.format_string, '')
return ''
@@ -24,11 +24,11 @@ def get_setting(parser, token):
# Splitting by None == splitting by spaces.
tag_name, arg = token.contents.split(None, 1)
except ValueError:
raise TemplateSyntaxError, "%r tag requires arguments" % token.contents.split()[0]
raise TemplateSyntaxError('%r tag requires arguments' % token.contents.split()[0])
m = re.search(r'(.*?) as (\w+)', arg)
if not m:
raise TemplateSyntaxError, "%r tag had invalid arguments" % tag_name
raise TemplateSyntaxError('%r tag had invalid arguments' % tag_name)
format_string, var_name = m.groups()
if not (format_string[0] == format_string[-1] and format_string[0] in ('"', "'")):
raise TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name
raise TemplateSyntaxError('%r tag\'s argument should be in quotes' % tag_name)
return SettingsNode(format_string[1:-1], var_name)

View File

@@ -1,27 +1,27 @@
from django.conf.urls.defaults import *
from django.conf.urls.defaults import patterns, url
from django.views.generic.simple import direct_to_template
from django.conf import settings
urlpatterns = patterns('common.views',
url(r'^about/$', direct_to_template, { 'template' : 'about.html'}, 'about'),
url(r'^about/$', direct_to_template, {'template': 'about.html'}, 'about'),
url(r'^password/change/done/$', 'password_change_done', (), name='password_change_done'),
url(r'^object/multiple/action/$', 'multi_object_action_view', (), name='multi_object_action_view'),
)
urlpatterns += patterns('',
url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}, name='login_view'),
url(r'^logout/$', 'django.contrib.auth.views.logout', {'next_page' : '/'}, name='logout_view' ),
url(r'^logout/$', 'django.contrib.auth.views.logout', {'next_page': '/'}, name='logout_view'),
url(r'^password/change/$', 'django.contrib.auth.views.password_change', {'template_name': 'password_change_form.html', 'post_change_redirect': '/password/change/done/'}, name='password_change_view'),
#url(r'^password/change/done/$', 'django.contrib.auth.views.password_change_done', {'template_name': 'password_change_done.html'}),
url(r'^password/reset/$', 'django.contrib.auth.views.password_reset', {'email_template_name' : 'password_reset_email.html', 'template_name': 'password_reset_form.html', 'post_reset_redirect' : '/password/reset/done'}, name='password_reset_view'),
url(r'^password/reset/confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm', { 'template_name' : 'password_reset_confirm.html', 'post_reset_redirect' : '/password/reset/complete/'}, name='password_reset_confirm_view'),
url(r'^password/reset/complete/$', 'django.contrib.auth.views.password_reset_complete', { 'template_name' : 'password_reset_complete.html' }, name='password_reset_complete_view'),
url(r'^password/reset/done/$', 'django.contrib.auth.views.password_reset_done', { 'template_name' : 'password_reset_done.html'}, name='password_reset_done_view'),
url(r'^password/reset/$', 'django.contrib.auth.views.password_reset', {'email_template_name': 'password_reset_email.html', 'template_name': 'password_reset_form.html', 'post_reset_redirect': '/password/reset/done'}, name='password_reset_view'),
url(r'^password/reset/confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm', {'template_name': 'password_reset_confirm.html', 'post_reset_redirect': '/password/reset/complete/'}, name='password_reset_confirm_view'),
url(r'^password/reset/complete/$', 'django.contrib.auth.views.password_reset_complete', {'template_name': 'password_reset_complete.html'}, name='password_reset_complete_view'),
url(r'^password/reset/done/$', 'django.contrib.auth.views.password_reset_done', {'template_name': 'password_reset_done.html'}, name='password_reset_done_view'),
(r'^favicon\.ico$', 'django.views.generic.simple.redirect_to', {'url': '%s%s' %(settings.MEDIA_URL, 'images/favicon.ico')}),
(r'^favicon\.ico$', 'django.views.generic.simple.redirect_to', {'url': '%s%s' % (settings.MEDIA_URL, 'images/favicon.ico')}),
)
urlpatterns += patterns('',

View File

@@ -34,7 +34,7 @@ def urlquote(link=None, get={}):
link = ''
assert isinstance(get, dict), 'wrong type "%s", dict required' % type(get)
#assert not (link.startswith('http://') or link.startswith('https://')), \
# 'This method should only quote the url path.
# 'This method should only quote the url path.
# It should not start with http(s):// (%s)' % (
# link)
if get:
@@ -72,15 +72,16 @@ def return_attrib(obj, attrib, arguments={}):
#http://snippets.dzone.com/posts/show/5434
#http://snippets.dzone.com/user/jakob
def pretty_size(size, suffixes = [('B', 2**10), ('K', 2**20), ('M', 2**30), ('G', 2**40), ('T', 2**50)]):
def pretty_size(size, suffixes=[('B', 2 ** 10), ('K', 2 ** 20), ('M', 2 ** 30), ('G', 2 ** 40), ('T', 2 ** 50)]):
for suf, lim in suffixes:
if size > lim:
continue
else:
return round(size/float(lim/2**10), 2).__str__()+suf
return round(size / float(lim / 2 ** 10), 2).__str__() + suf
def pretty_size_10(size):
return pretty_size(size, suffixes = [('B', 10**3), ('K', 10**6), ('M', 10**9), ('G', 10**12), ('T', 10**15)])
return pretty_size(size, suffixes=[('B', 10 ** 3), ('K', 10 ** 6), ('M', 10 ** 9), ('G', 10 ** 12), ('T', 10 ** 15)])
def exists_with_famfam(path):
@@ -113,8 +114,8 @@ def proper_name(name):
"""Does the work of capitalizing a name (can be a full name)."""
suffixes = [
u"II", u"(II)", u"III", u"(III)", u"IV", u"(IV)", u"VI", u"(VI)",
u"VII", u"(VII)", u"2nd", u"(2nd)", u"3rd", u"(3rd)", u"4th", u"(4th)",
u"II", u"(II)", u"III", u"(III)", u"IV", u"(IV)", u"VI", u"(VI)",
u"VII", u"(VII)", u"2nd", u"(2nd)", u"3rd", u"(3rd)", u"4th", u"(4th)",
u"5th", u"(5th)"
]
@@ -122,133 +123,133 @@ def proper_name(name):
# http://www.johncardinal.com/tmgutil/index.htm
# John Cardinal maintains the copyright for this list of names.
surnames = [
u"ApShaw", u"d'Albini", "d'Aubigney", u"d'Aubigné", u"d'Autry",
u"ApShaw", u"d'Albini", "d'Aubigney", u"d'Aubigné", u"d'Autry",
u"d'Entremont", u"d'Hurst", u"D'ovidio", u"da Graça", u"DaSilva",
u"DeAnda", u"deAnnethe", u"deAubigne", u"deAubigny", u"DeBardelaben",
u"DeBardeleben", u"DeBaugh", u"deBeauford", u"DeBerry", u"deBethune",
u"DeBetuile", u"DeBoard", u"DeBoer", u"DeBohun", u"DeBord", u"DeBose",
u"DeBrouwer", u"DeBroux", u"DeBruhl", u"deBruijn", u"deBrus", u"deBruse",
u"DeBrouwer", u"DeBroux", u"DeBruhl", u"deBruijn", u"deBrus", u"deBruse",
u"deBrusse", u"DeBruyne", u"DeBusk", u"DeCamp", u"deCastilla", u"DeCello",
u"deClare", u"DeClark", u"DeClerck", u"DeCoste", u"deCote", u"DeCoudres",
u"DeCoursey", u"DeCredico", u"deCuire", u"DeCuyre", u"DeDominicios",
u"DeDuyster", u"DeDuytscher", u"DeDuytser", u"deFiennes", u"DeFord",
u"DeForest", u"DeFrance", u"DeFriece", u"DeGarmo", u"deGraaff", u"DeGraff",
u"DeGraffenreid", u"DeGraw", u"DeGrenier", u"DeGroats", u"DeGroft",
u"DeGrote", u"DeHaan", u"DeHaas", u"DeHaddeclive", u"deHannethe",
u"DeHatclyf", u"DeHaven", u"DeHeer", u"DeJager", u"DeJarnette", u"DeJean",
u"DeJong", u"deJonge", u"deKemmeter", u"deKirketon", u"DeKroon",
u"deKype", u"del-Rosario", u"dela Chamotte", u"DeLa Cuadra",
u"DeLa Force", u"dela Fountaine", u"dela Greña", u"dela Place",
u"DeLa Ward", u"DeLaci", u"DeLacy", u"DeLaet", u"DeLalonde", u"DelAmarre",
u"DeLancey", u"DeLascy", u"DelAshmutt", u"DeLassy", u"DeLattre",
u"DeLaughter", u"DeLay", u"deLessine", u"DelGado", u"DelGaudio",
u"DeLiberti", u"DeLoache", u"DeLoatch", u"DeLoch", u"DeLockwood",
u"DeLong", u"DeLozier", u"DeLuca", u"DeLucenay", u"deLucy", u"DeMars",
u"DeMartino", u"deMaule", u"DeMello", u"DeMinck", u"DeMink", u"DeMoree",
u"DeMoss", u"DeMott", u"DeMuynck", u"deNiet", u"DeNise", u"DeNure",
u"DePalma", u"DePasquale", u"dePender", u"dePercy", u"DePoe", u"DePriest",
u"DePu", u"DePui", u"DePuis", u"DeReeper", u"deRochette", u"deRose",
u"DeRossett", u"DeRover", u"deRuggele", u"deRuggle", u"DeRuyter",
u"deSaint-Sauveur", u"DeSantis", u"desCuirs", u"DeSentis", u"DeShane",
u"DeSilva", u"DesJardins", u"DesMarest", u"deSoleure", u"DeSoto",
u"DeSpain", u"DeStefano", u"deSwaert", u"deSwart", u"DeVall", u"DeVane",
u"DeVasher", u"DeVasier", u"DeVaughan", u"DeVaughn", u"DeVault", u"DeVeau",
u"DeVeault", u"deVilleneuve", u"DeVilliers", u"DeVinney", u"DeVito",
u"deVogel", u"DeVolder", u"DeVolld", u"DeVore", u"deVos", u"DeVries",
u"deVries", u"DeWall", u"DeWaller", u"DeWalt", u"deWashington",
u"deWerly", u"deWessyngton", u"DeWet", u"deWinter", u"DeWitt", u"DeWolf",
u"DeWolfe", u"DeWolff", u"DeWoody", u"DeYager", u"DeYarmett", u"DeYoung",
u"DiCicco", u"DiCredico", u"DiFillippi", u"DiGiacomo", u"DiMarco",
u"DiMeo", u"DiMonte", u"DiNonno", u"DiPietro", u"diPilato", u"DiPrima",
u"DiSalvo", u"du Bosc", u"du Hurst", u"DuFort", u"DuMars", u"DuPre",
u"DuPue", u"DuPuy", u"FitzUryan", u"kummel", u"LaBarge", u"LaBarr",
u"LaBauve", u"LaBean", u"LaBelle", u"LaBerteaux", u"LaBine", u"LaBonte",
u"LaBorde", u"LaBounty", u"LaBranche", u"LaBrash", u"LaCaille", u"LaCasse",
u"LaChapelle", u"LaClair", u"LaComb", u"LaCoste", u"LaCount", u"LaCour",
u"LaCroix", u"LaFarlett", u"LaFarlette", u"LaFerry", u"LaFlamme",
u"LaFollette", u"LaForge", u"LaFortune", u"LaFoy", u"LaFramboise",
u"LaFrance", u"LaFuze", u"LaGioia", u"LaGrone", u"LaLiberte", u"LaLonde",
u"LaLone", u"LaMaster", u"LaMay", u"LaMere", u"LaMont", u"LaMotte",
u"LaPeer", u"LaPierre", u"LaPlante", u"LaPoint", u"LaPointe", u"LaPorte",
u"LaPrade", u"LaRocca", u"LaRochelle", u"LaRose", u"LaRue", u"LaVallee",
u"LaVaque", u"LaVeau", u"LeBleu", u"LeBoeuf", u"LeBoiteaux", u"LeBoyteulx",
u"LeCheminant", u"LeClair", u"LeClerc", u"LeCompte", u"LeCroy", u"LeDuc",
u"LeFevbre", u"LeFever", u"LeFevre", u"LeFlore", u"LeGette", u"LeGrand",
u"LeGrave", u"LeGro", u"LeGros", u"LeJeune", u"LeMaistre", u"LeMaitre",
u"LeMaster", u"LeMesurier", u"LeMieux", u"LeMoe", u"LeMoigne", u"LeMoine",
u"LeNeve", u"LePage", u"LeQuire", u"LeQuyer", u"LeRou", u"LeRoy", u"LeSuer",
u"LeSueur", u"LeTardif", u"LeVally", u"LeVert", u"LoMonaco", u"Macabe",
u"Macaluso", u"MacaTasney", u"Macaulay", u"Macchitelli", u"Maccoone",
u"Maccurry", u"Macdermattroe", u"Macdiarmada", u"Macelvaine", u"Macey",
u"Macgraugh", u"Machan", u"Machann", u"Machum", u"Maciejewski", u"Maciel",
u"Mackaben", u"Mackall", u"Mackartee", u"Mackay", u"Macken", u"Mackert",
u"Mackey", u"Mackie", u"Mackin", u"Mackins", u"Macklin", u"Macko",
u"Macksey", u"Mackwilliams", u"Maclean", u"Maclinden", u"Macomb",
u"Macomber", u"Macon", u"Macoombs", u"Macraw", u"Macumber", u"Macurdy",
u"Macwilliams", u"MaGuinness", u"MakCubyn", u"MakCumby", u"Mcelvany",
u"Mcsherry", u"Op den Dyck", u"Op den Graeff", u"regory", u"Schweißguth",
u"StElmo", u"StGelais", u"StJacques", u"te Boveldt", u"VanAernam",
u"VanAken", u"VanAlstine", u"VanAmersfoort", u"VanAntwerp", u"VanArlem",
u"VanArnam", u"VanArnem", u"VanArnhem", u"VanArnon", u"VanArsdale",
u"VanArsdalen", u"VanArsdol", u"vanAssema", u"vanAsten", u"VanAuken",
u"VanAwman", u"VanBaucom", u"VanBebber", u"VanBeber", u"VanBenschoten",
u"VanBibber", u"VanBilliard", u"vanBlare", u"vanBlaricom", u"VanBuren",
u"VanBuskirk", u"VanCamp", u"VanCampen", u"VanCleave", u"VanCleef",
u"VanCleve", u"VanCouwenhoven", u"VanCovenhoven", u"VanCowenhoven",
u"VanCuren", u"VanDalsem", u"VanDam", u"VanDe Poel", u"vanden Dijkgraaf",
u"vanden Kommer", u"VanDer Aar", u"vander Gouwe", u"VanDer Honing",
u"VanDer Hooning", u"vander Horst", u"vander Kroft", u"vander Krogt",
u"VanDer Meer", u"vander Meulen", u"vander Putte", u"vander Schooren",
u"VanDer Veen", u"VanDer Ven", u"VanDer Wal", u"VanDer Weide",
u"VanDer Willigen", u"vander Wulp", u"vander Zanden", u"vander Zwan",
u"VanDer Zweep", u"VanDeren", u"VanDerlaan", u"VanDerveer",
u"VanderWoude", u"VanDeursen", u"VanDeusen", u"vanDijk", u"VanDoren",
u"VanDorn", u"VanDort", u"VanDruff", u"VanDryer", u"VanDusen", u"VanDuzee",
u"VanDuzen", u"VanDuzer", u"VanDyck", u"VanDyke", u"VanEman", u"VanEmmen",
u"vanEmmerik", u"VanEngen", u"vanErp", u"vanEssen", u"VanFleet",
u"VanGalder", u"VanGelder", u"vanGerrevink", u"VanGog", u"vanGogh",
u"VanGorder", u"VanGordon", u"VanGroningen", u"VanGuilder", u"VanGundy",
u"VanHaaften", u"VanHaute", u"VanHees", u"vanHeugten", u"VanHise",
u"VanHoeck", u"VanHoek", u"VanHook", u"vanHoorn", u"VanHoornbeeck",
u"VanHoose", u"VanHooser", u"VanHorn", u"VanHorne", u"VanHouten",
u"VanHoye", u"VanHuijstee", u"VanHuss", u"VanImmon", u"VanKersschaever",
u"VanKeuren", u"VanKleeck", u"VanKoughnet", u"VanKouwenhoven",
u"VanKuykendaal", u"vanLeeuwen", u"vanLent", u"vanLet", u"VanLeuven",
u"vanLingen", u"VanLoozen", u"VanLopik", u"VanLuven", u"vanMaasdijk",
u"VanMele", u"VanMeter", u"vanMoorsel", u"VanMoorst", u"VanMossevelde",
u"VanNaarden", u"VanNamen", u"VanNemon", u"VanNess", u"VanNest",
u"VanNimmen", u"vanNobelen", u"VanNorman", u"VanNormon", u"VanNostrunt",
u"VanNote", u"VanOker", u"vanOosten", u"VanOrden", u"VanOrder",
u"VanOrma", u"VanOrman", u"VanOrnum", u"VanOstrander", u"VanOvermeire",
u"VanPelt", u"VanPool", u"VanPoole", u"VanPoorvliet", u"VanPutten",
u"vanRee", u"VanRhijn", u"vanRijswijk", u"VanRotmer", u"VanSchaick",
u"vanSchelt", u"VanSchoik", u"VanSchoonhoven", u"VanSciver", u"VanScoy",
u"VanScoyoc", u"vanSeters", u"VanSickle", u"VanSky", u"VanSnellenberg",
u"vanStaveren", u"VanStraten", u"VanSuijdam", u"VanTassel", u"VanTassell",
u"VanTessel", u"VanTexel", u"VanTuyl", u"VanValckenburgh", u"vanValen",
u"VanValkenburg", u"VanVelsor", u"VanVelzor", u"VanVlack", u"VanVleck",
u"VanVleckeren", u"VanWaard", u"VanWart", u"VanWassenhove", u"VanWinkle",
u"VanWoggelum", u"vanWordragen", u"VanWormer", u"VanZuidam",
u"VanZuijdam", u"VonAdenbach", u"vonAllmen", u"vonBardeleben",
u"vonBerckefeldt", u"VonBergen", u"vonBreyman", u"VonCannon",
u"vonFreymann", u"vonHeimburg", u"VonHuben", u"vonKramer",
u"vonKruchenburg", u"vonPostel", u"VonRohr", u"VonRohrbach",
u"VonSass", u"VonSasse", u"vonSchlotte", u"VonSchneider", u"VonSeldern",
u"deClare", u"DeClark", u"DeClerck", u"DeCoste", u"deCote", u"DeCoudres",
u"DeCoursey", u"DeCredico", u"deCuire", u"DeCuyre", u"DeDominicios",
u"DeDuyster", u"DeDuytscher", u"DeDuytser", u"deFiennes", u"DeFord",
u"DeForest", u"DeFrance", u"DeFriece", u"DeGarmo", u"deGraaff", u"DeGraff",
u"DeGraffenreid", u"DeGraw", u"DeGrenier", u"DeGroats", u"DeGroft",
u"DeGrote", u"DeHaan", u"DeHaas", u"DeHaddeclive", u"deHannethe",
u"DeHatclyf", u"DeHaven", u"DeHeer", u"DeJager", u"DeJarnette", u"DeJean",
u"DeJong", u"deJonge", u"deKemmeter", u"deKirketon", u"DeKroon",
u"deKype", u"del-Rosario", u"dela Chamotte", u"DeLa Cuadra",
u"DeLa Force", u"dela Fountaine", u"dela Greña", u"dela Place",
u"DeLa Ward", u"DeLaci", u"DeLacy", u"DeLaet", u"DeLalonde", u"DelAmarre",
u"DeLancey", u"DeLascy", u"DelAshmutt", u"DeLassy", u"DeLattre",
u"DeLaughter", u"DeLay", u"deLessine", u"DelGado", u"DelGaudio",
u"DeLiberti", u"DeLoache", u"DeLoatch", u"DeLoch", u"DeLockwood",
u"DeLong", u"DeLozier", u"DeLuca", u"DeLucenay", u"deLucy", u"DeMars",
u"DeMartino", u"deMaule", u"DeMello", u"DeMinck", u"DeMink", u"DeMoree",
u"DeMoss", u"DeMott", u"DeMuynck", u"deNiet", u"DeNise", u"DeNure",
u"DePalma", u"DePasquale", u"dePender", u"dePercy", u"DePoe", u"DePriest",
u"DePu", u"DePui", u"DePuis", u"DeReeper", u"deRochette", u"deRose",
u"DeRossett", u"DeRover", u"deRuggele", u"deRuggle", u"DeRuyter",
u"deSaint-Sauveur", u"DeSantis", u"desCuirs", u"DeSentis", u"DeShane",
u"DeSilva", u"DesJardins", u"DesMarest", u"deSoleure", u"DeSoto",
u"DeSpain", u"DeStefano", u"deSwaert", u"deSwart", u"DeVall", u"DeVane",
u"DeVasher", u"DeVasier", u"DeVaughan", u"DeVaughn", u"DeVault", u"DeVeau",
u"DeVeault", u"deVilleneuve", u"DeVilliers", u"DeVinney", u"DeVito",
u"deVogel", u"DeVolder", u"DeVolld", u"DeVore", u"deVos", u"DeVries",
u"deVries", u"DeWall", u"DeWaller", u"DeWalt", u"deWashington",
u"deWerly", u"deWessyngton", u"DeWet", u"deWinter", u"DeWitt", u"DeWolf",
u"DeWolfe", u"DeWolff", u"DeWoody", u"DeYager", u"DeYarmett", u"DeYoung",
u"DiCicco", u"DiCredico", u"DiFillippi", u"DiGiacomo", u"DiMarco",
u"DiMeo", u"DiMonte", u"DiNonno", u"DiPietro", u"diPilato", u"DiPrima",
u"DiSalvo", u"du Bosc", u"du Hurst", u"DuFort", u"DuMars", u"DuPre",
u"DuPue", u"DuPuy", u"FitzUryan", u"kummel", u"LaBarge", u"LaBarr",
u"LaBauve", u"LaBean", u"LaBelle", u"LaBerteaux", u"LaBine", u"LaBonte",
u"LaBorde", u"LaBounty", u"LaBranche", u"LaBrash", u"LaCaille", u"LaCasse",
u"LaChapelle", u"LaClair", u"LaComb", u"LaCoste", u"LaCount", u"LaCour",
u"LaCroix", u"LaFarlett", u"LaFarlette", u"LaFerry", u"LaFlamme",
u"LaFollette", u"LaForge", u"LaFortune", u"LaFoy", u"LaFramboise",
u"LaFrance", u"LaFuze", u"LaGioia", u"LaGrone", u"LaLiberte", u"LaLonde",
u"LaLone", u"LaMaster", u"LaMay", u"LaMere", u"LaMont", u"LaMotte",
u"LaPeer", u"LaPierre", u"LaPlante", u"LaPoint", u"LaPointe", u"LaPorte",
u"LaPrade", u"LaRocca", u"LaRochelle", u"LaRose", u"LaRue", u"LaVallee",
u"LaVaque", u"LaVeau", u"LeBleu", u"LeBoeuf", u"LeBoiteaux", u"LeBoyteulx",
u"LeCheminant", u"LeClair", u"LeClerc", u"LeCompte", u"LeCroy", u"LeDuc",
u"LeFevbre", u"LeFever", u"LeFevre", u"LeFlore", u"LeGette", u"LeGrand",
u"LeGrave", u"LeGro", u"LeGros", u"LeJeune", u"LeMaistre", u"LeMaitre",
u"LeMaster", u"LeMesurier", u"LeMieux", u"LeMoe", u"LeMoigne", u"LeMoine",
u"LeNeve", u"LePage", u"LeQuire", u"LeQuyer", u"LeRou", u"LeRoy", u"LeSuer",
u"LeSueur", u"LeTardif", u"LeVally", u"LeVert", u"LoMonaco", u"Macabe",
u"Macaluso", u"MacaTasney", u"Macaulay", u"Macchitelli", u"Maccoone",
u"Maccurry", u"Macdermattroe", u"Macdiarmada", u"Macelvaine", u"Macey",
u"Macgraugh", u"Machan", u"Machann", u"Machum", u"Maciejewski", u"Maciel",
u"Mackaben", u"Mackall", u"Mackartee", u"Mackay", u"Macken", u"Mackert",
u"Mackey", u"Mackie", u"Mackin", u"Mackins", u"Macklin", u"Macko",
u"Macksey", u"Mackwilliams", u"Maclean", u"Maclinden", u"Macomb",
u"Macomber", u"Macon", u"Macoombs", u"Macraw", u"Macumber", u"Macurdy",
u"Macwilliams", u"MaGuinness", u"MakCubyn", u"MakCumby", u"Mcelvany",
u"Mcsherry", u"Op den Dyck", u"Op den Graeff", u"regory", u"Schweißguth",
u"StElmo", u"StGelais", u"StJacques", u"te Boveldt", u"VanAernam",
u"VanAken", u"VanAlstine", u"VanAmersfoort", u"VanAntwerp", u"VanArlem",
u"VanArnam", u"VanArnem", u"VanArnhem", u"VanArnon", u"VanArsdale",
u"VanArsdalen", u"VanArsdol", u"vanAssema", u"vanAsten", u"VanAuken",
u"VanAwman", u"VanBaucom", u"VanBebber", u"VanBeber", u"VanBenschoten",
u"VanBibber", u"VanBilliard", u"vanBlare", u"vanBlaricom", u"VanBuren",
u"VanBuskirk", u"VanCamp", u"VanCampen", u"VanCleave", u"VanCleef",
u"VanCleve", u"VanCouwenhoven", u"VanCovenhoven", u"VanCowenhoven",
u"VanCuren", u"VanDalsem", u"VanDam", u"VanDe Poel", u"vanden Dijkgraaf",
u"vanden Kommer", u"VanDer Aar", u"vander Gouwe", u"VanDer Honing",
u"VanDer Hooning", u"vander Horst", u"vander Kroft", u"vander Krogt",
u"VanDer Meer", u"vander Meulen", u"vander Putte", u"vander Schooren",
u"VanDer Veen", u"VanDer Ven", u"VanDer Wal", u"VanDer Weide",
u"VanDer Willigen", u"vander Wulp", u"vander Zanden", u"vander Zwan",
u"VanDer Zweep", u"VanDeren", u"VanDerlaan", u"VanDerveer",
u"VanderWoude", u"VanDeursen", u"VanDeusen", u"vanDijk", u"VanDoren",
u"VanDorn", u"VanDort", u"VanDruff", u"VanDryer", u"VanDusen", u"VanDuzee",
u"VanDuzen", u"VanDuzer", u"VanDyck", u"VanDyke", u"VanEman", u"VanEmmen",
u"vanEmmerik", u"VanEngen", u"vanErp", u"vanEssen", u"VanFleet",
u"VanGalder", u"VanGelder", u"vanGerrevink", u"VanGog", u"vanGogh",
u"VanGorder", u"VanGordon", u"VanGroningen", u"VanGuilder", u"VanGundy",
u"VanHaaften", u"VanHaute", u"VanHees", u"vanHeugten", u"VanHise",
u"VanHoeck", u"VanHoek", u"VanHook", u"vanHoorn", u"VanHoornbeeck",
u"VanHoose", u"VanHooser", u"VanHorn", u"VanHorne", u"VanHouten",
u"VanHoye", u"VanHuijstee", u"VanHuss", u"VanImmon", u"VanKersschaever",
u"VanKeuren", u"VanKleeck", u"VanKoughnet", u"VanKouwenhoven",
u"VanKuykendaal", u"vanLeeuwen", u"vanLent", u"vanLet", u"VanLeuven",
u"vanLingen", u"VanLoozen", u"VanLopik", u"VanLuven", u"vanMaasdijk",
u"VanMele", u"VanMeter", u"vanMoorsel", u"VanMoorst", u"VanMossevelde",
u"VanNaarden", u"VanNamen", u"VanNemon", u"VanNess", u"VanNest",
u"VanNimmen", u"vanNobelen", u"VanNorman", u"VanNormon", u"VanNostrunt",
u"VanNote", u"VanOker", u"vanOosten", u"VanOrden", u"VanOrder",
u"VanOrma", u"VanOrman", u"VanOrnum", u"VanOstrander", u"VanOvermeire",
u"VanPelt", u"VanPool", u"VanPoole", u"VanPoorvliet", u"VanPutten",
u"vanRee", u"VanRhijn", u"vanRijswijk", u"VanRotmer", u"VanSchaick",
u"vanSchelt", u"VanSchoik", u"VanSchoonhoven", u"VanSciver", u"VanScoy",
u"VanScoyoc", u"vanSeters", u"VanSickle", u"VanSky", u"VanSnellenberg",
u"vanStaveren", u"VanStraten", u"VanSuijdam", u"VanTassel", u"VanTassell",
u"VanTessel", u"VanTexel", u"VanTuyl", u"VanValckenburgh", u"vanValen",
u"VanValkenburg", u"VanVelsor", u"VanVelzor", u"VanVlack", u"VanVleck",
u"VanVleckeren", u"VanWaard", u"VanWart", u"VanWassenhove", u"VanWinkle",
u"VanWoggelum", u"vanWordragen", u"VanWormer", u"VanZuidam",
u"VanZuijdam", u"VonAdenbach", u"vonAllmen", u"vonBardeleben",
u"vonBerckefeldt", u"VonBergen", u"vonBreyman", u"VonCannon",
u"vonFreymann", u"vonHeimburg", u"VonHuben", u"vonKramer",
u"vonKruchenburg", u"vonPostel", u"VonRohr", u"VonRohrbach",
u"VonSass", u"VonSasse", u"vonSchlotte", u"VonSchneider", u"VonSeldern",
u"VonSpringer", u"VonVeyelmann", u"VonZweidorff"
]
hyphen_indexes = []
while name.find('-') > -1:
index = name.find('-')
while name.find(u'-') > -1:
index = name.find(u'-')
hyphen_indexes.append(index)
name = name[:index] + ' ' + name[index+1:]
name = name[:index] + u' ' + name[index + 1:]
name = name.split()
name = [w.capitalize() for w in name] # standard capitalization
name = [w.capitalize() for w in name] # standard capitalization
# "Mcx" should be "McX"
index = 0
for w in name:
try:
name[index] = mc.sub("Mc"+w[2].upper(), w)
name[index] = mc.sub(u'Mc' + w[2].upper(), w)
except:
pass
index += 1
@@ -256,21 +257,21 @@ def proper_name(name):
index = 0
for w in name:
try:
name[index] = mac.sub("Mac"+w[3].upper(), w)
name[index] = mac.sub(u'Mac' + w[3].upper(), w)
except:
pass
index += 1
name = ' '.join( name )
name = u' '.join(name)
for index in hyphen_indexes:
name = name[:index] + '-' + name[index+1:]
name = name[:index] + u'-' + name[index + 1:]
# funky stuff (no capitalization)
name = name.replace(" Dit ", " dit ")
name = name.replace(" Van ", " van ")
name = name.replace(" De ", " de ")
name = name.replace(' Dit ', ' dit ')
name = name.replace(' Van ', ' van ')
name = name.replace(' De ', ' de ')
# special surnames and suffixes
name += ' '
name += u' '
for surname in surnames + suffixes:
pos = name.lower().find(surname.lower())
if pos > -1:
@@ -278,11 +279,11 @@ def proper_name(name):
# 1. at start of name or after a space
# -and-
# 2. followed by the end of string or a space
if (((pos == 0) or (pos > 0 and name[pos-1] == ' '))
and ((len(name) == pos+len(surname))
or (name[pos+len(surname)] == ' '))):
name = name[:pos] + surname + name[pos+len(surname):]
if (((pos == 0) or (pos > 0 and name[pos - 1] == u' '))
and ((len(name) == pos + len(surname))
or (name[pos + len(surname)] == u' '))):
name = name[:pos] + surname + name[pos + len(surname):]
return name.strip()
mc = re.compile(r"^Mc(\w)(?=\w)", re.I)
mac = re.compile(r"^Mac(\w)(?=\w)", re.I)
mc = re.compile(r'^Mc(\w)(?=\w)', re.I)
mac = re.compile(r'^Mac(\w)(?=\w)', re.I)

View File

@@ -6,7 +6,7 @@ from django.http import HttpResponseRedirect
def password_change_done(request):
'''View called when the new user password has been accepted'''
messages.success(request, _(u'Your password has been successfully changed.'))
return redirect('home')
@@ -14,10 +14,10 @@ def password_change_done(request):
def multi_object_action_view(request):
'''Proxy view called first when usuing a multi object action, which
then redirects to the appropiate specialized view'''
action = request.GET.get('action', None)
id_list = u','.join([key[3:] for key in request.GET.keys() if key.startswith('pk_')])
if not action:
messages.error(request, _(u'No action selected.'))
return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
@@ -25,5 +25,5 @@ def multi_object_action_view(request):
if not id_list:
messages.error(request, _(u'Must select at least one item.'))
return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
return HttpResponseRedirect('%s?id_list=%s' % (action, id_list))

View File

@@ -13,6 +13,7 @@ from django.utils.hashcompat import md5_constructor
__all__ = ('security_hash', 'BoundFormWizard')
def security_hash(request, form, exclude=None, *args):
"""Calculates a security hash for the given Form/FormSet instance.
@@ -48,6 +49,7 @@ def security_hash(request, form, exclude=None, *args):
return md5_constructor(pickled).hexdigest()
class BoundFormWizard(FormWizard):
"""Render prev_fields as a list of bound form fields in the template
context rather than raw html."""
@@ -78,5 +80,3 @@ class BoundFormWizard(FormWizard):
bf = BoundField(forms.Form(), hash_field, hash_name)
prev_fields.append(bf)
return self.render_template(request, form, prev_fields, step, context)
# vim: ai ts=4 sts=4 et sw=4

View File

@@ -1,3 +1,3 @@
TRANFORMATION_CHOICES = {
'rotate':'-rotate %(degrees)d'
'rotate': '-rotate %(degrees)d'
}

View File

@@ -77,6 +77,10 @@ class Document(models.Model):
self.update_page_count(save=False)
self.apply_default_transformations()
@models.permalink
def get_absolute_url(self):
return ('document_view_simple', [self.id])
def get_fullname(self):
return os.extsep.join([self.file_filename, self.file_extension])
@@ -102,10 +106,6 @@ class Document(models.Model):
def open(self):
return self.file.storage.open(self.file.path)
@models.permalink
def get_absolute_url(self):
return ('document_view_simple', [self.id])
def update_checksum(self, save=True):
if self.exists():
source = self.open()