Skip to content

Commit

Permalink
Merge pull request #225 from idlesign/feat/major_refactoring
Browse files Browse the repository at this point in the history
Major refactoring.
  • Loading branch information
idlesign committed Dec 21, 2016
2 parents 7e50bc9 + 11ed9c0 commit 061459f
Show file tree
Hide file tree
Showing 14 changed files with 960 additions and 327 deletions.
6 changes: 2 additions & 4 deletions sitetree/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ def _build_choices(self):
tree_token = u'sitetree_tree from "%s" template "%s"' % (self.tree, self.template)

context_kwargs = {'current_app': 'admin'}
if VERSION >= (1, 8):
context = template.Context(context_kwargs)
else:
context = template.Context(**context_kwargs)
context = template.Context(context_kwargs) if VERSION >= (1, 8) else template.Context(**context_kwargs)
context.update({'request': object()})

choices_str = sitetree_tree(
Parser(None), Token(token_type=TOKEN_BLOCK, contents=tree_token)
Expand Down
11 changes: 4 additions & 7 deletions sitetree/management/commands/sitetreeload.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
help='Mode to put data into DB. Variants: `replace`, `append`.'),

CommandOption(
'--items_into_tree', action='store', dest='into_tree', default=None,
'--items_into_tree', action='store', dest='items_into_tree', default=None,
help='Import only tree items data into tree with given alias.'),
))

Expand All @@ -50,7 +50,7 @@ def handle(self, *fixture_files, **options):

using = options.get('database', DEFAULT_DB_ALIAS)
mode = options.get('mode', 'append')
items_into_tree = options.get('into_tree', None)
items_into_tree = options.get('items_into_tree', None)

if items_into_tree is not None:
try:
Expand Down Expand Up @@ -78,11 +78,8 @@ def handle(self, *fixture_files, **options):
loaded_object_count = 0

if mode == 'replace':
try:
MODEL_TREE_CLASS.objects.all().delete()
MODEL_TREE_ITEM_CLASS.objects.all().delete()
except ObjectDoesNotExist:
pass
MODEL_TREE_CLASS.objects.all().delete()
MODEL_TREE_ITEM_CLASS.objects.all().delete()

for fixture_file in fixture_files:

Expand Down
Loading

0 comments on commit 061459f

Please sign in to comment.