added about us page and settings
This commit is contained in:
commit
4c2c05021e
11 changed files with 70 additions and 45 deletions
|
|
@ -49,8 +49,10 @@ cur_frm.cscript.refresh = function(doc, dt, dn) {
|
|||
if(r.exc) {
|
||||
//msgprint(r.exc);
|
||||
} else {
|
||||
if(r.server_messages) { cur_frm.cscript.doc_type(doc, doc.doctype, doc.name); }
|
||||
cur_frm.frm_head.set_label(['Updated', 'label-success']);
|
||||
if(r.server_messages) {
|
||||
cur_frm.cscript.doc_type(doc, doc.doctype, doc.name);
|
||||
cur_frm.frm_head.set_label(['Updated', 'label-success']);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,3 +105,11 @@ a {
|
|||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.missing-image {
|
||||
background-color: #eee;
|
||||
padding: 40px;
|
||||
width: 32px;
|
||||
font-size: 32px;
|
||||
color: #888;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,9 @@ Field.prototype.make_body = function() {
|
|||
// label
|
||||
if(this.with_label) {
|
||||
this.label_span = $a(label_wrapper, 'span', 'small')
|
||||
|
||||
if(wn.boot && wn.boot.developer_mode)
|
||||
$(this.label_span).attr("title", this.df.fieldname);
|
||||
|
||||
// error icon
|
||||
this.label_icon = $('<i class="icon icon-warning-sign">').toggle(false)
|
||||
.appendTo(label_wrapper).css('margin-left','7px')
|
||||
|
|
|
|||
|
|
@ -166,7 +166,10 @@ _f.ImageField.prototype.onrefresh = function() {
|
|||
$(this.wrapper).find("img").remove();
|
||||
if(this.df.options && this.frm.doc[this.df.options]) {
|
||||
$("<img src='"+wn.utils.get_file_link(this.frm.doc[this.df.options])+"' style='max-width: 70%;'>")
|
||||
.appendTo(this.wrapper);
|
||||
.appendTo($(this.wrapper).empty());
|
||||
} else {
|
||||
$("<div class='missing-image'><i class='icon-camera'></i></div>")
|
||||
.appendTo($(this.wrapper).empty())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ wn.views.CommunicationList = Class.extend({
|
|||
return;
|
||||
}
|
||||
|
||||
var sortfn = function (a, b) { return (b > a) ? 1 : -1; }
|
||||
var sortfn = function (a, b) { return (b.creation > a.creation) ? 1 : -1; }
|
||||
this.list = this.list.sort(sortfn);
|
||||
|
||||
this.make();
|
||||
|
|
@ -61,6 +61,7 @@ wn.views.CommunicationList = Class.extend({
|
|||
prepare: function(doc) {
|
||||
//doc.when = comment_when(this.doc.modified);
|
||||
doc.when = doc.modified;
|
||||
if(!doc.content) doc.content = "[no content]";
|
||||
if(doc.content.indexOf("<br>")== -1 && doc.content.indexOf("<p>")== -1) {
|
||||
doc.content = doc.content.replace(/\n/g, "<br>");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ wn.views.ListView = Class.extend({
|
|||
// multiple content
|
||||
if(opts.content.indexOf && opts.content.indexOf('+')!=-1) {
|
||||
$.map(opts.content.split('+'), function(v) {
|
||||
me.render_column(data, parent, {content:v});
|
||||
me.render_column(data, parent, {content:v, title: opts.title});
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
@ -39,7 +39,8 @@ wn.views.ListView = Class.extend({
|
|||
opts.content(parent, data, me);
|
||||
}
|
||||
else if(opts.content=='name') {
|
||||
$(parent).append(repl('<a href="#Form/%(doctype)s/%(name)s">%(name)s</a>', data));
|
||||
$(parent).append(repl('<a href="#Form/%(doctype)s/%(name)s" \
|
||||
title=\"%(name)s\">%(name)s</a>', data));
|
||||
}
|
||||
else if(opts.content=='avatar') {
|
||||
$(parent).append(wn.avatar(data.owner, false, "Created by: "
|
||||
|
|
@ -54,14 +55,16 @@ wn.views.ListView = Class.extend({
|
|||
$(parent).find('input').data('name', data.name);
|
||||
}
|
||||
else if(opts.content=='docstatus') {
|
||||
$(parent).append(repl('<span class="docstatus"><i class="%(docstatus_icon)s" \
|
||||
$(parent).append(repl('<span class="docstatus"> \
|
||||
<i class="%(docstatus_icon)s" \
|
||||
title="%(docstatus_title)s"></i></span>', data));
|
||||
}
|
||||
else if(opts.content=='tags') {
|
||||
this.add_user_tags(parent, data);
|
||||
}
|
||||
else if(opts.content=='modified') {
|
||||
$(parent).append(data.when);
|
||||
$(parent).append(data.when)
|
||||
.attr("title", "Last Modified On: " + data.when);
|
||||
}
|
||||
else if(opts.type=='bar-graph') {
|
||||
this.render_bar_graph(parent, data, opts.content, opts.label);
|
||||
|
|
@ -77,8 +80,14 @@ wn.views.ListView = Class.extend({
|
|||
if(opts.type=="date") {
|
||||
data[opts.content] = wn.datetime.str_to_user(data[opts.content])
|
||||
}
|
||||
|
||||
$(parent).append(repl('<span title="%(title)s"> %(content)s</span>', {
|
||||
"title": opts.title || opts.content, "content": data[opts.content]}));
|
||||
"title": (opts.title || opts.content)
|
||||
+ (data[opts.content].indexOf("<")===-1
|
||||
? ": " + data[opts.content].replace(/\"/g, '"')
|
||||
: ""),
|
||||
"content": data[opts.content]
|
||||
}));
|
||||
}
|
||||
|
||||
},
|
||||
|
|
|
|||
|
|
@ -319,7 +319,16 @@ def rename_doc(doctype, old, new, is_doctype=0, debug=0):
|
|||
def insert(doclist):
|
||||
import webnotes.model
|
||||
return webnotes.model.insert(doclist)
|
||||
|
||||
|
||||
def get_method(method_string):
|
||||
modulename = '.'.join(method_string.split('.')[:-1])
|
||||
methodname = method_string.split('.')[-1]
|
||||
|
||||
__import__(modulename)
|
||||
import sys
|
||||
moduleobj = sys.modules[modulename]
|
||||
return getattr(moduleobj, methodname)
|
||||
|
||||
def get_application_home_page(user='Guest'):
|
||||
"""get home page for user"""
|
||||
hpl = conn.sql("""select home_page
|
||||
|
|
|
|||
|
|
@ -114,13 +114,7 @@ def uploadfile():
|
|||
else:
|
||||
if webnotes.form_dict.get('method'):
|
||||
m = webnotes.form_dict['method']
|
||||
modulename = '.'.join(m.split('.')[:-1])
|
||||
methodname = m.split('.')[-1]
|
||||
|
||||
__import__(modulename)
|
||||
import sys
|
||||
moduleobj = sys.modules[modulename]
|
||||
ret = getattr(moduleobj, methodname)()
|
||||
ret = webnotes.get_method(m)()
|
||||
except Exception, e:
|
||||
webnotes.msgprint(e)
|
||||
webnotes.errprint(webnotes.utils.getTraceback())
|
||||
|
|
@ -219,11 +213,7 @@ def call(fn, args):
|
|||
def get_method(cmd):
|
||||
"""get method object from cmd"""
|
||||
if '.' in cmd:
|
||||
cmd_parts = cmd.split('.')
|
||||
module_string = ".".join(cmd_parts[:-1])
|
||||
fn_string = cmd_parts[-1]
|
||||
module = __import__(module_string, fromlist=[module_string.split('.')[-1].encode('utf-8')])
|
||||
method = getattr(module, fn_string)
|
||||
method = webnotes.get_method(cmd)
|
||||
else:
|
||||
method = globals()[cmd]
|
||||
return method
|
||||
|
|
|
|||
|
|
@ -40,9 +40,11 @@ class ModelWrapper:
|
|||
self.docs = []
|
||||
self.obj = None
|
||||
self.to_docstatus = 0
|
||||
if isinstance(dt, basestring) and not dn:
|
||||
dn = dt
|
||||
if dt and dn:
|
||||
self.load_from_db(dt, dn)
|
||||
if isinstance(dt, list):
|
||||
elif isinstance(dt, list):
|
||||
self.set_doclist(dt)
|
||||
|
||||
def load_from_db(self, dt=None, dn=None, prefix='tab'):
|
||||
|
|
@ -65,6 +67,7 @@ class ModelWrapper:
|
|||
doclist += getchildren(doc.name, t[0], t[1], dt, prefix=prefix)
|
||||
|
||||
self.set_doclist(doclist)
|
||||
self.run_method("onload")
|
||||
|
||||
def __iter__(self):
|
||||
"""
|
||||
|
|
@ -200,7 +203,7 @@ class ModelWrapper:
|
|||
if hasattr(self.obj, 'custom_' + method):
|
||||
getattr(self.obj, 'custom_' + method)()
|
||||
|
||||
trigger(method, self.obj.doc)
|
||||
notify(self.obj, method)
|
||||
|
||||
self.set_doclist(self.obj.doclist)
|
||||
|
||||
|
|
@ -315,18 +318,26 @@ def clone(source_wrapper):
|
|||
return new_wrapper
|
||||
|
||||
|
||||
def trigger(method, doc):
|
||||
"""trigger doctype events"""
|
||||
def notify(controller, caller_method):
|
||||
try:
|
||||
import startup.event_handlers
|
||||
from startup.observers import observer_map
|
||||
except ImportError:
|
||||
return
|
||||
|
||||
if hasattr(startup.event_handlers, method):
|
||||
getattr(startup.event_handlers, method)(doc)
|
||||
|
||||
if hasattr(startup.event_handlers, 'doclist_all'):
|
||||
startup.event_handlers.doclist_all(doc, method)
|
||||
doctype = controller.doc.doctype
|
||||
|
||||
def call_observers(key):
|
||||
if key in observer_map:
|
||||
observer_list = observer_map[key]
|
||||
if isinstance(observer_list, basestring):
|
||||
observer_list = [observer_list]
|
||||
for observer_method in observer_list:
|
||||
webnotes.get_method(observer_method)(controller, caller_method)
|
||||
|
||||
call_observers("*:*")
|
||||
call_observers(doctype + ":*")
|
||||
call_observers("*:" + caller_method)
|
||||
call_observers(doctype + ":" + caller_method)
|
||||
|
||||
# for bc
|
||||
def getlist(doclist, parentfield):
|
||||
|
|
|
|||
|
|
@ -68,8 +68,7 @@ def execute_patch(patchmodule, method=None, methodargs=None):
|
|||
try:
|
||||
log('Executing %s in %s' % (patchmodule or str(methodargs), webnotes.conn.cur_db_name))
|
||||
if patchmodule:
|
||||
patch = __import__(patchmodule, fromlist=True)
|
||||
getattr(patch, 'execute')()
|
||||
webnotes.get_method(patchmodule + ".execute")()
|
||||
update_patch_log(patchmodule)
|
||||
elif method:
|
||||
method(**methodargs)
|
||||
|
|
|
|||
|
|
@ -84,21 +84,12 @@ def getdoctype():
|
|||
|
||||
def load_single_doc(dt, dn, user):
|
||||
"""load doc and call onload methods"""
|
||||
import webnotes.model.code
|
||||
|
||||
if not dn: dn = dt
|
||||
dl = webnotes.model.doc.get(dt, dn)
|
||||
|
||||
try:
|
||||
so, r = webnotes.model.code.get_server_obj(dl[0], dl), None
|
||||
if hasattr(so, 'onload'):
|
||||
r = webnotes.model.code.run_server_obj(so, 'onload')
|
||||
dl = so.doclist
|
||||
if hasattr(so, 'custom_onload'):
|
||||
r = webnotes.model.code.run_server_obj(so, 'custom_onload')
|
||||
dl = so.doclist
|
||||
if r:
|
||||
webnotes.msgprint(r)
|
||||
doclist = webnotes.model_wrapper(dt, dn)
|
||||
except Exception, e:
|
||||
webnotes.errprint(webnotes.utils.getTraceback())
|
||||
webnotes.msgprint('Error in script while loading')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue