Skip to content

Commit

Permalink
Add constance config to toggle if registration is open
Browse files Browse the repository at this point in the history
  • Loading branch information
tyilo committed Oct 15, 2018
1 parent 389adb0 commit 371b377
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 15 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ django-logentry-admin = "*"
django-admin-views = "*"
django-cors-headers = "*"
django-bootstrap-datepicker-plus = "*"
django-constance = {extras = ["database"], version = "*"}

[dev-packages]

Expand Down
33 changes: 26 additions & 7 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions fredagscafeen/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
('RECAPTCHA_PRIVATE_KEY', 'ReCaptcha private key'),
]

CONSTANCE_CONFIG = {
'REGISTRATION_OPEN': (True, 'Er bartendertilmelding åben?', bool),
}

# Inject all secret keys
for k, _ in SECRET_ADMIN_KEYS:
v = os.getenv(k)
Expand Down Expand Up @@ -66,6 +70,8 @@
'django.contrib.staticfiles',
'django_object_actions',
'django_extensions',
'constance',
'constance.backends.database',
'rest_framework.authtoken',
'bootstrap3',
'bootstrap_datepicker_plus',
Expand Down Expand Up @@ -120,6 +126,7 @@
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'constance.context_processors.config',
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
Expand Down Expand Up @@ -173,6 +180,8 @@
CORS_URLS_REGEX = r'^/api/.*$' # Only allow CORS requests in /api
CORS_ORIGIN_ALLOW_ALL = True

CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend'

# Server admins (get an email when server errors happen)
ADMINS = [
('Oskar Haarklou Veileborg', '[email protected]'),
Expand Down
19 changes: 11 additions & 8 deletions web/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@
<div class="row">
<div class="col-md-8">
<h2>Bartendertilmelding</h2>

<p>Som bartender har du ca. 2 vagter per semester, hvor du er med til at sørge for, at Fredagscafeen løber rundt.<p>
<p>Udover dette inviteres du til vores årlige arrangementer for bartendere og bestyrelse, såsom turen til Djurs Sommerland.</p>
<p>Det er en god idé at læse <a href="{% static 'guides/barvagt.pdf' %}" alt="guide">barvagt-guiden</a> før du tilmelder dig, så du
ved hvad en typisk vagt i Fredagscafeen indebærer.</p>
<form method="post" action="/">
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
{% bootstrap_button "Indsend" button_type="submit" icon="send" button_class="btn-primary" %}
{% endbuttons %}
</form>
{% if config.REGISTRATION_OPEN %}
<form method="post" action="/">
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
{% bootstrap_button "Indsend" button_type="submit" icon="send" button_class="btn-primary" %}
{% endbuttons %}
</form>
{% else %}
<b>Bartendertilmeldingen er lukket.</b>
{% endif %}
</div>
</div>

Expand Down

0 comments on commit 371b377

Please sign in to comment.