@@ -420,6 +420,31 @@ | |||||
"set_only_once": 0, | "set_only_once": 0, | ||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | |||||
"allow_on_submit": 0, | |||||
"bold": 0, | |||||
"collapsible": 0, | |||||
"fieldname": "phone", | |||||
"fieldtype": "Data", | |||||
"hidden": 0, | |||||
"ignore_user_permissions": 0, | |||||
"ignore_xss_filter": 0, | |||||
"in_filter": 0, | |||||
"in_list_view": 0, | |||||
"label": "Phone", | |||||
"length": 0, | |||||
"no_copy": 0, | |||||
"permlevel": 0, | |||||
"precision": "", | |||||
"print_hide": 0, | |||||
"print_hide_if_no_value": 0, | |||||
"read_only": 0, | |||||
"report_hide": 0, | |||||
"reqd": 0, | |||||
"search_index": 0, | |||||
"set_only_once": 0, | |||||
"unique": 0 | |||||
}, | |||||
{ | { | ||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
@@ -1458,7 +1483,7 @@ | |||||
"hide_heading": 0, | "hide_heading": 0, | ||||
"hide_toolbar": 0, | "hide_toolbar": 0, | ||||
"icon": "icon-user", | "icon": "icon-user", | ||||
"idx": 1, | |||||
"idx": 253, | |||||
"in_create": 0, | "in_create": 0, | ||||
"in_dialog": 0, | "in_dialog": 0, | ||||
"is_submittable": 0, | "is_submittable": 0, | ||||
@@ -1466,7 +1491,7 @@ | |||||
"istable": 0, | "istable": 0, | ||||
"max_attachments": 5, | "max_attachments": 5, | ||||
"menu_index": 0, | "menu_index": 0, | ||||
"modified": "2016-03-29 06:26:24.316335", | |||||
"modified": "2016-03-30 07:32:15.815142", | |||||
"modified_by": "Administrator", | "modified_by": "Administrator", | ||||
"module": "Core", | "module": "Core", | ||||
"name": "User", | "name": "User", | ||||
@@ -369,7 +369,8 @@ class Database: | |||||
"""Returns `get_value` with fieldname='*'""" | """Returns `get_value` with fieldname='*'""" | ||||
return self.get_value(doctype, filters, "*", as_dict=as_dict, cache=cache) | return self.get_value(doctype, filters, "*", as_dict=as_dict, cache=cache) | ||||
def get_value(self, doctype, filters=None, fieldname="name", ignore=None, as_dict=False, debug=False, cache=False): | |||||
def get_value(self, doctype, filters=None, fieldname="name", ignore=None, as_dict=False, | |||||
debug=False, cache=False): | |||||
"""Returns a document property or list of properties. | """Returns a document property or list of properties. | ||||
:param doctype: DocType name. | :param doctype: DocType name. | ||||
@@ -418,6 +419,7 @@ class Database: | |||||
user = frappe.db.get_values("User", "test@example.com", "*")[0] | user = frappe.db.get_values("User", "test@example.com", "*")[0] | ||||
""" | """ | ||||
out = None | out = None | ||||
cache = False | |||||
if cache and isinstance(filters, basestring) and \ | if cache and isinstance(filters, basestring) and \ | ||||
(doctype, filters, fieldname) in self.value_cache: | (doctype, filters, fieldname) in self.value_cache: | ||||
return self.value_cache[(doctype, filters, fieldname)] | return self.value_cache[(doctype, filters, fieldname)] | ||||
@@ -23,7 +23,8 @@ def update_link_count(): | |||||
link_count = frappe.cache().get_value('_link_count') | link_count = frappe.cache().get_value('_link_count') | ||||
if link_count: | if link_count: | ||||
for key, count in link_count.iteritems(): | for key, count in link_count.iteritems(): | ||||
frappe.db.sql('update `tab{0}` set idx = idx + %s where name=%s'.format(key[0]), (count, key[1])) | |||||
frappe.db.sql('update `tab{0}` set idx = idx + %s where name=%s'.format(key[0]), | |||||
(count, key[1])) | |||||
# reset the count | # reset the count | ||||
frappe.cache().delete_value('_link_count') | frappe.cache().delete_value('_link_count') |
@@ -0,0 +1,46 @@ | |||||
{% extends "templates/web.html" %} | |||||
{% block title %} {{ "Edit Profile" }} {% endblock %} | |||||
{% block header %}<h2>{{ _("Edit Profile") }}</h2>{% endblock %} | |||||
{% block page_content %} | |||||
<div class="user-content" style="max-width: 500px;"> | |||||
<div class="alert alert-warning" id="message" style="display: none;"></div> | |||||
<form> | |||||
<fieldset> | |||||
<label>{{ _("Full Name") }}</label> | |||||
<input class="form-control" type="text" id="fullname" value="{{ user.full_name or "" }}"> | |||||
</fieldset> | |||||
<fieldset> | |||||
<label>{{ _("Phone") }}</label> | |||||
<input class="form-control" type="text" id="phone" value="{{ user.phone or "" }}"> | |||||
</fieldset> | |||||
<button id="update_user" type="submit" class="btn btn-default">{{ _("Update") }}</button> | |||||
</form> | |||||
</div> | |||||
<script> | |||||
frappe.ready(function() { | |||||
$("#fullname").val(getCookie("full_name") || ""); | |||||
$("#update_user").click(function() { | |||||
frappe.call({ | |||||
method: "frappe.templates.pages.edit_profile.update_user", | |||||
type: "POST", | |||||
args: { | |||||
fullname: $("#fullname").val(), | |||||
org_name: $("#org_name").val(), | |||||
phone: $("#phone").val() | |||||
}, | |||||
btn: this, | |||||
msg: $("#message"), | |||||
callback: function(r) { | |||||
if(!r.exc) $("#user-full-name").html($("#fullname").val()); | |||||
} | |||||
}); | |||||
return false; | |||||
}) | |||||
}) | |||||
</script> | |||||
<!-- no-sidebar --> | |||||
{% endblock %} | |||||
@@ -0,0 +1,29 @@ | |||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors | |||||
# License: GNU General Public License v3. See license.txt | |||||
from __future__ import unicode_literals | |||||
import frappe | |||||
from frappe import _ | |||||
no_cache = 1 | |||||
no_sitemap = 1 | |||||
def get_context(context): | |||||
user = frappe.get_doc('User', frappe.session.user) | |||||
user.full_name = user.get_fullname() | |||||
context.user = user | |||||
@frappe.whitelist() | |||||
def update_user(fullname, phone=None): | |||||
if not fullname: | |||||
return _("Name is required") | |||||
user = frappe.get_doc('User', frappe.session.user) | |||||
user.first_name = fullname | |||||
user.last_name = '' | |||||
user.phone = phone | |||||
user.save(ignore_permissions=True) | |||||
frappe.local.cookie_manager.set_cookie("full_name", fullname) | |||||
return _("Updated") |
@@ -69,7 +69,7 @@ def set_route(context): | |||||
'''Set link for the list item''' | '''Set link for the list item''' | ||||
if context.is_web_form: | if context.is_web_form: | ||||
context.route = "{0}?name={1}".format(context.pathname, quote_plus(context.doc.name)) | context.route = "{0}?name={1}".format(context.pathname, quote_plus(context.doc.name)) | ||||
elif hasattr(context.doc, 'get_route'): | |||||
elif context.doc and getattr(context.doc, 'get_route', None): | |||||
context.route = context.doc.get_route() | context.route = context.doc.get_route() | ||||
else: | else: | ||||
context.route = "{0}/{1}".format(context.pathname or quote_plus(context.doc.doctype), quote_plus(context.doc.name)) | context.route = "{0}/{1}".format(context.pathname or quote_plus(context.doc.doctype), quote_plus(context.doc.name)) | ||||