Skip to content

Commit

Permalink
Created example site if it didn't already exist
Browse files Browse the repository at this point in the history
  • Loading branch information
dlareau committed Mar 20, 2020
1 parent 7521018 commit 06407b3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
5 changes: 1 addition & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ services:

huey:
image: django_puzzlehunt # re-use above image
command: >
bash -c "python /code/manage.py migrate sites --no-input &&
python /code/manage.py migrate --no-input &&
python /code/manage.py run_huey --quiet"
command: bash -c "python /code/manage.py migrate --no-input && python /code/manage.py run_huey --quiet"
restart: always
volumes:
- .:/code
Expand Down
25 changes: 14 additions & 11 deletions huntserver/migrations/0054_auto_20200318_2145.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,29 @@ def setup_pages(apps, schema_editor):
FlatPage = apps.get_model('flatpages', 'FlatPage')
Site = apps.get_model('sites', 'Site')

source = get_template("contact_us.html").template.source.split("</readme> -->")[1]
fp = FlatPage.objects.create(url='/contact-us/', title='Contact Us', content=source)
fp.sites.add(Site.objects.get(pk=1))
try:
our_site = Site.objects.get(pk=1)
except:
our_site = Site.objects.create(domain="example.com", name="example.com")

source = get_template("resources.html").template.source.split("</readme> -->")[1]
fp = FlatPage.objects.create(url='/extra/resources/', title='Resources', content=source)
fp.sites.add(Site.objects.get(pk=1))
source = get_template("contact_us.html").template.source.split("</readme> -->")[1]
fp = FlatPage.objects.create(url='/contact-us/', title='Contact Us', content=source)
fp.sites.add(our_site)

source = get_template("hunt_info.html").template.source.split("</readme> -->")[1]
fp = FlatPage.objects.create(url='/hunt-info/', title='Current Hunt Info', content=source)
fp.sites.add(Site.objects.get(pk=1))
return
source = get_template("resources.html").template.source.split("</readme> -->")[1]
fp = FlatPage.objects.create(url='/extra/resources/', title='Resources', content=source)
fp.sites.add(our_site)

source = get_template("hunt_info.html").template.source.split("</readme> -->")[1]
fp = FlatPage.objects.create(url='/hunt-info/', title='Current Hunt Info', content=source)
fp.sites.add(our_site)


def remove_pages(apps, schema_editor):
FlatPage = apps.get_model('flatpages', 'FlatPage')
FlatPage.objects.filter(url='/contact-us/').delete()
FlatPage.objects.filter(url='/extra/resources/').delete()
FlatPage.objects.filter(url='/hunt-info/').delete()
return


class Migration(migrations.Migration):
Expand Down

0 comments on commit 06407b3

Please sign in to comment.