Skip to content

Conversation

@DeeMysterio
Copy link
Contributor

@DeeMysterio DeeMysterio commented May 21, 2019

Purpose-
You may want to get a draft document authorised by the customer first and then go ahead with further processing.

Screenshot 2019-05-22 at 6 18 56 PM

Screenshot 2019-05-22 at 6 17 09 PM

Screenshot 2019-05-22 at 6 12 13 PM

Updates :

  • Authorization Request for Quotation :

auth_req_quotation

  • Authorization Request for Contract :

auth_req_contract

@vjFaLk vjFaLk temporarily deployed to Tugboat May 21, 2019 15:32 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat May 22, 2019 10:53 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat May 22, 2019 14:54 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat May 22, 2019 15:01 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat May 23, 2019 00:41 Destroyed
self.token_generated_on = now_datetime()
self.request_link = "http://localhost:8000/authorize_document?token={0}&name={1}".format(self.token, self.name)

def email_link(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Call this send_authorization_request instead?

def generate_token(self):
self.token = frappe.generate_hash(self.name, 32)
self.token_generated_on = now_datetime()
self.request_link = "http://localhost:8000/authorize_document?token={0}&name={1}".format(self.token, self.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use frappe.local.site to get sitename


def email_link(self):
"""
Email the document link to user for them to authorize the document
Copy link
Contributor

Choose a reason for hiding this comment

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

Change to "Email the link to user for them to authorize the document"

"""
message = frappe.render_template("templates/emails/authorization_request.html", {
"authorization_request": self,
"link": self.request_link
Copy link
Contributor

Choose a reason for hiding this comment

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

The authorization request will have the link anyway. No need to pass the link separately.

})

frappe.sendmail(recipients=[self.authorizer_email], subject="You have a document to authorize", message=message)
frappe.msgprint("Document has been successfully sent to Email")
Copy link
Contributor

Choose a reason for hiding this comment

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

Change this to "Request Link has been successfully sent to Email"

if (!frm.doc.customer_signature) {
frm.add_custom_button(__("Authorize"), () => {
frappe.new_doc("Authorization Request", {
linked_doctype: frm.doc.doctype,
Copy link
Contributor

Choose a reason for hiding this comment

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

Add email and name as well?


@frappe.whitelist()
def make_authorization_request(source_name, target_doc=None):
print(locals())
Copy link
Contributor

Choose a reason for hiding this comment

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

Errr 😅

docname = frappe.local.request.args.get("name")

auth_req = frappe.get_doc("Authorization Request", docname)
if not token or token == auth_req.token:
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be if not token or token != auth_req.token

@vjFaLk vjFaLk temporarily deployed to Tugboat May 24, 2019 00:42 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat May 25, 2019 00:41 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat May 26, 2019 00:43 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat May 27, 2019 00:41 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat May 28, 2019 00:42 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat May 28, 2019 09:57 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat May 28, 2019 13:08 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat May 29, 2019 00:44 Destroyed
authorization_request.save()

authorized_doc = frappe.get_doc(authorization_request.linked_doctype, authorization_request.linked_docname)
try:
Copy link
Contributor

Choose a reason for hiding this comment

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

You always want to except for a particular exception. I don't see the point of this try catch if you're going to do a .submit() anyway?

I think you should spend some time understanding how exception handling works

frappe.ui.form.on("Authorization Request", {

});
// frm.set_df_property("patient", "hidden", 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this commented out code

@vjFaLk vjFaLk temporarily deployed to Tugboat May 29, 2019 11:59 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat May 30, 2019 00:24 Destroyed
def generate_token(self):
self.token = frappe.generate_hash(self.name, 32)
self.token_generated_on = now_datetime()
self.request_link = "http://{0}/authorize_document?token={1}&name={2}".format(frappe.local.site, self.token, self.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
self.request_link = "http://{0}/authorize_document?token={1}&name={2}".format(frappe.local.site, self.token, self.name)
from frappe.utils.data import get_url
self.request_link = "{0}/authorize_document?token={1}&name={2}".format(get_url(), self.token, self.name)

@@ -0,0 +1 @@
<p>Hi, a document has been generated for you to authorize, please go here {{ link }}</p> No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

Ashwin shared an HTML file on the Task for this feature. Replace this HTML with that - maybe get @Er-Naren719 to help you with the template.

$("#step2").on("click", function () {
var sign = $sigdiv.jSignature("getData");
var signee = document.getElementById("signee").value;
if (!($sigdiv.jSignature('getData', 'native').length == 0) && signee) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add some comments on what you're doing here exactly. Especially since you're using a separate library. Also fix formatting for this file ("Format Document" in VSCode).


@frappe.whitelist(allow_guest=True)
def authorize_document(sign=None, signee=None, docname=None):
authorization_request = frappe.get_doc("Authorization Request", docname)
Copy link
Contributor

Choose a reason for hiding this comment

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

get_doc will fail if the document doesn't exist. Just as a sanity check, do:

Suggested change
authorization_request = frappe.get_doc("Authorization Request", docname)
if frappe.db.exists("Authorization Request", docname):
authorization_request = frappe.get_doc("Authorization Request", docname)


authorized_doc = frappe.get_doc(authorization_request.linked_doctype, authorization_request.linked_docname)
if hasattr(authorized_doc, "is_signed"):
authorized_doc.is_signed = 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Only set this if the document is not already signed.

@vjFaLk vjFaLk temporarily deployed to Tugboat May 31, 2019 00:24 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat May 31, 2019 11:53 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat May 31, 2019 12:20 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 1, 2019 00:10 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 2, 2019 00:09 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 3, 2019 00:11 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 6, 2019 10:30 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 7, 2019 00:40 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 8, 2019 00:52 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 9, 2019 01:03 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 10, 2019 01:09 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 11, 2019 00:11 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 14, 2019 00:54 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 15, 2019 01:07 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 16, 2019 01:05 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 17, 2019 01:05 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 18, 2019 00:09 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 19, 2019 00:39 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 20, 2019 00:10 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 21, 2019 00:12 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 21, 2019 07:11 Destroyed
@vjFaLk
Copy link
Contributor

vjFaLk commented Jun 21, 2019

@Alchez Is this approved?

@Alchez
Copy link
Contributor

Alchez commented Jun 21, 2019

@DeeMysterio, can you update the screenshots with the new web view and other changes?

@vjFaLk vjFaLk temporarily deployed to Tugboat June 21, 2019 10:42 Destroyed
frappe.local.flags.ignore_print_permissions = True
context.print_doc = frappe.get_print(auth_req.linked_doctype, auth_req.linked_docname)
print_doc = frappe.get_print(auth_req.linked_doctype, auth_req.linked_docname)
context.print_doc = print_doc[print_doc.find('<body>')+len('<body>'):len(print_doc)-len('</body>')]
Copy link
Contributor

Choose a reason for hiding this comment

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

Wow, there has to be a better way to do this 🤣

@DeeMysterio DeeMysterio changed the title Request Authorization for a quotation feat(core): authorization request for a document Jun 21, 2019
@vjFaLk vjFaLk temporarily deployed to Tugboat June 22, 2019 00:10 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 23, 2019 00:09 Destroyed
@vjFaLk vjFaLk temporarily deployed to Tugboat June 24, 2019 00:09 Destroyed
@vjFaLk vjFaLk merged commit b932a87 into Bloomstack:staging Jun 24, 2019
@Alchez Alchez deleted the request-authorization branch June 28, 2019 07:45
@Alchez Alchez restored the request-authorization branch June 28, 2019 07:45
@dti-deploy
Copy link

🎉 This PR is included in version 1.3.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants