2019-01-22 18:22:20 +05:30
|
|
|
from __future__ import unicode_literals
|
2017-11-24 17:24:41 +05:30
|
|
|
import frappe
|
|
|
|
|
|
|
|
def get_context(context):
|
|
|
|
context.no_cache = True
|
|
|
|
chapter = frappe.get_doc('Chapter', frappe.form_dict.name)
|
|
|
|
if frappe.session.user!='Guest':
|
2018-01-15 14:10:23 +05:30
|
|
|
if frappe.session.user in [d.user for d in chapter.members if d.enabled == 1]:
|
2017-11-24 17:24:41 +05:30
|
|
|
context.already_member = True
|
|
|
|
else:
|
|
|
|
if frappe.request.method=='GET':
|
|
|
|
pass
|
|
|
|
elif frappe.request.method=='POST':
|
|
|
|
chapter.append('members', dict(
|
2017-12-05 17:19:02 +05:30
|
|
|
user=frappe.session.user,
|
2017-11-24 17:24:41 +05:30
|
|
|
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
|