Skip to content

Commit

Permalink
[refs #120208] Use zope login/logout
Browse files Browse the repository at this point in the history
  • Loading branch information
dianaboiangiu committed Aug 27, 2020
1 parent dbad6f8 commit 4edd13c
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 45 deletions.
1 change: 1 addition & 0 deletions bdr/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@
BDR_EMAIL_FROM = env('BDR_EMAIL_FROM', 'bdr@localhost')

USE_ZOPE_LAYOUT = env('USE_ZOPE_LAYOUT', True)
USE_ZOPE_LOGIN = env('USE_ZOPE_LOGIN', False)

USE_SIDEMENU = env('USE_SIDEMENU', False)
BDR_SIDEMENU_URL=env('BDR_SIDEMENU_URL', '')
Expand Down
3 changes: 2 additions & 1 deletion docker/app.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ BDR_SIDEMENU_URL=
BDR_API_USER=
BDR_API_PASSWORD=

BDRREGISTRY_URL=
BDR_SERVER_URL=
USE_ZOPE_LAYOUT=True
USE_ZOPE_LOGIN=False

EMAIL_HOST=postfix
EMAIL_PASS=
Expand Down
4 changes: 3 additions & 1 deletion notifications/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ def debug(request):

def utils(request):
return {
"bcc_email_address": env('BCC', '')
'bcc_email_address': env('BCC', ''),
'USE_ZOPE_LOGIN': env('USE_ZOPE_LOGIN', ''),
'BDR_SERVER_URL': env('BDR_SERVER_URL', ''),
}
65 changes: 36 additions & 29 deletions notifications/templates/notifications/base_zope.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,34 @@
<body>
<div id="container">
<div id="toolribbon">
<div id="lefttools">
<a id="eealink" href="http://www.eea.europa.eu/">{% trans "EEA" %}</a>
<a id="ewlink" href="http://ew.eea.europa.eu/">{% trans "EnviroWindows" %}</a>
</div>
<div id="righttools">
{% if user.is_anonymous %}
<a id="loginlink" href="{% url 'notifications:accounts:login' %}?next={{ request.get_full_path }}">{% trans "Login" %}</a>
{% else %}
<a id="logoutlink" href="{% url 'notifications:accounts:logout' %}">{% trans "Logout" %} ({{ user.username }})</a>
{% endif %}

<a id="printlink" title="{% trans 'Print this page' %}" href="javascript:this.print();"><span>{% trans "Print" %}</span></a>
<a id="fullscreenlink" href="javascript:toggleFullScreenMode()" title="{% trans 'Switch to/from full screen mode' %}"><span>{% trans "Switch to/from full screen mode" %}</span></a>
</div>
<div id="lefttools">
<a id="eealink" href="http://www.eea.europa.eu/">{% trans "EEA" %}</a>
<a id="ewlink" href="http://ew.eea.europa.eu/">{% trans "EnviroWindows" %}</a>
</div>
<div id="righttools">
{% if user.is_anonymous %}
{% if USE_ZOPE_LOGIN %}
<a id="loginlink" href="{{ BDR_SERVER_URL }}Login/ldap_login?came_from={{ request.get_full_path }}">{% trans "Login" %}</a>
{% else %}
<a id="loginlink" href="{% url 'notifications:accounts:login' %}?next={{ request.get_full_path }}">{% trans "Login" %}</a>
{% endif %}
{% else %}
{% if USE_ZOPE_LOGIN %}
<a id="logoutlink" href="{{ BDR_SERVER_URL }}Login/ldap_logout">{% trans "Logout" %} ({{ user.username }})</a>
{% else %}
<a id="logoutlink" href="{% url 'notifications:accounts:logout' %}">{% trans "Logout" %} ({{ user.username }})</a>
{% endif %}
{% endif %}
<a id="printlink" title="{% trans 'Print this page' %}" href="javascript:this.print();"><span>{% trans "Print" %}</span></a>
<a id="fullscreenlink" href="javascript:toggleFullScreenMode()" title="{% trans 'Switch to/from full screen mode' %}"><span>{% trans "Switch to/from full screen mode" %}</span></a>
</div>
</div>

<div id="pagehead">
<a href="/" accesskey="1"><img src="https://www.eionet.europa.eu/styles/eionet2007/eea-print-logo.gif" alt="Logo" id="logo" /></a>
<div id="networktitle">{% trans 'Eionet' %}</div>
<div id="sitetitle">{% trans "Data reporting for business" %}</div>
<div id="sitetagline">{% trans "This site is part of the Reportnet" %}</div>
<div id="networktitle">{% trans 'Eionet' %}</div>
<div id="sitetitle">{% trans "Data reporting for business" %}</div>
<div id="sitetagline">{% trans "This site is part of the Reportnet" %}</div>
</div>

<div id="menuribbon"></div>
Expand All @@ -85,26 +92,26 @@

{% for item in view.breadcrumbs %}
<div class="breadcrumbitem{% if forloop.last %}last{% endif %}">
{% if item.url %}
<a href="{{ item.url }}">{{ item.title }}</a>
{% else %}
{{ item.title }}
{% endif %}
</div>
{% if item.url %}
<a href="{{ item.url }}">{{ item.title }}</a>
{% else %}
{{ item.title }}
{% endif %}
</div>
{% endfor %}
</div>

<div id="leftcolumn" class="localnav">
{% if USE_SIDEMENU %}
{% cache 3000 sidebar request.user %}
{% get_sidebar request.user %}
{% get_sidebar request.user %}
{% endcache %}
{% else %}
{% else %}
<h2>Services</h2>
<ul>
<li><a href="/" title="{% trans 'BDR home' %}">{% trans "BDR home" %}</a></li>
<li><a href="/searchdataflow" title="{% trans 'Search' %}">{% trans "Search" %}</a></li>
<li><a href="/help/fgases" title="{% trans 'Help F-gases' %}">{% trans "Help F-gases" %}</a></li>
<ul>
<li><a href="/" title="{% trans 'BDR home' %}">{% trans "BDR home" %}</a></li>
<li><a href="/searchdataflow" title="{% trans 'Search' %}">{% trans "Search" %}</a></li>
<li><a href="/help/fgases" title="{% trans 'Help F-gases' %}">{% trans "Help F-gases" %}</a></li>
<li><a href="/help/ods" title="{% trans 'Help ODS' %}">{% trans "Help ODS" %}</a></li>
<li><a href="/help/cars_vans" title="{% trans 'Help Cars and Vans' %}">{% trans "Help Cars and Vans" %}</a></li>
<li><a href="/help/dataconfidentiality" title="{% trans 'Confidentiality' %}">{% trans "Confidentiality" %}</a></li>
Expand Down
30 changes: 16 additions & 14 deletions notifications/templates/notifications/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,27 @@
{% block content %}

{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
<p>Your username and password didn't match. Please try again.</p>
{% endif %}

<h1>Login</h1>

<form method="post" action="{% url 'notifications:accounts:login' %}">
{% csrf_token %}
<table>
<tr>
<td>{{ form.username.label_tag }}</td>
<td>{{ form.username }}</td>
</tr>
<tr>
<td>{{ form.password.label_tag }}</td>
<td>{{ form.password }}</td>
</tr>
</table>
<input type="hidden" name="next" value="{{ next }}" />
<button type="submit">Login</button>
{% csrf_token %}

<table>
<tr>
<td>{{ form.username.label_tag }}</td>
<td>{{ form.username }}</td>
</tr>

<tr>
<td>{{ form.password.label_tag }}</td>
<td>{{ form.password }}</td>
</tr>
</table>
<input type="hidden" name="next" value="{{ next }}" />
<button type="submit">Login</button>
</form>

{% endblock %}
5 changes: 5 additions & 0 deletions notifications/views/breadcrumb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ class NotificationsBaseView(braces_views.StaffuserRequiredMixin,

login_url = reverse_lazy('notifications:accounts:login')

def __init__(self, *args, **kwargs):
if settings.USE_ZOPE_LOGIN:
self.login_url = "".join([settings.BDR_SERVER_URL,'Login/ldap_login?came_from='])
return super(NotificationsBaseView, self).__init__(*args, **kwargs)

def breadcrumbs(self):
return [
Breadcrumb(settings.BDR_SERVER_URL, 'BDR'),
Expand Down

0 comments on commit 4edd13c

Please sign in to comment.