From 8c815c48973c5db54fea8eea8e0578d4d6ee264d Mon Sep 17 00:00:00 2001 From: Ashwini Save Date: Mon, 15 May 2017 14:57:16 +0530 Subject: [PATCH] Adding User details to Chapter Member docType. --- .../doctype/chapter/chapter.py | 10 +- .../doctype/chapter/templates/chapter.html | 13 +- .../chapter_member/chapter_member.json | 92 ++++++++- .../doctype/chapter_member/chapter_member.py | 6 +- .../chapter_message/chapter_message.js | 1 - foundation/www/join-chapter.html | 178 ++++++++++++++++++ foundation/www/join_chapter.js | 12 ++ foundation/www/join_chapter.py | 1 + foundation/www/user-intro.html | 7 + foundation/www/user_intro.py | 15 ++ 10 files changed, 329 insertions(+), 6 deletions(-) create mode 100644 foundation/www/join_chapter.js create mode 100644 foundation/www/user-intro.html create mode 100644 foundation/www/user_intro.py diff --git a/foundation/erpnext_foundation/doctype/chapter/chapter.py b/foundation/erpnext_foundation/doctype/chapter/chapter.py index 323a15ac..67bd2342 100644 --- a/foundation/erpnext_foundation/doctype/chapter/chapter.py +++ b/foundation/erpnext_foundation/doctype/chapter/chapter.py @@ -16,8 +16,14 @@ class Chapter(WebsiteGenerator): chapter_head = self.chapter_head chapter = frappe.get_all('Chapter', filters={'published': True}, fields=['chapter_head']) - if chapter_head in [d.chapter_head for d in chapter]: - frappe.throw(_('You are not allow to create more than one Chapter')) + # if chapter_head in [d.chapter_head for d in chapter]: + # frappe.throw(_('You are not allow to create more than one Chapter')) + + def enable(self): + chapter = frappe.get_doc('Chapter', frappe.form_dict.name) + chapter.append('members', dict(enable=self.value)) + chapter.save(ignore_permissions=1) + frappe.db.commit() def get_list_context(context): diff --git a/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html b/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html index ed2ce9f6..9f713507 100644 --- a/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html +++ b/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html @@ -6,15 +6,26 @@

{{ introduction }}

List of Members

{% if members %} - +
+ + + {% for user in members %} + + + {% else %} + {{ user.website_url }} + {% endif %} + {% endfor %} diff --git a/foundation/erpnext_foundation/doctype/chapter_member/chapter_member.json b/foundation/erpnext_foundation/doctype/chapter_member/chapter_member.json index b76f8104..eefae909 100644 --- a/foundation/erpnext_foundation/doctype/chapter_member/chapter_member.json +++ b/foundation/erpnext_foundation/doctype/chapter_member/chapter_member.json @@ -42,6 +42,96 @@ "search_index": 0, "set_only_once": 0, "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "introduction", + "fieldtype": "Text", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Introduction", + "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": "enabled", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Enabled", + "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": "website_url", + "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": "Website URL", + "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, @@ -54,7 +144,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2017-05-08 17:01:30.018083", + "modified": "2017-05-12 16:36:07.139907", "modified_by": "Administrator", "module": "ERPNext Foundation", "name": "Chapter Member", diff --git a/foundation/erpnext_foundation/doctype/chapter_member/chapter_member.py b/foundation/erpnext_foundation/doctype/chapter_member/chapter_member.py index 02fa4634..ebeffa51 100644 --- a/foundation/erpnext_foundation/doctype/chapter_member/chapter_member.py +++ b/foundation/erpnext_foundation/doctype/chapter_member/chapter_member.py @@ -7,4 +7,8 @@ import frappe from frappe.model.document import Document class ChapterMember(Document): - pass + def get_context(self, context): + context.no_cache = True + + + diff --git a/foundation/erpnext_foundation/doctype/chapter_message/chapter_message.js b/foundation/erpnext_foundation/doctype/chapter_message/chapter_message.js index 371fea5e..739eaa99 100644 --- a/foundation/erpnext_foundation/doctype/chapter_message/chapter_message.js +++ b/foundation/erpnext_foundation/doctype/chapter_message/chapter_message.js @@ -9,5 +9,4 @@ frappe.ui.form.on('Chapter Message', { frm.set_value('chapter', data.name); }) }, - // refs }); diff --git a/foundation/www/join-chapter.html b/foundation/www/join-chapter.html index 7ec84ed3..b4abcccd 100644 --- a/foundation/www/join-chapter.html +++ b/foundation/www/join-chapter.html @@ -10,7 +10,185 @@ {% else %}

Welcome to chapter {{ chapter.title }}!

{% endif %} +
+
+
+
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ +
+
+
+

Go to Chapter Page

{% endif %} + + {% endblock %} \ No newline at end of file diff --git a/foundation/www/join_chapter.js b/foundation/www/join_chapter.js new file mode 100644 index 00000000..e2bc8bca --- /dev/null +++ b/foundation/www/join_chapter.js @@ -0,0 +1,12 @@ +// Copyright (c) 2017, EOSSF and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Chapter Member', { + onsubmit: function (frm) { + console.log("here" + frappe.session.user) + // body... + } + refresh: function(frm) { + + } +}); diff --git a/foundation/www/join_chapter.py b/foundation/www/join_chapter.py index d18bad72..b5a6290d 100644 --- a/foundation/www/join_chapter.py +++ b/foundation/www/join_chapter.py @@ -3,6 +3,7 @@ import frappe def get_context(context): context.no_cache = True chapter = frappe.get_doc('Chapter', frappe.form_dict.name) + print chapter if frappe.session.user!='Guest': if frappe.session.user in [d.user for d in chapter.members]: context.already_member = True diff --git a/foundation/www/user-intro.html b/foundation/www/user-intro.html new file mode 100644 index 00000000..6777496f --- /dev/null +++ b/foundation/www/user-intro.html @@ -0,0 +1,7 @@ +{% extends "templates/web.html" %} + +{% block page_content %} + +

Go to Chapter Page

+ +{% endblock %} \ No newline at end of file diff --git a/foundation/www/user_intro.py b/foundation/www/user_intro.py new file mode 100644 index 00000000..c5926e1a --- /dev/null +++ b/foundation/www/user_intro.py @@ -0,0 +1,15 @@ +import frappe + +def get_context(context): + context.no_cache = True + chapter = frappe.get_doc('Chapter', frappe.form_dict.name) + print chapter + if frappe.session.user!='Guest': + if chapter in [d.name for d in chapter]: + context.already_member = True + else: + chapter.append('members', dict(user=frappe.session.user)) + chapter.save(ignore_permissions=1) + frappe.db.commit() + + context.chapter = chapter
Member Name Member EmailIntroductionWebsite URLEnable
{{ frappe.db.get_value('User', user.user, 'full_name') }} {{ frappe.db.get_value('User', user.user, 'email') }}{{ user.introduction }} + {% if user.website_url %} + {{ user.website_url }}