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

Release 0.1.2 #73

Merged
merged 80 commits into from
Jul 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
62aa298
Merge pull request #55 from rl-institut/hotfix-server-init
Bachibouzouk May 22, 2019
00b6623
Merge pull request #62 from rl-institut/master
nesnoj Jun 28, 2019
2398a6d
add support for custom id in InfoButton widget
nesnoj Jun 28, 2019
37f55d6
update CHANGELOG
nesnoj Jun 28, 2019
20cd249
fix space around keyword argument assignment
nesnoj Jun 28, 2019
e0f35d3
Merge pull request #63 from rl-institut/features/info_button_custom_id
nesnoj Jun 28, 2019
41ec808
add exchangelib to requirements
nesnoj Jun 28, 2019
17b1175
Session errors are logged
henhuy Jun 28, 2019
2e5375a
Fixed pylint error (lazy-logging)
henhuy Jun 28, 2019
c25c12c
add feedback form view (+views for error and success)
nesnoj Jun 28, 2019
b907429
add templates for feedback form, success and error page
nesnoj Jun 28, 2019
97751cf
define django form for feedback
nesnoj Jun 28, 2019
2a4b472
pimp docstring
nesnoj Jun 28, 2019
05b4278
add feedback views to urls
nesnoj Jun 28, 2019
994bb96
get exchange mail cfg from env vars
nesnoj Jun 28, 2019
70a2ed6
add fct to send mail via exchange server
nesnoj Jun 28, 2019
4da01ee
move message preparation to view
nesnoj Jun 28, 2019
50db0e0
update CHANGELOG
nesnoj Jun 28, 2019
5c7e650
add feedback form to helpers doc
nesnoj Jun 29, 2019
41efb17
add email note in app.cfg to helpers doc
nesnoj Jun 29, 2019
af42c67
check for env vars' existence, redirect to error page if one or more …
nesnoj Jun 29, 2019
f4f7512
add different error types to feedback error view with corresponding m…
nesnoj Jun 29, 2019
dd0405b
include error type in urls
nesnoj Jun 29, 2019
cc30a41
use error text from context in feedback error template
nesnoj Jun 29, 2019
8a073d2
fix typo
nesnoj Jun 29, 2019
8e8cb66
pep8
nesnoj Jun 29, 2019
a59dee5
rm orphaned arg
nesnoj Jun 29, 2019
98c638d
fix import order
nesnoj Jun 29, 2019
762758a
fix travis: rm unnecessary else
nesnoj Jun 29, 2019
3340b5b
fix travis: rm unnecessary __init__
nesnoj Jun 29, 2019
5d2e6c8
add docstring to fct send_mail()
nesnoj Jun 29, 2019
38b135e
fix travis: rm args and kwargs
nesnoj Jun 30, 2019
a511b86
fix travis: disable too-many-ancestors err in FeedbackView
nesnoj Jun 30, 2019
b43ea6e
update CHANGELOG
nesnoj Jun 30, 2019
c3aa2da
Merge branch 'dev' into enhancement/session_error_log
nesnoj Jun 30, 2019
679e9fd
fix travis: add ignore on import-error and broad-except
nesnoj Jul 2, 2019
62ca879
fix pep8
nesnoj Jul 2, 2019
dd2440f
rm grid-x layout in template of InfoButton widget #66
nesnoj Jul 2, 2019
03bedf7
change icon in feedback error page
nesnoj Jul 2, 2019
779c4d0
fix name of WAM index page
nesnoj Jul 2, 2019
df13a07
fix name of WAM index page
nesnoj Jul 2, 2019
3a753e8
add css for orange warning background
nesnoj Jul 2, 2019
a068238
add generic error view and views for HTTP status code 404+500
nesnoj Jul 2, 2019
6ac14ce
add template for error view
nesnoj Jul 2, 2019
53ca201
add error handlers to urls (override django's default views)
nesnoj Jul 2, 2019
44c7896
rm feedback form from wam's URLs as it is to be used in apps only
nesnoj Jul 3, 2019
cc9c2ea
rm orphaned import
nesnoj Jul 3, 2019
f3ad5a4
use config file instead of env vars for exchange credentials
nesnoj Jul 3, 2019
ff7b906
add WAM exchange params to example config
nesnoj Jul 3, 2019
7b01c25
amend helpers doc
nesnoj Jul 3, 2019
82df80b
Merge pull request #68 from rl-institut/features/info_button_rm_gridx
nesnoj Jul 3, 2019
a2e3efe
Merge branch 'dev' into features/add_custom_404_and_500_pages
nesnoj Jul 3, 2019
a261608
Merge branch 'dev' into features/feedback_form
nesnoj Jul 3, 2019
971f5e6
Merge pull request #65 from rl-institut/features/feedback_form
nesnoj Jul 3, 2019
dad49e6
Merge branch 'dev' into features/add_custom_404_and_500_pages
nesnoj Jul 3, 2019
eba9364
Merge pull request #70 from rl-institut/features/add_custom_404_and_5…
nesnoj Jul 3, 2019
41f0bab
update CHANGELOG
nesnoj Jul 3, 2019
6005f80
Merge branch 'dev' into enhancement/session_error_log
nesnoj Jul 3, 2019
596f7db
update CHANGELOG for release v0.1.2
nesnoj Jul 3, 2019
d6b9248
Merge pull request #64 from rl-institut/enhancement/session_error_log
henhuy Jul 4, 2019
5484632
Merge branch 'dev' into release-0.1.2
henhuy Jul 4, 2019
42fecb0
Importing of additional settings are checked for duplicates
henhuy Jul 4, 2019
4834def
Merge branch 'release-0.1.2' into dev
nesnoj Jul 4, 2019
d52b06d
future-proof CHANGELOG.md #73
nesnoj Jul 4, 2019
a54db3b
Merge branch 'dev' into release-0.1.2
nesnoj Jul 4, 2019
4e3b5f0
add session error PR no to CHANGELOG.md #73
nesnoj Jul 4, 2019
89a0d4c
Merge branch 'release-0.1.2' into dev
nesnoj Jul 4, 2019
1f006c3
Merge branch 'dev' into fixes/duplicate_installed_apps
nesnoj Jul 4, 2019
02ef8de
Add explanation regarding javascript package binding at app level
Jul 5, 2019
595acff
generalize explanation of packages in settings
nesnoj Jul 5, 2019
3821ca3
add warning for config conflicts to getting started #74
nesnoj Jul 5, 2019
f8bf3f0
Merge pull request #75 from rl-institut/fixes/duplicate_installed_apps
nesnoj Jul 5, 2019
b547ed4
Merge branch 'dev' into release-0.1.2
nesnoj Jul 5, 2019
09a1948
Merge branch 'release-0.1.2' into dev
nesnoj Jul 5, 2019
ba432f2
custom error views now return the correct http status code
nesnoj Jul 5, 2019
4f18c8e
fix: switch from class- to function-based views for custom error page…
nesnoj Jul 5, 2019
ec9f05c
Merge branch 'fixes/custom_404_and_500_pages_func_based' into release…
nesnoj Jul 5, 2019
366fb89
fix travis: add ignore on unused-argument in custom error handles
nesnoj Jul 5, 2019
6b759a5
Merge branch 'fixes/custom_404_and_500_pages_func_based' into release…
nesnoj Jul 5, 2019
6daf795
update CHANGELOG
nesnoj Jul 5, 2019
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
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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing a password in an uncrypted file???

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have a better idea right now as stated in #65. Hashes do not make sense here.
Do you?

As a first step, we should change config file permissions on the server to 600 (-rw-------). Agree, @henhuy?


[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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have the text content of these form in english as well, no?

We should in any case avoid to mix the two languages within the WAM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, I'd keep it for now but we should refactor all language-related stuff as you recommended in #76 later.

{% 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