Skip to content

Commit

Permalink
Merge a7efdef into 63d6312
Browse files Browse the repository at this point in the history
  • Loading branch information
serge-gaia authored Oct 20, 2016
2 parents 63d6312 + a7efdef commit 0646097
Show file tree
Hide file tree
Showing 29 changed files with 1,829 additions and 205 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.10 on 2016-10-12 02:42
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('wl_applications', '0010_auto_20160901_1436'),
]

operations = [
migrations.CreateModel(
name='ApplicationUserAction',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('when', models.DateTimeField(auto_now_add=True)),
('what', models.TextField()),
('application', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wl_applications.Application')),
('who', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'abstract': False,
},
),
]
40 changes: 39 additions & 1 deletion wildlifelicensing/apps/applications/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from ledger.accounts.models import EmailUser, Profile, Document, RevisionedMixin
from wildlifelicensing.apps.main.models import WildlifeLicence, WildlifeLicenceType, Condition, \
CommunicationsLogEntry, AssessorGroup, Variant
CommunicationsLogEntry, AssessorGroup, Variant, UserAction


@python_2_unicode_compatible
Expand Down Expand Up @@ -130,6 +130,9 @@ def is_senior_offer_applicable(self):
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)


class ApplicationVariantLink(models.Model):
application = models.ForeignKey(Application)
Expand Down Expand Up @@ -210,6 +213,41 @@ class Meta:
unique_together = ('condition', 'assessment', 'order')


class ApplicationUserAction(UserAction):
ACTION_CREATE_CUSTOMER_ = "Create customer {}"
ACTION_CREATE_PROFILE_ = "Create profile {}"
ACTION_LODGE_APPLICATION = "Lodge application {}"
ACTION_ASSIGN_TO_ = "Assign to {}"
ACTION_UNASSIGN = "Unassign"
ACTION_ACCEPT_ID = "Accept ID"
ACTION_RESET_ID = "Reset ID"
ACTION_ID_REQUEST_UPDATE = 'Request ID update'
ACTION_ACCEPT_CHARACTER = 'Accept character'
ACTION_RESET_CHARACTER = "Reset character"
ACTION_ACCEPT_REVIEW = 'Accept review'
ACTION_RESET_REVIEW = "Reset review"
ACTION_ID_REQUEST_AMENDMENTS = "Request amendments"
ACTION_SEND_FOR_ASSESSMENT_TO_ = "Send for assessment to {}"
ACTION_SEND_ASSESSMENT_REMINDER_TO_ = "Send assessment reminder to {}"
ACTION_DECLINE_APPLICATION = "Decline application"
ACTION_ENTER_CONDITIONS = "Enter Conditions"
ACTION_CREATE_CONDITION_ = "Create condition {}"
ACTION_ISSUE_LICENCE_ = "Issue Licence {}"
# Assessors
ACTION_SAVE_ASSESSMENT_ = "Save assessment {}"
ACTION_CONCLUDE_ASSESSMENT_ = "Conclude assessment {}"

@classmethod
def log_action(cls, application, action, user):
return cls.objects.create(
application=application,
who=user,
what=str(action)
)

application = models.ForeignKey(Application)


@receiver(pre_delete, sender=Application)
def delete_documents(sender, instance, *args, **kwargs):
for document in instance.documents.all():
Expand Down
2 changes: 1 addition & 1 deletion wildlifelicensing/apps/applications/static/wl/js/entry/select_licence_type.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define(['jQuery', 'bootstrap.treeView'], function ($) {
define(['jQuery', 'js/wl.bootstrap-treeview'], function ($) {
"use strict";

function _convertToSlug(text) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,22 @@
{% endblock %}

{% block requirements %}
require(['js/conditions/assessor_enter_conditions', 'js/communications_log'], function (enter_conditions, commsLog) {
require([
'js/conditions/assessor_enter_conditions',
'js/logs'
], function (enter_conditions, logs) {
$(function () {
enter_conditions.init({{ assessment|jsonify }}, {{ application|jsonify }},
{{ form_structure|jsonify }}, {{ other_assessments|jsonify }});

commsLog.initCommunicationLog({
showLogPopoverSelector: '#showLog',
showLogEntryModalSelector: '#addLogEntry',
logEntryModalSelector: '#logEntryModal',
logEntryFormSelector: '#addLogEntryForm',
logs.initCommunicationLog({
logListURL: "{% url 'wl_applications:log_list' application.id %}",
addLogEntryURL: "{% url 'wl_applications:add_log_entry' application.id %}"
});
logs.initActionLog({
logListURL: "{% url 'wl_applications:action_list' application.id %}",
});

});
});
{% endblock %}
Expand Down Expand Up @@ -103,9 +106,7 @@ <h3>{{ application.licence_type.name }}</h3>
</div>
</div>
</div>
{% with disable_collapse=True add_text='Add application log entry' %}
{% include 'wl/communications_panel.html' %}
{% endwith %}
{% include 'wl/logs_panel.html' %}
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
Expand Down Expand Up @@ -176,5 +177,5 @@ <h3>Current Conditions</h3>
{% endblock %}

{% block modals %}
{% include 'wl/communications_modal.html' %}
{% include 'wl/logs_comm_entry_modal.html' %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,22 @@
<link href="{% static 'wl/css/application.css' %}" rel="stylesheet"/>
{% endblock %}


{% block requirements %}
require(['js/conditions/enter_conditions', 'js/communications_log'], function (enterConditions, commLog) {
require([
'js/conditions/enter_conditions',
'js/logs'
],
function (enterConditions, logs) {
enterConditions.init({{ application|jsonify }}, {{ assessments|jsonify }}, {{form_structure|jsonify}}, '{{ csrf_token }}');

commLog.initCommunicationLog({
showLogPopoverSelector: '#showLog',
showLogEntryModalSelector: '#addLogEntry',
logEntryModalSelector: '#logEntryModal',
logEntryFormSelector: '#addLogEntryForm',
logs.initCommunicationLog({
logListURL: "{% url 'wl_applications:log_list' application.id %}",
addLogEntryURL: "{% url 'wl_applications:add_log_entry' application.id %}"
});
logs.initActionLog({
logListURL: "{% url 'wl_applications:action_list' application.id %}",
});
});
{% endblock %}

Expand Down Expand Up @@ -108,9 +112,7 @@ <h3>{{ application.licence_type.name }}</h3>
</div>
</div>
</div>
{% with disable_collapse=True add_text='Add application log entry' %}
{% include 'wl/communications_panel.html' %}
{% endwith %}
{% include 'wl/logs_panel.html' %}
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
Expand Down Expand Up @@ -209,7 +211,7 @@ <h3>Current Conditions</h3>
<div class="modal fade" id="createCustomConditionModal" tabindex="-1">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form method="post" action="{% url 'wl_applications:create_condition' %}" id="createConditionForm">
<form method="post" action="{% url 'wl_applications:create_condition' application.id %}" id="createConditionForm">
{% csrf_token %}
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span>&times;</span></button>
Expand Down Expand Up @@ -241,5 +243,5 @@ <h4 class="modal-title">Create Custom Condition</h4>
</div>
</div>
</div>
{% include 'wl/communications_modal.html' %}
{% include 'wl/logs_comm_entry_modal.html' %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
{% endblock %}

{% block requirements %}
require(['js/issue/issue_licence', 'js/communications_log'], function(issueLicence, commsLog) {
$(function () {
issueLicence.initialise();

commsLog.initCommunicationLog({
showLogPopoverSelector: '#showLog',
showLogEntryModalSelector: '#addLogEntry',
logEntryModalSelector: '#logEntryModal',
logEntryFormSelector: '#addLogEntryForm',
logListURL: "{% url 'wl_applications:log_list' application.id %}",
addLogEntryURL: "{% url 'wl_applications:add_log_entry' application.id %}"
});
require([
'js/issue/issue_licence',
'js/logs'
],
function(issueLicence, logs) {
issueLicence.initialise();
logs.initCommunicationLog({
logListURL: "{% url 'wl_applications:log_list' application.id %}",
addLogEntryURL: "{% url 'wl_applications:add_log_entry' application.id %}"
});
logs.initActionLog({
logListURL: "{% url 'wl_applications:action_list' application.id %}",
});
});
{% endblock %}
Expand Down Expand Up @@ -116,9 +116,7 @@ <h3>{{ application.licence_type.name }}</h3>
</div>
</div>
</div>
{% with add_text='Add application log entry' %}
{% include 'wl/communications_panel.html' %}
{% endwith %}
{% include 'wl/logs_panel.html' %}
{% if payment_status == 'Awaiting Payment' %}
<button id="issue" type="button" class="btn btn-sm btn-success pull-right disabled"
data-title="Payment must be received before licence can be issued">
Expand Down Expand Up @@ -154,5 +152,5 @@ <h3>{{ application.licence_type.name }}</h3>
{% endblock %}

{% block modals %}
{% include 'wl/communications_modal.html' %}
{% include 'wl/logs_comm_entry_modal.html' %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@
{% endblock %}

{% block requirements %}
require(['js/process/process_app', 'js/communications_log'], function (app, commsLog) {
$(function () {
data = {{ data|jsonify }};
app.initialiseApplicationProcesssing(data);
require(['js/process/process_app', 'js/logs'],
function (app, logs) {
$(function () {
data = {{ data|jsonify }};
app.initialiseApplicationProcesssing(data);

commsLog.initCommunicationLog({
showLogPopoverSelector: '#showLog',
showLogEntryModalSelector: '#addLogEntry',
logEntryModalSelector: '#logEntryModal',
logEntryFormSelector: '#addLogEntryForm',
logListURL: "{% url 'wl_applications:log_list' data.application.id %}",
addLogEntryURL: "{% url 'wl_applications:add_log_entry' data.application.id %}"
});
logs.initCommunicationLog({
logListURL: "{% url 'wl_applications:log_list' data.application.id %}",
addLogEntryURL: "{% url 'wl_applications:add_log_entry' data.application.id %}"
});
logs.initActionLog({
logListURL: "{% url 'wl_applications:action_list' data.application.id %}",
});

$('#mainContainer').removeClass('hidden');
$('#mainContainer').removeClass('hidden');
});
});
});
{% endblock %}

{% block breadcrumbs %}
Expand Down Expand Up @@ -119,9 +119,7 @@ <h3>{{ data.application.licence_type.name }}</h3>
</div>
</div>
</div>
{% with disable_collapse=True add_text='Add application log entry' %}
{% include 'wl/communications_panel.html' %}
{% endwith %}
{% include 'wl/logs_panel.html' %}
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
Expand Down Expand Up @@ -458,6 +456,6 @@ <h4 class="modal-title">Request Amendments to Application</h4>
</div>
</div>
</div>
{% include 'wl/communications_modal.html' %}
{% include 'wl/logs_comm_entry_modal.html' %}
{% endblock %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,22 @@
{% endblock %}

{% block requirements %}
require(['jQuery', 'js/entry/application_preview', 'js/communications_log'], function($, applicationPreview, commsLog) {
require([
'jQuery',
'js/entry/application_preview',
'js/logs'
],
function($, applicationPreview, logs) {
applicationPreview.layoutPreviewItems('#applicationContainer', {{ application.licence_type.application_schema|jsonify }}, {{ application.data|jsonify }});

$('#mainContainer').removeClass('hidden');

commsLog.initCommunicationLog({
showLogPopoverSelector: '#showLog',
showLogEntryModalSelector: '#addLogEntry',
logEntryModalSelector: '#logEntryModal',
logEntryFormSelector: '#addLogEntryForm',
logs.initCommunicationLog({
logListURL: "{% url 'wl_applications:log_list' application.id %}",
addLogEntryURL: "{% url 'wl_applications:add_log_entry' application.id %}"
});
logs.initActionLog({
logListURL: "{% url 'wl_applications:action_list' application.id %}",
});

// need to initialise sidebar menu after showing main container otherwise affix height will be wrong
applicationPreview.initialiseSidebarMenu('#sectionList');
Expand Down Expand Up @@ -64,9 +67,7 @@ <h3>Application (read-only)</h3>
<div class="col-md-3">
<nav class="hidden-xs top-buffer">
{% if customer %}
{% with disable_collapse=True add_text='Add entry' %}
{% include 'wl/communications_panel.html' %}
{% endwith %}
{% include 'wl/logs_panel.html' %}
{% else %}
<div class="row">
<div class="col-md-12">
Expand Down Expand Up @@ -103,6 +104,6 @@ <h3>Application (read-only)</h3>
{% endblock %}
{% block modals %}
{% if customer %}
{% include 'wl/communications_modal.html' %}
{% include 'wl/logs_comm_entry_modal.html' %}
{% endif %}
{% endblock %}
Loading

0 comments on commit 0646097

Please sign in to comment.