feat: added mail function and new fields

This commit is contained in:
Shivam Mishra
2019-08-02 19:23:02 +05:30
parent a24371e587
commit 3d8cad0b49
2 changed files with 28 additions and 6 deletions

View File

@@ -7,6 +7,7 @@
"field_order": [
"participant_details_section",
"participant_name",
"participant_designation",
"column_break_3",
"email",
"conference_details_section",
@@ -42,7 +43,7 @@
"fieldname": "email",
"fieldtype": "Data",
"label": "Email",
"options": "User"
"options": "Email"
},
{
"fieldname": "conference_details_section",
@@ -53,7 +54,7 @@
"fieldname": "conference",
"fieldtype": "Select",
"label": "Conference",
"options": "\n2017\n2018"
"options": "\n2017\n2018\n2019"
},
{
"fieldname": "full_conference_tickets",
@@ -107,9 +108,15 @@
"fieldtype": "Table",
"label": "T-Shirt Sizes",
"options": "TShirt Sizes"
},
{
"fieldname": "participant_designation",
"fieldtype": "Select",
"label": "Participant Designation",
"options": "\nCxO\nAnalyst\nConsultant\nDeveloper\nSystem Administrator\nOther"
}
],
"modified": "2019-08-02 10:29:22.188416",
"modified": "2019-08-02 19:07:44.339770",
"modified_by": "Administrator",
"module": "ERPNext Foundation",
"name": "Conference Participant",

View File

@@ -8,9 +8,8 @@ from frappe.model.document import Document
class ConferenceParticipant(Document):
def validate(self):
self.conference = '2018'
if self.owner not in ["Guest", "Administrator"] and not self.get("email"):
self.email = frappe.db.get_value('User', self.owner, "email")
self.conference = '2019'
self.send_ticket_mail()
def validate_payment(self):
self.amount = self.full_conference_tickets * (4000 if self.currency == 'INR' else 60)
@@ -18,3 +17,19 @@ class ConferenceParticipant(Document):
def on_payment_authorized(self, status_changed_to=None):
self.paid = 1
self.save(ignore_permissions=True)
def send_ticket_mail(self):
if self.paid == 1:
message = """Thank you for participating in the ERPNext Conference {0}.
<br> You can find your ticket attached with this email,
for more details about the conference please visit https://erpnext.com/conf/{0}""".format(self.conference)
email_args = {
"recipients": [self.email],
"message": _(message),
"subject": 'Your Ticket for ERPNext Conference 2019',
"attachments": [frappe.attach_print(self.doctype, self.name, file_name=self.name, print_format='Conference Ticket')],
"reference_doctype": self.doctype,
"reference_name": self.name
}
frappe.sendmail(**email_args)
self.thank_you_email_sent = 1