Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dbtemplates Dependency #86

Merged
merged 5 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bagitobjecttransfer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
13 changes: 12 additions & 1 deletion bagitobjecttransfer/bagitobjecttransfer/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
'formtools',
'django_rq',
'captcha',
'dbtemplates',
]

MIDDLEWARE = [
Expand All @@ -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',
Expand All @@ -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',
]
},
},
]
Expand Down Expand Up @@ -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/'
Expand Down
68 changes: 68 additions & 0 deletions bagitobjecttransfer/recordtransfer/migrations/0026_dbtemplates.py
Original file line number Diff line number Diff line change
@@ -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),
]
1 change: 1 addition & 0 deletions bagitobjecttransfer/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
git+https://github.com/NationalCentreTruthReconciliation/[email protected]#egg=django-dbtemplates
asgiref==3.4.1
bagit==1.8.1
click==8.0.3
Expand Down