Merge branch 'develop' into feature/21-add-package-params
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Create a default superuser if no superuser is already present. This aids automatic deployment inside a container."
|
||||
|
||||
def add_arguments(self, parser: CommandParser):
|
||||
parser.add_argument('--user',
|
||||
help='Username to create if no admin account is present',
|
||||
default='admin')
|
||||
parser.add_argument('--password',
|
||||
help='Password to set for newly created user. Ignored, if any admin user is already present',
|
||||
default='admin')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
User = get_user_model()
|
||||
|
||||
# Query if there is any admin user
|
||||
if not User.objects.filter(is_superuser=True).exists():
|
||||
self.stdout.write(f'No superuser present. Creating {options['user']} with supplied password')
|
||||
User.objects.create_superuser(username=options['user'], password=options['password'])
|
||||
else:
|
||||
self.stdout.write('At least one superuser already exists. Skipping superuser creation')
|
@@ -56,7 +56,6 @@ if get_env_value('DJANGO_FORCE_DEV_MODE', default=False) == 'True':
|
||||
|
||||
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', get_env_value('DJANGO_ALLOWED_HOST')]
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
@@ -239,4 +238,7 @@ CSRF_COOKIE_SECURE = True
|
||||
|
||||
SECURE_SSL_REDIRECT = False
|
||||
|
||||
# allow detection of https behind "old" nginx
|
||||
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
||||
|
||||
SECURE_HSTS_SECONDS = get_env_value('DJANGO_SECURE_HSTS_SECONDS', default=120)
|
||||
|
@@ -75,7 +75,7 @@
|
||||
'component-parameter-type-list': '{% url 'componentparametertype-list' %}',
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="{% static 'js/kenyusho-api-v1.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'js/kenkyusho-api-v1.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'js/autocomplete.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'js/autocomplete-foreign-key-field.js' %}"></script>
|
||||
<!-- Initialize bootstrap popovers -->
|
||||
@@ -95,4 +95,4 @@
|
||||
{% endblock custom_scripts %}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user