Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
fix populate reset
Browse files Browse the repository at this point in the history
  • Loading branch information
rochacbruno committed Dec 19, 2015
1 parent 9c44e2d commit e57034c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
4 changes: 3 additions & 1 deletion quokka/ext/fixtures.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# coding: utf-8
from quokka.utils.populate import Populate
from quokka.core.models.config import Quokka
from quokka.core.models.config import Config


def configure(app, db):
Expand Down Expand Up @@ -31,7 +32,8 @@ def configure(app, db):
except Exception as e:
app.logger.warning("Cant create initial user and post: %s" % e)
except Exception as e:
app.logger.error("Error loading fixtures: %s" % e)
app.logger.error("Error loading fixtures, try again - %s" % e)
populate.reset()
Config.objects.delete()
else:
Quokka.objects.create(slug="is_installed")
19 changes: 8 additions & 11 deletions quokka/utils/populate.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,17 +313,14 @@ def reset(self):
]
).delete()

base_channels = Channel.objects(parent=None)
second_level = Channel.objects(parent__in=base_channels)
third_level = Channel.objects(parent__in=second_level)

third_level.delete()
second_level.delete()
base_channels.delete()

Config.objects(
group__in=[item['group'] for item in self.json_data.get('configs')]
).delete()
for channel in Channel.objects(
slug__in=[
item['slug'] for item in self.json_data.get('channels')]):
for subchannel in channel.get_children():
for subsubchannel in subchannel.get_children():
subsubchannel.delete()
subchannel.delete()
channel.delete()

User.objects(
email__in=[item['email'] for item in self.json_data.get('users')]
Expand Down

0 comments on commit e57034c

Please sign in to comment.