Merge branch 'master' of github.com:webnotes/wnframework into wsgi
Conflicts: requirements.txt webnotes/handler.py webnotes/install_lib/install.py webnotes/model/sync.py webnotes/webutils.py
This commit is contained in:
commit
c7253a830a
18 changed files with 70 additions and 39 deletions
|
|
@ -16,10 +16,10 @@ public_path = 'public'
|
|||
max_file_size = 1000000
|
||||
|
||||
# generate schema (.txt files)
|
||||
developer_mode = 1
|
||||
developer_mode = 0
|
||||
|
||||
# clear cache on refresh
|
||||
auto_cache_clear = 1
|
||||
auto_cache_clear = 0
|
||||
|
||||
# email logs to admin (beta)
|
||||
admin_email_notification = 0
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from __future__ import unicode_literals
|
|||
import webnotes
|
||||
import inspect, os, json, datetime, shutil
|
||||
from webnotes.modules import get_doc_path, get_module_path, scrub
|
||||
from webnotes.utils import get_path, get_base_path
|
||||
from webnotes.utils import get_path, get_base_path, cstr
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
|
@ -36,6 +36,7 @@ def get_static_pages():
|
|||
for repo in ("lib", "app"):
|
||||
for basepath, folders, files in os.walk(get_path(repo, "docs")):
|
||||
for fname in files:
|
||||
fname = cstr(fname)
|
||||
if fname.endswith(".md"):
|
||||
fpath = get_path(basepath, fname)
|
||||
with open(fpath, "r") as docfile:
|
||||
|
|
@ -78,6 +79,7 @@ def get_docs_for(docs, name):
|
|||
mydocs["_toc"] = []
|
||||
dirname = os.path.dirname(obj.__file__)
|
||||
for fname in os.listdir(dirname):
|
||||
fname = cstr(fname)
|
||||
fpath = os.path.join(dirname, fname)
|
||||
if os.path.isdir(fpath):
|
||||
# append if package
|
||||
|
|
@ -176,6 +178,7 @@ def get_modules(for_module=None):
|
|||
prefix = prefix + ".py_modules."
|
||||
for basepath, folders, files in os.walk(module_path):
|
||||
for f in files:
|
||||
f = cstr(f)
|
||||
if f.endswith(".py") and \
|
||||
(not f.split(".")[0] in os.path.split(basepath)) and \
|
||||
(not f.startswith("__")):
|
||||
|
|
@ -436,6 +439,7 @@ def write_docs(data, build_sitemap=None, domain=None):
|
|||
domain = domain + "/"
|
||||
content = ""
|
||||
for fname in os.listdir(get_path("public", "docs")):
|
||||
fname = cstr(fname)
|
||||
if fname.endswith(".html"):
|
||||
content += sitemap_link_xml % (domain + fname,
|
||||
get_timestamp(get_path("public", "docs", fname)))
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ _f.Frm.prototype.watch_model_updates = function() {
|
|||
wn.model.on(me.doctype, "*", function(fieldname, value, doc) {
|
||||
// set input
|
||||
if(doc.name===me.docname) {
|
||||
me.dirty();
|
||||
me.fields_dict[fieldname]
|
||||
&& me.fields_dict[fieldname].refresh(fieldname);
|
||||
me.refresh_dependency();
|
||||
|
|
@ -142,6 +143,7 @@ _f.Frm.prototype.watch_model_updates = function() {
|
|||
$.each(wn.model.get("DocField", {fieldtype:"Table", parent: me.doctype}), function(i, df) {
|
||||
wn.model.on(df.options, "*", function(fieldname, value, doc) {
|
||||
if(doc.parent===me.docname && doc.parentfield===df.fieldname) {
|
||||
me.dirty();
|
||||
me.fields_dict[df.fieldname].grid.set_value(fieldname, value, doc);
|
||||
me.script_manager.trigger(fieldname, doc.doctype, doc.name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,6 @@ wn.ui.form.Control = Class.extend({
|
|||
set_model_value: function(value) {
|
||||
if(wn.model.set_value(this.doctype, this.docname, this.df.fieldname,
|
||||
value, this.df.fieldtype)) {
|
||||
this.frm && this.frm.dirty();
|
||||
this.last_value = value;
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -47,7 +47,9 @@ wn.ui.form.Grid = Class.extend({
|
|||
this.docfields = wn.meta.get_docfields(this.doctype, this.frm.docname);
|
||||
this.display_status = wn.perm.get_field_display_status(this.df, this.frm.doc,
|
||||
this.perm);
|
||||
|
||||
|
||||
if(this.display_status==="None") return;
|
||||
|
||||
if(!force && this.data_rows_are_same(data)) {
|
||||
// soft refresh
|
||||
this.header_row.refresh();
|
||||
|
|
@ -146,7 +148,8 @@ wn.ui.form.Grid = Class.extend({
|
|||
return this.fieldinfo[fieldname];
|
||||
},
|
||||
set_value: function(fieldname, value, doc) {
|
||||
this.grid_rows_by_docname[doc.name].refresh_field(fieldname);
|
||||
if(this.display_status!=="None")
|
||||
this.grid_rows_by_docname[doc.name].refresh_field(fieldname);
|
||||
},
|
||||
add_new_row: function(idx, callback, show) {
|
||||
if(this.is_editable()) {
|
||||
|
|
|
|||
|
|
@ -207,18 +207,19 @@ $.extend(wn.model, {
|
|||
},
|
||||
|
||||
trigger: function(fieldname, value, doc) {
|
||||
var run = function(events) {
|
||||
var run = function(events, event_doc) {
|
||||
$.each(events || [], function(i, fn) {
|
||||
fn && fn(fieldname, value, doc);
|
||||
fn && fn(fieldname, value, event_doc || doc);
|
||||
});
|
||||
};
|
||||
|
||||
if(wn.model.events[doc.doctype]) {
|
||||
// doctype-level
|
||||
run(wn.model.events[doc.doctype]['*']);
|
||||
|
||||
|
||||
// field-level
|
||||
run(wn.model.events[doc.doctype][fieldname]);
|
||||
|
||||
// doctype-level
|
||||
run(wn.model.events[doc.doctype]['*']);
|
||||
};
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
Jinja2==2.7.1
|
||||
MySQL-python==1.2.4
|
||||
chardet==2.1.1
|
||||
dropbox==1.6
|
||||
google-api-python-client==1.2
|
||||
httplib2==0.8
|
||||
markdown2==2.1.0
|
||||
pygeoip==0.2.7
|
||||
python-dateutil==2.1
|
||||
python-memcached==1.53
|
||||
Jinja2
|
||||
MarkupSafe
|
||||
MySQL-python
|
||||
chardet
|
||||
dropbox
|
||||
google-api-python-client
|
||||
httplib2
|
||||
markdown2
|
||||
pygeoip
|
||||
python-dateutil
|
||||
python-memcached
|
||||
pytz==2013d
|
||||
requests==1.2.3
|
||||
six==1.4.0
|
||||
termcolor==1.1.0
|
||||
Werkzeug==0.9.4
|
||||
gunicorn==18.0
|
||||
requests
|
||||
six
|
||||
termcolor
|
||||
Werkzeug
|
||||
gunicorn
|
||||
|
|
@ -13,6 +13,7 @@ import getpass
|
|||
|
||||
from webnotes.model.db_schema import DbManager
|
||||
from webnotes.model.sync import sync_for
|
||||
from webnotes.utils import cstr
|
||||
|
||||
class Installer:
|
||||
def __init__(self, root_login, root_password=None, db_name=None, site=None):
|
||||
|
|
@ -126,7 +127,6 @@ class Installer:
|
|||
_update_password("Administrator", webnotes.conf.get("admin_password") or password)
|
||||
webnotes.conn.commit()
|
||||
|
||||
|
||||
def import_core_docs(self):
|
||||
install_docs = [
|
||||
# profiles
|
||||
|
|
@ -245,6 +245,7 @@ def install_fixtures():
|
|||
print "Importing install fixtures..."
|
||||
for basepath, folders, files in os.walk(os.path.join("app", "startup", "install_fixtures")):
|
||||
for f in files:
|
||||
f = cstr(f)
|
||||
if f.endswith(".json"):
|
||||
print "Importing " + f
|
||||
with open(os.path.join(basepath, f), "r") as infile:
|
||||
|
|
|
|||
|
|
@ -404,7 +404,7 @@ class Bean:
|
|||
elif doc.fields.get(df.fieldname) is None:
|
||||
msg = _("Error") + ": "
|
||||
if doc.parentfield:
|
||||
msg += _("Row") + (" # %d: " % doc.idx)
|
||||
msg += _("Row") + (" # %s: " % (doc.idx,))
|
||||
|
||||
msg += _("Value missing for") + ": " + _(df.label)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from __future__ import unicode_literals
|
|||
import webnotes
|
||||
import os
|
||||
from webnotes.modules.import_file import import_file
|
||||
from webnotes.utils import get_path
|
||||
from webnotes.utils import get_path, cstr
|
||||
|
||||
def sync_all(force=0):
|
||||
sync_for("lib", force)
|
||||
|
|
@ -32,6 +32,7 @@ def walk_and_sync(start_path, force=0, sync_everything = False):
|
|||
|
||||
if sync_everything or (os.path.basename(os.path.dirname(path)) in document_type):
|
||||
for f in files:
|
||||
f = cstr(f)
|
||||
if f.endswith(".txt"):
|
||||
doc_name = f.split(".txt")[0]
|
||||
if doc_name == os.path.basename(path):
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import webnotes, os
|
||||
import webnotes.modules
|
||||
from webnotes.utils import cstr
|
||||
from webnotes.modules import export_doc, get_module_path, scrub
|
||||
|
||||
def listfolders(path, only_name=0):
|
||||
"""
|
||||
|
|
@ -13,11 +16,12 @@ def listfolders(path, only_name=0):
|
|||
|
||||
out = []
|
||||
for each in os.listdir(path):
|
||||
each = cstr(each)
|
||||
dirname = each.split(os.path.sep)[-1]
|
||||
fullpath = os.path.join(path, dirname)
|
||||
|
||||
if os.path.isdir(fullpath) and not dirname.startswith('.'):
|
||||
out.append(only_name and dirname or fullname)
|
||||
out.append(only_name and dirname or fullpath)
|
||||
return out
|
||||
|
||||
def switch_module(dt, dn, to, frm=None, export=None):
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import unittest
|
|||
from webnotes.model.meta import has_field
|
||||
from webnotes.model.code import load_doctype_module, get_module_name
|
||||
from webnotes.model.doctype import get_link_fields
|
||||
from webnotes.utils import cstr
|
||||
|
||||
|
||||
def make_test_records(doctype, verbose=0):
|
||||
|
|
@ -148,6 +149,7 @@ def run_all_tests(verbose):
|
|||
for path, folders, files in os.walk("."):
|
||||
# print path
|
||||
for filename in files:
|
||||
filename = cstr(filename)
|
||||
if filename.startswith("test_") and filename.endswith(".py"):
|
||||
print filename[:-3]
|
||||
webnotes.session.user = "Administrator"
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import json
|
|||
import re
|
||||
from csv import reader
|
||||
from webnotes.modules import get_doc_path
|
||||
from webnotes.utils import get_base_path
|
||||
from webnotes.utils import get_base_path, cstr
|
||||
|
||||
def translate(lang=None):
|
||||
languages = [lang]
|
||||
|
|
@ -114,6 +114,7 @@ def build_for_pages(path):
|
|||
if os.path.basename(os.path.dirname(basepath))=="page":
|
||||
messages_js, messages_py = [], []
|
||||
for fname in files:
|
||||
fname = cstr(fname)
|
||||
if fname.endswith('.js'):
|
||||
messages_js += get_message_list(os.path.join(basepath, fname))
|
||||
if fname.endswith('.py'):
|
||||
|
|
@ -165,6 +166,7 @@ def build_for_framework(path, mtype, with_doctype_names = False):
|
|||
messages = []
|
||||
for (basepath, folders, files) in os.walk(path):
|
||||
for fname in files:
|
||||
fname = cstr(fname)
|
||||
if fname.endswith('.' + mtype):
|
||||
messages += get_message_list(os.path.join(basepath, fname))
|
||||
|
||||
|
|
@ -190,6 +192,7 @@ def build_from_doctype_code(path):
|
|||
messagespy = []
|
||||
messagesjs = []
|
||||
for fname in files:
|
||||
fname = cstr(fname)
|
||||
if fname.endswith('py'):
|
||||
messagespy += get_message_list(os.path.join(basepath, fname))
|
||||
if fname.endswith('js'):
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from __future__ import unicode_literals
|
|||
#Imports
|
||||
import os, webnotes
|
||||
from datetime import datetime
|
||||
|
||||
from webnotes.utils import cstr
|
||||
|
||||
#Global constants
|
||||
verbose = 0
|
||||
|
|
@ -62,6 +62,7 @@ class BackupGenerator:
|
|||
def get_recent_backup(self, older_than):
|
||||
file_list = os.listdir(get_backup_path())
|
||||
for this_file in file_list:
|
||||
this_file = cstr(this_file)
|
||||
this_file_path = os.path.join(get_backup_path(), this_file)
|
||||
if not is_file_old(this_file_path, older_than):
|
||||
if "_files" in this_file_path:
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import extract_email_id, convert_utc_to_user_timezone, now
|
||||
from webnotes.utils import extract_email_id, convert_utc_to_user_timezone, now, cint
|
||||
|
||||
class IncomingMail:
|
||||
"""
|
||||
|
|
@ -130,7 +130,7 @@ class POP3Mailbox:
|
|||
def connect(self):
|
||||
import poplib
|
||||
|
||||
if self.settings.use_ssl:
|
||||
if cint(self.settings.use_ssl):
|
||||
self.pop = poplib.POP3_SSL(self.settings.host)
|
||||
else:
|
||||
self.pop = poplib.POP3(self.settings.host)
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ def save_file(fname, content, dt, dn):
|
|||
file_size = check_max_file_size(content)
|
||||
temp_fname = write_file(content, files_path)
|
||||
fname = scrub_file_name(fname)
|
||||
fpath = os.path.join(files_path, fname).encode("utf-8")
|
||||
fpath = os.path.join(files_path, fname)
|
||||
|
||||
fname_parts = fname.split(".", -1)
|
||||
main = ".".join(fname_parts[:-1])
|
||||
|
|
@ -96,10 +96,10 @@ def save_file(fname, content, dt, dn):
|
|||
fname = get_new_fname_based_on_version(files_path, main, extn, versions)
|
||||
|
||||
# rename
|
||||
os.rename(temp_fname, fpath)
|
||||
os.rename(temp_fname, fpath.encode("utf-8"))
|
||||
else:
|
||||
# rename new file
|
||||
os.rename(temp_fname, fpath)
|
||||
os.rename(temp_fname, fpath.encode("utf-8"))
|
||||
|
||||
f = webnotes.bean({
|
||||
"doctype": "File Data",
|
||||
|
|
@ -114,7 +114,12 @@ def save_file(fname, content, dt, dn):
|
|||
return f.doc
|
||||
|
||||
def get_file_versions(files_path, main, extn):
|
||||
return filter(lambda f: f.startswith(main) and f.endswith(extn), os.listdir(files_path))
|
||||
out = []
|
||||
for f in os.listdir(files_path):
|
||||
f = cstr(f)
|
||||
if f.startswith(main) and f.endswith(extn):
|
||||
out.append(f)
|
||||
return out
|
||||
|
||||
def get_new_fname_based_on_version(files_path, main, extn, versions):
|
||||
versions.sort()
|
||||
|
|
@ -190,6 +195,7 @@ def get_file(fname):
|
|||
# check in folders
|
||||
for basepath, folders, files in os.walk(files_path):
|
||||
if file_name in files:
|
||||
file_name = cstr(file_name)
|
||||
file_path = os.path.join(basepath, file_name)
|
||||
break
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,9 @@ def report_errors():
|
|||
|
||||
errors = [("""<p>Time: %(modified)s</p>
|
||||
<pre><code>%(error)s</code></pre>""" % d) for d in webnotes.conn.sql("""select modified, error
|
||||
from `tabScheduler Log` where DATEDIFF(NOW(), modified) < 1 limit 10""", as_dict=True)]
|
||||
from `tabScheduler Log` where DATEDIFF(NOW(), modified) < 1
|
||||
and error not like '%%[Errno 110] Connection timed out%%'
|
||||
limit 10""", as_dict=True)]
|
||||
|
||||
if errors:
|
||||
sendmail_to_system_managers("ERPNext Scheduler Failure Report", ("""
|
||||
|
|
|
|||
|
|
@ -190,6 +190,7 @@ def build_website_sitemap_config():
|
|||
for path, folders, files in os.walk(basepath, followlinks=True):
|
||||
if os.path.basename(path)=="pages" and os.path.basename(os.path.dirname(path))=="templates":
|
||||
for fname in files:
|
||||
fname = webnotes.utils.cstr(fname)
|
||||
if fname.split(".")[-1] in ("html", "xml", "js", "css"):
|
||||
options = get_options(path, fname)
|
||||
config["pages"][options.link_name] = options
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue