diff options
| author | Mitch Riedstra <Mitch@riedstra.us> | 2017-11-27 16:20:24 -0500 |
|---|---|---|
| committer | Mitch Riedstra <Mitch@riedstra.us> | 2017-11-27 16:20:24 -0500 |
| commit | 1eb7582e6a291f2c5b3a30c408cb50f199fa6eac (patch) | |
| tree | 521bd9ce0deeb5ae9b082d8834583d5977c4f06f | |
| parent | 807c082bc71ed79651533551111b0e3507ae410b (diff) | |
| download | dispatch-tracker-1eb7582e6a291f2c5b3a30c408cb50f199fa6eac.tar.gz dispatch-tracker-1eb7582e6a291f2c5b3a30c408cb50f199fa6eac.tar.xz | |
Add snippets to the home page from the configuration file
| -rw-r--r-- | app/app/settings.py | 5 | ||||
| -rw-r--r-- | app/config-example.yml | 24 | ||||
| -rw-r--r-- | app/dispatch/context_processors.py | 10 | ||||
| -rw-r--r-- | app/dispatch/templates/dispatch/base.html | 4 | ||||
| -rw-r--r-- | app/dispatch/templates/dispatch/login.html | 21 |
5 files changed, 60 insertions, 4 deletions
diff --git a/app/app/settings.py b/app/app/settings.py index 59c7c1a..888d53b 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -64,6 +64,10 @@ if CONFIG.get('SET_EMAIL'): else: print("WARNING EMAIL SETTINGS NOT APPLIED. CHECK CONFIG") +TEMPLATE_VARS = {} +if CONFIG.get('TEMPLATE_VARS'): + TEMPLATE_VARS = CONFIG['TEMPLATE_VARS'] + ACCOUNT_ACTIVATION_DAYS = CONFIG['ACCOUNT_ACTIVATION_DAYS'] @@ -110,6 +114,7 @@ TEMPLATES = [ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', + 'dispatch.context_processors.additional_template_vars', ], }, }, diff --git a/app/config-example.yml b/app/config-example.yml index 09a23b9..958d2d0 100644 --- a/app/config-example.yml +++ b/app/config-example.yml @@ -49,3 +49,27 @@ EMAIL_HOST_USER: django@example.com EMAIL_PORT: 2525 EMAIL_USE_TLS: True DEFAULT_FROM_EMAIL: webmaster@localhost + +TEMPLATE_VARS: + app_name: Subcontractor Invoicing System Demo + login_blurb: Here's an example blurb above the sign-in box + login_info: ' + <p class="flow-text"> + Welcome to a demo Subcontractor Invoicing system. + </p> + <p class="flow-text"> + We can design a system that works specifically for your + use case. + </p> + <p class="flow-text"> + <a href="https://www.stridet.com/contact">Please contact us</a> + if you would like more information. This version has been + specifically designed for use by a trucking company. + </p> + </p> + ' + + + + + diff --git a/app/dispatch/context_processors.py b/app/dispatch/context_processors.py new file mode 100644 index 0000000..d6d50d5 --- /dev/null +++ b/app/dispatch/context_processors.py @@ -0,0 +1,10 @@ +from django.conf import settings + + +def additional_template_vars(request): + """ + A neat little hack to load up + additional variables into templates directly into the templates + """ + return {"template_vars": settings.TEMPLATE_VARS} + diff --git a/app/dispatch/templates/dispatch/base.html b/app/dispatch/templates/dispatch/base.html index efc9eb3..cac1b18 100644 --- a/app/dispatch/templates/dispatch/base.html +++ b/app/dispatch/templates/dispatch/base.html @@ -4,7 +4,7 @@ <html lang="en"> <head> <meta charset="UTF-8"> - <title>{% block title %}{% endblock %}</title> + <title>{% block title %}{{template_vars.app_name}}{% endblock %}</title> <!--Import Google Icon Font--> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <!--Import materialize.css--> @@ -34,7 +34,7 @@ <nav class="brown darken-3" role="navigation"> <div class="nav-wrapper container"> - <a id="logo-container" href="{% url 'home' %}" class="brand-logo">Dispatch Tracker</a> + <a id="logo-container" href="{% url 'home' %}" class="brand-logo">{{template_vars.app_name}}</a> <ul class="right hide-on-med-and-down"> {% include "dispatch/nav.html" %} </ul> diff --git a/app/dispatch/templates/dispatch/login.html b/app/dispatch/templates/dispatch/login.html index eb7f1a7..b3df716 100644 --- a/app/dispatch/templates/dispatch/login.html +++ b/app/dispatch/templates/dispatch/login.html @@ -4,11 +4,28 @@ <div class="container"> <br /> <div class="row"> - <div class="col s12 m8 push-m2 l6 push-l3"> + {% if template_vars.login_info %} + <div class="col s6"> + {% autoescape off %}{{template_vars.login_info}}{% endautoescape %} + </div> + <div class="col s6"> + {% else %} + <div class="col s12"> + {% endif %} + {% if template_vars.login_blurb %} + {% autoescape off %} + <div class="card"> + <div class="card-content"> + {{template_vars.login_blurb}} + </div> + </div> + {% endautoescape %} + {% endif %} + {% if form.errors %} <div class="card red lighten-5"> <div class="card-content red-text"> - Your username and password didn't match. Please try again. + Your username or password didn't match. Please try again. </div> </div> {% endif %} |
