mirror of
https://github.com/erpnext/foundation.git
synced 2026-10-16 18:00:47 +02:00
Adding User details to Chapter Member docType.
This commit is contained in:
@@ -16,8 +16,14 @@ class Chapter(WebsiteGenerator):
|
|||||||
chapter_head = self.chapter_head
|
chapter_head = self.chapter_head
|
||||||
chapter = frappe.get_all('Chapter', filters={'published': True}, fields=['chapter_head'])
|
chapter = frappe.get_all('Chapter', filters={'published': True}, fields=['chapter_head'])
|
||||||
|
|
||||||
if chapter_head in [d.chapter_head for d in chapter]:
|
# if chapter_head in [d.chapter_head for d in chapter]:
|
||||||
frappe.throw(_('You are not allow to create more than one Chapter'))
|
# frappe.throw(_('You are not allow to create more than one Chapter'))
|
||||||
|
|
||||||
|
def enable(self):
|
||||||
|
chapter = frappe.get_doc('Chapter', frappe.form_dict.name)
|
||||||
|
chapter.append('members', dict(enable=self.value))
|
||||||
|
chapter.save(ignore_permissions=1)
|
||||||
|
frappe.db.commit()
|
||||||
|
|
||||||
|
|
||||||
def get_list_context(context):
|
def get_list_context(context):
|
||||||
|
|||||||
@@ -6,15 +6,26 @@
|
|||||||
<p>{{ introduction }}</p>
|
<p>{{ introduction }}</p>
|
||||||
<h3>List of Members</h3>
|
<h3>List of Members</h3>
|
||||||
{% if members %}
|
{% if members %}
|
||||||
<table class="table table-bordered small" style="max-width: 400px;">
|
<table class="table table-bordered small" style="max-width: 600px;">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Member Name</th>
|
<th>Member Name</th>
|
||||||
<th>Member Email</th>
|
<th>Member Email</th>
|
||||||
|
<th>Introduction</th>
|
||||||
|
<th>Website URL</th>
|
||||||
|
<th>Enable</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for user in members %}
|
{% for user in members %}
|
||||||
<tr>
|
<tr>
|
||||||
<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>{{ frappe.db.get_value('User', user.user, 'email') }}</td>
|
||||||
|
<td>{{ user.introduction }}</td>
|
||||||
|
<td>
|
||||||
|
{% if user.website_url %}
|
||||||
|
<a href="{{ user.website_url }}">{{ user.website_url }}</a></td>
|
||||||
|
{% else %}
|
||||||
|
{{ user.website_url }}
|
||||||
|
{% endif %}
|
||||||
|
<td><label><input type="checkbox" name="enable" {{ checked if user.enabled == 1 else '' }}></label></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@@ -42,6 +42,96 @@
|
|||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fieldname": "introduction",
|
||||||
|
"fieldtype": "Text",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Introduction",
|
||||||
|
"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
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fieldname": "enabled",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Enabled",
|
||||||
|
"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
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fieldname": "website_url",
|
||||||
|
"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": "Website URL",
|
||||||
|
"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,
|
"has_web_view": 0,
|
||||||
@@ -54,7 +144,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2017-05-08 17:01:30.018083",
|
"modified": "2017-05-12 16:36:07.139907",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "ERPNext Foundation",
|
"module": "ERPNext Foundation",
|
||||||
"name": "Chapter Member",
|
"name": "Chapter Member",
|
||||||
|
|||||||
@@ -7,4 +7,8 @@ import frappe
|
|||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class ChapterMember(Document):
|
class ChapterMember(Document):
|
||||||
pass
|
def get_context(self, context):
|
||||||
|
context.no_cache = True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,5 +9,4 @@ frappe.ui.form.on('Chapter Message', {
|
|||||||
frm.set_value('chapter', data.name);
|
frm.set_value('chapter', data.name);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// refs
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,7 +10,185 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<p>Welcome to chapter {{ chapter.title }}!</p>
|
<p>Welcome to chapter {{ chapter.title }}!</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<div style="padding: 20px 0;">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-8 col-md-8">
|
||||||
|
<form name="user-intro">
|
||||||
|
<div class="form-group">
|
||||||
|
<input id="chapter_name" name="chapter_name" class="form-control" type="text" value={{chapter.name}} />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="username" class="">User Name</label>
|
||||||
|
<input id="username" name="username" class="form-control" type="text" value={{ frappe.session.user }} />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="weburl" class="">Website URL</label>
|
||||||
|
<input id="weburl" name="weburl" class="form-control" type="text" placeholder="Please Enter website URL" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="introduction" class="">Introduction</label>
|
||||||
|
<textarea id="introduction" name="introduction" class="form-control" placeholder="Please Enter your Introduction"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<button type="Submit" id="update_member" class="btn-primary">Submit</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<p><a href="/{{ chapter.route }}" class='btn btn-primary'>Go to Chapter Page</a></p>
|
<p><a href="/{{ chapter.route }}" class='btn btn-primary'>Go to Chapter Page</a></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
frappe.ready(function() {
|
||||||
|
|
||||||
|
// $("#reset-password").on("submit", function() {
|
||||||
|
// return false;
|
||||||
|
// });
|
||||||
|
|
||||||
|
// $("#new_password").on("press", function(e) {
|
||||||
|
// if(e.which===13) $("#update").click();
|
||||||
|
// })
|
||||||
|
|
||||||
|
$("#update_member").click(function() {
|
||||||
|
var args = {
|
||||||
|
: get_url_arg("key") || "",
|
||||||
|
weburl: $("#weburl").val(),
|
||||||
|
introduction: $("#introduction").val()
|
||||||
|
}
|
||||||
|
|
||||||
|
// if(!args.old_password && !args.key) {
|
||||||
|
// frappe.msgprint("Old Password Required.");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// if(!args.new_password) {
|
||||||
|
// frappe.msgprint("New Password Required.")
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
frappe.call({
|
||||||
|
type: "POST",
|
||||||
|
method: "frappe.core.doctype.user.user.update_password",
|
||||||
|
btn: $("#update"),
|
||||||
|
args: args,
|
||||||
|
statusCode: {
|
||||||
|
401: function() {
|
||||||
|
$('.page-card-head .indicator').removeClass().addClass('indicator red')
|
||||||
|
.text(__('Invalid Password'));
|
||||||
|
},
|
||||||
|
200: function(r) {
|
||||||
|
$("input").val("");
|
||||||
|
// strength_indicator.addClass('hidden');
|
||||||
|
// strength_message.addClass('hidden');
|
||||||
|
$('.page-card-head .indicator')
|
||||||
|
// .removeClass().addClass('indicator green')
|
||||||
|
.html(__('Password Updated'));
|
||||||
|
if(r.message) {
|
||||||
|
frappe.msgprint(__("Password Updated"));
|
||||||
|
setTimeout(function() {
|
||||||
|
window.location.href = r.message;
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
// window.strength_indicator = $('.password-strength-indicator');
|
||||||
|
// window.strength_message = $('.password-strength-message');
|
||||||
|
|
||||||
|
// $('#new_password').on('keyup', function() {
|
||||||
|
// window.clear_timeout();
|
||||||
|
// window.timout_password_strength = setTimeout(window.test_password_strength, 200);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// window.test_password_strength = function() {
|
||||||
|
// window.timout_password_strength = null;
|
||||||
|
|
||||||
|
// var args = {
|
||||||
|
// key: get_url_arg("key") || "",
|
||||||
|
// old_password: $("#old_password").val(),
|
||||||
|
// new_password: $("#new_password").val()
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (!args.new_password) {
|
||||||
|
// set_strength_indicator('grey', {'warning': __('Please enter the password') });
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return frappe.call({
|
||||||
|
// type: 'GET',
|
||||||
|
// method: 'frappe.core.doctype.user.user.test_password_strength',
|
||||||
|
// args: args,
|
||||||
|
// callback: function(r) {
|
||||||
|
// // console.log(r.message);
|
||||||
|
// },
|
||||||
|
// statusCode: {
|
||||||
|
// 401: function() {
|
||||||
|
// $('.page-card-head .indicator').removeClass().addClass('indicator red')
|
||||||
|
// .text(__('Invalid Password'));
|
||||||
|
// },
|
||||||
|
// 200: function(r) {
|
||||||
|
// if (r.message && r.message.entropy) {
|
||||||
|
// var score = r.message.score,
|
||||||
|
// feedback = r.message.feedback;
|
||||||
|
|
||||||
|
// feedback.crack_time_display = r.message.crack_time_display;
|
||||||
|
// feedback.score = score;
|
||||||
|
|
||||||
|
// if(feedback.password_policy_validation_passed){
|
||||||
|
// set_strength_indicator('green', feedback);
|
||||||
|
// }else{
|
||||||
|
// set_strength_indicator('red', feedback);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
|
||||||
|
// window.set_strength_indicator = function(color, feedback) {
|
||||||
|
// var message = [];
|
||||||
|
// feedback.help_msg = "";
|
||||||
|
// if(!feedback.password_policy_validation_passed){
|
||||||
|
// feedback.help_msg = __("Hint: Include symbols, numbers and capital letters in the password");
|
||||||
|
// }
|
||||||
|
// if (feedback) {
|
||||||
|
// if(!feedback.password_policy_validation_passed){
|
||||||
|
// if (feedback.suggestions && feedback.suggestions.length) {
|
||||||
|
// feedback.suggestions = feedback.suggestions + ' ' + feedback.help_msg;
|
||||||
|
// message = message.concat(feedback.suggestions);
|
||||||
|
// } else if (feedback.warning) {
|
||||||
|
// feedback.warning = feedback.warning + ' ' + feedback.help_msg;
|
||||||
|
// message.push(feedback.warning);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (!message.length) {
|
||||||
|
// message.push(feedback.help_msg);
|
||||||
|
// }
|
||||||
|
// }else{
|
||||||
|
// message.push(__('Success! You are good to go 👍'));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// strength_indicator.removeClass().addClass('password-strength-indicator indicator ' + color);
|
||||||
|
// strength_message.text(message.join(' ') || '').removeClass('hidden');
|
||||||
|
// // strength_indicator.attr('title', message.join(' ') || '');
|
||||||
|
// }
|
||||||
|
|
||||||
|
window.clear_timeout = function() {
|
||||||
|
if (window.timout_password_strength) {
|
||||||
|
clearTimeout(window.timout_password_strength);
|
||||||
|
window.timout_password_strength = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
12
foundation/www/join_chapter.js
Normal file
12
foundation/www/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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -3,6 +3,7 @@ import frappe
|
|||||||
def get_context(context):
|
def get_context(context):
|
||||||
context.no_cache = True
|
context.no_cache = True
|
||||||
chapter = frappe.get_doc('Chapter', frappe.form_dict.name)
|
chapter = frappe.get_doc('Chapter', frappe.form_dict.name)
|
||||||
|
print chapter
|
||||||
if frappe.session.user!='Guest':
|
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]:
|
||||||
context.already_member = True
|
context.already_member = True
|
||||||
|
|||||||
7
foundation/www/user-intro.html
Normal file
7
foundation/www/user-intro.html
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{% extends "templates/web.html" %}
|
||||||
|
|
||||||
|
{% block page_content %}
|
||||||
|
|
||||||
|
<p><a href="" class='btn btn-primary'>Go to Chapter Page</a></p>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
15
foundation/www/user_intro.py
Normal file
15
foundation/www/user_intro.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)
|
||||||
|
print chapter
|
||||||
|
if frappe.session.user!='Guest':
|
||||||
|
if chapter in [d.name for d in chapter]:
|
||||||
|
context.already_member = True
|
||||||
|
else:
|
||||||
|
chapter.append('members', dict(user=frappe.session.user))
|
||||||
|
chapter.save(ignore_permissions=1)
|
||||||
|
frappe.db.commit()
|
||||||
|
|
||||||
|
context.chapter = chapter
|
||||||
Reference in New Issue
Block a user