Merge branch 'master' of github.com:bornhack/bornhack-website

This commit is contained in:
Thomas Steen Rasmussen 2017-01-31 22:50:49 +01:00
commit 2a41b03e56
3 changed files with 83 additions and 3 deletions

View file

@ -57,6 +57,13 @@ Enjoy!
### How to add a camp
Add a new camp in the admin interface and run `
```
(venv) $ ./manage.py createcamp {camp-slug}
```
or go through the manuel process below:
* Add a new camp in the admin interface.
* Add a sponsers page, `{camp-slug}-sponsors.html`, to `sponsors/templates`.
* Add a frontpage, `{camp-slug}-camp_detail.html`, to `camps/templates`.
@ -66,7 +73,8 @@ Enjoy!
* `{camp-slug}-logo-small.png`
### multicamp prod migration notes
#### when villages.0008 migration fails go add camp_id to all existing villages
#### go to admin interface and add bornhack 2017, and set slug for bornhack 2016
#### convert events to the new format (somehow)
* when villages.0008 migration fails go add camp_id to all existing villages
* go to admin interface and add bornhack 2017, and set slug for bornhack 2016
* convert events to the new format (somehow)

View file

@ -7,6 +7,8 @@ def local_dir(entry):
entry
)
DJANGO_BASE_PATH = os.path.dirname(os.path.dirname(__file__))
WSGI_APPLICATION = 'bornhack.wsgi.application'
ROOT_URLCONF = 'bornhack.urls'

View file

@ -0,0 +1,70 @@
# coding: utf-8
from django.core.management.base import BaseCommand
from django.utils import timezone
from django.conf import settings
import os
class Command(BaseCommand):
help = 'Creates html files needed for a camp'
def add_arguments(self, parser):
parser.add_argument('camp_slug', type=str)
def output(self, message):
self.stdout.write('{}: {}'.format(
timezone.now().strftime("%Y-%m-%d %H:%M:%S"),
message
)
)
def local_dir(self, entry):
return os.path.join(
settings.DJANGO_BASE_PATH,
entry
)
def handle(self, *args, **options):
# files to create, relative to DJANGO_BASE_PATH
files = [
'sponsors/templates/{camp_slug}-sponsors.html',
'camps/templates/{camp_slug}-camp_detail.html',
'program/templates/{camp_slug}-call_for_speakers.html'
]
# directories to create, relative to DJANGO_BASE_PATH
dirs = [
'static/img/{camp_slug}/logo'
]
camp_slug = options['camp_slug']
for _file in files:
path = self.local_dir(_file.format(camp_slug=camp_slug))
if os.path.isfile(_file):
self.output('File {} exists...'.format(path))
else:
self.output('Creating {}'.format(path))
with open(path, mode='w', encoding='utf-8') as f:
f.write(_file.format(camp_slug=camp_slug))
for _dir in dirs:
path = self.local_dir(_file.format(camp_slug=camp_slug))
if os.path.exists(path):
self.output('Path {} exists...'.format(path))
else:
self.output('Creating {}'.format(path))
os.mkdir(path, mode=0o644)
self.output('All there is left is to create:')
self.output(
self.local_dir(
'static/img/{camp_slug}/logo/{camp_slug}-logo-large.png'.format(camp_slug=camp_slug)
)
)
self.output(
self.local_dir(
'static/img/{camp_slug}/logo/{camp_slug}-logo-small.png'.format(camp_slug=camp_slug)
)
)