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) %}
-
+