mirror of
https://github.com/erpnext/foundation.git
synced 2026-10-16 18:00:47 +02:00
Created View for Send Chapter Message to Chapter Members via email for ERPNext foudation.
This commit is contained in:
@@ -267,7 +267,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2017-05-11 12:54:19.260083",
|
"modified": "2017-05-11 17:07:13.825474",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "ERPNext Foundation",
|
"module": "ERPNext Foundation",
|
||||||
"name": "Chapter",
|
"name": "Chapter",
|
||||||
|
|||||||
@@ -5,11 +5,20 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.website.website_generator import WebsiteGenerator
|
from frappe.website.website_generator import WebsiteGenerator
|
||||||
|
from frappe.model.document import Document
|
||||||
|
from frappe import _
|
||||||
|
|
||||||
class Chapter(WebsiteGenerator):
|
class Chapter(WebsiteGenerator):
|
||||||
def get_context(self, context):
|
def get_context(self, context):
|
||||||
context.no_cache = True
|
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):
|
def get_list_context(context):
|
||||||
context.allow_guest = True
|
context.allow_guest = True
|
||||||
|
|||||||
@@ -43,24 +43,6 @@
|
|||||||
|
|
||||||
<p style="margin: 20px 0 30px;"><a href="/join-chapter?name={{ name }}" class='btn btn-primary'>Join this Chapter</a></p>
|
<p style="margin: 20px 0 30px;"><a href="/join-chapter?name={{ name }}" class='btn btn-primary'>Join this Chapter</a></p>
|
||||||
|
|
||||||
<div class="form-wrapper">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-6">
|
|
||||||
<form method="post" action="/post-comments.html?name={{ name }}">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="name">Enter Name</label>
|
|
||||||
<input type="text" class="form-control" placeholder="Enter Name" name="name" value= "{{ frappe.session.user }}" />
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="">Enter Comment</label>
|
|
||||||
<textarea class="form-control" placeholder="Enter your comment"></textarea>
|
|
||||||
</div>
|
|
||||||
<div class="filed-wrap"><button class="btn-primary btn" type="submit">Post comment</button></div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
<!-- this is a sample default web page template -->
|
<!-- this is a sample default web page template -->
|
||||||
@@ -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
|
||||||
|
});
|
||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
{% macro gold_member(m) %}
|
{% macro gold_member(m) %}
|
||||||
<div class='gold-member'>
|
<div class='gold-member'>
|
||||||
<div class="media with-border clickable {% if m.placeholder == True %} text-muted {% endif %}" style="cursor: pointer;" onclick="location.href='{{ m.route }}'">
|
<div class="media with-border clickable {{ 'text-muted' if m.placeholder else '' }}" style="cursor: pointer;" onclick="location.href='{{ m.route }}'">
|
||||||
<div class="media-left">
|
<div class="media-left">
|
||||||
<a href="{{ m.route }}">
|
<a href="{{ m.route }}">
|
||||||
<img class="media-object" src="{{ m.image or '/assets/foundation/img/gold.png' }}"
|
<img class="media-object" src="{{ m.image or '/assets/foundation/img/gold.png' }}"
|
||||||
@@ -22,7 +22,8 @@
|
|||||||
|
|
||||||
{% macro silver_member(m) %}
|
{% macro silver_member(m) %}
|
||||||
<div class='col-sm-4'>
|
<div class='col-sm-4'>
|
||||||
<div class="silver-member with-border clickable {% if m.placeholder == True %} text-muted {% endif %}" style="cursor: pointer;" onclick="location.href='{{ m.route }}'">
|
<div class="silver-member with-border clickable {{ 'text-muted' if m.placeholder else '' }}"
|
||||||
|
style="cursor: pointer;" onclick="location.href='{{ m.route }}'">
|
||||||
<h4>{{ m.title }}</h4>
|
<h4>{{ m.title }}</h4>
|
||||||
<p><span class=label>Silver Member</span></p>
|
<p><span class=label>Silver Member</span></p>
|
||||||
<p>{{ m.introduction[:100] }}</p>
|
<p>{{ m.introduction[:100] }}</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user