Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add online RIGS authorisation #283

Merged
merged 46 commits into from
May 24, 2017
Merged

[WIP] Add online RIGS authorisation #283

merged 46 commits into from
May 24, 2017

Conversation

tomtom5152
Copy link
Member

@tomtom5152 tomtom5152 commented Apr 10, 2017

Changes from using signed paperwork to an online interface for clients to authorise the rig via a secure HMAC link.

Process is as follows:

  1. MIC provides an authorisation email for RIGS to send the secure link to.
  2. Link is used to identify the client and provide secure access to the event details
  3. Client provides their name, the full amount, has to agree to our Terms of Hire and provide either a PO (external) or Uni ID and Account Code (internal).
  4. Upon successful authorisation, RIGS emails MIC to notify them, and sends a PDF receipt to client.
  5. Details of the authorisation are included on all paperwork once provided, and are superseded by future versions.

This directly closes #228, and indirectly closes #282 and #195.

Merge notes:

  • migrate RIGS 0024 > merge/deploy > migrate

Add EventAuthorisation model + migrations

Add authorised property to Event.

Add appropriate tests
Add forms, views, templates and URLs.

Remove created at in favour of the built in versioning as that's much more accurate.
Switch to a OneToOneField with EventAuthorisation -> event as a result of this.

Move validation from models to forms where it probably belongs.
Provide more descriptive errors.

Add success page for authorisation.
Enable RevisionMixin for EventAuthorisation.

Add signal receivers for RIGS.

Expand RIGS into an explicitly defined app to support signals.
Add backup email if there isn't an MIC
Add email sending methods.

Add TEC side sending of emails.
PDFs now state QUOTE, INVOICE or RECEIPT.
Single copy and all but INVOICE includes terms of hire.
@davidtaylorhq davidtaylorhq temporarily deployed to pyrigs-pr-283 April 10, 2017 22:37 Inactive
I used python 3 syntax, we aren't yet using python 3...
@tomtom5152 tomtom5152 temporarily deployed to pyrigs-pr-283 April 10, 2017 22:44 Inactive
Copy link
Contributor

@davidtaylorhq davidtaylorhq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the whole I think this looks good. Needs more testing by teccies once treasury approves it though.

Some bugs I noticed:

  • Confirmation email does not at '£' before cost, and does not add decimal places. e.g. £1140.00 shows as just 1140

  • Click "Authorisation Request", type an invalid email and submit, it's then impossible to submit again

RIGS/forms.py Outdated


class BaseClientEventAuthorisationForm(forms.ModelForm):
tos = forms.BooleanField(required=True, label="Terms of hire")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting required=true is not enough validation for this field. I can just edit the HTML form to make the checkbox into a text field, and then I don't even have to put any text in the box for it to be accepted. Should be as simple as just adding an if(tos==true) statement to the clean function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect, both in testing and according to the docs, required=True on a BooleanField validation ensures that the value=True as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I suspect the reason this happens is

test = 'no I don't accept'

if test:
    print("They accepted")

But I think it's reasonable to assume clients won't mess with the HTML form, so this is a non-issue

RIGS/forms.py Outdated

def clean(self):
if self.cleaned_data.get('amount') != self.instance.event.total:
self.add_error('amount', 'The amount authorised must equal the total for the event.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest "The amount authorised must equal the total for the event (inc VAT)" for absolute clarity

event = models.OneToOneField('Event', related_name='authorisation')
email = models.EmailField()
name = models.CharField(max_length=255)
uni_id = models.CharField(max_length=10, blank=True, null=True, verbose_name="University ID")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do SU staff have Uni ID numbers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite even Ollie saying they did, having just asked Niki, they don't. This could be an issue.

@@ -1,16 +1,18 @@
import os
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ewww, why was this here!

RIGS/rigboard.py Outdated
buffer = StringIO.StringIO()

buffer = rml2pdf.parseString(rml)
context = RequestContext(request, { # this should be outside the loop, but bug in 1.8.2 prevents this
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the now un-necessary comment

{% endif %}
{% endif %}
</div>
{% include 'RIGS/event_detail_buttons.html' %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm glad this has finally been done!

<a class="btn btn-default item-add modal-href event-authorise-request"
href="{% url 'event_authorise_request' object.pk %}">
<span class="glyphicon glyphicon-send"></span>
Authorisation Request
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we need more context on this button than just colours - otherwise teccies may send many duplicate emails.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a tricky one, because by design you can send many emails, this was just to provide feedback that the email had been sent successfully when submitting an address. As it stands RIGS doesn't track when an email has been sent to reduce DB storage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should track this, waaay too much potential for teccie fail otherwise. It's not like we're short of database shortage.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not against tracking ti for DB storage, wrong phrasing, more complexity of models, which would rapidly grow to have many to many relationships. As I said, current system is stateless, using HMAC. I don't think it would be an issue, but if it is then we can look into it again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. How about sending an email to the teccy when the client gets sent one (obvs without the secret URL)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would work, but in your scenario the teccie is confused that the email has not been sent, so will just send it again, probably without checking their own email first.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, thinking about this further I did consider not autoclosing the modal and instead displaying a success alert informing the user to do this manually. That would be much more verbose, but also more annoying

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An idea I just had: how about just adding "Last sent to", "Last sent at" and "last_sent_by" fields to the EventAuthorisation model. Update those whenever a teccie presses "send", and the history will be kept by reversion


{{request.scheme}}://{{request.get_host}}{% url 'event_authorise' object.pk hmac %}

The TEC Rig Information Gathering System
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this needs a "PLEASE DO NOT RESPOND TO THIS ADDRESS"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always think that looks god awful, so I've set the reply-to address to something sensible now so theoretically we should never have a problem.

I would also suggest setting rigs@nottinghamtec.co.uk to forward somewhere sensible (productions or it, one or the other)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with just setting the reply-to, but just remember if they do reply to the email and it goes to the teccie, the teccie then has the super secret URL

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, well aware of that, but at that point, thats their problem for disclosing the secret URL, we have taken reasonable measures already.

Your event is now fully booked and our finance department will be contact to arrange payment.
{% endif %}

The TEC Rig Information Gathering System
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this needs a "PLEASE DO NOT RESPOND TO THIS ADDRESS"


<div class="form-group">
<label class="col-sm-2 control-label"
for="{{ form.email.id_for_label }}">{{ form.email.label }}</label>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This popup needs more warnings.

YOU ARE ABOUT TO SEND THIS TO A CLIENT, QUADRUPLE CHECK ALL THE THINGS, DON'T BE A MORON

The client will be able to see all contact info, event items, the event title, the event description (not notes), and the MIC name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to bring out the 'delete invoice' UI for sending emails now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preferably yes 🎉

@tomtom5152 tomtom5152 temporarily deployed to pyrigs-pr-283 April 11, 2017 13:03 Inactive
Noticed in testing, that could have gone badly.
@tomtom5152 tomtom5152 temporarily deployed to pyrigs-pr-283 April 11, 2017 13:10 Inactive
@tomtom5152 tomtom5152 temporarily deployed to pyrigs-pr-283 April 11, 2017 13:32 Inactive
@davidtaylorhq davidtaylorhq temporarily deployed to pyrigs-pr-283 May 18, 2017 15:22 Inactive
@davidtaylorhq davidtaylorhq temporarily deployed to pyrigs-pr-283 May 18, 2017 15:30 Inactive
@davidtaylorhq davidtaylorhq temporarily deployed to pyrigs-pr-283 May 18, 2017 15:34 Inactive
@davidtaylorhq davidtaylorhq temporarily deployed to pyrigs-pr-283 May 18, 2017 15:42 Inactive
@davidtaylorhq davidtaylorhq temporarily deployed to pyrigs-pr-283 May 18, 2017 16:23 Inactive
@davidtaylorhq davidtaylorhq temporarily deployed to pyrigs-pr-283 May 18, 2017 16:35 Inactive
@davidtaylorhq
Copy link
Contributor

If it's been sent to the client:
screen shot 2017-05-18 at 17 32 45

If it's been approved by the client:
screen shot 2017-05-18 at 17 32 34

# Conflicts:
#	RIGS/test_functional.py
@davidtaylorhq davidtaylorhq temporarily deployed to pyrigs-pr-283 May 18, 2017 16:50 Inactive
@davidtaylorhq davidtaylorhq temporarily deployed to pyrigs-pr-283 May 18, 2017 17:02 Inactive
@davidtaylorhq
Copy link
Contributor

Note to self: (cos I don't have time right now)

There's a missing space at the bottom of the paperwork

screen shot 2017-05-19 at 15 52 23

@tomtom5152 tomtom5152 temporarily deployed to pyrigs-pr-283 May 23, 2017 17:19 Inactive
@davidtaylorhq davidtaylorhq temporarily deployed to pyrigs-pr-283 May 23, 2017 17:26 Inactive
@davidtaylorhq davidtaylorhq temporarily deployed to pyrigs-pr-283 May 23, 2017 17:32 Inactive
@tomtom5152 tomtom5152 temporarily deployed to pyrigs-pr-283 May 23, 2017 18:18 Inactive
Actually finish fixing PDF footer formatting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show PO on finance screens Online rig authorisation
3 participants