From bbc5c10cea0da6c18317562642bec567a1baa843 Mon Sep 17 00:00:00 2001 From: Vishal Date: Wed, 15 Nov 2017 15:58:34 +0530 Subject: [PATCH] [new] On Chapter Leave member details not erased --- .../doctype/chapter/chapter.py | 14 +++++++ .../doctype/chapter/templates/chapter.html | 40 ++++++++++--------- .../chapter_member/chapter_member.json | 32 ++++++++++++++- foundation/www/join_chapter.py | 4 +- foundation/www/leave-chapter.html | 35 +++++++++++++++- foundation/www/leave_chapter.py | 16 +++++++- 6 files changed, 118 insertions(+), 23 deletions(-) diff --git a/foundation/erpnext_foundation/doctype/chapter/chapter.py b/foundation/erpnext_foundation/doctype/chapter/chapter.py index 67bd2342..b69b6c6e 100644 --- a/foundation/erpnext_foundation/doctype/chapter/chapter.py +++ b/foundation/erpnext_foundation/doctype/chapter/chapter.py @@ -33,3 +33,17 @@ def get_list_context(context): context.no_breadcrumbs = True context.order_by = 'creation desc' context.introduction = '

All ERPNext Chapters

' + + +@frappe.whitelist() +def leave(title, user_id, leave_reason): + chapter = frappe.get_doc("Chapter", title) + for member in chapter.members: + for x in xrange(1,10): + print(member.user, user_id) + if member.user == user_id: + member.enabled = 0 + member.leave_reason = leave_reason + chapter.save(ignore_permissions=1) + frappe.db.commit() + return "Thank you for Feedback" \ No newline at end of file diff --git a/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html b/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html index 8649904c..832aef51 100644 --- a/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html +++ b/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html @@ -8,31 +8,35 @@ {{ meetup_embed_html }} {% endif %}

List of Members

-{% if members %} +{% if members %} + {% set flag = 1 -%} {% for user in members %} - - - + + - + + + {% set flag = flag + 1 -%} + {% endif %} {% endfor %}
Member Details
{{ loop.index }} -
-
{{ frappe.db.get_value('User', user.user, 'full_name') }}
-
- {% if user.website_url %} - {{ user.website_url or '' }} - {% endif %} + {% if user.enabled == 1 %} +
{{ flag }} +
+
{{ frappe.db.get_value('User', user.user, 'full_name') }}
+
+ {% if user.website_url %} + {{ user.website_url or '' }} + {% endif %} +
+
+ {% if user.introduction %} + {{ user.introduction }} + {% endif %} +
-
- {% if user.introduction %} - {{ user.introduction }} - {% endif %} -
- -
{% else %} diff --git a/foundation/erpnext_foundation/doctype/chapter_member/chapter_member.json b/foundation/erpnext_foundation/doctype/chapter_member/chapter_member.json index dbc5f5af..60074372 100644 --- a/foundation/erpnext_foundation/doctype/chapter_member/chapter_member.json +++ b/foundation/erpnext_foundation/doctype/chapter_member/chapter_member.json @@ -132,6 +132,36 @@ "search_index": 0, "set_only_once": 0, "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "leave_reason", + "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": "Leave Reason", + "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, @@ -144,7 +174,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2017-05-22 16:29:01.536405", + "modified": "2017-11-15 02:09:49.082752", "modified_by": "Administrator", "module": "ERPNext Foundation", "name": "Chapter Member", diff --git a/foundation/www/join_chapter.py b/foundation/www/join_chapter.py index bc9ba6ba..121f4440 100644 --- a/foundation/www/join_chapter.py +++ b/foundation/www/join_chapter.py @@ -4,14 +4,14 @@ 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]: + if frappe.session.user in [d.user for d in chapter.members if d.enabled == 1]: context.already_member = True else: if frappe.request.method=='GET': pass elif frappe.request.method=='POST': chapter.append('members', dict( - user=frappe.session.user, + user=frappe.session.user, introduction=frappe.form_dict.introduction, website_url=frappe.form_dict.website_url, enabled=1 diff --git a/foundation/www/leave-chapter.html b/foundation/www/leave-chapter.html index 2f8452d5..4310831a 100644 --- a/foundation/www/leave-chapter.html +++ b/foundation/www/leave-chapter.html @@ -1,5 +1,5 @@ {% extends "templates/web.html" %} -