From 4045f91cc60e7d3754c9bd101c8670b816b83c43 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 8 May 2017 17:30:45 +0530 Subject: [PATCH] [wip] added chapters --- .../doctype/chapter/__init__.py | 0 .../doctype/chapter/chapter.js | 8 + .../doctype/chapter/chapter.json | 276 ++++++++++++++++++ .../doctype/chapter/chapter.py | 18 ++ .../doctype/chapter/templates/chapter.html | 9 + .../chapter/templates/chapter_row.html | 4 + .../doctype/chapter/test_chapter.py | 10 + .../doctype/chapter_member/__init__.py | 0 .../chapter_member/chapter_member.json | 72 +++++ .../doctype/chapter_member/chapter_member.py | 10 + foundation/hooks.py | 2 + foundation/www/join-chapter.html | 12 + foundation/www/join_chapter.py | 12 + 13 files changed, 433 insertions(+) create mode 100644 foundation/erpnext_foundation/doctype/chapter/__init__.py create mode 100644 foundation/erpnext_foundation/doctype/chapter/chapter.js create mode 100644 foundation/erpnext_foundation/doctype/chapter/chapter.json create mode 100644 foundation/erpnext_foundation/doctype/chapter/chapter.py create mode 100644 foundation/erpnext_foundation/doctype/chapter/templates/chapter.html create mode 100644 foundation/erpnext_foundation/doctype/chapter/templates/chapter_row.html create mode 100644 foundation/erpnext_foundation/doctype/chapter/test_chapter.py create mode 100644 foundation/erpnext_foundation/doctype/chapter_member/__init__.py create mode 100644 foundation/erpnext_foundation/doctype/chapter_member/chapter_member.json create mode 100644 foundation/erpnext_foundation/doctype/chapter_member/chapter_member.py create mode 100644 foundation/www/join-chapter.html create mode 100644 foundation/www/join_chapter.py diff --git a/foundation/erpnext_foundation/doctype/chapter/__init__.py b/foundation/erpnext_foundation/doctype/chapter/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/foundation/erpnext_foundation/doctype/chapter/chapter.js b/foundation/erpnext_foundation/doctype/chapter/chapter.js new file mode 100644 index 00000000..d09224d9 --- /dev/null +++ b/foundation/erpnext_foundation/doctype/chapter/chapter.js @@ -0,0 +1,8 @@ +// Copyright (c) 2017, EOSSF and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Chapter', { + refresh: function(frm) { + + } +}); diff --git a/foundation/erpnext_foundation/doctype/chapter/chapter.json b/foundation/erpnext_foundation/doctype/chapter/chapter.json new file mode 100644 index 00000000..d13154e7 --- /dev/null +++ b/foundation/erpnext_foundation/doctype/chapter/chapter.json @@ -0,0 +1,276 @@ +{ + "allow_copy": 0, + "allow_guest_to_view": 1, + "allow_import": 0, + "allow_rename": 0, + "autoname": "field:title", + "beta": 0, + "creation": "2017-05-08 17:00:17.610142", + "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": "title", + "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": "Title", + "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_head", + "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 Head", + "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": "introduction", + "fieldtype": "Text Editor", + "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": "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": 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": "region", + "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": "Region", + "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": "members", + "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": "Members", + "length": 0, + "no_copy": 0, + "options": "Chapter Member", + "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": 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, + "hide_heading": 0, + "hide_toolbar": 0, + "idx": 0, + "image_view": 0, + "in_create": 0, + "is_published_field": "published", + "is_submittable": 0, + "issingle": 0, + "istable": 0, + "max_attachments": 0, + "modified": "2017-05-08 17:05:38.056334", + "modified_by": "Administrator", + "module": "ERPNext Foundation", + "name": "Chapter", + "name_case": "Title 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, + "route": "chapters", + "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/chapter.py b/foundation/erpnext_foundation/doctype/chapter/chapter.py new file mode 100644 index 00000000..6ca9ef8f --- /dev/null +++ b/foundation/erpnext_foundation/doctype/chapter/chapter.py @@ -0,0 +1,18 @@ +# -*- 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.website.website_generator import WebsiteGenerator + +class Chapter(WebsiteGenerator): + pass + +def get_list_context(context): + context.allow_guest = True + context.no_cache = True + context.title = 'ERPNext Chapters' + context.no_breadcrumbs = True + context.order_by = 'creation desc' + context.introduction = '

All ERPNext Chapters

' diff --git a/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html b/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html new file mode 100644 index 00000000..9a0d82b2 --- /dev/null +++ b/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html @@ -0,0 +1,9 @@ +{% extends "templates/web.html" %} + +{% block page_content %} +

{{ title }}

+

{{ introduction }}

+


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 new file mode 100644 index 00000000..fba2398e --- /dev/null +++ b/foundation/erpnext_foundation/doctype/chapter/templates/chapter_row.html @@ -0,0 +1,4 @@ +
+ {{ title }} hosted by {{ chapter_head }} +
+ \ No newline at end of file diff --git a/foundation/erpnext_foundation/doctype/chapter/test_chapter.py b/foundation/erpnext_foundation/doctype/chapter/test_chapter.py new file mode 100644 index 00000000..f2d67782 --- /dev/null +++ b/foundation/erpnext_foundation/doctype/chapter/test_chapter.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 TestChapter(unittest.TestCase): + pass diff --git a/foundation/erpnext_foundation/doctype/chapter_member/__init__.py b/foundation/erpnext_foundation/doctype/chapter_member/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/foundation/erpnext_foundation/doctype/chapter_member/chapter_member.json b/foundation/erpnext_foundation/doctype/chapter_member/chapter_member.json new file mode 100644 index 00000000..b76f8104 --- /dev/null +++ b/foundation/erpnext_foundation/doctype/chapter_member/chapter_member.json @@ -0,0 +1,72 @@ +{ + "allow_copy": 0, + "allow_guest_to_view": 0, + "allow_import": 0, + "allow_rename": 0, + "beta": 0, + "creation": "2017-05-08 17:01:23.626064", + "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": "user", + "fieldtype": "Link", + "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": "User", + "length": 0, + "no_copy": 0, + "options": "User", + "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": 1, + "max_attachments": 0, + "modified": "2017-05-08 17:01:30.018083", + "modified_by": "Administrator", + "module": "ERPNext Foundation", + "name": "Chapter Member", + "name_case": "", + "owner": "Administrator", + "permissions": [], + "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_member/chapter_member.py b/foundation/erpnext_foundation/doctype/chapter_member/chapter_member.py new file mode 100644 index 00000000..02fa4634 --- /dev/null +++ b/foundation/erpnext_foundation/doctype/chapter_member/chapter_member.py @@ -0,0 +1,10 @@ +# -*- 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 + +class ChapterMember(Document): + pass diff --git a/foundation/hooks.py b/foundation/hooks.py index 29678e0d..456f7a7a 100644 --- a/foundation/hooks.py +++ b/foundation/hooks.py @@ -42,6 +42,8 @@ website_context = { "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"}, ], "footer_items": [ {"label": "Foundation", "child_items": [ diff --git a/foundation/www/join-chapter.html b/foundation/www/join-chapter.html new file mode 100644 index 00000000..b49b9a20 --- /dev/null +++ b/foundation/www/join-chapter.html @@ -0,0 +1,12 @@ +{% extends "templates/web.html" %} + +{% block page_content %} +{% if frappe.session.user=='Guest' %} +

Please signup and login to join this chapter

+

Login

+{% else %} +

Welcome to chapter {{ chapter.title }}!

+

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 new file mode 100644 index 00000000..0e4cfc5c --- /dev/null +++ b/foundation/www/join_chapter.py @@ -0,0 +1,12 @@ +import frappe + +def get_context(context): + 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]: + chapter.append('members', dict(user=frappe.session.user)) + chapter.save() + frappe.db.commit() + + context.chapter = chapter