[new] Chapter Module clean up after review
This commit is contained in:
parent
fe0c6c8e28
commit
a72a3bd536
@ -2,7 +2,7 @@
|
||||
"allow_copy": 0,
|
||||
"allow_guest_to_view": 1,
|
||||
"allow_import": 0,
|
||||
"allow_rename": 0,
|
||||
"allow_rename": 1,
|
||||
"autoname": "field:title",
|
||||
"beta": 0,
|
||||
"creation": "2017-09-14 13:36:03.904702",
|
||||
@ -170,6 +170,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "chapters/chapter_name\nleave blank automatically set after saving chapter.",
|
||||
"fieldname": "route",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
@ -297,7 +298,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2017-11-23 17:31:44.669507",
|
||||
"modified": "2017-11-24 15:47:01.752772",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Non Profit",
|
||||
"name": "Chapter",
|
||||
@ -329,7 +330,7 @@
|
||||
"read_only": 0,
|
||||
"read_only_onload": 0,
|
||||
"restrict_to_domain": "Non Profit",
|
||||
"route": "chapter",
|
||||
"route": "chapters",
|
||||
"show_name_in_global_search": 0,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
|
@ -5,18 +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):
|
||||
_website = frappe._dict(
|
||||
condition_field = "published",
|
||||
)
|
||||
|
||||
def get_context(self, context):
|
||||
context.no_cache = True
|
||||
context.parents = [dict(label='View All Chapters',
|
||||
route='chapters', title='View Chapters')]
|
||||
|
||||
def validate(self):
|
||||
chapter_head = self.chapter_head
|
||||
chapter = frappe.get_all('Chapter', filters={'published': True}, fields=['chapter_head'])
|
||||
if not self.route: #pylint: disable=E0203
|
||||
self.route = 'chapter/' + self.scrub(self.name)
|
||||
self.route = 'chapters/' + self.scrub(self.name)
|
||||
|
||||
def enable(self):
|
||||
chapter = frappe.get_doc('Chapter', frappe.form_dict.name)
|
||||
|
@ -57,8 +57,8 @@
|
||||
<h3>Address</h3>
|
||||
<p>{{ address }}</p>
|
||||
|
||||
<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="/leave-chapter?name={{ name }}" class=''>Leave this Chapter</a></p>
|
||||
<p style="margin: 20px 0 30px;"><a href="/non_profit/join-chapter?name={{ name }}" class='btn btn-primary'>Join this Chapter</a></p>
|
||||
<p style="margin: 20px 0 30px;"><a href="/non_profit/leave-chapter?name={{ name }}" class=''>Leave this Chapter</a></p>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<div style="margin-bottom: 30px; max-width: 600px" class="with-border clickable">
|
||||
<a href={{ route }}>
|
||||
<a href="/{{ doc.route }}">
|
||||
<h3>{{ doc.title }}</h3>
|
||||
<p>
|
||||
<span class="label">{{ frappe.db.get_value('User', chapter_head, 'full_name') }}</span>
|
||||
@ -14,4 +14,45 @@
|
||||
<p>{{ html2text(doc.introduction[:200]) }}{% if introduction|len > 200 %}...{% endif %}</p>
|
||||
</a>
|
||||
</div>
|
||||
<!-- this is a sample default list template -->
|
||||
<style type="text/css">
|
||||
|
||||
.label {
|
||||
font-weight: normal;
|
||||
background-color: #d1d8dd;
|
||||
font-size: 13px;
|
||||
padding: 3px 7px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
|
||||
.with-border {
|
||||
border: 1px solid #d1d8dd;
|
||||
border-radius: 3px;
|
||||
padding: 15px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.with-border h3 {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #5E64FF;
|
||||
}
|
||||
|
||||
.clickable a {
|
||||
color: #161c23;
|
||||
}
|
||||
|
||||
.with-border.clickable:hover {
|
||||
border-color: #36414C;
|
||||
background-color: #fafbfc;
|
||||
|
||||
}
|
||||
|
||||
.with-border a, .with-border a:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
0
erpnext/templates/pages/non_profit/__init__.py
Normal file
0
erpnext/templates/pages/non_profit/__init__.py
Normal file
59
erpnext/templates/pages/non_profit/join-chapter.html
Normal file
59
erpnext/templates/pages/non_profit/join-chapter.html
Normal file
@ -0,0 +1,59 @@
|
||||
{% extends "templates/web.html" %}
|
||||
|
||||
{% block page_content %}
|
||||
|
||||
{% macro chapter_button() %}
|
||||
<p><a href="/{{ chapter.route }}" class='btn btn-primary'>
|
||||
Go to Chapter Page</a></p>
|
||||
{% endmacro %}
|
||||
{% if frappe.session.user=='Guest' %}
|
||||
<p>Please signup and login to join this chapter</p>
|
||||
<p><a href="/login?redirect-to=/{{ chapter.route }}" class='btn btn-primary'>Login</a></p>
|
||||
{% else %}
|
||||
{% if already_member %}
|
||||
<p>You are already a member of {{ chapter.title }}!</p>
|
||||
{{ chapter_button() }}
|
||||
<p><a href="">Leave Chapter</a></p>
|
||||
{% else %}
|
||||
{% if frappe.local.request.method=='POST' %}
|
||||
<p>Welcome to chapter {{ chapter.title }}!</p>
|
||||
{{ chapter_button() }}
|
||||
{% else %}
|
||||
<div style="padding: 20px 0;">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-md-8">
|
||||
<form name="user-intro" action="/join-chapter" method='POST'>
|
||||
<div class="form-group">
|
||||
<input name="name" class="hidden form-control" type="text"
|
||||
value="{{chapter.name}}">
|
||||
<input name="csrf_token" class="hidden form-control" type="text"
|
||||
value="{{frappe.session.csrf_token}}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="user" class="">User Name</label>
|
||||
<input name="user" class="form-control" type="text" value="{{ frappe.session.user }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="website_url" class="">Website URL</label>
|
||||
<input name="website_url" required class="form-control" type="text"
|
||||
placeholder="https://example.com" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="introduction" class="">Introduction</label>
|
||||
<textarea name="introduction" required class="form-control"
|
||||
placeholder="Your profession and how you are associated with ERPNext"></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="Submit" id="update_member" class="btn btn-primary">
|
||||
Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
12
erpnext/templates/pages/non_profit/join_chapter.js
Normal file
12
erpnext/templates/pages/non_profit/join_chapter.js
Normal file
@ -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) {
|
||||
|
||||
}
|
||||
});
|
22
erpnext/templates/pages/non_profit/join_chapter.py
Normal file
22
erpnext/templates/pages/non_profit/join_chapter.py
Normal file
@ -0,0 +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':
|
||||
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()
|
||||
|
||||
context.chapter = chapter
|
16
erpnext/templates/pages/non_profit/leave-chapter.html
Normal file
16
erpnext/templates/pages/non_profit/leave-chapter.html
Normal file
@ -0,0 +1,16 @@
|
||||
{% extends "templates/web.html" %}
|
||||
<!--
|
||||
{% macro chapter_button() %}
|
||||
<p><a href="/{{ chapter.route }}" class='btn btn-primary'>
|
||||
Go to Chapter Page</a></p>
|
||||
{% endmacro %}
|
||||
-->
|
||||
{% block page_content %}
|
||||
|
||||
{% if member_deleted %}
|
||||
<p>You are not a member of {{ chapter.title }}!</p>
|
||||
<p>Please signup and login to join this chapter</p>
|
||||
|
||||
<p><a href="/join-chapter?name={{ chapter.name }}" class='btn btn-primary'>Become Member agian</a></p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
15
erpnext/templates/pages/non_profit/leave_chapter.py
Normal file
15
erpnext/templates/pages/non_profit/leave_chapter.py
Normal file
@ -0,0 +1,15 @@
|
||||
import frappe
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = True
|
||||
chapter = frappe.get_doc('Chapter', frappe.form_dict.name)
|
||||
# if frappe.session.user!='Guest':
|
||||
if frappe.session.user in [d.user for d in chapter.members]:
|
||||
user = frappe.session.user
|
||||
parent = frappe.form_dict.name
|
||||
frappe.db.sql("""delete from `tabChapter Member` where parent = %s and user = %s """, (parent, user))
|
||||
frappe.db.commit()
|
||||
|
||||
context.member_deleted = True
|
||||
|
||||
context.chapter = chapter
|
Loading…
Reference in New Issue
Block a user