From a6a302f8a6134ff33866f7c13acadc1211143e86 Mon Sep 17 00:00:00 2001 From: Vishal Date: Tue, 31 Oct 2017 13:27:49 +0530 Subject: [PATCH] [new] Grant Application Web Form Added --- erpnext/hooks.py | 4 +- .../grant_application/grant_application.json | 122 +++++++++++++++++- .../grant_application/grant_application.py | 28 +++- .../templates/grant_application.html | 52 ++++++++ .../templates/grant_application_row.html | 9 ++ erpnext/non_profit/web_form/__init__.py | 0 .../web_form/grant_application/__init__.py | 0 .../grant_application/grant_application.js | 3 + .../grant_application/grant_application.json | 117 +++++++++++++++++ .../grant_application/grant_application.py | 7 + 10 files changed, 335 insertions(+), 7 deletions(-) create mode 100644 erpnext/non_profit/doctype/grant_application/templates/grant_application.html create mode 100644 erpnext/non_profit/doctype/grant_application/templates/grant_application_row.html create mode 100644 erpnext/non_profit/web_form/__init__.py create mode 100644 erpnext/non_profit/web_form/grant_application/__init__.py create mode 100644 erpnext/non_profit/web_form/grant_application/grant_application.js create mode 100644 erpnext/non_profit/web_form/grant_application/grant_application.json create mode 100644 erpnext/non_profit/web_form/grant_application/grant_application.py diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 65953ece3d0..0b7d3eecc09 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -125,6 +125,7 @@ website_route_rules = [ {"from_route": "/admissions", "to_route": "Student Admission"}, {"from_route": "/boms", "to_route": "BOM"}, {"from_route": "/timesheets", "to_route": "Timesheet"}, + {"from_route": "/grant-application", "to_route": "Grant Application"}, ] standard_portal_menu_items = [ @@ -144,7 +145,8 @@ standard_portal_menu_items = [ {"title": _("Patient Appointment"), "route": "/patient-appointments", "reference_doctype": "Patient Appointment", "role":"Patient"}, {"title": _("Fees"), "route": "/fees", "reference_doctype": "Fees", "role":"Student"}, {"title": _("Newsletter"), "route": "/newsletters", "reference_doctype": "Newsletter"}, - {"title": _("Admission"), "route": "/admissions", "reference_doctype": "Student Admission"} + {"title": _("Admission"), "route": "/admissions", "reference_doctype": "Student Admission"}, + {"title": _("Grant Application"), "route": "/grant-application", "reference_doctype": "Grant Application"} ] default_roles = [ diff --git a/erpnext/non_profit/doctype/grant_application/grant_application.json b/erpnext/non_profit/doctype/grant_application/grant_application.json index e7d23144eba..509f67b6311 100644 --- a/erpnext/non_profit/doctype/grant_application/grant_application.json +++ b/erpnext/non_profit/doctype/grant_application/grant_application.json @@ -1,6 +1,6 @@ { "allow_copy": 0, - "allow_guest_to_view": 0, + "allow_guest_to_view": 1, "allow_import": 0, "allow_rename": 0, "autoname": "field:email", @@ -19,7 +19,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "organization", + "fieldname": "title", "fieldtype": "Data", "hidden": 0, "ignore_user_permissions": 0, @@ -132,6 +132,38 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "default": "Open", + "fieldname": "status", + "fieldtype": "Select", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Status", + "length": 0, + "no_copy": 0, + "options": "Open\nReceived\nIn Progress\nApproved\nRejected\nExpired\nWithdrawan", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -462,20 +494,81 @@ "search_index": 0, "set_only_once": 0, "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "route", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Route", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "published", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Show on Website", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 } ], - "has_web_view": 0, + "has_web_view": 1, "hide_heading": 0, "hide_toolbar": 0, "idx": 0, "image_field": "image", "image_view": 0, "in_create": 0, + "is_published_field": "published", "is_submittable": 0, "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-09-22 13:10:32.303551", + "modified": "2017-10-30 16:18:40.911012", "modified_by": "Administrator", "module": "Non Profit", "name": "Grant Application", @@ -501,11 +594,32 @@ "share": 1, "submit": 0, "write": 1 + }, + { + "amend": 0, + "apply_user_permissions": 0, + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "export": 1, + "if_owner": 0, + "import": 0, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Website Manager", + "set_user_permissions": 0, + "share": 1, + "submit": 0, + "write": 1 } ], "quick_entry": 1, "read_only": 0, "read_only_onload": 0, + "route": "grant-application", "show_name_in_global_search": 0, "sort_field": "modified", "sort_order": "DESC", diff --git a/erpnext/non_profit/doctype/grant_application/grant_application.py b/erpnext/non_profit/doctype/grant_application/grant_application.py index d97de40918c..de44e7975d8 100644 --- a/erpnext/non_profit/doctype/grant_application/grant_application.py +++ b/erpnext/non_profit/doctype/grant_application/grant_application.py @@ -3,10 +3,34 @@ # For license information, please see license.txt from __future__ import unicode_literals -from frappe.model.document import Document +import frappe +from frappe.website.website_generator import WebsiteGenerator from frappe.contacts.address_and_contact import load_address_and_contact -class GrantApplication(Document): +class GrantApplication(WebsiteGenerator): + _website = frappe._dict( + condition_field = "published", + ) + + def validate(self): + if not self.route: + self.route = 'grant-application/' + self.scrub(self.name) + def onload(self): """Load address and contacts in `__onload`""" load_address_and_contact(self) + + + def get_context(self, context): + context.no_cache = True + context.parents = [dict(label='View All ', + route='grant-application', title='View All')] + + + +def get_list_context(context): + context.allow_guest = True + context.no_cache = True + context.no_breadcrumbs = True + context.order_by = 'creation desc' + context.introduction ='
Grant Application List

Apply for new Grant Application' diff --git a/erpnext/non_profit/doctype/grant_application/templates/grant_application.html b/erpnext/non_profit/doctype/grant_application/templates/grant_application.html new file mode 100644 index 00000000000..8532ea78b39 --- /dev/null +++ b/erpnext/non_profit/doctype/grant_application/templates/grant_application.html @@ -0,0 +1,52 @@ +{% extends "templates/web.html" %} + +{% block page_content %} +

{{ title }}

+{% if frappe.user == owner %} +

Edit Grant

+{% endif %} +
+ + + + + + + + + + + + + + + + + + + + + +
Organization/Indvidual{{ title }}
Grant Applicant Name{{ grant_applicant_name }}
Date{{ frappe.format_date(creation) }}
Status{{ status }}
Email{{ email }}
+

Please outline your current situation and why you are applying for a grant?

+

{{ grant_description }}

+

Please Describe the purpose of the grant and how it will benfit your organization?

+

{{ grant_purpose }}

+

Amount Requested Details

+

{{ amount }}

+

Have you Recevied grant from us before?

+

{{ grant_past_record }}

+

Contact

+{% if frappe.user != 'Guest' %} + + + + + +
Email{{ email }}
+{% else %} +

You must register and login to view contact details

+{% endif %} +


Post a New Grant

+ +{% endblock %} \ No newline at end of file diff --git a/erpnext/non_profit/doctype/grant_application/templates/grant_application_row.html b/erpnext/non_profit/doctype/grant_application/templates/grant_application_row.html new file mode 100644 index 00000000000..18c1ffec6f2 --- /dev/null +++ b/erpnext/non_profit/doctype/grant_application/templates/grant_application_row.html @@ -0,0 +1,9 @@ +
+ +

{{ doc.title }}

+

+ {{ frappe.format_date(doc.creation) }} +

+
+
diff --git a/erpnext/non_profit/web_form/__init__.py b/erpnext/non_profit/web_form/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/non_profit/web_form/grant_application/__init__.py b/erpnext/non_profit/web_form/grant_application/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/non_profit/web_form/grant_application/grant_application.js b/erpnext/non_profit/web_form/grant_application/grant_application.js new file mode 100644 index 00000000000..699703c5792 --- /dev/null +++ b/erpnext/non_profit/web_form/grant_application/grant_application.js @@ -0,0 +1,3 @@ +frappe.ready(function() { + // bind events here +}) \ No newline at end of file diff --git a/erpnext/non_profit/web_form/grant_application/grant_application.json b/erpnext/non_profit/web_form/grant_application/grant_application.json new file mode 100644 index 00000000000..70df81ebf9e --- /dev/null +++ b/erpnext/non_profit/web_form/grant_application/grant_application.json @@ -0,0 +1,117 @@ +{ + "accept_payment": 0, + "allow_comments": 0, + "allow_delete": 1, + "allow_edit": 1, + "allow_incomplete": 0, + "allow_multiple": 1, + "allow_print": 0, + "amount": 0.0, + "amount_based_on_field": 0, + "creation": "2017-10-30 15:57:10.825188", + "currency": "INR", + "doc_type": "Grant Application", + "docstatus": 0, + "doctype": "Web Form", + "idx": 0, + "introduction_text": "Share as many details as you can to get quick response from organization", + "is_standard": 1, + "login_required": 1, + "max_attachment_size": 0, + "modified": "2017-10-31 13:25:40.670895", + "modified_by": "Administrator", + "module": "Non Profit", + "name": "grant-application", + "owner": "Administrator", + "payment_button_label": "Buy Now", + "published": 1, + "route": "my-grant", + "show_sidebar": 1, + "sidebar_items": [], + "success_url": "/grant-application", + "title": "Grant Application", + "web_form_fields": [ + { + "fieldname": "title", + "fieldtype": "Data", + "hidden": 0, + "label": "Organization", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "grant_applicant_name", + "fieldtype": "Data", + "hidden": 0, + "label": "Grant Applicant Name", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "email", + "fieldtype": "Data", + "hidden": 0, + "label": "Email Address", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 1 + }, + { + "description": "", + "fieldname": "grant_description", + "fieldtype": "Text", + "hidden": 0, + "label": "Please outline your current situation and why you are applying for a grant?", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "grant_purpose", + "fieldtype": "Text", + "hidden": 0, + "label": "Grant Purpose", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "amount", + "fieldtype": "Float", + "hidden": 0, + "label": "Amount Request", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "grant_past_record", + "fieldtype": "Select", + "hidden": 0, + "label": "Grant History", + "max_length": 0, + "max_value": 0, + "options": "YES\nNO", + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "published", + "fieldtype": "Check", + "hidden": 0, + "label": "Show on Website", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 0 + } + ] +} \ No newline at end of file diff --git a/erpnext/non_profit/web_form/grant_application/grant_application.py b/erpnext/non_profit/web_form/grant_application/grant_application.py new file mode 100644 index 00000000000..2334f8b26d8 --- /dev/null +++ b/erpnext/non_profit/web_form/grant_application/grant_application.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +import frappe + +def get_context(context): + # do your magic here + pass