Make ALLOW_UPLOADS a setting dependent on user preference and platform

This commit is contained in:
Isaac Bythewood 2017-11-18 20:57:29 -05:00
parent 5117575256
commit a503d346ae
7 changed files with 25 additions and 1 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
@ -11,6 +12,9 @@ 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',)
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',