Skip to content
Browse files

pep8 fix

  • Loading branch information...
1 parent 0a8349d commit b287a582310d3484167b9ca8d00e0d83926d87f9 Stefano Parmesan committed
View
6 bandbook/__init__.py
@@ -3,8 +3,8 @@
def dummy_for_makemessages():
"""
- This function allows manage makemessages to find the forecast types for translation.
- Removing this code causes makemessages to comment out those PO entries, so don't do that
- unless you find a better way to do this
+ This function allows manage makemessages to find the forecast types
+ for translation. Removing this code causes makemessages to comment out
+ those PO entries, so don't do that unless you find a better way to do this
"""
_('Owned')
View
2 bandbook/conf/settings/__init__.py
@@ -1 +1 @@
-# empty file
+# empty file
View
15 bandbook/conf/settings/default.py
@@ -15,12 +15,12 @@
DATABASES = {
'default': {
- 'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
- 'NAME': 'bandbook', # Or path to database file if using sqlite3.
- 'USER': 'bandbook', # Not used with sqlite3.
- 'PASSWORD': 'b@ndb00k', # Not used with sqlite3.
- 'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3.
- 'PORT': '5432', # Set to empty string for default. Not used with sqlite3.
+ 'ENGINE': 'django.db.backends.postgresql_psycopg2',
+ 'NAME': 'bandbook',
+ 'USER': 'bandbook',
+ 'PASSWORD': 'b@ndb00k',
+ 'HOST': '127.0.0.1',
+ 'PORT': '5432',
}
}
@@ -124,7 +124,8 @@
ROOT_URLCONF = 'bandbook.urls'
TEMPLATE_DIRS = (
- # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
+ # Put strings here, like "/home/html/django_templates" or
+ # "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
View
12 bandbook/conf/settings/travis.py
@@ -2,11 +2,11 @@
DATABASES = {
'default': {
- 'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
- 'NAME': 'bandbook', # Or path to database file if using sqlite3.
- 'USER': 'postgres', # Not used with sqlite3.
- 'PASSWORD': '', # Not used with sqlite3.
- 'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3.
- 'PORT': '5432', # Set to empty string for default. Not used with sqlite3.
+ 'ENGINE': 'django.db.backends.postgresql_psycopg2',
+ 'NAME': 'bandbook',
+ 'USER': 'postgres',
+ 'PASSWORD': '',
+ 'HOST': '127.0.0.1',
+ 'PORT': '5432',
}
}
View
6 bandbook/instruments/admin.py
@@ -1,7 +1,8 @@
import reversion
from django.contrib import admin
-from bandbook.instruments.models import InstrumentCategory, Instrument, InstrumentType, InstrumentManufacturer, InstrumentModel, InstrumentHistory
+from bandbook.instruments.models import InstrumentCategory, Instrument, \
+ InstrumentType, InstrumentManufacturer, InstrumentModel, InstrumentHistory
class InstrumentCategoryAdmin(reversion.VersionAdmin):
@@ -32,7 +33,8 @@ class InstrumentAdmin(reversion.VersionAdmin):
class InstrumentHistoryAdmin(reversion.VersionAdmin):
- list_display = ['instrument', 'get_event', 'date_start', 'date_end', 'target']
+ list_display = ['instrument', 'get_event', 'date_start',
+ 'date_end', 'target']
admin.site.register(InstrumentCategory, InstrumentCategoryAdmin)
View
7 bandbook/instruments/forms.py
@@ -5,7 +5,8 @@
from django.forms.widgets import HiddenInput, Textarea
from django.forms import ModelChoiceField, ChoiceField
from bandbook.instruments.helpers import get_default_ordering
-from bandbook.instruments.models import Instrument, InstrumentHistory, InstrumentCategory, InstrumentType
+from bandbook.instruments.models import Instrument, InstrumentHistory, \
+ InstrumentCategory, InstrumentType
from bandbook.instruments.handlers.instrument_history import site
from bandbook.main.widgets import BootstrapDatepicker
from bandbook.players.models import Player
@@ -57,8 +58,8 @@ class Meta:
'instrument': HiddenInput(),
'content_type': HiddenInput(),
'object_id': HiddenInput(),
- 'condition': Textarea(attrs={'rows':2, 'class': 'span4'}),
- 'notes': Textarea(attrs={'rows':2, 'class': 'span4'}),
+ 'condition': Textarea(attrs={'rows': 2, 'class': 'span4'}),
+ 'notes': Textarea(attrs={'rows': 2, 'class': 'span4'}),
}
def __init__(self, *args, **kwargs):
View
18 bandbook/instruments/models.py
@@ -19,6 +19,7 @@ class InstrumentCategory(TimeStampedModel):
unique=True, editable=False)
search_by = ('name', 'instrumenttype__name')
+
class Meta:
ordering = ['ordering']
verbose_name_plural = "Instrument categories"
@@ -29,13 +30,15 @@ def __unicode__(self):
class InstrumentType(TimeStampedModel):
name = models.CharField(max_length=64, verbose_name=_("Name"))
- category = models.ForeignKey(InstrumentCategory, verbose_name=_("Category"))
+ category = models.ForeignKey(InstrumentCategory,
+ verbose_name=_("Category"))
ordering = models.IntegerField(editable=False,
default=-1, verbose_name=_("Ordering"))
slug = AutoSlugField('slug', populate_from='name',
unique=True, editable=False)
parent_model = ('category', InstrumentCategory)
+
class Meta:
ordering = ['ordering']
@@ -48,8 +51,10 @@ class InstrumentManufacturer(TimeStampedModel):
slug = AutoSlugField('slug', populate_from='name',
unique=True, editable=False)
- search_by = ('name', 'instrumentmodel__name', 'instrumentmodel__type__name',
+ search_by = ('name', 'instrumentmodel__name',
+ 'instrumentmodel__type__name',
'instrumentmodel__type__category__name')
+
class Meta:
ordering = ['name']
@@ -66,6 +71,7 @@ class InstrumentModel(TimeStampedModel):
unique=True, editable=False)
parent_model = ('manufacturer', InstrumentManufacturer)
+
class Meta:
ordering = ['type__ordering']
@@ -82,6 +88,7 @@ class Instrument(TimeStampedModel):
search_by = ('code', 'model__name', 'model__manufacturer__name',
'model__type__name', 'model__type__category__name', )
+
class Meta:
ordering = ['model__type__ordering']
@@ -97,7 +104,8 @@ def get_status(self):
def get_condition(self):
try:
return self.instrumenthistory_set.filter(~Q(condition=None) &
- ~Q(condition=''))[0].condition
+ ~Q(condition=''))[0]\
+ .condition
except IndexError:
return _('---')
@@ -111,7 +119,8 @@ class InstrumentHistory(TimeStampedModel):
date_start = models.DateField(verbose_name=_("From"))
date_end = models.DateField(blank=True, null=True, verbose_name=_("To"))
event_id = models.IntegerField(verbose_name=_("Event"))
- condition = models.TextField(blank=True, default='', verbose_name=_("Condition"))
+ condition = models.TextField(blank=True, default='',
+ verbose_name=_("Condition"))
notes = models.TextField(blank=True, default='', verbose_name=_("Notes"))
content_type = models.ForeignKey(ContentType, blank=True, null=True)
object_id = models.PositiveIntegerField(blank=True, null=True)
@@ -119,6 +128,7 @@ class InstrumentHistory(TimeStampedModel):
target = GenericForeignKey('content_type', 'object_id')
parent_model = ('instrument', Instrument)
+
class Meta:
ordering = ['-date_start']
View
157 bandbook/instruments/tests.py
@@ -54,22 +54,33 @@ def _test_ordering(self, url, model):
def _test_ordering_with_parent(self, url, model, parent_field):
orig_list = self._group(model.objects.all(), attrgetter(parent_field))
- ordering_keys = dict((k, dict([(y.pk, i) for i, y in enumerate(orig_list[k])])) for k in orig_list)
+ ordering_keys = dict(
+ (k, dict([(y.pk, i) for i, y in enumerate(orig_list[k])]))
+ for k in orig_list)
orig_positions = dict((k, range(len(orig_list[k]))) for k in orig_list)
- orig_ordering = dict((k, [x.ordering for x in orig_list[k]]) for k in orig_list)
+ orig_ordering = dict(
+ (k, [x.ordering for x in orig_list[k]])
+ for k in orig_list)
response = self.client.post(url)
self.assertEqual(response.status_code, 200)
new_list = self._group(model.objects.all(), attrgetter(parent_field))
- new_ordering_keys = dict((k, dict([(y.pk, i) for i, y in enumerate(new_list[k])])) for k in new_list)
- new_positions = dict((k, [new_ordering_keys[k][x.pk] for x in orig_list[k]]) for k in orig_list)
- resorted_list = dict((k, sorted(new_list[k], key=lambda x: ordering_keys[k][x.pk])) for k in new_list)
- new_ordering = dict((k, [x.ordering for x in resorted_list[k]]) for k in resorted_list)
+ new_ordering_keys = dict(
+ (k, dict([(y.pk, i) for i, y in enumerate(new_list[k])]))
+ for k in new_list)
+ new_positions = dict(
+ (k, [new_ordering_keys[k][x.pk] for x in orig_list[k]])
+ for k in orig_list)
+ resorted_list = dict(
+ (k, sorted(new_list[k], key=lambda x: ordering_keys[k][x.pk]))
+ for k in new_list)
+ new_ordering = dict(
+ (k, [x.ordering for x in resorted_list[k]])
+ for k in resorted_list)
return orig_positions, orig_ordering, new_positions, new_ordering
-
def test_category_ordering_down(self):
categories = [x for x in InstrumentCategory.objects.all()]
obja = categories[0]
@@ -84,7 +95,6 @@ def test_category_ordering_down(self):
self.assertEqual(orig_ordering, [1, 2, 3])
self.assertEqual(new_ordering, [2, 1, 3])
-
def test_category_ordering_down_last(self):
categories = [x for x in InstrumentCategory.objects.all()]
obja = categories[0] # move cat[0] to the end
@@ -114,7 +124,8 @@ def test_category_ordering_up(self):
def test_type_ordering_down(self):
categories = [x for x in InstrumentCategory.objects.all()]
- types = self._group(InstrumentType.objects.all(), lambda x: x.category_id)
+ types = self._group(InstrumentType.objects.all(),
+ lambda x: x.category_id)
obja = types[categories[0].pk][1]
objb = types[categories[0].pk][6]
@@ -125,23 +136,36 @@ def test_type_ordering_down(self):
self._test_ordering_with_parent(url, InstrumentType,
parent_field='category_id')
- self.assertEqual(orig_positions[categories[0].pk], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
- self.assertEqual(new_positions[categories[0].pk], [0, 5, 1, 2, 3, 4, 6, 7, 8, 9, 10])
- self.assertEqual(orig_positions[categories[1].pk], [0, 1, 2, 3, 4, 5])
- self.assertEqual(new_positions[categories[1].pk], orig_positions[categories[1].pk])
- self.assertEqual(orig_positions[categories[2].pk], [0, 1, 2, 3])
- self.assertEqual(new_positions[categories[2].pk], orig_positions[categories[2].pk])
-
- self.assertEqual(orig_ordering[categories[0].pk], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110])
- self.assertEqual(new_ordering[categories[0].pk], [10, 69, 29, 39, 49, 59, 70, 80, 90, 100, 110])
- self.assertEqual(orig_ordering[categories[1].pk], [10, 20, 30, 40, 50, 60])
- self.assertEqual(new_ordering[categories[1].pk], orig_ordering[categories[1].pk])
- self.assertEqual(orig_ordering[categories[2].pk], [10, 20, 30, 40])
- self.assertEqual(new_ordering[categories[2].pk], orig_ordering[categories[2].pk])
+ self.assertEqual(orig_positions[categories[0].pk],
+ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
+ self.assertEqual(new_positions[categories[0].pk],
+ [0, 5, 1, 2, 3, 4, 6, 7, 8, 9, 10])
+ self.assertEqual(orig_positions[categories[1].pk],
+ [0, 1, 2, 3, 4, 5])
+ self.assertEqual(new_positions[categories[1].pk],
+ orig_positions[categories[1].pk])
+ self.assertEqual(orig_positions[categories[2].pk],
+ [0, 1, 2, 3])
+ self.assertEqual(new_positions[categories[2].pk],
+ orig_positions[categories[2].pk])
+
+ self.assertEqual(orig_ordering[categories[0].pk],
+ [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110])
+ self.assertEqual(new_ordering[categories[0].pk],
+ [10, 69, 29, 39, 49, 59, 70, 80, 90, 100, 110])
+ self.assertEqual(orig_ordering[categories[1].pk],
+ [10, 20, 30, 40, 50, 60])
+ self.assertEqual(new_ordering[categories[1].pk],
+ orig_ordering[categories[1].pk])
+ self.assertEqual(orig_ordering[categories[2].pk],
+ [10, 20, 30, 40])
+ self.assertEqual(new_ordering[categories[2].pk],
+ orig_ordering[categories[2].pk])
def test_type_ordering_up(self):
categories = [x for x in InstrumentCategory.objects.all()]
- types = self._group(InstrumentType.objects.all(), lambda x: x.category_id)
+ types = self._group(InstrumentType.objects.all(),
+ lambda x: x.category_id)
obja = types[categories[0].pk][8]
objb = types[categories[0].pk][3]
@@ -152,23 +176,36 @@ def test_type_ordering_up(self):
self._test_ordering_with_parent(url, InstrumentType,
parent_field='category_id')
- self.assertEqual(orig_positions[categories[0].pk], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
- self.assertEqual(new_positions[categories[0].pk], [0, 1, 2, 4, 5, 6, 7, 8, 3, 9, 10])
- self.assertEqual(orig_positions[categories[1].pk], [0, 1, 2, 3, 4, 5])
- self.assertEqual(new_positions[categories[1].pk], orig_positions[categories[1].pk])
- self.assertEqual(orig_positions[categories[2].pk], [0, 1, 2, 3])
- self.assertEqual(new_positions[categories[2].pk], orig_positions[categories[2].pk])
-
- self.assertEqual(orig_ordering[categories[0].pk], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110])
- self.assertEqual(new_ordering[categories[0].pk], [10, 20, 30, 41, 51, 61, 71, 81, 40, 100, 110])
- self.assertEqual(orig_ordering[categories[1].pk], [10, 20, 30, 40, 50, 60])
- self.assertEqual(new_ordering[categories[1].pk], orig_ordering[categories[1].pk])
- self.assertEqual(orig_ordering[categories[2].pk], [10, 20, 30, 40])
- self.assertEqual(new_ordering[categories[2].pk], orig_ordering[categories[2].pk])
+ self.assertEqual(orig_positions[categories[0].pk],
+ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
+ self.assertEqual(new_positions[categories[0].pk],
+ [0, 1, 2, 4, 5, 6, 7, 8, 3, 9, 10])
+ self.assertEqual(orig_positions[categories[1].pk],
+ [0, 1, 2, 3, 4, 5])
+ self.assertEqual(new_positions[categories[1].pk],
+ orig_positions[categories[1].pk])
+ self.assertEqual(orig_positions[categories[2].pk],
+ [0, 1, 2, 3])
+ self.assertEqual(new_positions[categories[2].pk],
+ orig_positions[categories[2].pk])
+
+ self.assertEqual(orig_ordering[categories[0].pk],
+ [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110])
+ self.assertEqual(new_ordering[categories[0].pk],
+ [10, 20, 30, 41, 51, 61, 71, 81, 40, 100, 110])
+ self.assertEqual(orig_ordering[categories[1].pk],
+ [10, 20, 30, 40, 50, 60])
+ self.assertEqual(new_ordering[categories[1].pk],
+ orig_ordering[categories[1].pk])
+ self.assertEqual(orig_ordering[categories[2].pk],
+ [10, 20, 30, 40])
+ self.assertEqual(new_ordering[categories[2].pk],
+ orig_ordering[categories[2].pk])
def test_type_ordering_down_last(self):
categories = [x for x in InstrumentCategory.objects.all()]
- types = self._group(InstrumentType.objects.all(), lambda x: x.category_id)
+ types = self._group(InstrumentType.objects.all(),
+ lambda x: x.category_id)
obja = types[categories[0].pk][4]
@@ -178,30 +215,42 @@ def test_type_ordering_down_last(self):
self._test_ordering_with_parent(url, InstrumentType,
parent_field='category_id')
- self.assertEqual(orig_positions[categories[0].pk], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
- self.assertEqual(new_positions[categories[0].pk], [0, 1, 2, 3, 10, 4, 5, 6, 7, 8, 9])
- self.assertEqual(orig_positions[categories[1].pk], [0, 1, 2, 3, 4, 5])
- self.assertEqual(new_positions[categories[1].pk], orig_positions[categories[1].pk])
- self.assertEqual(orig_positions[categories[2].pk], [0, 1, 2, 3])
- self.assertEqual(new_positions[categories[2].pk], orig_positions[categories[2].pk])
-
- self.assertEqual(orig_ordering[categories[0].pk], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110])
- self.assertEqual(new_ordering[categories[0].pk], [10, 20, 30, 40, 110, 59, 69, 79, 89, 99, 109])
- self.assertEqual(orig_ordering[categories[1].pk], [10, 20, 30, 40, 50, 60])
- self.assertEqual(new_ordering[categories[1].pk], orig_ordering[categories[1].pk])
- self.assertEqual(orig_ordering[categories[2].pk], [10, 20, 30, 40])
- self.assertEqual(new_ordering[categories[2].pk], orig_ordering[categories[2].pk])
-
+ self.assertEqual(orig_positions[categories[0].pk],
+ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
+ self.assertEqual(new_positions[categories[0].pk],
+ [0, 1, 2, 3, 10, 4, 5, 6, 7, 8, 9])
+ self.assertEqual(orig_positions[categories[1].pk],
+ [0, 1, 2, 3, 4, 5])
+ self.assertEqual(new_positions[categories[1].pk],
+ orig_positions[categories[1].pk])
+ self.assertEqual(orig_positions[categories[2].pk],
+ [0, 1, 2, 3])
+ self.assertEqual(new_positions[categories[2].pk],
+ orig_positions[categories[2].pk])
+
+ self.assertEqual(orig_ordering[categories[0].pk],
+ [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110])
+ self.assertEqual(new_ordering[categories[0].pk],
+ [10, 20, 30, 40, 110, 59, 69, 79, 89, 99, 109])
+ self.assertEqual(orig_ordering[categories[1].pk],
+ [10, 20, 30, 40, 50, 60])
+ self.assertEqual(new_ordering[categories[1].pk],
+ orig_ordering[categories[1].pk])
+ self.assertEqual(orig_ordering[categories[2].pk],
+ [10, 20, 30, 40])
+ self.assertEqual(new_ordering[categories[2].pk],
+ orig_ordering[categories[2].pk])
class InstrumentTypeViews(TestCase):
def test_change_category(self):
self.assertEqual(1 + 10, 11)
# type = InstrumentType.objects.all()[18]
-# category = InstrumentCategory.objects.filter(pk__not=type.category_id)[0]
+# category = InstrumentCategory.objects.filter(
+# pk__not=type.category_id)[0]
#
-# url = reverse('instrumenttype_update', args=(type.category.slug, type.pk))
+# url = reverse('instrumenttype_update',
+# args=(type.category.slug, type.pk))
# response = self.client.post(url, {
# 'name': None
# })
-# self.assertTrue(False)
View
18 bandbook/instruments/urls.py
@@ -7,25 +7,31 @@
)
urlpatterns += patterns('bandbook.instruments.views',
- *InstrumentTypeView.urls('list/(?P<slug>[a-z0-9-_]+)/types', ['create', 'update', 'delete', 'order'])
+ *InstrumentTypeView.urls('list/(?P<slug>[a-z0-9-_]+)/types',
+ ['create', 'update', 'delete', 'order'])
)
urlpatterns += patterns('bandbook.instruments.views',
- *InstrumentCategoryView.urls('list', ['list', 'create', 'update', 'delete', 'order'], uregex=SLUG_REGEX)
+ *InstrumentCategoryView.urls('list',
+ ['list', 'create', 'update', 'delete', 'order'], uregex=SLUG_REGEX)
)
urlpatterns += patterns('bandbook.instruments.views',
- *InstrumentModelView.urls('manufacturers/(?P<slug>[a-z0-9-_]+)/models', ['create', 'update', 'delete'])
+ *InstrumentModelView.urls('manufacturers/(?P<slug>[a-z0-9-_]+)/models',
+ ['create', 'update', 'delete'])
)
urlpatterns += patterns('bandbook.instruments.views',
- *InstrumentManufacturerView.urls('manufacturers', ['list', 'create', 'update', 'delete'], uregex=SLUG_REGEX)
+ *InstrumentManufacturerView.urls('manufacturers',
+ ['list', 'create', 'update', 'delete'], uregex=SLUG_REGEX)
)
urlpatterns += patterns('bandbook.instruments.views',
- *InstrumentHistoryView.urls('(?P<slug>[a-z0-9-_]+)/history', ['create', 'update', 'delete', 'print'])
+ *InstrumentHistoryView.urls('(?P<slug>[a-z0-9-_]+)/history',
+ ['create', 'update', 'delete', 'print'])
)
urlpatterns += patterns('bandbook.instruments.views',
- *InstrumentView.urls('', ['list', 'create', 'detail', 'update', 'delete'], uregex=SLUG_REGEX)
+ *InstrumentView.urls('',
+ ['list', 'create', 'detail', 'update', 'delete'], uregex=SLUG_REGEX)
)
View
3 bandbook/instruments/views.py
@@ -1,5 +1,6 @@
from bandbook.main.views import BBView
-from bandbook.instruments.forms import InstrumentForm, InstrumentHistoryForm, InstrumentCategoryForm, InstrumentTypeForm
+from bandbook.instruments.forms import InstrumentForm, InstrumentHistoryForm, \
+ InstrumentCategoryForm, InstrumentTypeForm
from bandbook.instruments.models import Instrument, InstrumentCategory, \
InstrumentManufacturer, InstrumentType, InstrumentModel, InstrumentHistory
View
9 bandbook/main/helpers.py
@@ -7,6 +7,7 @@
reverse_lazy = lazy(reverse, str)
+
def index_block(x, y, width, gravity, style=None, url=None,
img_class=None, tmpl_class=None):
padding = 4
@@ -29,8 +30,10 @@ def index_block(x, y, width, gravity, style=None, url=None,
if img_list:
img_url = img_list[randint(0, len(img_list) - 1)]
- if gravity[0] == 'n': y -= (width + padding)
- if gravity[1] == 'w': x -= (width + padding)
+ if gravity[0] == 'n':
+ y -= (width + padding)
+ if gravity[1] == 'w':
+ x -= (width + padding)
return x, y, width, width, style, url, img_url, tmpl_class
@@ -58,7 +61,7 @@ def filter_searchby(parent_searchby, parent_field_set):
key = parent_field_set[:-4]
set_children = [x for x in parent_searchby if x.find(key) != -1]
set_parent = [x for x in parent_searchby if x not in set_children]
- return set_parent, [x[len(key)+2:] for x in set_children]
+ return set_parent, [x[len(key) + 2:] for x in set_children]
def filter_matches(obj, query, filters):
View
3 bandbook/main/templatetags/bandbook_main.py
@@ -4,7 +4,8 @@
from django.template.defaultfilters import register
from django.utils.safestring import mark_safe
-from bandbook.main.helpers import index_block, filter_queryset, filter_searchby, filter_matches
+from bandbook.main.helpers import index_block, filter_queryset, \
+ filter_searchby, filter_matches
@register.inclusion_tag('logo.html')
View
8 bandbook/main/templatetags/breadcrumbs.py
@@ -7,7 +7,8 @@
@tag(register, [])
def breadcrumb_open(context):
- return """<ul class="breadcrumb"> %s""" % breadcrumb_entry(context, "", "index", icon='home')
+ return """<ul class="breadcrumb"> %s""" % \
+ breadcrumb_entry(context, "", "index", icon='home')
@tag(register, [Variable(), Constant("to"), Variable()])
@@ -16,7 +17,10 @@ def breadcrumb_entry(context, title, url_name, last=False, icon=None):
url = reverse(url_name)
except NoReverseMatch:
url = ''
- return """<li class="%(class)s"><a href="%(url)s">%(icon)s %(title)s</a> %(divider)s</li>""" % {
+ return """
+ <li class="%(class)s">
+ <a href="%(url)s">%(icon)s %(title)s</a> %(divider)s
+ </li>""" % {
'title': _(title) if title else "",
'url': url,
'class': 'active' if last else '',
View
35 bandbook/main/views.py
@@ -42,7 +42,7 @@ def login_view(request):
login(request, user)
else:
messages.error(request,
- _('This account has been disabled. Sorry for that!'))
+ _('This account has been disabled. Sorry for that!'))
else:
messages.error(request,
_('Wrong username or password'))
@@ -89,7 +89,8 @@ def index(request):
index_block(413, 409, 35, 'nw', style='error'),
index_block(413, 410, 10, 'ne', style='warning'),
index_block(413, 410, 30, 'se', style='info'),
- index_block(427, 233, 100, 'se', url='instruments/', img_class='instruments'),
+ index_block(427, 233, 100, 'se', url='instruments/',
+ img_class='instruments'),
index_block(589, 395, 40, 'ne', style='info'),
index_block(589, 395, 30, 'se', style='warning'),
@@ -144,7 +145,8 @@ def get(self, request, **kwargs):
template = self.get_template_names()[0]
return render_to_pdf(template, context)
-# TODO che succede se sposto un elemento in un'altra lista? l'ordinamento va a quel paese?
+
+# TODO che succede se sposto un elemento in un'altra lista? Broken!
# TODO v problemi spostando in ultima posizione se ci sono buchi..
# TODO v ordinamento non e' parent-aware!
class OrderView(View):
@@ -159,7 +161,7 @@ def post(self, request, *args, **kwargs):
pkb = kwargs.get('pkb')
if pka is None or pkb is None:
- return HttpResponse(status = 400)
+ return HttpResponse(status=400)
try:
obja = self.model._default_manager.get(pk=pka)
@@ -184,8 +186,9 @@ def post(self, request, *args, **kwargs):
.update(ordering=F('ordering') + offset)
target_ordering = objb.ordering - 1 if objb is not None \
- else get_default_ordering(self.model)
- if not moving_down: target_ordering += 1
+ else get_default_ordering(self.model)
+ if not moving_down:
+ target_ordering += 1
self.model._default_manager.filter(pk=obja.pk)\
.update(ordering=target_ordering)
@@ -216,7 +219,7 @@ def get_initial(self):
if self.parent is not None:
param = self.kwargs.get(self.parent['param'])
obj = self.parent['model']._default_manager.get(
- **{self.parent['param']:param})
+ **{self.parent['param']: param})
initials.update({
self.parent['field']: obj,
})
@@ -264,9 +267,9 @@ def as_update_view(cls):
@classmethod
def as_delete_view(cls):
- return _BBDeleteView.as_view(model = cls.model,
- success_url = reverse_lazy('close_modal'),
- template_name = 'layouts/delete_base.html')
+ return _BBDeleteView.as_view(model=cls.model,
+ success_url=reverse_lazy('close_modal'),
+ template_name='layouts/delete_base.html')
@classmethod
def as_order_view(cls):
@@ -300,14 +303,18 @@ def render_to_pdf(template_src, context_dict):
# see http://tinyurl.com/87ncxd3 for header/footer configuration
template = get_template(template_src)
context = Context(context_dict)
- html = template.render(context)
+ html = template.render(context)
result = StringIO.StringIO()
- pdf = pisa.pisaDocument(StringIO.StringIO(html.encode("ISO-8859-1")), result)
+ pdf = pisa.pisaDocument(
+ StringIO.StringIO(html.encode("ISO-8859-1")), result)
if not pdf.err:
if 'filename' not in context_dict:
- context_dict['filename'] = ''.join([str(x) for x in datetime.utcnow().timetuple() if x >= 0])
+ context_dict['filename'] = ''.join(
+ [str(x) for x in datetime.utcnow().timetuple() if x >= 0])
filename = '%s.pdf' % context_dict['filename']
- response = HttpResponse(result.getvalue(), mimetype='application/pdf', content_type='application/pdf')
+ response = HttpResponse(result.getvalue(),
+ mimetype='application/pdf',
+ content_type='application/pdf')
response['Content-Disposition'] = 'filename=%s' % filename
return response
return HttpResponse('PDF generation error: <pre>%s</pre>' %
View
1 bandbook/main/widgets.py
@@ -1,5 +1,6 @@
from django.forms.widgets import DateInput
+
class BootstrapDatepicker(DateInput):
def render(self, name, value, attrs=None):
if attrs is None:

0 comments on commit b287a58

Please sign in to comment.
Something went wrong with that request. Please try again.