diff --git a/conf/index.html b/conf/index.html
index 90d5d442ec..b7e69a4f2b 100644
--- a/conf/index.html
+++ b/conf/index.html
@@ -4,7 +4,7 @@
ERPNext
{{ ajax_meta_tag }}
-
+
""" % dt
return
@@ -53,7 +53,7 @@ def upload():
webnotes.response['result'] = """
""" % {
'dt': dt,
diff --git a/py/webnotes/utils/transfer.py b/py/webnotes/utils/transfer.py
index bb9e879395..28c1c34424 100644
--- a/py/webnotes/utils/transfer.py
+++ b/py/webnotes/utils/transfer.py
@@ -52,8 +52,6 @@ def set_doc(doclist, ovr=0, ignore=1, onupdate=1):
if dt=='DocType':
ud = UpdateDocType(doclist)
- elif dt == 'Module Def':
- ud = UpdateModuleDef(doclist)
elif dt == 'DocType Mapper':
ud = UpdateDocTypeMapper(doclist)
else:
@@ -301,30 +299,6 @@ class UpdateDocType(UpdateDocumentMerge):
so.on_update()
-class UpdateModuleDef(UpdateDocumentMerge):
- """
- Merge `Module Def`
- """
- def __init__(self, in_doclist):
- UpdateDocumentMerge.__init__(self, in_doclist)
- self.to_update_doctype = ['Module Def', 'Module Def Item']
-
- def get_id(self, d):
- return webnotes.conn.sql("select name from `tabModule Def Item` where doc_type=%s and doc_name=%s and display_name=%s and parent=%s", (d.doc_type, d.doc_name, d.display_name, d.parent))
-
- def to_update(self, d):
- if d.doctype=='Module Def Item': return 1
-
- def get_orignal_values(self, d):
- if d.doctype=='Module Def Item':
- return {'name': self.get_id(d)[0][0]}
- if d.doctype=='Module Def':
- return webnotes.conn.sql("select module_seq, disabled, is_hidden from `tabModule Def` where name=%s", d.name, as_dict = 1)[0]
-
- def run_on_update(self):
- # no scripts for Module Def
- pass
-
class UpdateDocTypeMapper(UpdateDocumentMerge):
"""
diff --git a/py/webnotes/widgets/doclistview.py b/py/webnotes/widgets/doclistview.py
new file mode 100644
index 0000000000..8b7e4980e4
--- /dev/null
+++ b/py/webnotes/widgets/doclistview.py
@@ -0,0 +1,137 @@
+# Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
+#
+# MIT License (MIT)
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+"""build query for doclistview and return results"""
+
+import webnotes, json
+
+@webnotes.whitelist()
+def get(arg=None):
+ """
+ build query
+
+ gets doctype, subject, filters
+ limit_start, limit_page_length
+ """
+
+ data = webnotes.form_dict
+ filters = json.loads(data['filters'])
+ fields = json.loads(data['fields'])
+ tables = ['`tab' + data['doctype'] + '`']
+ docstatus = json.loads(data['docstatus'])
+ if docstatus:
+ conditions = [tables[0] + '.docstatus in (' + ','.join(docstatus) + ')']
+ else:
+ conditions = [tables[0] + '.docstatus < 2']
+ # add table explict to field
+ joined = [tables[0]]
+
+ # make conditions from filters
+ for f in filters:
+ tname = ('`tab' + f[0] + '`')
+ if not tname in tables:
+ tables.append(tname)
+
+ # prepare in condition
+ if f[2]=='in':
+ opts = ["'" + t.strip().replace("'", "\'") + "'" for t in f[3].split(',')]
+ f[3] = "(" + ', '.join(opts) + ")"
+ else:
+ f[3] = "'" + f[3].replace("'", "\'") + "'"
+
+ conditions.append(tname + '.' + f[1] + " " + f[2] + " " + f[3])
+
+ if not tname in joined:
+ conditions.append(tname + '.parent = ' + tables[0] + '.name')
+ joined.append(tname)
+
+ data['tables'] = ', '.join(tables)
+ data['conditions'] = ' and '.join(conditions)
+ data['fields'] = ', '.join(fields)
+ if not data.get('order_by'):
+ data['order_by'] = tables[0] + '.modified desc'
+
+ query = """select %(fields)s from %(tables)s where %(conditions)s
+ order by %(order_by)s
+ limit %(limit_start)s, %(limit_page_length)s""" % data
+ return webnotes.conn.sql(query, as_dict=1)
+
+@webnotes.whitelist()
+def delete_items():
+ """delete selected items"""
+ import json
+ from webnotes.model import delete_doc
+ from webnotes.model.code import get_obj
+
+ il = json.loads(webnotes.form_dict.get('items'))
+ doctype = webnotes.form_dict.get('doctype')
+
+ for d in il:
+ dt_obj = get_obj(doctype, d)
+ if hasattr(dt_obj, 'on_trash'):
+ dt_obj.on_trash()
+ delete_doc(doctype, d)
+
+@webnotes.whitelist()
+def get_stats():
+ """get tag info"""
+ import json
+ tags = json.loads(webnotes.form_dict.get('stats'))
+ doctype = webnotes.form_dict['doctype']
+
+ stats = {}
+
+ for tag in tags:
+ tagcount = webnotes.conn.sql("""select %(tag)s, count(*)
+ from `tab%(doctype)s`
+ where ifnull(%(tag)s, '')!=''
+ group by %(tag)s;""" % locals(), as_list=1)
+
+ if tag=='_user_tags':
+ stats[tag] = scrub_user_tags(tagcount)
+ else:
+ stats[tag] = tagcount
+
+ return stats
+
+def scrub_user_tags(tagcount):
+ """rebuild tag list for tags"""
+ rdict = {}
+ tagdict = dict(tagcount)
+ for t in tagdict:
+ alltags = t.split(',')
+ for tag in alltags:
+ if tag:
+ if not tag in rdict:
+ rdict[tag] = 0
+
+ rdict[tag] += tagdict[t]
+
+ rlist = []
+ for tag in rdict:
+ rlist.append([tag, rdict[tag]])
+
+ return rlist
+
+
+
+
\ No newline at end of file
diff --git a/py/webnotes/widgets/form/assign_to.py b/py/webnotes/widgets/form/assign_to.py
index bc305eda22..969203041c 100644
--- a/py/webnotes/widgets/form/assign_to.py
+++ b/py/webnotes/widgets/form/assign_to.py
@@ -90,27 +90,36 @@ def notify_assignment(assigned_by, owner, doc_type, doc_name, action='CLOSE', no
Notify assignee that there is a change in assignment
"""
if not (assigned_by and owner and doc_type and doc_name): return
+
+ from webnotes.boot import get_fullnames
+ user_info = get_fullnames()
+
# Search for email address in description -- i.e. assignee
- assignment = """%s""" % (doc_type, doc_name, doc_name)
+ assignment = """%s: %s""" % (doc_type, doc_name,
+ doc_type, doc_name)
if action=='CLOSE':
if owner == webnotes.session.get('user'):
arg = {
'uid': assigned_by,
'comment': "The task %s, that you assigned to %s, has been \
- closed." % (assignment, owner)
+ closed." % (assignment,
+ user_info.get(owner, {}).get('fullname'))
}
else:
arg = {
'uid': assigned_by,
'comment': "The task %s, that you assigned to %s, \
- has been closed by %s." % (assignment, owner,
- webnotes.session.get('user'))
+ has been closed by %s." % (assignment,
+ user_info.get(owner, {}).get('fullname'),
+ user_info.get(webnotes.session.get('user'),
+ {}).get('fullname'))
}
else:
arg = {
'uid': owner,
'comment': "A new task, %s, has been assigned to you by %s." \
- % (assignment, webnotes.session.get('uer')),
+ % (assignment,
+ user_info.get(webnotes.session.get('user'), {}).get('fullname')),
'notify': notify
}
from home.page.my_company import my_company
diff --git a/py/webnotes/widgets/page.py b/py/webnotes/widgets/page.py
index 5d4e13ac1f..c680a69151 100644
--- a/py/webnotes/widgets/page.py
+++ b/py/webnotes/widgets/page.py
@@ -36,94 +36,63 @@ class Page:
def __init__(self, name):
self.name = name
- def get_from_files(self, doc, module):
+ def get_from_files(self, doc):
"""
Loads page info from files in module
"""
- # load js
- doc.fields['__script'] = module.get_doc_file('page',doc.name,'.js').read() or doc.script
+ from webnotes.modules import get_module_path, scrub
+ import os
+
+ path = os.path.join(get_module_path(doc.module), 'page', scrub(doc.name))
+
+ # script
+ fpath = os.path.join(path, scrub(doc.name) + '.js')
+ if os.path.exists(fpath):
+ with open(fpath, 'r') as f:
+ doc.fields['__script'] = f.read()
doc.script = None
- # load css
- css = module.get_doc_file('page',doc.name,'.css').read()
- if css: doc.style = css
+ # css
+ fpath = os.path.join(path, scrub(doc.name) + '.css')
+ if os.path.exists(fpath):
+ with open(fpath, 'r') as f:
+ doc.style = f.read()
# html
- doc.content = module.get_doc_file('page',doc.name,'.html').read() or doc.content
+ fpath = os.path.join(path, scrub(doc.name) + '.html')
+ if os.path.exists(fpath):
+ with open(fpath, 'r') as f:
+ doc.content = f.read()
- def get_template(self, template):
- """
- Returns the page template content
- """
- ret = '%(content)s'
- # load code from template
- if template:
- from webnotes.modules import Module
- ret = Module(webnotes.conn.get_value('Page Template', template, 'module'))\
- .get_doc_file('Page Template', template, '.html').read()
- if not ret:
- ret = webnotes.conn.get_value('Page Template', template, 'template')
-
- return ret
-
def process_content(self, doc):
"""
Put in template and generate dynamic if starts with #!python
"""
- template = self.get_template(doc.template)
content = ''
# eval content
if doc.content and doc.content.startswith('#!python'):
from webnotes.model.code import execute
- content = template % {'content': execute(doc.content).get('content')}
+ doc.__content = execute(doc.content).get('content')
else:
- content = template % {'content': doc.content or ''}
-
- doc.__content = content
+ doc.__content = content
def load(self):
"""
Returns :term:`doclist` of the `Page`
- """
- from webnotes.modules import Module
-
+ """
doclist = webnotes.model.doc.get('Page', self.name)
doc = doclist[0]
# load from module
if doc.module:
- module = Module(doc.module)
- self.get_from_files(doc, module)
+ self.get_from_files(doc)
# process
self.process_content(doc)
-
- # add stylesheet
- if doc.stylesheet:
- doclist += self.load_stylesheet(doc.stylesheet)
return doclist
- def load_stylesheet(self, stylesheet):
- import webnotes
- # load stylesheet
- loaded = eval(webnotes.form_dict.get('stylesheets') or '[]')
- if not stylesheet in loaded:
- import webnotes.model.doc
- from webnotes.modules import Module
-
- # doclist
- sslist = webnotes.model.doc.get('Stylesheet', stylesheet)
-
- # stylesheet from file
- css = Module(sslist[0].module).get_doc_file('Stylesheet', stylesheet, '.css').read()
-
- if css: sslist[0].stylesheet = css
- return sslist
- else:
- return []
-
@webnotes.whitelist()
def get(name):
"""
diff --git a/py/webnotes/widgets/search.py b/py/webnotes/widgets/search.py
index e24733a322..febdac6ece 100644
--- a/py/webnotes/widgets/search.py
+++ b/py/webnotes/widgets/search.py
@@ -84,7 +84,7 @@ def build_for_autosuggest(res):
if len(info) > 30:
info = info[:30] + '...'
- results.append({'id':r[0], 'value':r[0], 'info':info})
+ results.append({'label':r[0], 'value':r[0], 'info':info})
return results
def scrub_custom_query(query, key, txt):
diff --git a/py/webnotes/widgets/tags.py b/py/webnotes/widgets/tags.py
index f74ef16a04..195fce5504 100644
--- a/py/webnotes/widgets/tags.py
+++ b/py/webnotes/widgets/tags.py
@@ -152,7 +152,7 @@ class DocTags:
def setup_tags(self):
"""creates the tabTag table if not exists"""
webnotes.conn.commit()
- from webnotes.modules.module_manager import reload_doc
+ from webnotes.modules import reload_doc
reload_doc('core','doctype','tag')
webnotes.conn.begin()