This commit is contained in:
Rushabh Mehta 2013-09-13 13:02:48 +05:30
parent 49d833e72b
commit c4296eca23
6 changed files with 40 additions and 18 deletions

View file

@ -8,20 +8,29 @@ Projects: [erpnext](http://erpnext.org) | [webnotes/erpnext](https://github.com/
To start a new project, in the application root:
Note:
Install:
1. wnframework must be called as `lib`
1. your application must be called as `app`
1. Install webnotes and treemapper
Finally:
$ git clone git@github.com:webnotes/wnframework lib
$ git clone git@github.com:webnotes/[your app] app
$ lib/wnf.py --make_conf
$ lib/wnf.py --reinstall
$ git clone git@github.com:webnotes/wnframework lib
$ git clone git@github.com:webnotes/[your app] app
$ lib/wnf.py --make_conf
$ lib/wnf.py --reinstall
1. Setup Apache Conf
enjoy!
#### Export
Before pushing, export install fixtures
$ lib/wnf.py --export_doclist "Website Settings" - app/startup/website_settings.json
$ lib/wnf.py --export_doclist "Style Settings" - app/startup/style_settings.json
$ lib/wnf.py --export_csv "Tree Species" app/startup/Tree_Species.csv
$ lib/wnf.py --export_csv "Tree Family" app/startup/Tree_Family.csv
## wnf.py
`$ lib/wnf.py --help` for more info

View file

@ -33,12 +33,9 @@ def get_doctype_options():
webnotes.model.doctype.get(doctype)))
@webnotes.whitelist()
def get_template():
def get_template(doctype=None, parent_doctype=None, all_doctypes="No", with_data="No"):
webnotes.check_admin_or_system_manager()
doctype = webnotes.form_dict.doctype
parenttype = webnotes.form_dict.parent_doctype
all_doctypes = webnotes.form_dict.all_doctypes=="Yes"
with_data = webnotes.form_dict.with_data
all_doctypes = all_doctypes=="Yes"
column_start_end = {}
if all_doctypes:
@ -52,8 +49,8 @@ def get_template():
w.writerow(['Data Import Template'])
w.writerow([data_keys.main_table, doctype])
if parenttype != doctype:
w.writerow([data_keys.parent_table, parenttype])
if parent_doctype != doctype:
w.writerow([data_keys.parent_table, parent_doctype])
else:
w.writerow([''])
@ -199,7 +196,7 @@ def get_template():
w.writerow(row)
w = UnicodeWriter()
key = 'parent' if parenttype != doctype else 'name'
key = 'parent' if parent_doctype != doctype else 'name'
add_main_header()

View file

@ -37,7 +37,11 @@ wn.core.pages.desktop.render = function() {
</div>\
<div class="case-label">%(label)s</div>\
</div>', module)).click(function() {
wn.set_route($(this).attr("data-link"));
var link = $(this).attr("data-link");
if(link.substr(0, 1)==="/") {
window.open(link.substr(1))
}
wn.set_route(link);
}).css({
cursor:"pointer"
}).appendTo("#icon-grid");

View file

@ -110,7 +110,7 @@ $.extend(wn.user, {
ret = m;
break;
default:
ret = null;
ret = m;
}
return ret;
})

View file

@ -54,6 +54,7 @@ def render_page(page_name):
def build_page(page_name):
from jinja2 import Environment, FileSystemLoader
from markdown2 import markdown
if not webnotes.conn:
webnotes.connect()
@ -102,7 +103,9 @@ def build_page(page_name):
context.update(module.get_context())
context.update(get_website_settings())
jenv = Environment(loader = FileSystemLoader(basepath))
jenv.filters["markdown"] = markdown
context["base_template"] = jenv.get_template(webnotes.get_config().get("base_template"))
template_name = page_options['template']

9
wnf.py
View file

@ -286,6 +286,9 @@ def setup_options():
parser.add_option('--export_doclist', nargs=3, metavar="DOCTYPE NAME PATH",
help="""Export doclist as json to the given path, use '-' as name for Singles.""")
parser.add_option('--export_csv', nargs=2, metavar="DOCTYPE PATH",
help="""Dump DocType as csv.""")
parser.add_option('--import_doclist', nargs=1, metavar="PATH",
help="""Import (insert/update) doclist. If the argument is a directory, all files ending with .json are imported""")
@ -533,6 +536,12 @@ def run():
d["__islocal"] = 1
outfile.write(json.dumps(doclist, default=json_handler, indent=1, sort_keys=True))
elif options.export_csv:
from core.page.data_import_tool.data_import_tool import get_template
with open(options.export_csv[1], "w") as csvfile:
get_template(doctype=options.export_csv[0], all_doctypes="Yes", with_data="Yes")
csvfile.write(webnotes.response.result)
elif options.import_doclist:
import json
if os.path.isdir(options.import_doclist):