Skip to content

Commit

Permalink
Merge pull request #73 from rl-institut/release-0.1.2
Browse files Browse the repository at this point in the history
Release 0.1.2
  • Loading branch information
nesnoj authored Jul 5, 2019
2 parents 9864b7a + 6daf795 commit 841e54f
Show file tree
Hide file tree
Showing 19 changed files with 488 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .config/config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
ALLOWED_HOSTS=127.0.0.1
SECRET_KEY=<secret_key>
DJANGO_DB=DEFAULT
WAM_EXCHANGE_ACCOUNT=<Microsoft Exchange Account, e.g. [email protected]>
WAM_EXCHANGE_EMAIL=<Microsoft Exchange E-Mail Adress, e.g. [email protected]>
WAM_EXCHANGE_PW=<Microsoft Exchange Account Password>

[DATABASES]
[[DEFAULT]]
Expand Down
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,28 @@ Here is a template for new release sections
```
## [Unreleased]

### Added

### Changed

## [0.1.2] 2019-07-04

### Added
- CHANGELOG.md
- CONTRIBUTING.md
- continuous integration with TravisCI (`.travis.yml`)
- linting tests and their config files (`.pylintrc` and `.flake8`)
- tests/ folder
- add session error logging #64
- support custom id in InfoButton widget #63
- add feedback form #65
- add custom 404 and 500 error pages #70

### Changed
- fix flake8 and pylint errors
- environnement.yml installs dependencies from requirements.txt so that conda is not required
- fix grid-x layout error in InfoButton widget #66
- fix: avoid reimport of modules if multiple apps use the same #75

## [0.1.1] 2019-05-22

Expand All @@ -54,4 +66,4 @@ Here is a template for new release sections
- fixed flake8 and pylint errors
- environment.yml installs dependencies
- if the environment variable WAM_CONFIG_PATH or WAM_APPS do not exist, the user is prompted with a meaningful error message
- if WAM_APPS is an empty string, the app loads until the start page.
- if WAM_APPS is an empty string, the app loads until the start page.
16 changes: 15 additions & 1 deletion doc/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,22 @@ Requirements:

Additional setups:

- *settings.py* can setup additional parameters for projects *settings.py*
- *settings.py* can setup additional parameters for projects *settings.py*.
If your app requires the use of additional packages, you should list them in the settings.py of your app (not the settings.py file form wam core) in the following way

.. code:: python
INSTALLED_APP = ['package1', 'package2']
Then, wam core will manage the packages' installation and avoid duplicate installations between the different apps.


- *app_settings.py* contains application specific settings and is loaded at start of django server at the end of *settings.py*. This file may include additional database connections, loading of config files needed for the application, etc.


.. warning:: Avoid using config variables for packages in your app as it may override or get overridden by package config of other app!


- *labels.cfg* (uses configobj_) supports easy adding of labels to templates via templatetags (see :ref:`label_tags`)


Expand Down
36 changes: 36 additions & 0 deletions doc/helpers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,42 @@ Additionally, the label template tag supports two attributes:
If no label is found or given (sub-) section is not found, *None* will be returned.


Feedback Form
-------------

A feedback form is available which can be used in all apps. The feedback is send via e-mail using an Exchange account.
Required configuration parameters for the Exchange account are *WAM_EXCHANGE_ACCOUNT*, *WAM_EXCHANGE_EMAIL* and
*WAM_EXCHANGE_PW*. They must be set in the *[WAM]* section of the *config.cfg* file, see :ref:`configuration_file` for
details.

To use the form, just add the view to your urls like

.. code:: python
# my_app/urls.py
from utils.views import FeedbackView
admin_url_patterns = [
path(<path to other view>),
...,
path('feedback/', FeedbackView.as_view(app_name='<my app name>'), name='feedback')
]
Make sure you have the parameter ``email`` set in your *app.cfg*, example:

.. code:: text
# my_app/app.cfg
category = app
name = ...
icon = ...
email = '[email protected]'
This address is used to send feedback messages for the app.
If the Exchange account or app admin's e-mail address is not configured correctly, the user will be redirected to an
error page.

.. _custom_admin_site:

Customizing Admin Site
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pandas
whitenoise
celery
configobj
exchangelib
django-markdownx
django-crispy-forms
psycopg2-binary
Expand Down
3 changes: 3 additions & 0 deletions static/foundation/css/app.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions templates/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

{% extends 'base.html' %}

{% load static %}

{% block content %}
<div class="u-vh--100">

<main>

<section class="grid-x l-bg-color hp-hero">
<div class="cell u-text--center">
<img src="{% static '/img/logos/WAM_logo_w.png' %}" alt="Logo WAM" class="hp_wam_img">
</div>
</section>

<section class="grid-x align-center l-bg-color--error hp-features">
<div class="cell large-10">
<div class="grid-x align-center">
<h2><i class='icon ion-alert-circled icon--large'></i> {{ err_text }}</h2>
</div>
</div>
</section>

</main>


<footer class="footer-hp l-bg-color--w">
<div class="grid-x">

<div class="cell footer-hp__logo">
<ul>
<li>
<a href="{% url 'index' %}" rel=”noopener” title="WAM-Startseite">
<img class="footer-hp__logo-wam" src="{% static '/img/logos/WAM_logo.png' %}" alt="Logo WAM">
</a>
</li>
<li>
<a href="https://reiner-lemoine-institut.de/" target="_blank" rel=”noopener noreferrer” title="Reiner Lemoine Institut">
<img class="footer-hp__logo-rli" src="{% static 'img/rli_logo.png' %}" alt="Logo Reiner Lemoine Institut">
</a>
</li>
</ul>
</div>

<div class="cell medium-10 medium-offset-1">
<ul class="u-text--center" id="footer-links">
<li><a class="anchor-text--dark" href="{% url 'contact' %}">Kontakt</a></li>
<li><a class="anchor-text--dark" href="{% url 'impressum' %}">Impressum</a></li>
<li><a class="anchor-text--dark" href="{% url 'privacy' %}">Datenschutz</a></li>
<li class="hide-for-small-only">
<p class="u-no-margin">&copy; Reiner Lemoine Institut gGmbH</p>
</li>
</ul>
</div>

</div>
</footer>

</div>
{% endblock %}
60 changes: 60 additions & 0 deletions templates/feedback.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{% extends 'base.html' %}

{% load static %}
{% block content %}
<div class="u-vh--100">
<main>
<section class="grid-x align-center l-bg-color--light hp-features">
<div class="cell medium-8 large-6">
<h1><i class='icon ion-chatbubbles icon--large'></i> Ihr Feedback</h1>
<p><strong>App: <a href="../" class="u-padding-top--l u-padding-bt--l">{{ app_name }}</a></strong></p>
{% if intro_text %}
<p>{{ intro_text }}</p>
{% else %}
<p>Hier können Sie uns eine Rückmeldung zur App geben, wir freuen uns über Ihre Nachricht!</p>
{% endif %}

<form method="post">
{% csrf_token %}
{{ form }}
<button class="btn btn-cta" type="submit" style="float: right;">Abschicken</button>
</form>
</div>
</section>
</main>

<footer class="footer-hp l-bg-color--w">
<div class="grid-x">

<div class="cell footer-hp__logo">
<ul>
<li>
<a href="{% url 'index' %}" rel=”noopener” title="WAM-Startseite">
<img class="footer-hp__logo-wam" src="{% static '/img/logos/WAM_logo.png' %}" alt="Logo WAM">
</a>
</li>
<li>
<a href="https://reiner-lemoine-institut.de/" target="_blank" rel=”noopener” title="Reiner Lemoine Institut">
<img class="footer-hp__logo-rli" src="{% static 'img/rli_logo.png' %}" alt="Logo Reiner Lemoine Institut">
</a>
</li>
</ul>
</div>

<div class="cell medium-10 medium-offset-1">
<ul class="u-text--center" id="footer-links">
<li><a class="anchor-text--dark" href="{% url 'contact' %}">Kontakt</a></li>
<li><a class="anchor-text--dark" href="{% url 'impressum' %}">Impressum</a></li>
<li><a class="anchor-text--dark" href="{% url 'privacy' %}">Datenschutz</a></li>
<li class="hide-for-small-only">
<p class="u-no-margin">&copy; Reiner Lemoine Institut gGmbH</p>
</li>
</ul>
</div>

</div>
</footer>

</div>

{% endblock %}
10 changes: 10 additions & 0 deletions templates/feedback_error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% extends 'base.html' %}

{% block content %}
<div class="grid-x grid-padding-x align-center">
<div class="cell medium-8 large-6">
<h1><i class='icon ion-alert-circled icon--large'></i> {{ error_text }}</h1>
<p><a href="{% url 'index' %}" class="u-padding-top--l u-padding-bt--l">Zur WAM-Startseite</a></p>
</div>
</div>
{% endblock %}
10 changes: 10 additions & 0 deletions templates/feedback_successful.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% extends 'base.html' %}

{% block content %}
<div class="grid-x grid-padding-x align-center">
<div class="cell medium-8 large-6">
<h1><i class='icon ion-chatbubbles icon--large'></i> Vielen Dank für Ihr Feedback!</h1>
<p><a href="{% url 'index' %}" class="u-padding-top--l u-padding-bt--l">Zur WAM-Startseite</a></p>
</div>
</div>
{% endblock %}
4 changes: 1 addition & 3 deletions templates/widgets/info_button.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
<i data-open="{{info_id}}" class="icon {{ionicon_type}} icon--{{ionicon_size}} info-box" {% if ionicon_color is not None %}style="color: {{ionicon_color}};"{% endif %} title="{{tooltip}}"></i>
</span>
<div class="reveal" id="{{info_id}}" data-reveal>
<div class="grid-x">
{{text|safe}}
</div>
{{text|safe}}
<button class="close-button" data-close aria-label="Schließen" type="button">
<span aria-hidden="true">&times;</span>
</button>
Expand Down
18 changes: 18 additions & 0 deletions user_sessions/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import logging

from django.shortcuts import render

from wam.settings import SESSION_DATA
from utils.shortcuts import get_app_from_request


def check_session_method(func):
Expand All @@ -13,6 +16,7 @@ def func_wrapper(self, request, *args, **kwargs):
try:
session = SESSION_DATA.get_session(request)
except KeyError:
log_session_error(request)
return render(request, 'stemp/session_not_found.html')
return func(self, request, session=session, *args, **kwargs)
return func_wrapper
Expand All @@ -28,6 +32,20 @@ def func_wrapper(request, *args, **kwargs):
try:
session = SESSION_DATA.get_session(request)
except KeyError:
log_session_error(request)
return render(request, 'stemp/session_not_found.html')
return func(request, session=session, *args, **kwargs)
return func_wrapper


def log_session_error(request):
app = get_app_from_request(request)
err_msg = (
f'Session error for app "{app}":\n'
f'Session-Key: {request.session.session_key}\n'
f'Current session data:\n' +
'\n'.join(
[f'{k}: {str(v)}' for k, v in SESSION_DATA.sessions[app].items()]
)
)
logging.error(err_msg)
19 changes: 19 additions & 0 deletions utils/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from django import forms


class FeedbackForm(forms.Form):
"""Input form for feedback page"""
from_name = forms.CharField(required=False,
max_length=100,
label='Ihr Name (optional)')
from_email = forms.EmailField(required=False,
label='Ihre E-Mail-Adresse (optional)')
subject = forms.CharField(required=True,
max_length=100,
label='Betreff')
message = forms.CharField(widget=forms.Textarea,
required=True,
label='Ihr Feedback')

def submit(self):
pass
Loading

0 comments on commit 841e54f

Please sign in to comment.