Skip to content

Commit 9ee05af

Browse files
authored
Merge pull request #86 from NationalCentreTruthReconciliation/dbtemplates
Add dbtemplates Dependency to resolve issue #64
2 parents 011c800 + 85e5e07 commit 9ee05af

File tree

4 files changed

+82
-1
lines changed

4 files changed

+82
-1
lines changed

bagitobjecttransfer/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ WORKDIR /app
77
ENV PYTHONUNBUFFERED=1
88

99
# Install Dependencies
10+
RUN yum install -y git
1011
RUN yum install -y python3
1112
RUN python3 -m pip install --upgrade pip
1213
COPY ./requirements.txt .

bagitobjecttransfer/bagitobjecttransfer/settings/base.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
'formtools',
1919
'django_rq',
2020
'captcha',
21+
'dbtemplates',
2122
]
2223

2324
MIDDLEWARE = [
@@ -39,7 +40,7 @@
3940
'DIRS': [
4041
os.path.join(BASE_DIR, 'templates')
4142
],
42-
'APP_DIRS': True,
43+
'APP_DIRS': False,
4344
'OPTIONS': {
4445
'context_processors': [
4546
'django.template.context_processors.debug',
@@ -49,6 +50,11 @@
4950
'recordtransfer.context_processors.signup_status',
5051
'recordtransfer.context_processors.file_uploads',
5152
],
53+
'loaders': [
54+
'dbtemplates.loader.Loader',
55+
'django.template.loaders.filesystem.Loader',
56+
'django.template.loaders.app_directories.Loader',
57+
]
5258
},
5359
},
5460
]
@@ -118,6 +124,11 @@
118124

119125
COUNTRIES_FLAG_URL = 'flags/{code}.gif'
120126

127+
# django-dbtemplates configuration
128+
# https://github.com/NationalCentreTruthReconciliation/django-dbtemplates
129+
130+
DBTEMPLATES_USE_CODEMIRROR = True
131+
121132
# Media and Static files (CSS, JavaScript, Images)
122133

123134
MEDIA_URL = '/media/'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Generated by Django 3.2.11 on 2022-01-12 19:26
2+
3+
from django.db import migrations
4+
5+
from dbtemplates.models import Template
6+
7+
8+
RECORDTRANSFER_PREFIX = 'recordtransfer'
9+
10+
def populate_templates(apps, schema_editor):
11+
''' Add default editable templates to database '''
12+
13+
for name, description in (
14+
('about', (
15+
'Page for information relating to the application.'
16+
)),
17+
('activationcomplete', (
18+
'Page user is re-directed to after activating their account.'
19+
)),
20+
('activationinvalid', (
21+
'Page user is re-directed to if their account could not be '
22+
'activated.'
23+
)),
24+
('activationsent', (
25+
'Page user is re-directed to after submitting their info in '
26+
'the sign-up form.'
27+
)),
28+
('banner', (
29+
'Banner displayed at top of every page of site.'
30+
)),
31+
('base', (
32+
'Base template used for every page of site. Includes the head '
33+
'so that the title, scripts, meta tags, etc. can be edited.'
34+
)),
35+
('footer', (
36+
'Footer displayed on every page of site.'
37+
)),
38+
('header', (
39+
'Navigation header displayed on every page of site.'
40+
)),
41+
('home', (
42+
'Main homepage or "index" page.'
43+
)),
44+
('transfersent', (
45+
'Page user is re-directed to after submitting a transfer.'
46+
)),
47+
('transferform_legal', (
48+
'First page of transfer form that contains legal copy defining '
49+
'the legal parameters that apply to the transfer. Legal copy '
50+
'should be defined the form_explanation block.'
51+
)),
52+
):
53+
template_name = RECORDTRANSFER_PREFIX + '/' + name + '.html'
54+
template, _ = Template.objects.get_or_create(
55+
name=template_name,
56+
description=description,
57+
)
58+
59+
60+
class Migration(migrations.Migration):
61+
dependencies = [
62+
('recordtransfer', '0025_user_gets_notification_emails'),
63+
('dbtemplates', '0002_add_template_description'),
64+
]
65+
66+
operations = [
67+
migrations.RunPython(populate_templates),
68+
]

bagitobjecttransfer/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
git+https://github.com/NationalCentreTruthReconciliation/[email protected]#egg=django-dbtemplates
12
asgiref==3.4.1
23
bagit==1.8.1
34
click==8.0.3

0 commit comments

Comments
 (0)