@@ -6,4 +6,5 @@ locale | |||||
.wnf-lang-status | .wnf-lang-status | ||||
*.swp | *.swp | ||||
*.egg-info | *.egg-info | ||||
dist/ | |||||
dist/ | |||||
build/ |
@@ -15,6 +15,8 @@ import os, sys, importlib | |||||
import json | import json | ||||
import semantic_version | import semantic_version | ||||
from webnotes.core.doctype.print_format.print_format import get_html as get_print_html | |||||
local = Local() | local = Local() | ||||
class _dict(dict): | class _dict(dict): | ||||
@@ -106,6 +108,7 @@ def init(site, sites_path=None): | |||||
local.user = None | local.user = None | ||||
local.restrictions = None | local.restrictions = None | ||||
local.user_perms = {} | local.user_perms = {} | ||||
local.test_objects = {} | |||||
setup_module_map() | setup_module_map() | ||||
@@ -125,7 +128,6 @@ def destroy(): | |||||
release_local(local) | release_local(local) | ||||
_memc = None | _memc = None | ||||
test_objects = {} | |||||
# memcache | # memcache | ||||
def cache(): | def cache(): | ||||
@@ -3,7 +3,6 @@ | |||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import webnotes, os | import webnotes, os | ||||
from webnotes import conf | |||||
import webnotes.utils | import webnotes.utils | ||||
from webnotes.modules import get_doc_path | from webnotes.modules import get_doc_path | ||||
@@ -31,7 +30,7 @@ class DocType: | |||||
def export_doc(self): | def export_doc(self): | ||||
# export | # export | ||||
if self.doc.standard == 'Yes' and (conf.get('developer_mode') or 0) == 1: | |||||
if self.doc.standard == 'Yes' and (webnotes.conf.get('developer_mode') or 0) == 1: | |||||
from webnotes.modules.export_file import export_to_files | from webnotes.modules.export_file import export_to_files | ||||
export_to_files(record_list=[['Print Format', self.doc.name]], | export_to_files(record_list=[['Print Format', self.doc.name]], | ||||
record_module=self.doc.module) | record_module=self.doc.module) | ||||
@@ -66,9 +65,13 @@ def get_args(): | |||||
def get_html(doc, doclist, print_format=None): | def get_html(doc, doclist, print_format=None): | ||||
from jinja2 import Environment | from jinja2 import Environment | ||||
from webnotes.core.doctype.print_format.print_format import get_print_format | |||||
if isinstance(doc, basestring) and isinstance(doclist, basestring): | |||||
bean = webnotes.bean(doc, doclist) | |||||
doc = bean.doc | |||||
doclist = bean.doclist | |||||
template = Environment().from_string(get_print_format(doc.doctype, | |||||
template = Environment().from_string(get_print_format_name(doc.doctype, | |||||
print_format or webnotes.form_dict.format)) | print_format or webnotes.form_dict.format)) | ||||
doctype = webnotes.get_doctype(doc.doctype) | doctype = webnotes.get_doctype(doc.doctype) | ||||
@@ -82,7 +85,7 @@ def get_html(doc, doclist, print_format=None): | |||||
html = template.render(args) | html = template.render(args) | ||||
return html | return html | ||||
def get_print_format(doctype, format_name): | |||||
def get_print_format_name(doctype, format_name): | |||||
if format_name==standard_format: | if format_name==standard_format: | ||||
return format_name | return format_name | ||||
@@ -111,5 +114,5 @@ def get_print_style(style=None): | |||||
return "/* Standard Style Missing ?? */" | return "/* Standard Style Missing ?? */" | ||||
else: | else: | ||||
with open(path, 'r') as sfile: | with open(path, 'r') as sfile: | ||||
return sfile.read() + """ \* test *\ """ | |||||
return sfile.read() | |||||
@@ -6,7 +6,6 @@ from __future__ import unicode_literals | |||||
Utilities for using modules | Utilities for using modules | ||||
""" | """ | ||||
import webnotes, os | import webnotes, os | ||||
from webnotes import conf | |||||
import webnotes.utils | import webnotes.utils | ||||
lower_case_files_for = ['DocType', 'Page', 'Report', | lower_case_files_for = ['DocType', 'Page', 'Report', | ||||
@@ -25,7 +25,7 @@ body { | |||||
-webkit-text-size-adjust:none; | -webkit-text-size-adjust:none; | ||||
width: 100%!important; | width: 100%!important; | ||||
height: 100%; | height: 100%; | ||||
background-color: #f6f6f6; | |||||
background-color: #eee; | |||||
} | } | ||||
/* ------------------------------------- | /* ------------------------------------- | ||||
@@ -83,7 +83,7 @@ a { | |||||
------------------------------------- */ | ------------------------------------- */ | ||||
table.body-wrap { | table.body-wrap { | ||||
width: 100%; | width: 100%; | ||||
padding: 20px; | |||||
padding: 10px; | |||||
} | } | ||||
table.body-wrap .container{ | table.body-wrap .container{ | ||||
@@ -114,8 +114,11 @@ table.footer-wrap a{ | |||||
TYPOGRAPHY | TYPOGRAPHY | ||||
------------------------------------- */ | ------------------------------------- */ | ||||
h1,h2,h3{ | h1,h2,h3{ | ||||
font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; line-height: 1.1; margin-bottom:15px; color:#000; | |||||
margin: 20px 0 10px; | |||||
font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; | |||||
line-height: 1.1; | |||||
margin-top:15px; | |||||
margin-bottom:15px; | |||||
color:#000; | |||||
line-height: 1.2; | line-height: 1.2; | ||||
font-weight:200; | font-weight:200; | ||||
} | } | ||||
@@ -79,6 +79,7 @@ def _run_test(path, filename, verbose, test_suite=None, run=True): | |||||
def make_test_records(doctype, verbose=0): | def make_test_records(doctype, verbose=0): | ||||
webnotes.flags.mute_emails = True | webnotes.flags.mute_emails = True | ||||
if not webnotes.conn: | if not webnotes.conn: | ||||
webnotes.connect() | webnotes.connect() | ||||
@@ -87,9 +88,9 @@ def make_test_records(doctype, verbose=0): | |||||
options = options[5:] | options = options[5:] | ||||
if options == "[Select]": | if options == "[Select]": | ||||
continue | continue | ||||
if options not in webnotes.test_objects: | |||||
webnotes.test_objects[options] = [] | |||||
if options not in webnotes.local.test_objects: | |||||
webnotes.local.test_objects[options] = [] | |||||
make_test_records(options, verbose) | make_test_records(options, verbose) | ||||
make_test_records_for_doctype(options, verbose) | make_test_records_for_doctype(options, verbose) | ||||
@@ -116,6 +117,7 @@ def get_dependencies(doctype): | |||||
for doctype_name in test_module.test_ignore: | for doctype_name in test_module.test_ignore: | ||||
if doctype_name in options_list: | if doctype_name in options_list: | ||||
options_list.remove(doctype_name) | options_list.remove(doctype_name) | ||||
return options_list | return options_list | ||||
def make_test_records_for_doctype(doctype, verbose=0): | def make_test_records_for_doctype(doctype, verbose=0): | ||||
@@ -125,10 +127,10 @@ def make_test_records_for_doctype(doctype, verbose=0): | |||||
print "Making for " + doctype | print "Making for " + doctype | ||||
if hasattr(test_module, "_make_test_records"): | if hasattr(test_module, "_make_test_records"): | ||||
webnotes.test_objects[doctype] += test_module._make_test_records(verbose) | |||||
webnotes.local.test_objects[doctype] += test_module._make_test_records(verbose) | |||||
elif hasattr(test_module, "test_records"): | elif hasattr(test_module, "test_records"): | ||||
webnotes.test_objects[doctype] += make_test_objects(doctype, test_module.test_records, verbose) | |||||
webnotes.local.test_objects[doctype] += make_test_objects(doctype, test_module.test_records, verbose) | |||||
elif verbose: | elif verbose: | ||||
print_mandatory_fields(doctype) | print_mandatory_fields(doctype) | ||||
@@ -141,7 +143,7 @@ def make_test_objects(doctype, test_records, verbose=None): | |||||
doclist[0]["doctype"] = doctype | doclist[0]["doctype"] = doctype | ||||
d = webnotes.bean(copy=doclist) | d = webnotes.bean(copy=doclist) | ||||
if webnotes.test_objects.get(d.doc.doctype): | |||||
if webnotes.local.test_objects.get(d.doc.doctype): | |||||
# do not create test records, if already exists | # do not create test records, if already exists | ||||
return [] | return [] | ||||
if has_field(d.doc.doctype, "naming_series"): | if has_field(d.doc.doctype, "naming_series"): | ||||
@@ -21,8 +21,8 @@ class TestDB(unittest.TestCase): | |||||
self.assertEquals(webnotes.conn.get_value("Profile", {"modified": ["<=", now]}), "Administrator") | self.assertEquals(webnotes.conn.get_value("Profile", {"modified": ["<=", now]}), "Administrator") | ||||
time.sleep(2) | time.sleep(2) | ||||
if "Profile" in webnotes.test_objects: | |||||
del webnotes.test_objects["Profile"] | |||||
if "Profile" in webnotes.local.test_objects: | |||||
del webnotes.local.test_objects["Profile"] | |||||
make_test_records("Profile") | make_test_records("Profile") | ||||
self.assertEquals("test1@example.com", webnotes.conn.get_value("Profile", {"modified": [">", now]})) | self.assertEquals("test1@example.com", webnotes.conn.get_value("Profile", {"modified": [">", now]})) | ||||
@@ -26,12 +26,11 @@ def render(page_name): | |||||
except Exception: | except Exception: | ||||
html = render_page("error") | html = render_page("error") | ||||
set_content_type(page_name) | |||||
webnotes._response.data = html | webnotes._response.data = html | ||||
def render_page(page_name): | def render_page(page_name): | ||||
"""get page html""" | |||||
set_content_type(page_name) | |||||
"""get page html""" | |||||
if page_name.endswith('.html'): | if page_name.endswith('.html'): | ||||
page_name = page_name[:-5] | page_name = page_name[:-5] | ||||
html = '' | html = '' | ||||
@@ -46,7 +45,7 @@ def render_page(page_name): | |||||
if page_name=="error": | if page_name=="error": | ||||
html = html.replace("%(error)s", webnotes.get_traceback()) | html = html.replace("%(error)s", webnotes.get_traceback()) | ||||
elif "text/html" in webnotes._response.headers["Content-Type"]: | |||||
elif is_content_html(page_name): | |||||
comments = "\npage:"+page_name+\ | comments = "\npage:"+page_name+\ | ||||
"\nload status: " + (from_cache and "cache" or "fresh") | "\nload status: " + (from_cache and "cache" or "fresh") | ||||
html += """\n<!-- %s -->""" % webnotes.utils.cstr(comments) | html += """\n<!-- %s -->""" % webnotes.utils.cstr(comments) | ||||
@@ -56,10 +55,13 @@ def render_page(page_name): | |||||
def set_content_type(page_name): | def set_content_type(page_name): | ||||
webnotes._response.headers["Content-Type"] = "text/html; charset: utf-8" | webnotes._response.headers["Content-Type"] = "text/html; charset: utf-8" | ||||
if "." in page_name and not page_name.endswith(".html"): | |||||
if not is_content_html(page_name): | |||||
content_type, encoding = mimetypes.guess_type(page_name) | content_type, encoding = mimetypes.guess_type(page_name) | ||||
webnotes._response.headers["Content-Type"] = content_type | webnotes._response.headers["Content-Type"] = content_type | ||||
def is_content_html(page_name): | |||||
return False if ("." in page_name and not page_name.endswith(".html")) else True | |||||
def build_page(page_name): | def build_page(page_name): | ||||
if not webnotes.conn: | if not webnotes.conn: | ||||
webnotes.connect() | webnotes.connect() | ||||