Skip to content

Commit

Permalink
Functionality added for login and logout where REMOTE_USER is not used
Browse files Browse the repository at this point in the history
  • Loading branch information
profcturner committed Sep 18, 2018
1 parent a8e6626 commit 582f56f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions WAM/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"""
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.auth import views as auth_views


from loads import views

Expand All @@ -31,6 +33,8 @@

urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^accounts/login/$', auth_views.login, name='login'),
url(r'^accounts/logout/$', auth_views.logout, name='logout'),
url(r'^workpackage/change/$', views.workpackage_change, name='workpackage_change'),
url(r'^workpackage/migrate/$', views.workpackage_migrate, name='workpackage_migrate'),
url(r'^loads/$', views.loads, name='loads'),
Expand Down Expand Up @@ -68,6 +72,7 @@
url(r'^projects/generate_activities/(?P<project_id>[0-9]+)$', views.projects_generate_activities, name='projects_generate_activities'),
url(r'^staff/allocation/(?P<package_id>[0-9]+)/(?P<staff_id>[0-9]+)$', views.staff_module_allocation, name='staff_module_allocation'),
url(r'^forbidden/$', views.forbidden, name='forbidden'),
url(r'^logged_out/$', views.logged_out, name='logged out'),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', admin.site.urls),
url(r'^cadmin/$', views.custom_admin_index, name='custom_admin_index'),
Expand Down
5 changes: 5 additions & 0 deletions loads/templates/loads/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
<li class="menutop">
<a title="click to access section: Help" href="https://github.com/profcturner/WAM/wiki" target="_blank" >Help</a>
</li>
{% if not request.meta.remote_user %}
<li class="menutop">
<a title="click to access section: Help" href="{% url 'logout' %}">Logout</a>
</li>
{% endif %}


</ul>
Expand Down
7 changes: 7 additions & 0 deletions loads/templates/loads/logged_out.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% include "loads/header.html" %}

<h1>Logged Out</h1>

<p>Thanks for stopping by, you are now logged out.</p>

{% include "loads/footer.html" %}
12 changes: 12 additions & 0 deletions loads/templates/registration/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% include 'loads/header.html' %}

{% block content %}
<h2>Login</h2>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Login</button>
</form>
{% endblock %}

{% include 'loads/footer.html' %}
8 changes: 8 additions & 0 deletions loads/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ def forbidden(request):
return HttpResponse(template.render({}, request))


def logged_out(request):
"""Show that we are logged out"""

template = loader.get_template('loads/logged_out.html')

return HttpResponse(template.render({}, request))


@login_required
def download_assessment_resource(request, resource_id):
"""Download an assessment resource"""
Expand Down

0 comments on commit 582f56f

Please sign in to comment.