“Leave Chapter” button added for Foundation -> Chapter section.

This commit is contained in:
Ashwini Save
2017-05-19 11:42:08 +05:30
parent f2678cdf48
commit 7a9e2e42ee
5 changed files with 39 additions and 9 deletions

View File

@@ -8,14 +8,14 @@
{% if members %} {% if members %}
<table class="table table-bordered small" style="max-width: 600px;"> <table class="table table-bordered small" style="max-width: 600px;">
<tr> <tr>
<th>Serial No.</th>
<th>Member Name</th> <th>Member Name</th>
<th>Member Email</th>
<th>Website URL</th> <th>Website URL</th>
</tr> </tr>
{% for user in members %} {% for user in members %}
<tr> <tr>
<td>{{ i }}</td>
<td>{{ frappe.db.get_value('User', user.user, 'full_name') }}</td> <td>{{ frappe.db.get_value('User', user.user, 'full_name') }}</td>
<td>{{ frappe.db.get_value('User', user.user, 'email') }}</td>
<td> <td>
{% if user.website_url %} {% if user.website_url %}
<a href="{{ user.website_url }}">{{ user.website_url }}</a> <a href="{{ user.website_url }}">{{ user.website_url }}</a>
@@ -29,7 +29,6 @@
{{ user.introduction }} {{ user.introduction }}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% else %} {% else %}
@@ -55,6 +54,7 @@
<p>{{ address }}</p> <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="/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>
{% endblock %} {% endblock %}

View File

@@ -68,7 +68,7 @@
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0, "remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 1,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
@@ -98,7 +98,7 @@
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0, "remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 1,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
@@ -128,7 +128,7 @@
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0, "remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 1,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
@@ -144,7 +144,7 @@
"issingle": 0, "issingle": 0,
"istable": 1, "istable": 1,
"max_attachments": 0, "max_attachments": 0,
"modified": "2017-05-12 16:36:07.139907", "modified": "2017-05-16 15:24:25.355107",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "ERPNext Foundation", "module": "ERPNext Foundation",
"name": "Chapter Member", "name": "Chapter Member",

View File

@@ -35,12 +35,12 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="website_url" class="">Website URL</label> <label for="website_url" class="">Website URL</label>
<input name="website_url" class="form-control" type="text" <input name="website_url" required class="form-control" type="text"
placeholder="https://example.com" /> placeholder="https://example.com" />
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="introduction" class="">Introduction</label> <label for="introduction" class="">Introduction</label>
<textarea name="introduction" class="form-control" <textarea name="introduction" required class="form-control"
placeholder="Your profession and how you are associated with ERPNext"></textarea> placeholder="Your profession and how you are associated with ERPNext"></textarea>
</div> </div>
<div class="form-group"> <div class="form-group">

View 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 %}

View File

@@ -0,0 +1,14 @@
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))
context.member_deleted = True
context.chapter = chapter