New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[new] On Chapter Leave member details not erased #98

Merged
merged 4 commits into from Jan 3, 2018
Jump to file or symbol
Failed to load files and symbols.
+118 −23
Diff settings

Always

Just for now

Next

[new] On Chapter Leave member details not erased

  • Loading branch information...
vishdha committed Nov 15, 2017
commit bbc5c10cea0da6c18317562642bec567a1baa843
@@ -33,3 +33,17 @@ def get_list_context(context):
context.no_breadcrumbs = True
context.order_by = 'creation desc'
context.introduction = '<p>All ERPNext Chapters</p>'
@frappe.whitelist()
def leave(title, user_id, leave_reason):
chapter = frappe.get_doc("Chapter", title)
for member in chapter.members:
for x in xrange(1,10):
print(member.user, user_id)
if member.user == user_id:
member.enabled = 0
member.leave_reason = leave_reason
chapter.save(ignore_permissions=1)
frappe.db.commit()
return "Thank you for Feedback"
@@ -8,31 +8,35 @@ <h3>Details</h3>
{{ meetup_embed_html }}
{% endif %}
<h3>List of Members</h3>
{% if members %}
{% if members %}
{% set flag = 1 -%}
<table class="table table-bordered small" style="max-width: 500px;">
<tr>
<th width="15%" ></th>
<th>Member Details</th>
</tr>
{% for user in members %}
<tr>
<td>{{ loop.index }}</td>
<td>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">{{ frappe.db.get_value('User', user.user, 'full_name') }}</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
{% if user.website_url %}
<a href="{{ user.website_url }}">{{ user.website_url or '' }}</a>
{% endif %}
{% if user.enabled == 1 %}
<tr>
<td>{{ flag }}</td>
<td>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">{{ frappe.db.get_value('User', user.user, 'full_name') }}</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
{% if user.website_url %}
<a href="{{ user.website_url }}">{{ user.website_url or '' }}</a>
{% endif %}
</div>
<div class="col-lg-12">
{% if user.introduction %}
{{ user.introduction }}
{% endif %}
</div>
</div>
<div class="col-lg-12">
{% if user.introduction %}
{{ user.introduction }}
{% endif %}
</div>
</div>
</td>
</tr>
</td>
</tr>
{% set flag = flag + 1 -%}
{% endif %}
{% endfor %}
</table>
{% else %}
@@ -132,6 +132,36 @@
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "leave_reason",
"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": "Leave Reason",
"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,
@@ -144,7 +174,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2017-05-22 16:29:01.536405",
"modified": "2017-11-15 02:09:49.082752",
"modified_by": "Administrator",
"module": "ERPNext Foundation",
"name": "Chapter Member",
@@ -4,14 +4,14 @@ 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]:
if frappe.session.user in [d.user for d in chapter.members if d.enabled == 1]:
context.already_member = True
else:
if frappe.request.method=='GET':
pass
elif frappe.request.method=='POST':
chapter.append('members', dict(
user=frappe.session.user,
user=frappe.session.user,
introduction=frappe.form_dict.introduction,
website_url=frappe.form_dict.website_url,
enabled=1
@@ -1,5 +1,5 @@
{% extends "templates/web.html" %}
<!--
<!--
{% macro chapter_button() %}
<p><a href="/{{ chapter.route }}" class='btn btn-primary'>
Go to Chapter Page</a></p>
@@ -9,8 +9,41 @@
{% if member_deleted %}
<p>You are not a member of {{ chapter.title }}!</p>
<div>
<form>
<div class="form-group">
<label for="leave">Why do you want to leave this chapter</label>
<input type="text" name="leave" class="form-control" id="leave">
</div>
<button type="button" class="btn btn-default btn-leave" data-title= "{{ chapter.title }}" id="btn-leave">Submit
</button>
</form>
</div>
<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 %}
<script>
frappe.ready(function() {
$(".btn-leave").on("click", function() {
var leave = $("#leave").val();
var user_id = frappe.session.user;
var title = $(this).attr("data-title");
console.log(leave, user_id, title);
frappe.call({
method: 'foundation.erpnext_foundation.doctype.chapter.chapter.leave',
args: {
leave_reason: leave,
user_id: user_id,
title: title
},
callback: function(r) {
if(r.message) {
frappe.msgprint(r.message)
}
}
})
});
})
</script>
{% endblock %}
Copy path View file
@@ -7,9 +7,23 @@ def get_context(context):
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))
leave_reason = frappe.form_dict.leave
frappe.db.sql("""UPDATE `tabChapter Member` SET enabled = 0, leave_reason = %s WHERE parent = %s and user = %s ;""", (leave_reason, parent, user))
frappe.db.commit()
context.member_deleted = True
context.chapter = chapter
# def leave(title, user_id, leave_reason):
# chapter = frappe.get_doc("Chapter", title)
# for member in chapter.members:
# for x in xrange(1,10):
# print(member.user, user_id)
# if member.user == user_id:
# member.enabled = 0
# member.leave_reason = leave_reason
# chapter.save()
# frappe.db.commit()
# return "Thank you for Feedback"
ProTip! Use n and p to navigate between commits in a pull request.