Set up authentication system

This commit is contained in:
tjp03u
2014-10-23 22:13:03 +01:00
parent e10021d47b
commit 4540be7ecf
41 changed files with 705 additions and 1 deletions

6
templates/404.html Normal file
View File

@@ -0,0 +1,6 @@
{% extends 'base.html' %}
{% block title %}Page not found{% endblock %}
{% block content %}
The page you requested could not be found.
{% endblock %}

6
templates/500.html Normal file
View File

@@ -0,0 +1,6 @@
{% extends 'base.html' %}
{% block title %}Server error{% endblock %}
{% block content %}
There was an error while handling your request.
{% endblock %}

138
templates/base.html Normal file
View File

@@ -0,0 +1,138 @@
{% load static from staticfiles %}
<!DOCTYPE html>
<html
dir="{% if LANGUAGE_BIDI %}rtl{% else %}ltr{% endif %}"
xml:lang="{% firstof LANGUAGE_CODE 'en' %}"
lang="{% firstof LANGUAGE_CODE 'en' %}">
<head>
<title>{% block title %}{% endblock %} | Rig Information Gathering System</title>
<meta name="viewport" content="initial-scale=1">
<link rel="stylesheet" type="text/css" href="{% static "css/screen.css" %}">
{% block css %}
{% endblock %}
{% block preload_js %}
{% endblock %}
{% block extra-head %}{% endblock %}
</head>
<body>
<div class="navbar navbar-fixed-top navbar-inverse hidden-print" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">RIGS</a>
</div>
<div class="navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="/">Home</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Rigboard<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Rigboard</a></li>
<li><a href="#">Calendar</a></li>
<li><a href="#">Bookings</a></li>
<li><a href="#">Other Events</a></li>
</ul>
</li>
{% if perms.RIGS.view_vatrate or perms.RIGS.view_invoice %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Finance<b class="caret"></b>
</a>
<ul class="dropdown-menu">
{% if perms.RIGS.view_invoice %}
<li><a href="">Invoices</a></li>
{% endif %}
{% if perms.RIGS.view_vatrate %}
<li><a href="">VAT</a></li>
{% endif %}
</ul>
</li>
{% endif %}
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
{% if user.is_authenticated %}
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-user"></span>
Hi {{ user.first_name }}
<b class="caret"></b>
</a>
<ul class="dropdown-menu nav media-list pull-right" id="userdropdown">
<li class="media">
<span class="pull-left">
<img src="{{ request.user.profile_picture }}" class="media-object" />
</span>
<div class="media-body">
<b>{{ request.user.first_name }} {{ request.user.last_name }}</b>
<p class="muted">{{ request.user.email }}</p>
</div>
</li>
<li>
<a href="{% url 'logout' %}" class="btn btn-primary pull-right">Logout</a>
</li>
</ul>
{% else %}
<a href="{% url 'login' %}?next={{ request.build_absolute_uri }}">
<span class="icon-user"></span>
Hi guest
</a>
{% endif %}
</li>
</ul>
</div>
</div>
</div>
<div class="container">
<div id="content" class="row">
{% block content-header %}
{% if error %}<div class="error">{{ error }}</div>{% endif %}
{% if info %}<div class="info">{{ info }}</div>{% endif %}
{% if messages %}
{% for message in messages %}
<div class="info">{{ message }}</div>
{% endfor %}
{% endif %}
{% endblock %}
{% block content %}{% endblock %}
</div>
<div id="sidebar" class="column">
{% block sidebar %}
{% endblock %}
</div>
</div>
<script src="//code.jquery.com/jquery-latest.min.js"></script>
<script>
Date.prototype.getISOString = function() {
var yyyy = this.getFullYear().toString();
var mm = (this.getMonth()+1).toString(); // getMonth() is zero-based
var dd = this.getDate().toString();
return yyyy + '-' + (mm[1]?mm:"0"+mm[0]) + '-' + (dd[1]?dd:"0"+dd[0]); // padding
};
</script>
<script src="{% static "js/jquery.cookie.js" %}"></script>
<script src="{% static "js/alert.js" %}"></script>
<script src="{% static "js/collapse.js" %}"></script>
<script>
$('.navbar-collapse').addClass('collapse')
</script>
<script src="{% static "js/dropdown.js" %}"></script>
{% block js %}
{% endblock %}
</body>
</html>

View File

@@ -0,0 +1,8 @@
{% if messages %}
{% for message in messages %}
<script>{{message|safe}}</script>
{% endfor %}
{% endif %}
<script>
$('.modal').modal('hide');
</script>

View File

@@ -0,0 +1,14 @@
{% load nice_errors from filters %}
{% if form.errors %}
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<dl class="dl-horizontal">
{% with form|nice_errors as qq %}
{% for error_name,desc in qq.items %}
<dt>{{error_name}}</dt>
<dd>{{desc}}</dd>
{% endfor %}
{% endwith %}
</dl>
</div>
{% endif %}

27
templates/pagination.html Normal file
View File

@@ -0,0 +1,27 @@
{% if is_paginated %}
<div>
<ul class="pagination">
{% if page_obj.has_previous %}
<li><a href="?page{{ page_obj.previous_page_number }}{{ getvars }}{{ hashtag }}" class="prev">&lsaquo;&lsaquo;</a></li>
{% else %}
<li class="disabled prev"><a href="#">&lsaquo;&lsaquo;</a></li>
{% endif %}
{% for page in pages %}
{% if page %}
{% ifequal page page_obj.number %}
<li class="current page active"><a href="#">{{ page }}</a></li>
{% else %}
<li><a href="?page={{ page }}{{ getvars }}{{ hashtag }}" class="page">{{ page }}</a></li>
{% endifequal %}
{% else %}
...
{% endif %}
{% endfor %}
{% if page_obj.has_next %}
<li><a href="?page={{ page_obj.next_page_number }}{{ getvars }}{{ hashtag }}" class="next">&rsaquo;&rsaquo;</a></li>
{% else %}
<li class="disabled next"><a href="#">&rsaquo;&rsaquo;</a></li>
{% endif %}
</ul>
</div>
{% endif %}

View File

@@ -0,0 +1,12 @@
{% load url from future %}
Welcome {{ profile.first_name }},
You request to become a user on {{ site }} has been approved by an administrator.
To continue the registration process please visit http://{{ site.domain }}{% url 'registration_activate' activation_key=activation_key %}.
This link will be active for the next {{ expiration_days }} days.
{% if message %}
Message from administrator:
{{ message }}
{% endif %}

View File

@@ -0,0 +1 @@
{{ site }} user {{ user }} activation {{ activation_key }}

View File

@@ -0,0 +1,10 @@
{% extends 'base.html' %}
{% block title %}Activation Complete{% endblock %}
{% block content %}
<div class="alert alert-success">
<h2>Activation Complete</h2>
<p>You user account is now fully registered. Enjoy RIGS</p>
</div>
{% endblock %}

View File

@@ -0,0 +1,5 @@
Congratulations {{ user.first_name }}. You are now fully registered on {{ site }}.
{% if is_generated %}
You password for this site has been automatically set to {{ password }}. It is recommend you change this as soon as possible.
{% endif %}

View File

@@ -0,0 +1 @@
{{ user }} activation successful

View File

@@ -0,0 +1,17 @@
{% extends 'base.html' %}
{% load widget_tweaks %}
{% block title %}Activation{% endblock %}
{% block content %}
<form action="" method="post" class="form-horizontal" role="form">{% csrf_token %}
{% for field in form %}
<div class="form-group">
<label for="{{ field.id_for_label }}" class="control-label col-sm-2">{{ field.label }}</label>
<div class="controls col-sm-10">
{% render_field field class+="form-control" placeholder=field.label %}
</div>
</div>
{% endfor %}
<p><input type="submit" value="Activate Account" class="btn btn-primary pull-right"></p>
</form>
{% endblock %}

View File

@@ -0,0 +1,10 @@
{% extends 'base.html' %}
{% block title %}Logout Successful{% endblock %}
{% block content %}
<div class="alert alert-success">
<h2>Logout Successful</h2>
<p>You have successfully been logged out of RIGS</p>
</div>
{% endblock %}

View File

@@ -0,0 +1,7 @@
{% extends 'base.html' %}
{% block title %}Login{% endblock %}
{% block content %}
{% include 'registration/loginform.html' %}
{% endblock %}

View File

@@ -0,0 +1,22 @@
{% load url from future %}
{% load widget_tweaks %}
{% if form.errors %}
<div class="error">Your username or password was incorrect</div>
{% endif %}
<div class="col-md-4 col-md-offset-4">
<form action="{% url 'login' %}" method="post" role="form">{% csrf_token %}
<div class="form-group">
<label for="id_username">{{ form.username.label }}</label>
{% render_field form.username class+="form-control" placeholder=form.username.label %}
</div>
<div class="form-group">
<label for="{{ form.password.id_for_label }}">{{ form.password.label }}</label>
{% render_field form.password class+="form-control" placeholder=form.password.label %}
</div>
<a href="{% url 'registration_register' %}" class="btn">Register</a>
<a href="{% url 'password_reset' %}" class="btn">Forgotten Password</a>
<input type="submit" value="Login" class="btn btn-primary" />
<input type="hidden" name="next" value="{{next}}" />
</form>
</div>

View File

@@ -0,0 +1,3 @@
A new user has just registered on {{ site }} with username {{ user.username }} and email {{ user.email }}.
Please visit {{ site.domain }}{% url admin:registration_registrationprofile_change user.registration_profile.id %} to moderate this activation.

View File

@@ -0,0 +1 @@
{{ site }} New User Approval Require

View File

@@ -0,0 +1,56 @@
{% extends "admin/base_site.html" %}
{% load i18n static %}
{% load url from future %}
{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />{% endblock %}
{% block userlinks %}{% url 'django-admindocs-docroot' as docsroot %}{% if docsroot %}<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> / {% endif %} {% trans 'Change password' %} / <a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>{% endblock %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
&rsaquo; {% trans 'Password change' %}
</div>
{% endblock %}
{% block title %}{% trans 'Password change' %}{% endblock %}
{% block content %}<div id="content-main">
<form action="" method="post">{% csrf_token %}
<div>
{% if form.errors %}
<p class="errornote">
{% blocktrans count counter=form.errors.items|length %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
</p>
{% endif %}
<h1>{% trans 'Password change' %}</h1>
<p>{% trans "Please enter your old password, for security's sake, and then enter your new password twice so we can verify you typed it in correctly." %}</p>
<fieldset class="module aligned wide">
<div class="form-row">
{{ form.old_password.errors }}
<label for="id_old_password" class="required">{% trans 'Old password' %}:</label>{{ form.old_password }}
</div>
<div class="form-row">
{{ form.new_password1.errors }}
<label for="id_new_password1" class="required">{% trans 'New password' %}:</label>{{ form.new_password1 }}
</div>
<div class="form-row">
{{ form.new_password2.errors }}
<label for="id_new_password2" class="required">{% trans 'Password (again)' %}:</label>{{ form.new_password2 }}
</div>
</fieldset>
<div class="submit-row">
<input type="submit" value="{% trans 'Change my password' %}" class="default" />
</div>
<script type="text/javascript">document.getElementById("id_old_password").focus();</script>
</div>
</form></div>
{% endblock %}

View File

@@ -0,0 +1,23 @@
{% extends "base.html" %}
{% load i18n %}
{% load url from future %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
&rsaquo; {% trans 'Password reset' %}
</div>
{% endblock %}
{% block title %}{% trans 'Password reset complete' %}{% endblock %}
{% block content %}
<div class="col-sm-12">
<h1>{% trans 'Password reset complete' %}</h1>
<p>{% trans "Your password has been set. You may go ahead and log in now." %}</p>
<p><a href="{{ login_url }}">{% trans 'Log in' %}</a></p>
</div>
{% endblock %}

View File

@@ -0,0 +1,61 @@
{% extends "base.html" %}
{% load i18n %}
{% load widget_tweaks %}
{% load url from future %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
&rsaquo; {% trans 'Password reset confirmation' %}
</div>
{% endblock %}
{% block title %}{% trans 'Password reset' %}{% endblock %}
{% block content %}
{% if validlink %}
<div class="col-sm-12">
<h1>{% trans 'Enter new password' %}</h1>
<p>{% trans "Please enter your new password twice so we can verify you typed it in correctly." %}</p>
<div class="col-sm-8 col-sm-offset-2 well">
<form action="" method="post" role="form" class="form-horizontal">{% csrf_token %}
{% if form.errors %}
{% include 'form_errors.html' %}
{% endif %}
<div class="form-group">
<label for="{{form.new_password1.id_for_label}}" class="col-sm-4 control-label">{{form.new_password1.label}}</label>
<div class="col-sm-8">
{% render_field form.new_password1 class+="form-control" %}
</div>
</div>
<div class="form-group">
<label for="{{form.new_password2.id_for_label}}" class="col-sm-4 control-label">{{form.new_password2.label}}</label>
<div class="col-sm-8">
{% render_field form.new_password2 class+="form-control" %}
</div>
</div>
<div class="col-sm-12">
<div class="pull-right">
<div class="form-group">
<input type="submit" value="{% trans 'Change my password' %}" class="btn btn-primary" />
</div>
</div>
</div>
</form>
</div>
{% else %}
<h1>{% trans 'Password reset unsuccessful' %}</h1>
<p>{% trans "The password reset link was invalid, possibly because it has already been used. Please request a new password reset." %}</p>
</div>
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,20 @@
{% extends "base.html" %}
{% load i18n %}
{% load url from future %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
&rsaquo; {% trans 'Password reset' %}
</div>
{% endblock %}
{% block title %}{% trans 'Password reset successful' %}{% endblock %}
{% block content %}
<div class="col-sm-12">
<h1>{% trans 'Password reset successful' %}</h1>
<p>{% trans "We've e-mailed you instructions for setting your password to the e-mail address you submitted. You should be receiving it shortly." %}</p>
</div>
{% endblock %}

View File

@@ -0,0 +1,14 @@
{% load i18n %}{% load url from future %}{% autoescape off %}
{% blocktrans %}You're receiving this e-mail because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}
{% trans "Please go to the following page and choose a new password:" %}
{% block reset_link %}
{{ protocol }}://{{ domain }}{% url 'auth_password_reset_confirm' uidb64=uid token=token %}
{% endblock %}
{% trans "Your username, in case you've forgotten:" %} {{ user.username }}
{% trans "Thanks for using our site!" %}
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
{% endautoescape %}

View File

@@ -0,0 +1,34 @@
{% extends 'base.html' %}
{% load i18n %}
{% load widget_tweaks %}
{% block title %}Password reset{% endblock %}
{% block content %}
<div class="col-sm-12">
<h1>Password Reset</h1>
<p>{% trans "Forgotten your password? Enter your e-mail address below, and we'll e-mail instructions for setting a new one." %}</p>
<div class="col-sm-8 col-sm-offset-2 well">
<form action="" method="POST" role="form" class="form-horizontal">{% csrf_token %}
{% if form.errors %}
{% include 'form_errors.html' %}
{% endif %}
<div class="form-group">
<label for="{{form.email.id_for_label}}" class="col-sm-2 control-label">{{form.email.label}}</label>
<div class="col-sm-10">
{% render_field form.email type="email" class+="form-control" %}
</div>
</div>
<div class="col-sm-12">
<div class="pull-right">
<div class="form-group">
<input type="submit" value="Submit" class="btn btn-primary" />
</div>
</div>
</div>
</form>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,10 @@
{% extends 'base.html' %}
{% block title %}Registration complete{% endblock %}
{% block content %}
<div class="alert alert-success">
<h2>Thanks for registering</h2>
<p>Thanks for registering with RIGS, you application will now be moderated by an administrator and further instructions will be emailed to you</p>
</div>
{% endblock %}

View File

@@ -0,0 +1,3 @@
You account has been created but now requires approval by one of our moderation team.
Please wait while this is done.

View File

@@ -0,0 +1 @@
{{ site }} User Awaiting Approval

View File

@@ -0,0 +1,32 @@
{% extends 'base.html' %}
{% load widget_tweaks %}
{% block title %}Registration{% endblock %}
{% block content %}
{% if form.errors or supplement_form.errors %}
<div class="alert alert-danger">
{{form.errors}}
{{supplement_form.errors}}
</div>
{% endif %}
<form action="" method="post" class="form-horizontal" role="form">{% csrf_token %}
{% for field in form %}
<div class="form-group">
<label for="{{ field.id_for_label }}" class="control-label col-sm-2">{{ field.label }}</label>
<div class="controls col-sm-10">
{% render_field field class+="form-control" placeholder=field.label %}
</div>
</div>
{% endfor %}
{% for field in supplement_form %}
<div class="form-group">
<label for="{{ field.id_for_label }}" class="control-label col-sm-2">{{ field.label }}</label>
<div class="controls col-sm-10">
{% render_field field class+="form-control" placeholder=field.label %}
</div>
</div>
{% endfor %}
<p><input type="submit" value="Register" class="btn btn-primary pull-right"></p>
</form>
{% endblock %}