diff --git a/wildlifelicensing/apps/applications/mixins.py b/wildlifelicensing/apps/applications/mixins.py index d39984fc16..2e207c2aa8 100755 --- a/wildlifelicensing/apps/applications/mixins.py +++ b/wildlifelicensing/apps/applications/mixins.py @@ -1,3 +1,5 @@ +import datetime + from django.core.urlresolvers import reverse_lazy from django.contrib.auth.mixins import UserPassesTestMixin @@ -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 """ @@ -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(): @@ -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. @@ -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 """ diff --git a/wildlifelicensing/apps/applications/models.py b/wildlifelicensing/apps/applications/models.py index 25be6dbb8a..1f5a186944 100755 --- a/wildlifelicensing/apps/applications/models.py +++ b/wildlifelicensing/apps/applications/models.py @@ -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) diff --git a/wildlifelicensing/apps/applications/static/wl/css/application.css b/wildlifelicensing/apps/applications/static/wl/css/applications.css similarity index 98% rename from wildlifelicensing/apps/applications/static/wl/css/application.css rename to wildlifelicensing/apps/applications/static/wl/css/applications.css index 8faf6dc790..ab9a785724 100755 --- a/wildlifelicensing/apps/applications/static/wl/css/application.css +++ b/wildlifelicensing/apps/applications/static/wl/css/applications.css @@ -29,9 +29,10 @@ hr { a { cursor: pointer; -} +}intro /* enter details / preview */ +{% load bootstrap3 %} #sectionList > ul > .active { font-weight: bold; diff --git a/wildlifelicensing/apps/applications/templates/wl/applications_base.html b/wildlifelicensing/apps/applications/templates/wl/applications_base.html new file mode 100644 index 0000000000..140a052f75 --- /dev/null +++ b/wildlifelicensing/apps/applications/templates/wl/applications_base.html @@ -0,0 +1,18 @@ +{% extends 'wl/base.html' %} + +{% load static %} + +{% block extra_css %} + +{% endblock %} + +{% block intro %} +
+
+ {% block intro_title %}{% endblock %} + {% block intro_subtitle %}{% endblock %} +
+ {% block intro_text%}{% endblock %} +
+
+{% endblock %} \ No newline at end of file diff --git a/wildlifelicensing/apps/applications/templates/wl/conditions/assessor_enter_conditions.html b/wildlifelicensing/apps/applications/templates/wl/conditions/assessor_enter_conditions.html index 615f7a8b64..624109efa3 100755 --- a/wildlifelicensing/apps/applications/templates/wl/conditions/assessor_enter_conditions.html +++ b/wildlifelicensing/apps/applications/templates/wl/conditions/assessor_enter_conditions.html @@ -1,4 +1,4 @@ -{% extends 'wl/base.html' %} +{% extends 'wl/applications_base.html' %} {% load static %} @@ -10,7 +10,7 @@ - + {{ block.super }} {% endblock %} {% block requirements %} @@ -29,7 +29,6 @@ logs.initActionLog({ logListURL: "{% url 'wl_applications:action_list' application.id %}", }); - }); }); {% endblock %} @@ -48,15 +47,15 @@ {% endblock %} +{% block intro_title %}

Enter Licence Conditions

{% endblock %} +{% block intro_subtitle %} +

+ {{ application.licence_type.name }} +

+{% endblock %} + {% block content %}
-
-
-

Enter Licence Conditions

-

{{ application.licence_type.name }}

-
-
-
diff --git a/wildlifelicensing/apps/applications/templates/wl/conditions/enter_conditions.html b/wildlifelicensing/apps/applications/templates/wl/conditions/enter_conditions.html index dc833a2070..eceebc6f65 100755 --- a/wildlifelicensing/apps/applications/templates/wl/conditions/enter_conditions.html +++ b/wildlifelicensing/apps/applications/templates/wl/conditions/enter_conditions.html @@ -1,4 +1,4 @@ -{% extends 'wl/base.html' %} +{% extends 'wl/applications_base.html' %} {% load static %} @@ -11,7 +11,7 @@ - + {{ block.super }} {% endblock %} @@ -48,15 +48,15 @@
{% endblock %} +{% block intro_title %}

Enter Licence Conditions

{% endblock %} +{% block intro_subtitle %} +

+ {{ application.licence_type.name }} +

+{% endblock %} + {% block content %}
-
-
-

Enter Licence Conditions

-

{{ application.licence_type.name }}

-
-
-
diff --git a/wildlifelicensing/apps/applications/templates/wl/entry/complete.html b/wildlifelicensing/apps/applications/templates/wl/entry/complete.html index f83c0f8be0..ea82e88e74 100755 --- a/wildlifelicensing/apps/applications/templates/wl/entry/complete.html +++ b/wildlifelicensing/apps/applications/templates/wl/entry/complete.html @@ -1,4 +1,4 @@ -{% extends 'wl/base.html' %} +{% extends 'wl/applications_base.html' %} {% load static %} @@ -8,10 +8,6 @@ {% load users %} -{% block extra_css %} - -{% endblock %} - {% block breadcrumbs %}
@@ -25,22 +21,34 @@
{% endblock %} +{% block intro_title %}

Application Complete

{% endblock %} +{% block intro_subtitle %} +

+ {{ licence_type.name }} {% if is_renewal %}(Renewal) {% endif %} {% if is_amendment %}(Amendment) {% endif %} +

+ {% if customer %} +

Customer: {{ customer.get_full_name }}

+ {% endif %} + {% if variants %} +

+ ({{ variants }}) +

+ {% endif %} +{% endblock %} +{% block intro_text %} +
+

+ 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. +

+
+{% endblock %} + {% block content %}
- {% with heading='Application Complete' %} - {% include 'wl/entry/header.html' %} - {% endwith %} -
-
-
-
-

- 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. -

{% if show_invoice %}

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. diff --git a/wildlifelicensing/apps/applications/templates/wl/entry/create_select_customer.html b/wildlifelicensing/apps/applications/templates/wl/entry/create_select_customer.html index 10f2ea4a93..f3599bf17a 100755 --- a/wildlifelicensing/apps/applications/templates/wl/entry/create_select_customer.html +++ b/wildlifelicensing/apps/applications/templates/wl/entry/create_select_customer.html @@ -1,4 +1,4 @@ -{% extends 'wl/base.html' %} +{% extends 'wl/applications_base.html' %} {% load static %} @@ -9,7 +9,7 @@ - + {{ block.super }} {% endblock %} {% block requirements %} @@ -33,16 +33,13 @@

{% endblock %} +{% block intro_title %}

Select or Create Customer

{% endblock %} +{% block intro_subtitle %}

Select or create the customer for whom the application is being applied on behalf of.

{% endblock %} + {% block content %}
- {% with heading='Select or Create Customer' %} - {% include 'wl/entry/header.html' %} - {% endwith %} -

- Select or create the customer for whom the application is being applied on behalf of. -

{% csrf_token %}
diff --git a/wildlifelicensing/apps/applications/templates/wl/entry/create_select_profile.html b/wildlifelicensing/apps/applications/templates/wl/entry/create_select_profile.html index 870f363f9b..3d63d391ea 100755 --- a/wildlifelicensing/apps/applications/templates/wl/entry/create_select_profile.html +++ b/wildlifelicensing/apps/applications/templates/wl/entry/create_select_profile.html @@ -1,4 +1,4 @@ -{% extends 'wl/base.html' %} +{% extends 'wl/applications_base.html' %} {% load static %} @@ -6,10 +6,6 @@ {% load users %} -{% block extra_css %} - -{% endblock %} - {% block requirements %} require(['js/entry/navigation'], function(navigation) { navigation.setupNavigateAway('Warning: any information entered into the form '+ @@ -36,18 +32,32 @@
{% endblock %} +{% block intro_title %}

Select Profile

{% endblock %} +{% block intro_subtitle %} +

+ {{ licence_type.name }} {% if is_renewal %}(Renewal) {% endif %} {% if is_amendment %}(Amendment) {% endif %} +

+ {% if customer %} +

Customer: {{ customer.get_full_name }}

+ {% endif %} + {% if variants %} +

+ ({{ variants }}) +

+ {% endif %} +{% endblock %} +{% block intro_text %} +

+ 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. +

+{% endblock %} + {% block content %}
{% if profile_selection_form %}
- {% with heading='Select Profile' %} - {% include 'wl/entry/header.html' %} - {% endwith %} -

- 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. -

{% csrf_token %} {% bootstrap_form profile_selection_form %} diff --git a/wildlifelicensing/apps/applications/templates/wl/entry/enter_details.html b/wildlifelicensing/apps/applications/templates/wl/entry/enter_details.html index 58ab845dcd..ad64231fbb 100755 --- a/wildlifelicensing/apps/applications/templates/wl/entry/enter_details.html +++ b/wildlifelicensing/apps/applications/templates/wl/entry/enter_details.html @@ -1,4 +1,4 @@ -{% extends 'wl/base.html' %} +{% extends 'wl/applications_base.html' %} {% load static %} @@ -13,7 +13,7 @@ {% block extra_css %} - + {{ block.super }} {% endblock %} {% block requirements %} @@ -51,26 +51,36 @@
{% endblock %} +{% block intro_title %}

Enter Application Details

{% endblock %} +{% block intro_subtitle %} +

+ {{ licence_type.name }} {% if is_renewal %}(Renewal) {% endif %} {% if is_amendment %}(Amendment) {% endif %} +

+ {% if customer %} +

Customer: {{ customer.get_full_name }}

+ {% endif %} + {% if variants %} +

+ ({{ variants }}) +

+ {% endif %} +{% endblock %} +{% block intro_text %} +

+ In order to complete an application, you must fill out the questionnaire below. Please ensure the information provided is + clear and detailed enough for a wildlife licensing officer to assess your application. If the required information is insufficient, + we will need to contact you before we can finalise your application which could result in a delay in the issuing of the licence. +

+

+ At any point you can save your application as a draft by clicking the Save Draft button at the bottom, allowing you to return + to the application at a later time. When you are satisfied with your answers, click the Preview Application button at the bottom-right. + You will then be shown a preview of the application as it will be seen by a wildlife licensing officer. You will be asked to agree to + a disclaimer after which you will be able to lodge your application. +

+{% endblock %} + {% block content %}