From 708e5afbc0972a6f1f64f0df399e491933a01821 Mon Sep 17 00:00:00 2001 From: ashwinisave35 Date: Wed, 10 May 2017 16:59:11 +0530 Subject: [PATCH 1/5] Updated page view for Chapters list and Chapter single view. --- .../doctype/chapter/chapter.json | 132 +++++++++++++----- .../doctype/chapter/chapter.py | 2 + .../doctype/chapter/templates/chapter.html | 59 +++++++- .../chapter/templates/chapter_row.html | 17 ++- foundation/hooks.py | 3 +- foundation/www/join-chapter.html | 6 +- foundation/www/join_chapter.py | 12 +- 7 files changed, 186 insertions(+), 45 deletions(-) diff --git a/foundation/erpnext_foundation/doctype/chapter/chapter.json b/foundation/erpnext_foundation/doctype/chapter/chapter.json index d13154e7..cb6f00e1 100644 --- a/foundation/erpnext_foundation/doctype/chapter/chapter.json +++ b/foundation/erpnext_foundation/doctype/chapter/chapter.json @@ -50,7 +50,7 @@ "collapsible": 0, "columns": 0, "fieldname": "chapter_head", - "fieldtype": "Data", + "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -61,6 +61,7 @@ "label": "Chapter Head", "length": 0, "no_copy": 0, + "options": "User", "permlevel": 0, "precision": "", "print_hide": 0, @@ -103,6 +104,66 @@ "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": "Published", + "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": "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": 1, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -133,6 +194,36 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "address", + "fieldtype": "Text", + "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": "Address", + "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, @@ -170,8 +261,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "route", - "fieldtype": "Data", + "fieldname": "comments", + "fieldtype": "Table", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -179,39 +270,10 @@ "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": "Published", + "label": "Comments", "length": 0, "no_copy": 0, + "options": "Chapter Comments", "permlevel": 0, "precision": "", "print_hide": 0, @@ -236,7 +298,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-05-08 17:05:38.056334", + "modified": "2017-05-10 16:33:43.490022", "modified_by": "Administrator", "module": "ERPNext Foundation", "name": "Chapter", diff --git a/foundation/erpnext_foundation/doctype/chapter/chapter.py b/foundation/erpnext_foundation/doctype/chapter/chapter.py index 6ca9ef8f..dcbff3d4 100644 --- a/foundation/erpnext_foundation/doctype/chapter/chapter.py +++ b/foundation/erpnext_foundation/doctype/chapter/chapter.py @@ -7,6 +7,8 @@ import frappe from frappe.website.website_generator import WebsiteGenerator class Chapter(WebsiteGenerator): + def get_context(self, context): + context.no_cache = True pass 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 9a0d82b2..a4d796e2 100644 --- a/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html +++ b/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html @@ -2,8 +2,65 @@ {% block page_content %}

{{ title }}

+

Details

{{ introduction }}

-


Join this Chapter

+

List of Members

+{% if members %} + + + + + + {% for user in members %} + + + + + + {% endfor %} +
Member NameMember Email
{{ frappe.db.get_value('User', user.user, 'full_name') }}{{ frappe.db.get_value('User', user.user, 'email') }}
+{% else %} +

No member yet.

+{% endif %} + +

Chapter Head

+ + + + + + + + + + + + + +
Name{{ frappe.db.get_value('User', chapter_head, 'full_name') }}
Email{{ frappe.db.get_value('User', chapter_head, 'email') }}
Phone{{ frappe.db.get_value('User', chapter_head, 'phone') }}
+

Address

+

{{ address }}

+ +

Join this Chapter

+ +
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+ {% endblock %} \ No newline at end of file diff --git a/foundation/erpnext_foundation/doctype/chapter/templates/chapter_row.html b/foundation/erpnext_foundation/doctype/chapter/templates/chapter_row.html index fba2398e..042aede1 100644 --- a/foundation/erpnext_foundation/doctype/chapter/templates/chapter_row.html +++ b/foundation/erpnext_foundation/doctype/chapter/templates/chapter_row.html @@ -1,4 +1,17 @@ -
- {{ title }} hosted by {{ chapter_head }} + \ No newline at end of file diff --git a/foundation/hooks.py b/foundation/hooks.py index 456f7a7a..fb3a95ea 100644 --- a/foundation/hooks.py +++ b/foundation/hooks.py @@ -37,13 +37,14 @@ web_include_css = "/assets/foundation/css/style.css" home_page = "index" website_context = { - "navbar_search": 1, + # "navbar_search": 1, "brand_html": "ERPNext Foundation", "copyright": "ERPNext Open Source Software Foundation", "footer_address": "
ERPNext is and will always be 100% Open Source", "top_bar_items": [ {"label": "Service Providers", "url": "/service-providers"}, {"label": "Jobs", "url": "/erpnext-jobs"}, + {"label": "Chapters", "url": "/chapters"}, ], "footer_items": [ {"label": "Foundation", "child_items": [ diff --git a/foundation/www/join-chapter.html b/foundation/www/join-chapter.html index b49b9a20..7ec84ed3 100644 --- a/foundation/www/join-chapter.html +++ b/foundation/www/join-chapter.html @@ -3,9 +3,13 @@ {% block page_content %} {% if frappe.session.user=='Guest' %}

Please signup and login to join this chapter

-

Login

+

Login

{% else %} + {% if already_member %} +

You are already a member of {{ chapter.title }}!

+ {% else %}

Welcome to chapter {{ chapter.title }}!

+ {% endif %}

Go to Chapter Page

{% endif %} diff --git a/foundation/www/join_chapter.py b/foundation/www/join_chapter.py index 0e4cfc5c..d18bad72 100644 --- a/foundation/www/join_chapter.py +++ b/foundation/www/join_chapter.py @@ -1,12 +1,14 @@ import frappe def get_context(context): + context.no_cache = True + chapter = frappe.get_doc('Chapter', frappe.form_dict.name) if frappe.session.user!='Guest': - chapter = frappe.get_doc('Chapter', frappe.form_dict.name) - - if frappe.session.user not in [d.user for d in chapter.members]: + if frappe.session.user in [d.user for d in chapter.members]: + context.already_member = True + else: chapter.append('members', dict(user=frappe.session.user)) - chapter.save() + chapter.save(ignore_permissions=1) frappe.db.commit() - context.chapter = chapter + context.chapter = chapter From 8992da01be1a2b1d7c600c60c03bff3a7da8f234 Mon Sep 17 00:00:00 2001 From: Ashwini Save Date: Thu, 11 May 2017 12:59:15 +0530 Subject: [PATCH 2/5] =?UTF-8?q?Updated=20text=20colour=20lighter=20grey=20?= =?UTF-8?q?for=20=E2=80=9CService=20Provider=E2=80=9D=20view=20of=20Gold?= =?UTF-8?q?=20and=20Silver=20Member=E2=80=99s=20placeholder=20block.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../doctype/chapter/chapter.json | 33 +------------------ foundation/www/service-providers.html | 4 +-- foundation/www/service_providers.py | 6 ++-- 3 files changed, 7 insertions(+), 36 deletions(-) diff --git a/foundation/erpnext_foundation/doctype/chapter/chapter.json b/foundation/erpnext_foundation/doctype/chapter/chapter.json index cb6f00e1..e848a150 100644 --- a/foundation/erpnext_foundation/doctype/chapter/chapter.json +++ b/foundation/erpnext_foundation/doctype/chapter/chapter.json @@ -254,37 +254,6 @@ "search_index": 0, "set_only_once": 0, "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "comments", - "fieldtype": "Table", - "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": "Comments", - "length": 0, - "no_copy": 0, - "options": "Chapter Comments", - "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": 1, @@ -298,7 +267,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-05-10 16:33:43.490022", + "modified": "2017-05-11 12:54:19.260083", "modified_by": "Administrator", "module": "ERPNext Foundation", "name": "Chapter", diff --git a/foundation/www/service-providers.html b/foundation/www/service-providers.html index 926eb2e6..48b1d606 100644 --- a/foundation/www/service-providers.html +++ b/foundation/www/service-providers.html @@ -4,7 +4,7 @@ {% macro gold_member(m) %}
-
+
-
+

{{ m.title }}

Silver Member

{{ m.introduction[:100] }}

diff --git a/foundation/www/service_providers.py b/foundation/www/service_providers.py index bfdd8ca0..0188952e 100644 --- a/foundation/www/service_providers.py +++ b/foundation/www/service_providers.py @@ -27,7 +27,8 @@ def get_context(context): title='Your Company', introduction='Become a Gold Member today and get your company featured here', image='/assets/foundation/img/gold.png', - route='/members' + route='/members', + placeholder=True )) context.silver_members = [] @@ -43,7 +44,8 @@ def get_context(context): title='Your Company', introduction='Become a Silver Member today and get your company featured here', image='/assets/foundation/img/silver.png', - route='/members' + route='/members', + placeholder=True )) From cf4d74b10b6f07c77e8a4637887b63c3f583829c Mon Sep 17 00:00:00 2001 From: Ashwini Save Date: Fri, 12 May 2017 13:40:50 +0530 Subject: [PATCH 3/5] Created View for Send Chapter Message to Chapter Members via email for ERPNext foudation. --- .../doctype/chapter/chapter.json | 2 +- .../doctype/chapter/chapter.py | 11 +- .../doctype/chapter/templates/chapter.html | 18 --- .../doctype/chapter_message/__init__.py | 0 .../chapter_message/chapter_message.js | 13 ++ .../chapter_message/chapter_message.json | 153 ++++++++++++++++++ .../chapter_message/chapter_message.py | 43 +++++ .../chapter_message/test_chapter_message.py | 10 ++ foundation/www/service-providers.html | 5 +- 9 files changed, 233 insertions(+), 22 deletions(-) create mode 100644 foundation/erpnext_foundation/doctype/chapter_message/__init__.py create mode 100644 foundation/erpnext_foundation/doctype/chapter_message/chapter_message.js create mode 100644 foundation/erpnext_foundation/doctype/chapter_message/chapter_message.json create mode 100644 foundation/erpnext_foundation/doctype/chapter_message/chapter_message.py create mode 100644 foundation/erpnext_foundation/doctype/chapter_message/test_chapter_message.py diff --git a/foundation/erpnext_foundation/doctype/chapter/chapter.json b/foundation/erpnext_foundation/doctype/chapter/chapter.json index e848a150..9a3dc214 100644 --- a/foundation/erpnext_foundation/doctype/chapter/chapter.json +++ b/foundation/erpnext_foundation/doctype/chapter/chapter.json @@ -267,7 +267,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-05-11 12:54:19.260083", + "modified": "2017-05-11 17:07:13.825474", "modified_by": "Administrator", "module": "ERPNext Foundation", "name": "Chapter", diff --git a/foundation/erpnext_foundation/doctype/chapter/chapter.py b/foundation/erpnext_foundation/doctype/chapter/chapter.py index dcbff3d4..323a15ac 100644 --- a/foundation/erpnext_foundation/doctype/chapter/chapter.py +++ b/foundation/erpnext_foundation/doctype/chapter/chapter.py @@ -5,11 +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): def get_context(self, context): context.no_cache = True - pass + + def validate(self): + 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')) + def get_list_context(context): context.allow_guest = True diff --git a/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html b/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html index a4d796e2..ed2ce9f6 100644 --- a/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html +++ b/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html @@ -43,24 +43,6 @@

Join this Chapter

-
-
-
-
-
- - -
-
- - -
-
-
-
-
-
- {% endblock %} \ No newline at end of file diff --git a/foundation/erpnext_foundation/doctype/chapter_message/__init__.py b/foundation/erpnext_foundation/doctype/chapter_message/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/foundation/erpnext_foundation/doctype/chapter_message/chapter_message.js b/foundation/erpnext_foundation/doctype/chapter_message/chapter_message.js new file mode 100644 index 00000000..371fea5e --- /dev/null +++ b/foundation/erpnext_foundation/doctype/chapter_message/chapter_message.js @@ -0,0 +1,13 @@ +// Copyright (c) 2017, EOSSF and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Chapter Message', { + onload: function(frm){ + console.log("here" + frappe.session.user) + chapter_head = frappe.session.user + frappe.db.get_value('Chapter', {chapter_head: chapter_head}, 'name', function(data) { + frm.set_value('chapter', data.name); + }) + }, + // refs +}); diff --git a/foundation/erpnext_foundation/doctype/chapter_message/chapter_message.json b/foundation/erpnext_foundation/doctype/chapter_message/chapter_message.json new file mode 100644 index 00000000..6b1b76e9 --- /dev/null +++ b/foundation/erpnext_foundation/doctype/chapter_message/chapter_message.json @@ -0,0 +1,153 @@ +{ + "allow_copy": 0, + "allow_guest_to_view": 0, + "allow_import": 0, + "allow_rename": 0, + "beta": 0, + "creation": "2017-05-11 14:22:40.165630", + "custom": 0, + "docstatus": 0, + "doctype": "DocType", + "document_type": "", + "editable_grid": 1, + "engine": "InnoDB", + "fields": [ + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "subject", + "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": "Subject", + "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": 1, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "message", + "fieldtype": "Text", + "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": " Message", + "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": 1, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "chapter", + "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": "Chapter", + "length": 0, + "no_copy": 0, + "options": "", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + } + ], + "has_web_view": 0, + "hide_heading": 0, + "hide_toolbar": 0, + "idx": 0, + "image_view": 0, + "in_create": 0, + "is_submittable": 0, + "issingle": 0, + "istable": 0, + "max_attachments": 0, + "modified": "2017-05-12 11:10:12.066924", + "modified_by": "Administrator", + "module": "ERPNext Foundation", + "name": "Chapter Message", + "name_case": "", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "apply_user_permissions": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "if_owner": 0, + "import": 0, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "set_user_permissions": 0, + "share": 1, + "submit": 0, + "write": 1 + } + ], + "quick_entry": 1, + "read_only": 0, + "read_only_onload": 0, + "show_name_in_global_search": 0, + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1, + "track_seen": 0 +} \ No newline at end of file diff --git a/foundation/erpnext_foundation/doctype/chapter_message/chapter_message.py b/foundation/erpnext_foundation/doctype/chapter_message/chapter_message.py new file mode 100644 index 00000000..cf76e203 --- /dev/null +++ b/foundation/erpnext_foundation/doctype/chapter_message/chapter_message.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2017, EOSSF and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe.model.document import Document +from frappe import _ + +class ChapterMessage(Document): + def get_context(self, context): + context.no_cache = True + + def validate(self): + chapter = frappe.get_doc('Chapter', self.chapter) + if frappe.session.user != chapter.chapter_head: + frappe.throw(_('You are not athourize to send message for this Chapter.')) + + def on_update(self): + chapter = frappe.get_doc('Chapter', self.chapter) + recipients = [d.user for d in chapter.members] + message = self.message + message += "Chapter Title: " + self.chapter + # chapter_title = self.chapter + + frappe.sendmail(recipients = recipients, + message = self.message, + subject = self.subject) + # reference_doctype=self.doctype, reference_name=self.name) + + +def get_members_emails(chapterTitle): + + members_list = frappe.get_all('User', fields=['email'], + filters={'chapter.title': chapterTitle}) + + out = [] + for e in members_list: + if e.email: + # don't add if holiday + out.append(e.email) + print out + return out \ No newline at end of file diff --git a/foundation/erpnext_foundation/doctype/chapter_message/test_chapter_message.py b/foundation/erpnext_foundation/doctype/chapter_message/test_chapter_message.py new file mode 100644 index 00000000..21b63ed7 --- /dev/null +++ b/foundation/erpnext_foundation/doctype/chapter_message/test_chapter_message.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2017, EOSSF and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest + +class TestChapterMessage(unittest.TestCase): + pass diff --git a/foundation/www/service-providers.html b/foundation/www/service-providers.html index 48b1d606..e0a11890 100644 --- a/foundation/www/service-providers.html +++ b/foundation/www/service-providers.html @@ -4,7 +4,7 @@ {% macro gold_member(m) %}
-
+
-
+

{{ m.title }}

Silver Member

{{ m.introduction[:100] }}

From 8c815c48973c5db54fea8eea8e0578d4d6ee264d Mon Sep 17 00:00:00 2001 From: Ashwini Save Date: Mon, 15 May 2017 14:57:16 +0530 Subject: [PATCH 4/5] 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 From f2678cdf48fc9aae1ab154073178b670577d8c9b Mon Sep 17 00:00:00 2001 From: Ashwini Save Date: Tue, 16 May 2017 14:17:36 +0530 Subject: [PATCH 5/5] Feature for adding user data like website and Introduction for Chapter Members. --- .../doctype/chapter/templates/chapter.html | 12 +- foundation/www/join-chapter.html | 223 ++++-------------- foundation/www/join_chapter.py | 15 +- foundation/www/user-intro.html | 7 - foundation/www/user_intro.py | 15 -- 5 files changed, 62 insertions(+), 210 deletions(-) delete mode 100644 foundation/www/user-intro.html delete mode 100644 foundation/www/user_intro.py diff --git a/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html b/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html index 9f713507..10b0f95b 100644 --- a/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html +++ b/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html @@ -10,23 +10,25 @@ - - {% for user in members %} - + {{ user.website_url }} {% else %} {{ user.website_url }} {% endif %} - + + + + {% endfor %}
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 }}
Member Name Member EmailIntroduction Website 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 }}
+ {{ user.introduction }} +
diff --git a/foundation/www/join-chapter.html b/foundation/www/join-chapter.html index b4abcccd..4850376a 100644 --- a/foundation/www/join-chapter.html +++ b/foundation/www/join-chapter.html @@ -1,194 +1,59 @@ {% extends "templates/web.html" %} {% block page_content %} + +{% macro chapter_button() %} +

+ Go to Chapter Page

+{% endmacro %} {% if frappe.session.user=='Guest' %}

Please signup and login to join this chapter

Login

{% else %} {% if already_member %} -

You are already a member of {{ chapter.title }}!

+

You are already a member of {{ chapter.title }}!

+ {{ chapter_button() }} +

Leave Chapter

{% else %} -

Welcome to chapter {{ chapter.title }}!

- {% endif %} -
-
-
-
-
- + {% if frappe.local.request.method=='POST' %} +

Welcome to chapter {{ chapter.title }}!

+ {{ chapter_button() }} + {% else %} +
+
+
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
-
- - -
-
- - -
-
- - -
-
- -
- +
-
-
+ {% endif %} + {% endif %} -

Go to Chapter Page

{% endif %} - - {% endblock %} \ No newline at end of file diff --git a/foundation/www/join_chapter.py b/foundation/www/join_chapter.py index b5a6290d..bc9ba6ba 100644 --- a/foundation/www/join_chapter.py +++ b/foundation/www/join_chapter.py @@ -3,13 +3,20 @@ 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 else: - chapter.append('members', dict(user=frappe.session.user)) - chapter.save(ignore_permissions=1) - frappe.db.commit() + if frappe.request.method=='GET': + pass + elif frappe.request.method=='POST': + chapter.append('members', dict( + user=frappe.session.user, + introduction=frappe.form_dict.introduction, + website_url=frappe.form_dict.website_url, + enabled=1 + )) + chapter.save(ignore_permissions=1) + frappe.db.commit() context.chapter = chapter diff --git a/foundation/www/user-intro.html b/foundation/www/user-intro.html deleted file mode 100644 index 6777496f..00000000 --- a/foundation/www/user-intro.html +++ /dev/null @@ -1,7 +0,0 @@ -{% 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 deleted file mode 100644 index c5926e1a..00000000 --- a/foundation/www/user_intro.py +++ /dev/null @@ -1,15 +0,0 @@ -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