Merge pull request #20 from overshard/master

Make ALLOW_UPLOADS a setting dependent on user preference and platform
This commit is contained in:
Christopher Charbonneau Wells 2017-11-19 08:40:27 -05:00 committed by GitHub
commit 58c1cc4cbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 2 deletions

View File

@ -131,6 +131,8 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
WHITENOISE_ROOT = os.path.join(BASE_DIR, 'static', 'root')
ALLOW_UPLOADS = True
# Django Rest Framework
# http://www.django-rest-framework.org/#

View File

@ -10,6 +10,8 @@ INTERNAL_IPS = (
'127.0.0.1',
)
ALLOW_UPLOADS = True
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

View File

@ -6,6 +6,9 @@ from .base import * # noqa: F401,F403
DEBUG = os.environ.get('DEBUG', False)
ALLOW_UPLOADS = False
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ['SECRET_KEY']

View File

@ -8,6 +8,9 @@ from .base import * # noqa: F401,F403
DEBUG = os.environ.get('DEBUG', False)
ALLOW_UPLOADS = False
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ['SECRET_KEY']

View File

@ -6,6 +6,9 @@ from .base import * # noqa: F401,F403
DEBUG = os.environ.get('DEBUG', False)
ALLOW_UPLOADS = False
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ['SECRET_KEY']

View File

@ -2,6 +2,7 @@
from __future__ import unicode_literals
from django.contrib import admin
from django.conf import settings
from core import models
@ -10,7 +11,10 @@ from core import models
class ChildAdmin(admin.ModelAdmin):
list_display = ('first_name', 'last_name', 'birth_date', 'slug')
list_filter = ('last_name',)
search_fields = ('first_name', 'last_name', 'birth_date',)
search_fields = ('first_name', 'last_name', 'birth_date')
fields = ['first_name', 'last_name', 'birth_date']
if settings.ALLOW_UPLOADS:
fields.append('picture')
@admin.register(models.DiaperChange)

View File

@ -3,6 +3,7 @@ from __future__ import unicode_literals
from django import forms
from django.utils import timezone
from django.conf import settings
from core import models
@ -40,7 +41,13 @@ def set_default_duration(kwargs):
class ChildForm(forms.ModelForm):
class Meta:
model = models.Child
fields = ['first_name', 'last_name', 'birth_date', 'picture']
fields = [
'first_name',
'last_name',
'birth_date'
]
if settings.ALLOW_UPLOADS:
fields.append('picture')
widgets = {
'birth_date': forms.DateInput(attrs={
'class': 'datepicker-input',