Merge branch 'master' into edge

Conflicts:
	setup/doctype/backup_manager/backup_dropbox.py
This commit is contained in:
Anand Doshi 2013-03-22 18:43:47 +05:30
commit aeed499d12
10 changed files with 64 additions and 105 deletions

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-01-30 12:49:46",
"creation": "2013-03-07 12:35:57",
"docstatus": 0,
"modified": "2013-02-01 10:50:16",
"modified": "2013-03-21 13:02:27",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -24,6 +24,9 @@
"permlevel": 0
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"name": "__common__",
"parent": "Journal Voucher",
@ -31,7 +34,9 @@
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
"report": 1
"report": 1,
"submit": 1,
"write": 1
},
{
"doctype": "DocType",
@ -278,6 +283,7 @@
},
{
"default": "No",
"description": "Considered as Opening Balance",
"doctype": "DocField",
"fieldname": "is_opening",
"fieldtype": "Select",
@ -290,7 +296,7 @@
"search_index": 1
},
{
"description": "For opening invoice entry, this date will reflect in the period-wise aging report.",
"description": "Actual Posting Date",
"doctype": "DocField",
"fieldname": "aging_date",
"fieldtype": "Date",
@ -444,30 +450,11 @@
"read_only": 1
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Accounts User",
"submit": 1,
"write": 1
"role": "Accounts Manager"
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Accounts Manager",
"submit": 1,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"role": "Auditor",
"submit": 0,
"write": 0
"role": "Accounts User"
}
]

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-01-29 17:54:09",
"creation": "2013-03-07 13:16:13",
"docstatus": 0,
"modified": "2013-01-29 18:25:24",
"modified": "2013-03-22 18:17:14",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -636,6 +636,7 @@
},
{
"default": "No",
"description": "Considered as Opening Balance",
"doctype": "DocField",
"fieldname": "is_opening",
"fieldtype": "Select",
@ -648,6 +649,7 @@
"search_index": 1
},
{
"description": "Actual Invoice Date",
"doctype": "DocField",
"fieldname": "aging_date",
"fieldtype": "Date",
@ -774,40 +776,8 @@
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 1,
"doctype": "DocPerm",
"role": "Purchase User",
"submit": 0,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "supplier",
"role": "Supplier",
"submit": 0,
"write": 0
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Accounts Manager",
"submit": 1,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"role": "Auditor",
"submit": 0,
"write": 0
"role": "Supplier"
}
]

View File

@ -1,10 +1,10 @@
[
{
"creation": "2013-02-22 01:27:40",
"creation": "2013-03-08 15:36:47",
"docstatus": 0,
"modified": "2013-03-07 07:03:29",
"modified": "2013-03-22 16:45:28",
"modified_by": "Administrator",
"owner": "wasim@webnotestech.com"
"owner": "Administrator"
},
{
"autoname": "PVTD.######",
@ -26,6 +26,17 @@
"doctype": "DocType",
"name": "Purchase Taxes and Charges"
},
{
"default": "Valuation and Total",
"doctype": "DocField",
"fieldname": "category",
"fieldtype": "Select",
"label": "Consider Tax or Charge for",
"oldfieldname": "category",
"oldfieldtype": "Select",
"options": "Valuation and Total\nValuation\nTotal",
"reqd": 1
},
{
"doctype": "DocField",
"fieldname": "charge_type",
@ -105,17 +116,6 @@
"oldfieldname": "row_id",
"oldfieldtype": "Data"
},
{
"default": "Valuation and Total",
"doctype": "DocField",
"fieldname": "category",
"fieldtype": "Select",
"label": "Consider Tax or Charge for",
"oldfieldname": "category",
"oldfieldtype": "Select",
"options": "Valuation and Total\nValuation\nTotal",
"reqd": 1
},
{
"default": "Add",
"doctype": "DocField",

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-03-20 17:01:58",
"creation": "2013-03-22 18:37:25",
"docstatus": 0,
"modified": "2013-03-20 19:17:38",
"modified": "2013-03-22 18:38:13",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -750,11 +750,12 @@
},
{
"default": "No",
"description": "Considered as an Opening Balance",
"doctype": "DocField",
"fieldname": "is_opening",
"fieldtype": "Select",
"in_filter": 1,
"label": "Is Opening",
"label": "Is Opening Entry",
"oldfieldname": "is_opening",
"oldfieldtype": "Select",
"options": "No\nYes",
@ -762,6 +763,7 @@
"search_index": 0
},
{
"description": "Actual Invoice Date",
"doctype": "DocField",
"fieldname": "aging_date",
"fieldtype": "Date",

View File

@ -71,7 +71,9 @@ class DocType:
webnotes.conn.set_default("employee", self.doc.name, self.doc.user_id)
webnotes.conn.set_default("employee_name", self.doc.employee_name, self.doc.user_id)
webnotes.conn.set_default("company", self.doc.company, self.doc.user_id)
if self.doc.reports_to:
webnotes.conn.set_default("leave_approver", webnotes.conn.get_value("Employee", self.doc.reports_to, "user_id"), self.doc.user_id)
def update_profile(self):
# add employee role if missing
if not "Employee" in webnotes.conn.sql_list("""select role from tabUserRole

View File

@ -61,7 +61,7 @@ def dropbox_callback(oauth_token=None, not_approved=False):
webnotes.response['page_name'] = 'message.html'
def backup_to_dropbox():
from dropbox import client, session, rest
from dropbox import client, session
from conf import dropbox_access_key, dropbox_secret_key
from webnotes.utils.backups import new_backup
if not webnotes.conn:
@ -81,24 +81,23 @@ def backup_to_dropbox():
upload_file_to_dropbox(filename, "database", dropbox_client)
response = dropbox_client.metadata("/files")
# upload files to files folder
filename = os.path.join(get_base_path(), "public", "files")
for filename in os.listdir(filename):
path = os.path.join(get_base_path(), "public", "files")
for filename in os.listdir(path):
found = False
filepath = os.path.join(path, filename)
for file_metadata in response["contents"]:
if filename==os.path.basename(file_metadata["path"]):
if os.stat(filename).st_size==file_metadata["bytes"]:
found=True
if os.path.basename(filepath) == os.path.basename(file_metadata["path"]) and os.stat(filepath).st_size == int(file_metadata["bytes"]):
found = True
break
if not found:
upload_file_to_dropbox(os.path.join(get_base_path(),"public", "files", filename), "files", dropbox_client)
upload_file_to_dropbox(filepath, "files", dropbox_client)
def get_dropbox_session():
from dropbox import session
try:
from conf import dropbox_access_key, dropbox_secret_key
except ImportError, e:
except ImportError:
webnotes.msgprint(_("Please set Dropbox access keys in") + " conf.py",
raise_exception=True)
sess = session.DropboxSession(dropbox_access_key, dropbox_secret_key, "app_folder")
@ -113,11 +112,11 @@ def upload_file_to_dropbox(filename, folder, dropbox_client):
while uploader.offset < size:
try:
uploader.upload_chunked()
uploader.finish(folder + '/' + os.path.basename(filename), overwrite='True')
except rest.ErrorResponse, e:
uploader.finish(os.path.join(folder, os.path.basename(filename)), overwrite=True)
except rest.ErrorResponse:
pass
else:
response = dropbox_client.put_file(folder + "/" + os.path.basename(filename), f, overwrite=True)
dropbox_client.put_file(os.path.join(folder, os.path.basename(filename)), f, overwrite=True)
if __name__=="__main__":
backup_to_dropbox()

View File

@ -51,8 +51,6 @@ def upload_files(name, mimetype, service, folder_id):
def backup_to_gdrive():
from webnotes.utils.backups import new_backup
found_database = False
found_files = False
if not webnotes.conn:
webnotes.connect()
flow = get_gdrive_flow()
@ -73,10 +71,11 @@ def backup_to_gdrive():
# upload files to files folder
path = os.path.join(get_base_path(), "public", "files")
for files in os.listdir(path):
filename = path + "/" + files
for filename in os.listdir(path):
found = False
filepath = os.path.join(path, filename)
ext = filename.split('.')[-1]
size = os.path.getsize(filename)
size = os.path.getsize(filepath)
if ext == 'gz' or ext == 'gzip':
mimetype = 'application/x-gzip'
else:
@ -88,11 +87,11 @@ def backup_to_gdrive():
**param).execute()
for child in children.get('items', []):
file = drive_service.files().get(fileId=child['id']).execute()
if files == file['title'] and size == int(file['fileSize']):
found_files = True
if filename == file['title'] and size == int(file['fileSize']):
found = True
break
if not found_files:
upload_files(filename, mimetype, drive_service, webnotes.conn.get_value("Backup Manager", None, "files_folder_id"))
if not found:
upload_files(filepath, mimetype, drive_service, webnotes.conn.get_value("Backup Manager", None, "files_folder_id"))
def get_gdrive_flow():
from oauth2client.client import OAuth2WebServerFlow
@ -106,10 +105,9 @@ def get_gdrive_flow():
# + "?cmd=setup.doctype.backup_manager.backup_googledrive.googledrive_callback"
# for installed apps since google does not support subdomains
redirect_uri = "urn:ietf:wg:oauth:2.0:oob"
flow = OAuth2WebServerFlow(conf.gdrive_client_id, conf.gdrive_client_secret,
"https://www.googleapis.com/auth/drive", redirect_uri)
"https://www.googleapis.com/auth/drive", 'urn:ietf:wg:oauth:2.0:oob')
return flow
@webnotes.whitelist()

View File

@ -10,9 +10,9 @@ class DocType:
def onload(self):
"""load address"""
if self.doc.query_options:
self.doc.query_options = filter(None, self.doc.query_options.replace(",", "\n").split())
self.query_options = filter(None, self.doc.query_options.replace(",", "\n").split())
else:
self.doc.query_options = ["Sales", "Support", "General"]
self.query_options = ["Sales", "Support", "General"]
if self.doc.address:
self.address = webnotes.bean("Address", self.doc.address).doc

View File

@ -19,7 +19,7 @@
</div>
<div class="clearfix"></div>
<p><select class="span6" name="subject">
{% for option in obj.doc.query_options %}
{% for option in obj.query_options %}
<option value="{{ option }}">{{ option }}</option>
{% endfor %}
</select></p>

View File

@ -143,6 +143,7 @@ def prepare_args(page_name):
args.update(webnotes.get_method(target)())
else:
args.obj = webnotes.bean(page_settings_map[page_name]).obj
else:
args = get_doc_fields(page_name)