backup manager (wip)

This commit is contained in:
Rushabh Mehta
2013-03-06 11:20:56 +05:30
parent ba7ed4c27c
commit 8ff938a377
11 changed files with 11232 additions and 14 deletions

11055
master.sql Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -3,5 +3,6 @@ def execute():
webnotes.conn.sql("""delete from `tabSearch Criteria` \
where name = 'customer_address_contact'""")
webnotes.reload_doc("core", "doctype", "docfield")
webnotes.reload_doc("core", "doctype", "report")
webnotes.reload_doc('selling', 'report', 'customer_addresses_and_contacts')

View File

View File

@@ -0,0 +1,14 @@
cur_frm.cscript.allow_dropbox_access = function(doc) {
wn.call({
method: "setup.doctype.backup_manager.backup_manager.get_dropbox_authorize_url",
callback: function(r) {
if(!r.exc) {
cur_frm.set_value("dropbox_access_secret", r.message.secret);
cur_frm.set_value("dropbox_access_key", r.message.key);
cur_frm.save(null, function() {
window.open(r.message.url);
});
}
}
})
}

View File

@@ -0,0 +1,53 @@
# For license information, please see license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import _
from webnotes.utils import get_request_site_address
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
@webnotes.whitelist()
def get_dropbox_authorize_url():
from dropbox import session
try:
from conf import dropbox_access_key, dropbox_secret_key
except ImportError, e:
webnotes.msgprint(_("Please set Dropbox access keys in") + " conf.py",
raise_exception=True)
sess = session.DropboxSession(dropbox_access_key, dropbox_secret_key, "app_folder")
request_token = sess.obtain_request_token()
return_address = get_request_site_address(True) \
+ "?cmd=setup.doctype.backup_manager.backup_manager.dropbox_callback"
url = sess.build_authorize_url(request_token, return_address)
return {
"url": url,
"key": request_token.key,
"secret": request_token.secret,
}
@webnotes.whitelist(allow_guest=True)
def dropbox_callback(oauth_token=None, not_approved=False):
if not not_approved:
if webnotes.conn.get_value("Backup Manager", None, "dropbox_access_key")==oauth_token:
webnotes.conn.set_value("Backup Manager", "Backup Manager", "dropbox_access_allowed", 1)
message = "Dropbox access allowed."
else:
webnotes.conn.set_value("Backup Manager", "Backup Manager", "dropbox_access_allowed", 0)
message = "Illegal Access Token Please try again."
else:
webnotes.conn.set_value("Backup Manager", "Backup Manager", "dropbox_access_allowed", 0)
message = "Dropbox Access not approved."
webnotes.message_title = "Dropbox Approval"
webnotes.message = "<h3>%s</h3><p>Please close this window.</p>" % message
webnotes.conn.commit()
webnotes.response['type'] = 'page'
webnotes.response['page_name'] = 'message.html'

View File

@@ -0,0 +1,83 @@
[
{
"creation": "2013-03-05 16:35:50",
"docstatus": 0,
"modified": "2013-03-05 18:05:05",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"description": "System for managing Backups",
"doctype": "DocType",
"document_type": "System",
"issingle": 1,
"module": "Setup",
"name": "__common__"
},
{
"doctype": "DocField",
"name": "__common__",
"parent": "Backup Manager",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0
},
{
"create": 1,
"doctype": "DocPerm",
"name": "__common__",
"parent": "Backup Manager",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
"role": "System Manager",
"write": 1
},
{
"doctype": "DocType",
"name": "Backup Manager"
},
{
"doctype": "DocField",
"fieldname": "sync_with_dropbox",
"fieldtype": "Section Break",
"label": "Sync with Dropbox"
},
{
"doctype": "DocField",
"fieldname": "upload_backups_to_dropbox",
"fieldtype": "Check",
"label": "Upload Backups to Dropbox"
},
{
"doctype": "DocField",
"fieldname": "dropbox_access_key",
"fieldtype": "Data",
"hidden": 1,
"label": "Dropbox Access Key"
},
{
"doctype": "DocField",
"fieldname": "dropbox_access_secret",
"fieldtype": "Data",
"hidden": 1,
"label": "Dropbox Access Secret"
},
{
"doctype": "DocField",
"fieldname": "dropbox_access_allowed",
"fieldtype": "Check",
"label": "Dropbox Access Allowed",
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "allow_dropbox_access",
"fieldtype": "Button",
"label": "Allow Dropbox Access"
},
{
"doctype": "DocPerm"
}
]

View File

@@ -186,6 +186,19 @@ wn.module_page["Setup"] = [
},
]
},
// {
// title: wn._("Backups"),
// icon: "icon-cloud-upload",
// right: true,
// items: [
// {
// "route":"Form/Backup Manager",
// doctype:"Backup Manager",
// label: wn._("Backup Manager"),
// "description":wn._("Sync backups with remote tools like Dropbox etc.")
// },
// ]
// },
]
pscript['onload_Setup'] = function(wrapper) {

View File

@@ -0,0 +1,11 @@
{% extends "html/outer.html" %}
{% set title="{{ webnotes.message_title or 'Message' }}" %}
{% block content %}
<div class="content">
<div class="layout-wrapper layout-main">
{{ webnotes.message }}
</div>
</div>
{% endblock %}

View File

@@ -1,13 +0,0 @@
{% extends "html/outer.html" %}
{% set title="Unsubscribed" %}
{% block content %}
<div class="content">
<div class="layout-wrapper layout-main">
<h3>Unsubscribed</h3>
<br>
<p><b>{{ webnotes.unsubscribed_email }}</b> has been unsubscribed.</p>
</div>
</div>
{% endblock %}

View File

@@ -242,7 +242,8 @@ def get_outer_env(page_name, args):
where parent='Website Settings' and parentfield='footer_items'
order by idx asc""", as_dict=1),
'int':int
'int':int,
"webnotes": webnotes
})
args.update(ret)