diff --git a/manage.py b/manage.py index 860f67547..3f56f430e 100755 --- a/manage.py +++ b/manage.py @@ -1,9 +1,13 @@ #!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" + import os import sys -if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "apis.settings.settings_test_ci") + +def main(): + """Run administrative tasks.""" + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sample_project.settings") try: from django.core.management import execute_from_command_line except ImportError as exc: @@ -12,48 +16,8 @@ "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?" ) from exc + execute_from_command_line(sys.argv) - # TODO : Check at some time if the bug in dal_select2 has been fixed, and if so, remove this function here - def work_around_dal_select2_bug(): - """ - Due to a bug in dal_select2, this workaround function here goes into the offending file and replaces the - relevant code segment with a work-around segment. - - This function ensures that this replacement is done each time django is run and also modifies only the file - which is loaded via the respective library within the virtual environment of the current python interpreter. - """ - - import dal_select2 - - file_to_fix = dal_select2.__file__.replace( - "/__init__.py", "/static/autocomplete_light/select2.js" - ) - - try: - with open(file_to_fix, "r") as f: - lines = f.readlines() - - for i, line in enumerate(lines): - if ( - line == " processResults: function (data, page) {\n" - and lines[i + 1] - == " if (element.attr('data-tags')) {\n" - and lines[i + 2] - == " $.each(data.results, function(index, value) {\n" - and lines[i + 3] - == " value.id = value.text;\n" - ): - lines[i + 3] = " value.id = value.id;\n" - - with open(file_to_fix, "w") as f: - f.write("".join(lines)) - - except FileNotFoundError: - raise Exception( - "Could not find select2.js file to inject bug workaround into.\n" - + "Maybe the dal_select library has changed and this workaround is not necessary anymore?" - ) - - work_around_dal_select2_bug() - execute_from_command_line(sys.argv) +if __name__ == "__main__": + main() diff --git a/sample_project/settings.py b/sample_project/settings.py index c7b075558..e5ee126d3 100644 --- a/sample_project/settings.py +++ b/sample_project/settings.py @@ -1,4 +1,7 @@ -SECRET_KEY = "a+nkut46lzzg_=ul)zrs29$u_6^*)2by2mjmwn)tqlgw)_at&l" +import os +from django.core.management.utils import get_random_secret_key + +SECRET_KEY = os.environ.get("SECRET_KEY", get_random_secret_key()) DEBUG = True ALLOWED_HOSTS = [] @@ -28,10 +31,9 @@ "dal_select2", # api "rest_framework", - "rest_framework.authtoken", # for swagger ui generation "drf_spectacular", - "simple_history", + # our ontology "sample_project", ] @@ -43,8 +45,6 @@ "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", - "allow_cidr.middleware.AllowCIDRMiddleware", - "reversion.middleware.RevisionMiddleware", ] ROOT_URLCONF = "apis_core.urls" @@ -60,8 +60,6 @@ "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", - # we need this for accessing `basetemplate` - "apis_core.context_processors.custom_context_processors.list_apis_settings", ], }, },