Merge branch 'master' into edge

This commit is contained in:
Anand Doshi 2013-03-07 15:36:34 +05:30
commit f622845843
7 changed files with 28 additions and 98 deletions

View file

@ -74,6 +74,7 @@ wn.get_route_str = function(route) {
wn.set_route = function() {
route = $.map(arguments, function(a) { return a ? encodeURIComponent(a) : null; }).join('/');
window.location.hash = route;
// Set favicon (app.js)

View file

@ -68,6 +68,9 @@ $.extend(wn.report_dump, {
if(replace_dict[d.name]) {
data.push(replace_dict[d.name]);
delete replace_dict[d.name];
} else if(doctype_data.modified_names.indexOf(d.name)!==-1) {
// if modified but not in replace_dict, then assume it as cancelled
// don't push in data
} else {
data.push(d);
}
@ -155,13 +158,13 @@ wn.views.GridReport = Class.extend({
// refresh
this.filter_inputs.refresh && this.filter_inputs.refresh.click(function() {
me.set_route();
me.get_data();
});
// reset filters
this.filter_inputs.reset_filters && this.filter_inputs.reset_filters.click(function() {
me.init_filter_values();
me.set_route();
me.set_route();
});
// range
@ -387,7 +390,8 @@ wn.views.GridReport = Class.extend({
$(this.wrapper).trigger('apply_filters_from_route');
},
set_route: function() {
wn.set_route(wn.container.page.page_name, $.map(this.filter_inputs, function(v) {
var page_name = wn.container.page.page_name;
var filters_route = $.map(this.filter_inputs, function(v) {
var opts = v.get(0).opts;
if(opts.fieldtype === "Check") {
var val = v.attr("checked") ? 1 : 0;
@ -397,7 +401,9 @@ wn.views.GridReport = Class.extend({
if(val && val != opts.default_value)
return encodeURIComponent(opts.fieldname)
+ '=' + encodeURIComponent(val);
}).join('&&'));
}).join('&&');
wn.set_route(page_name, filters_route);
},
options: {
editable: false,
@ -634,7 +640,7 @@ wn.views.GridReport = Class.extend({
var me = this;
$.each(filters, function(i, f) {
me.filter_inputs[f] && me.filter_inputs[f].change(function() {
me.filter_inputs.refresh.click()
me.set_route();
});
});
}

View file

@ -100,33 +100,18 @@ class BackupGenerator:
for item in self.__dict__.copy().items())
cmd_string = """mysqldump -u %(user)s -p%(password)s %(db_name)s | gzip -c > %(backup_path_db)s""" % args
err, out = webnotes.utils.execute_in_shell(cmd_string)
def get_recipients(self):
"""
Get recepient's email address
"""
#import webnotes.db
#webnotes.conn = webnotes.db.Database(use_default=1)
recipient_list = webnotes.conn.sql(\
"""SELECT parent FROM tabUserRole
WHERE role='System Manager'
AND parent!='Administrator'
AND parent IN
(SELECT email FROM tabProfile WHERE enabled=1)""")
return [i[0] for i in recipient_list]
def send_email(self):
"""
Sends the link to backup file located at erpnext/backups
"""
from webnotes.utils.email_lib import sendmail
from webnotes.utils.email_lib import sendmail, get_system_managers
backup_url = webnotes.conn.get_value('Website Settings',
'Website Settings', 'subdomain') or ''
backup_url = os.path.join('http://' + backup_url, 'backups')
recipient_list = self.get_recipients()
recipient_list = get_system_managers()
msg = """<p>Hello,</p>
<p>Your backups are ready to be downloaded.</p>

View file

@ -51,3 +51,10 @@ def get_contact_list():
)
)
webnotes.response['cl'] = filter(None, [c[0] for c in cl])
def get_system_managers():
return webnotes.conn.sql_list("""select parent FROM tabUserRole
WHERE role='System Manager'
AND parent!='Administrator'
AND parent IN
(SELECT email FROM tabProfile WHERE enabled=1)""")

View file

@ -1,71 +0,0 @@
# 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.
#
from __future__ import unicode_literals
import os
import webnotes
def upload_to_dropbox():
from dropbox import client, rest, session
from conf import dropbox_access_key, dropbox_secret_key
from webnotes.utils.backups import new_backup
print "Taking backup..."
webnotes.connect()
backup = new_backup()
filename = backup.backup_path_db
print os.path.basename(filename)
print "Starting session..."
sess = session.DropboxSession(dropbox_access_key, dropbox_secret_key, "app_folder")
sess.set_token('rl8hpbk775mb77b','snmegusva4jt9t2')
client = client.DropboxClient(sess)
size = os.stat(filename).st_size
f = open(filename,'r')
# create folder
print "Creating folder..."
try:
client.file_create_folder("erpnext")
except rest.ErrorResponse, e:
if e.status!=403:
raise e
if size > 4194304:
print "Uploading (chunked)..."
uploader = client.get_chunked_uploader(f, size)
while uploader.offset < size:
try:
uploader.upload_chunked()
except rest.ErrorResponse, e:
pass
else:
print "Uploading..."
response = client.put_file('erpnext/' + os.path.basename(filename), f, overwrite=True)
if __name__=="__main__":
upload_to_dropbox()

View file

@ -37,27 +37,30 @@ def get_data(doctypes, last_modified):
for d in doctypes:
args = data_map[d]
dt = d.find("[") != -1 and d[:d.find("[")] or d
out[dt] = {}
if args.get("from"):
modified_table = "item."
else:
modified_table = ""
conditions = order_by = ""
table = args.get("from") or ("`tab%s`" % dt)
if d in last_modified:
if not args.get("conditions"):
args['conditions'] = []
args['conditions'].append(modified_table + "modified > '" + last_modified[d] + "'")
out[dt]["modified_names"] = webnotes.conn.sql_list("""select name from %s
where modified > %s""" % (table, "%s"), last_modified[d])
conditions = order_by = ""
if args.get("force_index"):
conditions = " force index (%s) " % args["force_index"]
if args.get("conditions"):
conditions += " where " + " and ".join(args["conditions"])
if args.get("order_by"):
order_by = " order by " + args["order_by"]
table = args.get("from") or ("`tab%s`" % dt)
out[dt] = {}
out[dt]["data"] = [list(t) for t in webnotes.conn.sql("""select %s from %s %s %s""" \
% (",".join(args["columns"]), table, conditions, order_by))]

3
wnf.py
View file

@ -399,8 +399,7 @@ def run():
sync_all(options.force or 0)
elif options.sync is not None:
import webnotes.model.sync
webnotes.model.sync.sync(options.sync[0], options.sync[1], options.force or 0)
webnotes.reload_doc(options.sync[0], "doctype", options.sync[1])
elif options.update:
update_erpnext(options.update[0], options.update[1])