diff --git a/foundation/erpnext_foundation/doctype/chapter/chapter.json b/foundation/erpnext_foundation/doctype/chapter/chapter.json index d13154e7..9a3dc214 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, @@ -163,66 +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": "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": 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", - "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": 1, @@ -236,7 +267,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-05-08 17:05:38.056334", + "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 6ca9ef8f..67bd2342 100644 --- a/foundation/erpnext_foundation/doctype/chapter/chapter.py +++ b/foundation/erpnext_foundation/doctype/chapter/chapter.py @@ -5,9 +5,26 @@ 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): - pass + def get_context(self, context): + context.no_cache = True + + 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 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): 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 9a0d82b2..10b0f95b 100644 --- a/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html +++ b/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html @@ -2,8 +2,60 @@ {% block page_content %}

{{ title }}

+

Details

{{ introduction }}

-


Join this Chapter

+

List of Members

+{% if members %} + + + + + + + {% for user in members %} + + + + + + + + + + {% endfor %} +
Member NameMember EmailWebsite URL
{{ frappe.db.get_value('User', user.user, 'full_name') }}{{ frappe.db.get_value('User', user.user, 'email') }} + {% if user.website_url %} + {{ user.website_url }} + {% else %} + {{ user.website_url }} + {% endif %} +
+ {{ user.introduction }} +
+{% 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 }} +
+ +

{{ doc.title }}

+

+ {{ frappe.db.get_value('User', chapter_head, 'full_name') }} + + {% if members %} + Members: {{ members|length }} + {% else %} + Members: 0 + {% endif %} + +

+

{{ html2text(doc.introduction[:200]) }}{% if introduction|len > 200 %}...{% endif %}

+
\ No newline at end of file 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/__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..739eaa99 --- /dev/null +++ b/foundation/erpnext_foundation/doctype/chapter_message/chapter_message.js @@ -0,0 +1,12 @@ +// 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); + }) + }, +}); 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/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..4850376a 100644 --- a/foundation/www/join-chapter.html +++ b/foundation/www/join-chapter.html @@ -1,12 +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

+

Login

{% else %} -

Welcome to chapter {{ chapter.title }}!

-

Go to Chapter Page

+ {% if already_member %} +

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

+ {{ chapter_button() }} +

Leave Chapter

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

Welcome to chapter {{ chapter.title }}!

+ {{ chapter_button() }} + {% else %} +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+ {% endif %} + {% endif %} + {% 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 0e4cfc5c..bc9ba6ba 100644 --- a/foundation/www/join_chapter.py +++ b/foundation/www/join_chapter.py @@ -1,12 +1,22 @@ 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 in [d.user for d in chapter.members]: + context.already_member = True + else: + 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() - if frappe.session.user not in [d.user for d in chapter.members]: - chapter.append('members', dict(user=frappe.session.user)) - chapter.save() - frappe.db.commit() - - context.chapter = chapter + context.chapter = chapter diff --git a/foundation/www/service-providers.html b/foundation/www/service-providers.html index 926eb2e6..e0a11890 100644 --- a/foundation/www/service-providers.html +++ b/foundation/www/service-providers.html @@ -4,7 +4,7 @@ {% macro gold_member(m) %}
-