Skip to content

Commit

Permalink
Merge pull request #130 from gaiaresources/aesthetic_changes
Browse files Browse the repository at this point in the history
Aesthetic changes and bug fixes
  • Loading branch information
serge-gaia committed Oct 28, 2016
2 parents 56fb6fc + e9d5247 commit 52517b4
Show file tree
Hide file tree
Showing 41 changed files with 730 additions and 385 deletions.
85 changes: 82 additions & 3 deletions wildlifelicensing/apps/applications/mixins.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import datetime

from django.core.urlresolvers import reverse_lazy
from django.contrib.auth.mixins import UserPassesTestMixin

Expand All @@ -9,7 +11,7 @@ class UserCanEditApplicationMixin(UserPassesTestMixin):
"""
CBV mixin that check that the user is the applicant and that the status of the application is
in editable mode.
This mixin assume that the url contains the pk of the application on 2nd position.
If the user is not logged-in it redirects to the login page, else it throws a 403
Officers can edit an application
"""
Expand All @@ -25,7 +27,7 @@ def get_application(self):

def test_func(self):
"""
implementation of the UserPassesTestMixin test_func
implementation of the UserCanEditApplicationMixin test_func
"""
user = self.request.user
if not user.is_authenticated():
Expand All @@ -41,6 +43,83 @@ def test_func(self):
return True


class UserCanRenewApplicationMixin(UserPassesTestMixin):
"""
CBV mixin that check that the user is the applicant and that the application is renewable.
If the user is not logged-in it redirects to the login page, else it throws a 403
Officers can edit an application
"""
login_url = reverse_lazy('home')
permission_denied_message = "You don't have the permission to access this resource."
raise_exception = True

def get_application(self):
if self.args:
return Application.objects.filter(licence=self.args[0]).first()
else:
return None

def test_func(self):
"""
implementation of the UserCanRenewApplicationMixin test_func
"""
user = self.request.user
if not user.is_authenticated():
self.raise_exception = False
return False
if is_officer(user):
return True
self.raise_exception = True
application = self.get_application()
if application is not None:
if application.applicant != user:
return False

expiry_days = (application.licence.end_date - datetime.date.today()).days
return expiry_days <= 30 and application.licence.is_renewable
else:
return False


class UserCanAmendApplicationMixin(UserPassesTestMixin):
"""
CBV mixin that check that the user is the applicant and that the application is amendable.
If the user is not logged-in it redirects to the login page, else it throws a 403
Officers can edit an application
"""
login_url = reverse_lazy('home')
permission_denied_message = "You don't have the permission to access this resource."
raise_exception = True

def get_application(self):
if self.args:
return Application.objects.filter(licence=self.args[0]).first()
else:
return None

def test_func(self):
"""
implementation of the UserCanAmendApplicationMixin test_func
"""
user = self.request.user
if not user.is_authenticated():
self.raise_exception = False
return False
if is_officer(user):
return True
self.raise_exception = True
application = self.get_application()
if application is not None:
if application.applicant != user:
return False

return application.licence.end_date >= datetime.date.today()
else:
return False


class CanPerformAssessmentMixin(UserPassesTestMixin):
"""
CBV mixin that check the 'editability' of assessment that the user is a assessor and that he/she belongs to the right assessor group.
Expand Down Expand Up @@ -74,7 +153,7 @@ def test_func(self):

class UserCanViewApplicationMixin(UserPassesTestMixin):
"""
CBV mixin that check that the user is the applicant or an officer and that the status of the
CBV mixin that check that the user is the applicant or an officer and that the status of the
application is in approved mode.
If the user is not logged-in it redirects to the login page, else it throws a 403
"""
Expand Down
4 changes: 2 additions & 2 deletions wildlifelicensing/apps/applications/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ def can_user_view(self):
@property
def is_senior_offer_applicable(self):
return self.licence_type.senior_applicable and \
self.applicant.is_senior and \
bool(self.applicant.senior_card)
self.applicant.is_senior and \
bool(self.applicant.senior_card)

def log_user_action(self, action, request):
return ApplicationUserAction.log_action(self, action, request.user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ hr {

a {
cursor: pointer;
}
}intro

/* enter details / preview */
{% load bootstrap3 %}

#sectionList > ul > .active {
font-weight: bold;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% extends 'wl/base.html' %}

{% load static %}

{% block extra_css %}
<link href="{% static 'wl/css/applications.css' %}" rel="stylesheet"/>
{% endblock %}

{% block intro %}
<div class="container bottom-buffer">
<div class="top-buffer bottom-buffer intro applications">
{% block intro_title %}{% endblock %}
{% block intro_subtitle %}{% endblock %}
</div>
{% block intro_text%}{% endblock %}
<hr>
</div>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'wl/base.html' %}
{% extends 'wl/applications_base.html' %}

{% load static %}

Expand All @@ -10,7 +10,7 @@
<link href="//static.dpaw.wa.gov.au/static/libs/select2/3.5.3/select2.min.css" rel="stylesheet"/>
<link href="//static.dpaw.wa.gov.au/static/libs/select2-bootstrap-css/1.4.6/select2-bootstrap.css"
rel="stylesheet"/>
<link href="{% static 'wl/css/application.css' %}" rel="stylesheet"/>
{{ block.super }}
{% endblock %}

{% block requirements %}
Expand All @@ -29,7 +29,6 @@
logs.initActionLog({
logListURL: "{% url 'wl_applications:action_list' application.id %}",
});

});
});
{% endblock %}
Expand All @@ -48,15 +47,15 @@
</div>
{% endblock %}

{% block intro_title %}<h3>Enter Licence Conditions</h3>{% endblock %}
{% block intro_subtitle %}
<h4 class="inline">
{{ application.licence_type.name }}
</h4>
{% endblock %}

{% block content %}
<div class="container bottom-buffer">
<div class="row">
<div class="col-md-12">
<h2>Enter Licence Conditions</h2>
<h3>{{ application.licence_type.name }}</h3>
<hr>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="row">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'wl/base.html' %}
{% extends 'wl/applications_base.html' %}

{% load static %}

Expand All @@ -11,7 +11,7 @@
<link href="//static.dpaw.wa.gov.au/static/libs/select2/3.5.3/select2.min.css" rel="stylesheet"/>
<link href="//static.dpaw.wa.gov.au/static/libs/select2-bootstrap-css/1.4.6/select2-bootstrap.css"
rel="stylesheet"/>
<link href="{% static 'wl/css/application.css' %}" rel="stylesheet"/>
{{ block.super }}
{% endblock %}


Expand Down Expand Up @@ -48,15 +48,15 @@
</div>
{% endblock %}

{% block intro_title %}<h3>Enter Licence Conditions</h3>{% endblock %}
{% block intro_subtitle %}
<h4 class="inline">
{{ application.licence_type.name }}
</h4>
{% endblock %}

{% block content %}
<div class="container bottom-buffer">
<div class="row">
<div class="col-md-12">
<h2>Enter Licence Conditions</h2>
<h3>{{ application.licence_type.name }}</h3>
<hr>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="row">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'wl/base.html' %}
{% extends 'wl/applications_base.html' %}

{% load static %}

Expand All @@ -8,10 +8,6 @@

{% load users %}

{% block extra_css %}
<link href="{% static 'wl/css/application.css' %}" rel="stylesheet"/>
{% endblock %}

{% block breadcrumbs %}
<div class="container">
<div class="row">
Expand All @@ -25,22 +21,34 @@
</div>
{% endblock %}

{% block intro_title %}<h3>Application Complete</h3>{% endblock %}
{% block intro_subtitle %}
<h4 class="inline">
{{ licence_type.name }} {% if is_renewal %}(Renewal) {% endif %} {% if is_amendment %}(Amendment) {% endif %}
</h4>
{% if customer %}
<h4 class="pull-right">Customer: {{ customer.get_full_name }}</h4>
{% endif %}
{% if variants %}
<h4>
<em>({{ variants }})</em>
</h4>
{% endif %}
{% endblock %}
{% block intro_text %}
<div class="info">
<p>
The application process is now complete and your application is now under review. Please allow up to 20 working days for processing. You can see the status of the application
on the dashboard and view a read-only version of the application details. You may receive requests for amendments to the application, at which
point you will be able to modify the content and resubmit.
</p>
</div>
{% endblock %}

{% block content %}
<div class="container">
<div class="row">
<div class="col-md-12">
{% with heading='Application Complete' %}
{% include 'wl/entry/header.html' %}
{% endwith %}
</div>
</div>
<div class="row">
<div class="col-md-12">
<p>
The application process is now complete and your application is now under review. Please allow up to 20 working days for processing. You can see the status of the application
on the dashboard and view a read-only version of the application details. You may receive requests for amendments to the application, at which
point you will be able to modify the content and resubmit.
</p>
{% if show_invoice %}
<p>
Note that if your licence requires payment, the invoice must be paid before the licence can be issued. You can download the invoice from the links below.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'wl/base.html' %}
{% extends 'wl/applications_base.html' %}

{% load static %}

Expand All @@ -9,7 +9,7 @@
<link href="//static.dpaw.wa.gov.au/static/libs/select2-bootstrap-css/1.4.6/select2-bootstrap.css" rel="stylesheet"/>
<link href="//static.dpaw.wa.gov.au/static/libs/bootstrap-datetimepicker/4.7.14/css/bootstrap-datetimepicker.min.css"
rel="stylesheet"/>
<link href="{% static 'wl/css/application.css' %}" rel="stylesheet"/>
{{ block.super }}
{% endblock %}

{% block requirements %}
Expand All @@ -33,16 +33,13 @@
</div>
{% endblock %}

{% block intro_title %}<h3>Select or Create Customer</h3>{% endblock %}
{% block intro_subtitle %}<h4>Select or create the customer for whom the application is being applied on behalf of.</h4>{% endblock %}

{% block content %}
<div class="container bottom-buffer">
<div class="row">
<div class="col-md-12">
{% with heading='Select or Create Customer' %}
{% include 'wl/entry/header.html' %}
{% endwith %}
<p>
Select or create the customer for whom the application is being applied on behalf of.
</p>
<form method="post">
{% csrf_token %}
<div class="form-group">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
{% extends 'wl/base.html' %}
{% extends 'wl/applications_base.html' %}

{% load static %}

{% load bootstrap3 %}

{% load users %}

{% block extra_css %}
<link href="{% static 'wl/css/application.css' %}" rel="stylesheet"/>
{% endblock %}

{% block requirements %}
require(['js/entry/navigation'], function(navigation) {
navigation.setupNavigateAway('Warning: any information entered into the form '+
Expand All @@ -36,18 +32,32 @@
</div>
{% endblock %}

{% block intro_title %}<h3>Select Profile</h3>{% endblock %}
{% block intro_subtitle %}
<h4 class="inline">
{{ licence_type.name }} {% if is_renewal %}(Renewal) {% endif %} {% if is_amendment %}(Amendment) {% endif %}
</h4>
{% if customer %}
<h4 class="pull-right">Customer: {{ customer.get_full_name }}</h4>
{% endif %}
{% if variants %}
<h4>
<em>({{ variants }})</em>
</h4>
{% endif %}
{% endblock %}
{% block intro_text %}
<p>
The Wildlife Licensing system utilises the concept of profiles to allow users to apply for a licence under different circumstances, such holding a licence
for personal, commercial or research purposes. Please select an existing profile or alternatively create a new profile for this licence application.
</p>
{% endblock %}

{% block content %}
<div class="container bottom-buffer">
{% if profile_selection_form %}
<div class="row">
<div class="col-md-12">
{% with heading='Select Profile' %}
{% include 'wl/entry/header.html' %}
{% endwith %}
<p>
The Wildlife Licensing system utilises the concept of profiles to allow users to apply for a licence under different circumstances, such holding a licence
for personal, commercial or research purposes. Please select an existing profile or alternatively create a new profile for this licence application.
</p>
<form method="post">
{% csrf_token %}
{% bootstrap_form profile_selection_form %}
Expand Down
Loading

0 comments on commit 52517b4

Please sign in to comment.