Skip to content

Commit

Permalink
Formatting changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
idlesign committed Dec 8, 2014
1 parent 98658c9 commit 7c18c10
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
6 changes: 5 additions & 1 deletion sitetree/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def override_item_admin(admin_class):


class TreeItemAdmin(admin.ModelAdmin):

exclude = ('tree', 'sort_order')
fieldsets = (
(_('Basic settings'), {
Expand Down Expand Up @@ -197,9 +198,11 @@ def item_move(self, request, tree_id, item_id, direction):
sort_order = 'sort_order'
else:
sort_order = '-sort_order'

siblings = MODEL_TREE_ITEM_CLASS._default_manager.filter(
parent=current_item.parent,
tree=current_item.tree).order_by(sort_order)
tree=current_item.tree
).order_by(sort_order)

previous_item = None
for item in siblings:
Expand Down Expand Up @@ -254,6 +257,7 @@ def redirects_handler(*args, **kwargs):


class TreeAdmin(admin.ModelAdmin):

list_display = ('alias', 'title')
list_display_links = ('title', 'alias')
search_fields = ['title', 'alias']
Expand Down
8 changes: 5 additions & 3 deletions sitetree/management/commands/sitetreeload.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class Command(BaseCommand):
help = 'Loads sitetrees from fixture in JSON format into database.'
args = '[fixture_file fixture_file ...]'


def handle(self, *fixture_files, **options):

using = options.get('database', DEFAULT_DB_ALIAS)
Expand Down Expand Up @@ -160,8 +159,11 @@ def handle(self, *fixture_files, **options):
transaction.rollback(using=using)
transaction.leave_transaction_management(using=using)
self.stderr.write(
self.style.ERROR('Fixture `%s` import error: %s\n' % (fixture_file,
''.join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))))
self.style.ERROR('Fixture `%s` import error: %s\n' % (
fixture_file, ''.join(traceback.format_exception(
sys.exc_type, sys.exc_value, sys.exc_traceback
))
))
)

fixture.close()
Expand Down
2 changes: 2 additions & 0 deletions sitetree/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def get_prep_value(self, value):

@python_2_unicode_compatible
class TreeBase(models.Model):

title = models.CharField(_('Title'), max_length=100, help_text=_('Site tree title for presentational purposes.'), blank=True)
alias = models.CharField(_('Alias'), max_length=80, help_text=_('Short name to address site tree from templates.<br /><b>Note:</b> change with care.'), unique=True, db_index=True)

Expand All @@ -45,6 +46,7 @@ def __str__(self):

@python_2_unicode_compatible
class TreeItemBase(models.Model):

PERM_TYPE_ANY = 1
PERM_TYPE_ALL = 2

Expand Down
2 changes: 1 addition & 1 deletion sitetree/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def import_app_sitetree_module(app):
try:
sub_module = import_module('%s.%s' % (app, module_name))
return sub_module
except:
except ImportError:
if module_has_submodule(module, module_name):
raise
return None
Expand Down

0 comments on commit 7c18c10

Please sign in to comment.