diff --git a/bagitobjecttransfer/Dockerfile b/bagitobjecttransfer/Dockerfile index a8b3d282..859716a8 100644 --- a/bagitobjecttransfer/Dockerfile +++ b/bagitobjecttransfer/Dockerfile @@ -7,6 +7,7 @@ WORKDIR /app ENV PYTHONUNBUFFERED=1 # Install Dependencies +RUN yum install -y git RUN yum install -y python3 RUN python3 -m pip install --upgrade pip COPY ./requirements.txt . diff --git a/bagitobjecttransfer/bagitobjecttransfer/settings/base.py b/bagitobjecttransfer/bagitobjecttransfer/settings/base.py index d5ecca86..24975e69 100644 --- a/bagitobjecttransfer/bagitobjecttransfer/settings/base.py +++ b/bagitobjecttransfer/bagitobjecttransfer/settings/base.py @@ -18,6 +18,7 @@ 'formtools', 'django_rq', 'captcha', + 'dbtemplates', ] MIDDLEWARE = [ @@ -39,7 +40,7 @@ 'DIRS': [ os.path.join(BASE_DIR, 'templates') ], - 'APP_DIRS': True, + 'APP_DIRS': False, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', @@ -49,6 +50,11 @@ 'recordtransfer.context_processors.signup_status', 'recordtransfer.context_processors.file_uploads', ], + 'loaders': [ + 'dbtemplates.loader.Loader', + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', + ] }, }, ] @@ -118,6 +124,11 @@ COUNTRIES_FLAG_URL = 'flags/{code}.gif' +# django-dbtemplates configuration +# https://github.com/NationalCentreTruthReconciliation/django-dbtemplates + +DBTEMPLATES_USE_CODEMIRROR = True + # Media and Static files (CSS, JavaScript, Images) MEDIA_URL = '/media/' diff --git a/bagitobjecttransfer/recordtransfer/migrations/0026_dbtemplates.py b/bagitobjecttransfer/recordtransfer/migrations/0026_dbtemplates.py new file mode 100644 index 00000000..7340c64c --- /dev/null +++ b/bagitobjecttransfer/recordtransfer/migrations/0026_dbtemplates.py @@ -0,0 +1,68 @@ +# Generated by Django 3.2.11 on 2022-01-12 19:26 + +from django.db import migrations + +from dbtemplates.models import Template + + +RECORDTRANSFER_PREFIX = 'recordtransfer' + +def populate_templates(apps, schema_editor): + ''' Add default editable templates to database ''' + + for name, description in ( + ('about', ( + 'Page for information relating to the application.' + )), + ('activationcomplete', ( + 'Page user is re-directed to after activating their account.' + )), + ('activationinvalid', ( + 'Page user is re-directed to if their account could not be ' + 'activated.' + )), + ('activationsent', ( + 'Page user is re-directed to after submitting their info in ' + 'the sign-up form.' + )), + ('banner', ( + 'Banner displayed at top of every page of site.' + )), + ('base', ( + 'Base template used for every page of site. Includes the head ' + 'so that the title, scripts, meta tags, etc. can be edited.' + )), + ('footer', ( + 'Footer displayed on every page of site.' + )), + ('header', ( + 'Navigation header displayed on every page of site.' + )), + ('home', ( + 'Main homepage or "index" page.' + )), + ('transfersent', ( + 'Page user is re-directed to after submitting a transfer.' + )), + ('transferform_legal', ( + 'First page of transfer form that contains legal copy defining ' + 'the legal parameters that apply to the transfer. Legal copy ' + 'should be defined the form_explanation block.' + )), + ): + template_name = RECORDTRANSFER_PREFIX + '/' + name + '.html' + template, _ = Template.objects.get_or_create( + name=template_name, + description=description, + ) + + +class Migration(migrations.Migration): + dependencies = [ + ('recordtransfer', '0025_user_gets_notification_emails'), + ('dbtemplates', '0002_add_template_description'), + ] + + operations = [ + migrations.RunPython(populate_templates), + ] diff --git a/bagitobjecttransfer/requirements.txt b/bagitobjecttransfer/requirements.txt index 89abe260..fc64d15e 100644 --- a/bagitobjecttransfer/requirements.txt +++ b/bagitobjecttransfer/requirements.txt @@ -1,3 +1,4 @@ +git+https://github.com/NationalCentreTruthReconciliation/django-dbtemplates@3.0.1-nctr#egg=django-dbtemplates asgiref==3.4.1 bagit==1.8.1 click==8.0.3