diff --git a/erpnext/non_profit/doctype/chapter/chapter.json b/erpnext/non_profit/doctype/chapter/chapter.json index 2d159f3a85..718df6f91e 100644 --- a/erpnext/non_profit/doctype/chapter/chapter.json +++ b/erpnext/non_profit/doctype/chapter/chapter.json @@ -2,7 +2,7 @@ "allow_copy": 0, "allow_guest_to_view": 1, "allow_import": 0, - "allow_rename": 0, + "allow_rename": 1, "autoname": "field:title", "beta": 0, "creation": "2017-09-14 13:36:03.904702", @@ -170,6 +170,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "description": "chapters/chapter_name\nleave blank automatically set after saving chapter.", "fieldname": "route", "fieldtype": "Data", "hidden": 0, @@ -297,7 +298,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-11-23 17:31:44.669507", + "modified": "2017-11-24 15:47:01.752772", "modified_by": "Administrator", "module": "Non Profit", "name": "Chapter", @@ -329,7 +330,7 @@ "read_only": 0, "read_only_onload": 0, "restrict_to_domain": "Non Profit", - "route": "chapter", + "route": "chapters", "show_name_in_global_search": 0, "sort_field": "modified", "sort_order": "DESC", diff --git a/erpnext/non_profit/doctype/chapter/chapter.py b/erpnext/non_profit/doctype/chapter/chapter.py index efde580b83..7ee74d2a38 100644 --- a/erpnext/non_profit/doctype/chapter/chapter.py +++ b/erpnext/non_profit/doctype/chapter/chapter.py @@ -5,18 +5,20 @@ from __future__ import unicode_literals import frappe from frappe.website.website_generator import WebsiteGenerator -from frappe.model.document import Document -from frappe import _ class Chapter(WebsiteGenerator): + _website = frappe._dict( + condition_field = "published", + ) + def get_context(self, context): context.no_cache = True + context.parents = [dict(label='View All Chapters', + route='chapters', title='View Chapters')] def validate(self): - chapter_head = self.chapter_head - chapter = frappe.get_all('Chapter', filters={'published': True}, fields=['chapter_head']) if not self.route: #pylint: disable=E0203 - self.route = 'chapter/' + self.scrub(self.name) + self.route = 'chapters/' + self.scrub(self.name) def enable(self): chapter = frappe.get_doc('Chapter', frappe.form_dict.name) @@ -31,4 +33,4 @@ def get_list_context(context): context.title = 'All Chapters' context.no_breadcrumbs = True context.order_by = 'creation desc' - context.introduction = '
All Chapters
' + context.introduction = 'All Chapters
' \ No newline at end of file diff --git a/erpnext/non_profit/doctype/chapter/templates/chapter.html b/erpnext/non_profit/doctype/chapter/templates/chapter.html index c2d871c5e7..8953481196 100644 --- a/erpnext/non_profit/doctype/chapter/templates/chapter.html +++ b/erpnext/non_profit/doctype/chapter/templates/chapter.html @@ -57,8 +57,8 @@{{ address }}
- - + + {% endblock %} diff --git a/erpnext/non_profit/doctype/chapter/templates/chapter_row.html b/erpnext/non_profit/doctype/chapter/templates/chapter_row.html index 042aede17c..b6780e2328 100644 --- a/erpnext/non_profit/doctype/chapter/templates/chapter_row.html +++ b/erpnext/non_profit/doctype/chapter/templates/chapter_row.html @@ -1,5 +1,5 @@{{ frappe.db.get_value('User', chapter_head, 'full_name') }} @@ -14,4 +14,45 @@
{{ html2text(doc.introduction[:200]) }}{% if introduction|len > 200 %}...{% endif %}
Please signup and login to join this chapter
+ +{% else %} + {% if already_member %} +You are already a member of {{ chapter.title }}!
+ {{ chapter_button() }} + + {% else %} + {% if frappe.local.request.method=='POST' %} +Welcome to chapter {{ chapter.title }}!
+ {{ chapter_button() }} + {% else %} +You are not a member of {{ chapter.title }}!
+Please signup and login to join this chapter
+ + + {% endif %} +{% endblock %} \ No newline at end of file diff --git a/erpnext/templates/pages/non_profit/leave_chapter.py b/erpnext/templates/pages/non_profit/leave_chapter.py new file mode 100644 index 0000000000..6dbdeca528 --- /dev/null +++ b/erpnext/templates/pages/non_profit/leave_chapter.py @@ -0,0 +1,15 @@ +import frappe + +def get_context(context): + context.no_cache = True + chapter = frappe.get_doc('Chapter', frappe.form_dict.name) + # if frappe.session.user!='Guest': + if frappe.session.user in [d.user for d in chapter.members]: + user = frappe.session.user + parent = frappe.form_dict.name + frappe.db.sql("""delete from `tabChapter Member` where parent = %s and user = %s """, (parent, user)) + frappe.db.commit() + + context.member_deleted = True + + context.chapter = chapter