Skip to content

Commit

Permalink
Merge pull request #112 from gaiaresources/master
Browse files Browse the repository at this point in the history
Features and fixes
  • Loading branch information
dbca-asi committed Aug 30, 2016
2 parents 6b2f65c + 8bc3be4 commit e15965f
Show file tree
Hide file tree
Showing 29 changed files with 410 additions and 217 deletions.
4 changes: 2 additions & 2 deletions ledger/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ class EmailUser(AbstractBaseUser, PermissionsMixin):
('Ms', 'Ms'),
('Dr', 'Dr')
)
title = models.CharField(max_length=100, choices=TITLE_CHOICES, null=True, blank=False, default=TITLE_CHOICES[0][0],
verbose_name='title', help_text="")
title = models.CharField(max_length=100, choices=TITLE_CHOICES, null=True, blank=True,
verbose_name='title', help_text='')
dob = models.DateField(auto_now=False, auto_now_add=False, null=True, blank=False,
verbose_name="date of birth", help_text='')
phone_number = models.CharField(max_length=50, null=True, blank=True,
Expand Down
36 changes: 25 additions & 11 deletions wildlifelicensing/apps/applications/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,14 @@ class LicenceIssuedEmail(TemplateEmailBase):
txt_template = 'wl/emails/licence_issued.txt'


def send_licence_issued_email(licence, application, request, ccs=None):
def send_licence_issued_email(licence, application, request, to=None, cc=None, bcc=None, additional_attachments=None):
email = LicenceIssuedEmail()
url = request.build_absolute_uri(
reverse('wl_dashboard:home')
)
context = {
'url': url,
'cover_letter_message': licence.cover_letter_message
'licence': licence
}
if licence.licence_document is not None:
file_name = 'WL_licence_' + smart_text(licence.licence_type.code_slug)
Expand All @@ -206,15 +206,19 @@ def send_licence_issued_email(licence, application, request, ccs=None):
attachments = [attachment]
else:
logger.error('The licence pk=' + licence.pk + ' has no document associated with it.')
attachments = None
to = [licence.profile.email]
if ccs:
to += ccs
msg = email.send(to, context=context, attachments=attachments)
attachments = []
if not to:
to = [licence.profile.email]
if additional_attachments and not isinstance(additional_attachments, list):
additional_attachments = list(additional_attachments)
if additional_attachments:
attachments += additional_attachments
msg = email.send(to, context=context, attachments=attachments, cc=cc, bcc=bcc)
log_entry = _log_email(msg, application=application, sender=request.user)
if licence.licence_document is not None:
log_entry.document = licence.licence_document
log_entry.save()
log_entry.documents.add(licence.licence_document)
if additional_attachments:
log_entry.documents.add(*additional_attachments)
return log_entry


Expand Down Expand Up @@ -262,14 +266,23 @@ def _log_email(email_message, application, sender=None):
fromm = smart_text(sender) if sender else smart_text(email_message.from_email)
# the to email is normally a list
if isinstance(email_message.to, list):
to = ';'.join(email_message.to)
to = ','.join(email_message.to)
else:
to = smart_text(email_message.to)
# we log the cc and bcc in the same cc field of the log entry as a ',' comma separated string
all_ccs = []
if email_message.cc:
all_ccs += list(email_message.cc)
if email_message.bcc:
all_ccs += list(email_message.bcc)
all_ccs = ','.join(all_ccs)

else:
text = smart_text(email_message)
subject = ''
to = application.applicant.email
fromm = smart_text(sender) if sender else SYSTEM_NAME
all_ccs = ''

customer = application.applicant

Expand All @@ -282,7 +295,8 @@ def _log_email(email_message, application, sender=None):
'customer': customer,
'officer': officer,
'to': to,
'fromm': fromm
'fromm': fromm,
'cc': all_ccs
}

email_entry = ApplicationLogEntry.objects.create(**kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ define(['jQuery', 'select2', 'bootstrap-datetimepicker'], function($) {
var $searchCustomer = $('#searchCustomer');

$searchCustomer.select2({
minimumInputLength: 3,
minimumInputLength: 2,
ajax: {
url: '/search_customers',
dataType: 'json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ define([
initialise: function() {
var $issueLicenceForm = $('#issueLicenceForm'),
$issueButton = $('#issue'),
$regionSelect = $issueLicenceForm.find('select');
$regionSelect = $issueLicenceForm.find('select'),
$addAttachment = $('#add_attachment');

// initialise all datapickers
$("input[id$='date']").each(function() {
Expand All @@ -36,6 +37,14 @@ define([
placeholder: "Select applicable regions."
});
$regionSelect.removeClass('hidden');

$addAttachment.on('click', function (e) {
var inputNode = $('<input class="top-buffer" id="id_attach" name="attachments" type="file" multiple>');
e.preventDefault();
$(e.target).parent().append(inputNode);
inputNode.click();
});

}
};
});
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
{% extends 'wl/emails/base_email.html' %}

{% block greetings %}
Dear {{ licence.holder.get_full_name }}
{% endblock %}

{% block content %}
Congratulations, your Wildlife Licensing application has been approved and the corresponding licence has been issued.
<p>Your licence is attached. Please read it carefully.</p>
{% comment 'Removed link to online system for beta' %}
{% if url %}
<p>You also can access it from your Wildlife Licensing <a href='{{ url }}'>dashboard.</a></p>
<p>Note: If you haven't been on the Wildlife Licensing site recently you might have to login first before using the provided link.</p>
{% endif %}
{% endcomment %}
<p>{{ cover_letter_message }}</p>
<p><strong>{{ licence.licence_type.name }}</strong></p>
<p>Please find the licence attached.</p>
<p>Please ensure that all the licence conditions are complied with, including the forwarding of a return at the end of the licence period.</p>
<p>{{ licence.cover_letter_message }}</p>
<p>If you have any queries, please contact the Wildlife Licensing section on 9219 9831.</p>
{% endblock %}

{% block signature %}
<p>
Yours sincerely
</p>
<p></p>
<p>
from Jim Sharp<br>
DIRECTOR GENERAL
</p>
<p>
{% now 'd/m/Y' %}
</p>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
{% extends 'wl/emails/base_email.txt' %}

{% block greetings %}
Dear {{ licence.holder.get_full_name }}
{% endblock %}

{% block content %}
Congratulations, your Wildlife Licensing application has been approved and the corresponding licence has been issued.
Your licence is attached. Please read it carefully.

{% comment 'Removed link to online system for beta' %}
{% if url %}
You also can access it from your Wildlife Licensing dashboard by copying and pasting the following link in your browser:
{{ url }}
Note: If you haven't been on the Wildlife Licensing site recently you might have to login first before using the provided link.
{% endif %}
{% endcomment %}

{{ cover_letter_message }}
{{ licence.licence_type.name }}
Please find the licence attached.
Please ensure that all the licence conditions are complied with, including the forwarding of a return at the end of the licence period.
{{ licence.cover_letter_message }}
If you have any queries, please contact the Wildlife Licensing section on 9219 9831.
{% endblock %}

{% block signature %}
Yours sincerely



from Jim Sharp

DIRECTOR GENERAL

{% now 'd/m/Y' %}

{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
{% extends 'wl/emails/base_email.html' %}

{% block greetings %}
Dear Licensee
Dear {{ licence.holder.get_full_name }}
{% endblock %}

{% block content %}
<p>
This is a reminder that your licence {{ licence.licence_number }}-{{ licence.licence_sequence }} is due to expire on {{ licence.end_date|date:'d/m/Y' }}.
This is a reminder that your licence
</p>
<p>
You are required to submit an electronic return. To do so, please logon to:
<p>
<p>
<a href='{{ url }}'>{{ url }}</a>
<strong>{{ licence.licence_type.name }} &lt;{{ licence.reference }}&gt;</strong>
</p>
<p>
Upon submitting your return, you will need to select one of the options listed below regarding licence renewal.
Please note the licence cannot be renewed until this return has been submitted.
</p>
<ul>
<li>Non-renewal</li>
<li>Renew</li>
<li>Renew with changes.</li>
</ul>
<p>
If you select <strong>renew</strong> or <strong>renew with changes</strong>, please make the relevant
changes to your project from your original application (if applicable) and detail the new expiry date.
is due to expire on {{ licence.end_date|date:'d/m/Y' }}.
</p>
<p>
If you have any queries, please contact Mr Danny Stefoni on 9219 9833 or <a href="mailto:wildlifelicensing@dpaw.wa.gov.au">wildlifelicensing@dpaw.wa.gov.au</a>.
Please note that if you have oustanding returns, these are required to be submitted before the licence can be renewed.
<p>
<p>
If you have any queries, please contact the wildlife licencing section on 9219 9831 or
<a href="mailto:wildlifelicensing@dpaw.wa.gov.au">wildlifelicensing@dpaw.wa.gov.au</a>.
</p>
{% endblock %}
{% block signature %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
{% extends 'wl/emails/base_email.html' %}

{% block greetings %}
Dear Licensee
Dear {{ licence.holder.get_full_name }}
{% endblock %}

{% block content %}
This is a reminder that your licence {{ licence.licence_number }}-{{ licence.licence_sequence }} is due to expire on {{ licence.end_date|date:'d/m/Y' }}.
This is a reminder that your licence

You are required to submit an electronic return. To do so, please logon to:
{{ url }}
{{ licence.licence_type.name }} <{{ licence.reference }}>

Upon submitting your return, you will need to select one of the options listed below regarding licence renewal.
Please note the licence cannot be renewed until this return has been submitted.
is due to expire on {{ licence.end_date|date:'d/m/Y' }}.

Non-renewal
Renew
Renew with changes.

If you select <strong>renew</strong>or <strong>renew with changes</strong>, please make the relevant
changes to your project from your original application (if applicable) and detail the new expiry date.

If you have any queries, please contact Mr Danny Stefoni on 9219 9833 or <a href="mailto:wildlifelicensing@dpaw.wa.gov.au">wildlifelicensing@dpaw.wa.gov.au</a>.
Please note that if you have oustanding returns, these are required to be submitted before the licence can be renewed.

If you have any queries, please contact the wildlife licencing section on 9219 9831 or wildlifelicensing@dpaw.wa.gov.au.
{% endblock %}

{% block signature %}
Yours sincerely

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<a class="left-buffer" href="{% url 'payments:invoice-pdf' application.invoice_reference %}" target="_blank">
Download as PDF
<img height="20px" src="{% static 'wl/img/pdf.png' %}"/>
</a>
</a>
</p>
{% endif %}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ <h3>{{ application.licence_type.name }}</h3>
</a>
</div>
<div class="col-md-9">
<form method="post" id="issueLicenceForm">
<form method="post" id="issueLicenceForm" enctype="multipart/form-data">
{% csrf_token %}
{% bootstrap_form issue_licence_form %}
<a href="#" id="add_attachment" class="top-buffer">Add attachment</a>
</form>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,41 @@ <h3>Application (read-only)</h3>
</div>
</div>
<div class="row">
<div class="col-md-2 col-sm-3">
<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 %}
{% else %}
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
Payment Status
</div>
<div class="panel-body">
<p class="no-margin">
{{ payment_status }}
{% if payment_status == 'Awaiting Payment' %}
<a class="left-buffer pull-right" href="{% url 'payments:invoice-pdf' application.invoice_reference %}" target="_blank">
Invoice
<img height="20px" src="{% static 'wl/img/pdf.png' %}"/>
</a>
{% endif %}
</p>
</div>
</div>
</div>
</div>
{% endif %}
<div id="sectionList">
<ul class="nav nav-stacked">
</ul>
</div>
</nav>
</div>
<div class="col-md-10 col-sm-9">
<div class="col-md-9">
<div id="applicationContainer"></div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion wildlifelicensing/apps/applications/tests/test_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


class ApplicationEntryTestCase(TestCase):
fixtures = ['licences.json', 'countries.json', 'catalogue.json', 'partner.json']
fixtures = ['licences.json', 'countries.json', 'catalogue.json', 'partner.json']

def setUp(self):
self.customer = get_or_create_default_customer()
Expand Down
4 changes: 2 additions & 2 deletions wildlifelicensing/apps/applications/views/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from wildlifelicensing.apps.applications.mixins import UserCanEditApplicationMixin,\
UserCanViewApplicationMixin
from wildlifelicensing.apps.main.mixins import OfficerRequiredMixin, OfficerOrCustomerRequiredMixin
from wildlifelicensing.apps.main.helpers import is_officer, is_customer
from wildlifelicensing.apps.main.helpers import is_customer
from django.core.urlresolvers import reverse
from wildlifelicensing.apps.applications.utils import delete_session_application
from wildlifelicensing.apps.payments.utils import is_licence_free
Expand Down Expand Up @@ -399,7 +399,7 @@ def get_context_data(self, **kwargs):
return redirect('wl_applications:new_application')

kwargs['is_payment_required'] = not is_licence_free(application.licence_type) and \
not application.invoice_reference
not application.invoice_reference and is_customer(self.request.user)

if application.data:
utils.convert_documents_to_url(application.data, application.documents.all(), '')
Expand Down
Loading

0 comments on commit e15965f

Please sign in to comment.