Code cleanups

This commit is contained in:
Roberto Rosario
2014-06-29 20:35:36 -04:00
parent 1d821a488f
commit 41d0cfb7bf
15 changed files with 31 additions and 64 deletions

View File

@@ -82,5 +82,5 @@ def auto_admin_account_passwd_change(sender, instance, **kwargs):
pass
if (validate_path(TEMPORARY_DIRECTORY) == False) or (not TEMPORARY_DIRECTORY):
if (not validate_path(TEMPORARY_DIRECTORY)) or (not TEMPORARY_DIRECTORY):
setattr(common_settings, 'TEMPORARY_DIRECTORY', tempfile.mkdtemp())

View File

@@ -55,10 +55,11 @@ Requires PyYaml (http://pyyaml.org/), of course.
from StringIO import StringIO
import yaml
from django.core.serializers.pyyaml import Serializer as YamlSerializer
from django.core.serializers.python import Deserializer as PythonDeserializer
from django.core.serializers.pyyaml import Serializer as YamlSerializer
from django.utils.encoding import smart_unicode
class Serializer (YamlSerializer):
"""
Serialize database objects as nested dicts, indexed first by

View File

@@ -13,7 +13,6 @@ class SetVarNode(template.Node):
value = template.Variable(self.var_value).resolve(context)
except template.VariableDoesNotExist:
value = ""
#context[self.var_name] = value
# Make it global across all blocks
context.dicts[0][self.var_name] = value

View File

@@ -44,7 +44,7 @@ def urlquote(link=None, get=None):
get = link
link = ''
assert isinstance(get, dict), u'wrong type "%s", dict required' % type(get)
#assert not (link.startswith('http://') or link.startswith('https://')), \
# assert not (link.startswith('http://') or link.startswith('https://')), \
# 'This method should only quote the url path.
# It should not start with http(s):// (%s)' % (
# link)
@@ -81,8 +81,8 @@ def return_attrib(obj, attrib, arguments=None):
pass
#http://snippets.dzone.com/posts/show/5434
#http://snippets.dzone.com/user/jakob
# http://snippets.dzone.com/posts/show/5434
# http://snippets.dzone.com/user/jakob
def pretty_size(size, suffixes=None):
suffixes = suffixes if not suffixes is None else [
(u'B', 1024L), (u'K', 1048576L), (u'M', 1073741824L),
@@ -326,7 +326,7 @@ def generate_choices_w_labels(choices, display_object_type=True):
else:
results.append((u'%s,%s' % (ct.model, choice.pk), u'%s' % (label)))
#Sort results by the label not the key value
# Sort results by the label not the key value
return sorted(results, key=lambda x: x[1])

View File

@@ -130,7 +130,7 @@ def assign_remove(request, left_list, right_list, add_method, remove_method, lef
context = {
'subtemplates_list': [
{
'name':'generic_form_subtemplate.html',
'name': 'generic_form_subtemplate.html',
'grid': 6,
'context': {
'form': unselected_list,
@@ -140,7 +140,7 @@ def assign_remove(request, left_list, right_list, add_method, remove_method, lef
}
},
{
'name':'generic_form_subtemplate.html',
'name': 'generic_form_subtemplate.html',
'grid': 6,
'grid_clear': True,
'context': {
@@ -238,7 +238,7 @@ def password_change_view(request):
"""
Password change wrapper for better control
"""
context={'title': _(u'Current user password change')}
context = {'title': _(u'Current user password change')}
return password_change(
request,

View File

@@ -1,12 +1,12 @@
import os
from itertools import chain
import os
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 conditional_escape
from django.utils.encoding import force_unicode
from django.utils.html import conditional_escape
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
class PlainWidget(forms.widgets.Widget):
@@ -32,15 +32,15 @@ class DetailSelectMultiple(forms.widgets.SelectMultiple):
options = None
if value:
if getattr(value, '__iter__', None):
options = [(index, string) for index, string in \
options = [(index, string) for index, string in
self.choices if index in value]
else:
options = [(index, string) for index, string in \
options = [(index, string) for index, string in
self.choices if index == value]
else:
if self.choices:
if self.choices[0] != (u'', u'---------') and value != []:
options = [(index, string) for index, string in \
options = [(index, string) for index, string in
self.choices]
if options: