Commit d11db413 by Freyja

Switch to Jinja2 templating, fix config and work on gunicorn conf

parent 74672410
Pipeline #101 failed with stage
in 14 seconds
......@@ -119,6 +119,13 @@ les lancer pour vérifier que vous n'avez rien cassé:
pytest mysite/tests
Déploiment
----------
- Create folder in /run : /run/gunicorn
- Create a group gunicorn to run gunicorn with
- Make nginx a member of that group/allowed to access gunicorn folder
Ont contribué
-------------
......
......@@ -15,6 +15,7 @@ import os
from mysite.localsettings import *
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PDFGENERATOR_PATH=os.path.abspath(os.path.join(BASE_DIR, 'pdfgenerator'))
# Quick-start development settings - unsuitable for production
......@@ -46,6 +47,7 @@ MIDDLEWARE = [
ROOT_URLCONF = 'mysite.urls'
TEMPLATES = [
{
'NAME': 'tex',
......@@ -59,6 +61,17 @@ TEMPLATES = [
}
},
{
'NAME': 'jinja2',
'BACKEND': 'django.template.backends.jinja2.Jinja2',
'DIRS': [
os.path.join(PDFGENERATOR_PATH, 'templates'),
],
'APP_DIRS': True,
'OPTIONS': {
'environment': 'mysite.jinja2.environment',
},
},
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
......@@ -128,4 +141,4 @@ PROJECT_APP = os.path.basename(PROJECT_APP_PATH)
PROJECT_ROOT = BASE_DIR = os.path.dirname(PROJECT_APP_PATH)
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(PROJECT_ROOT, STATIC_URL.strip("/"))
STATIC_ROOT = '/srv/trans-cec/'
......@@ -4,16 +4,16 @@
<meta charset="UTF-8">
<title>Trans Administratif</title>
<!-- Safari -->
<link rel="mask-icon" size="192x192" href={% static 'trans_pride_flag192x192.png' %}/>
<link rel="mask-icon" size="192x192" href={{ static('trans_pride_flag192x192.png') }}/>
<!-- iOS >= 5 -->
<link rel="apple-touch-icon" href={% static 'trans_pride_flag128x128.png' %}>
<link rel="shortcut icon" size="48x48" href={% static 'trans_pride_flag48x48.png' %}/>
<link rel="shortcut icon" size="192x192" href={% static 'trans_pride_flag192x192.png' %}/>
<link rel="apple-touch-icon" href={{ static('trans_pride_flag128x128.png') }}/>
<link rel="shortcut icon" size="48x48" href={{ static('trans_pride_flag48x48.png') }}/>
<link rel="shortcut icon" size="192x192" href={{ static('trans_pride_flag192x192.png') }}/>
<!-- Latest compiled and minified CSS -->
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"> -->
<link rel="stylesheet" href={% static 'css/bootstrap.min.css' %}>
<link rel="stylesheet" href={% static 'css/custom.css' %}>
<script src="{% static 'js/memory.js' %}"></script>
<link rel="stylesheet" href={{ static('css/bootstrap.min.css') }}/>
<link rel="stylesheet" href={{ static('css/custom.css') }}/>
<script src="{{ static('js/memory.js') }}"></script>
</head>
<body class="center">
......@@ -24,14 +24,14 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href={% url 'list_letters_type' %}>Trans Administratif</a>
<a class="navbar-brand" href={{ url('list_letters_type') }}>Trans Administratif</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
{% for category, list in lists %}
<li><a href={% url 'list' category=category %}>{{ list.title }}</a></li>
<li><a href={{ url('list', kwargs={'category': category}) }}>{{ list.title }}</a></li>
{% endfor %}
<li><a href={% url 'form' category='attestation' id='chgmtprenom' %}>Changement de prénom</a></li>
<li><a href={{ url('form', kwargs={'category': 'attestation', 'id': 'chgmtprenom'}) }}>Changement de prénom</a></li>
</ul>
<ul id="memory" class="nav navbar-nav">
<li><span title="{{ strings.enableMemory }}" class="icon" id="save">&#128062;&#xfe0e;</span></li>
......
......@@ -14,7 +14,8 @@
</h1>
<form class="memory form-horizontal" method="post">{% csrf_token %}
<form class="memory form-horizontal" method="post">
<input type='hidden' name='csrfmiddlewaretoken' value="{{ csrf_token }}" />
{% if form.errors and not form.non_field_errors() %}
<p class="message bg-danger">
Le formulaire contient des erreurs. Merci de les corriger.
......
......@@ -7,7 +7,7 @@
{% for form in list.forms[3*row:3*(row + 1)] %}
<div class="col-sm-4">
<article>
<header><a href="{% url 'form' category=list.category id=form.id %}">{{ form.title }}</a></header>
<header><a href="{{ url('form', kwargs={'category':list.category, 'id': form.id}) }}">{{ form.title }}</a></header>
<p>{{ form.description }}</p>
</article>
</div>
......
......@@ -19,7 +19,7 @@ def context(obj):
return obj
def list_letters_type(request):
return render(request, "pdfgenerator/list_letters_type.html", context({}))
return render(request, "pdfgenerator/list_letters_type.html", context({}), using='jinja2')
def list(request, category):
try:
......@@ -27,7 +27,7 @@ def list(request, category):
except KeyError:
raise http.Http404
list['category'] = category
return render(request, "pdfgenerator/list.html", context({"list": list}))
return render(request, "pdfgenerator/list.html", context({"list": list}), using='jinja2')
def form(request, category, id):
form_id = '{}_{}'.format(category, id)
......@@ -56,4 +56,4 @@ def form(request, category, id):
else:
form = form_class()
form_context['form'] = form
return render(request, "pdfgenerator/form.html", context(form_context))
return render(request, "pdfgenerator/form.html", context(form_context), using='jinja2')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment