@@ -13,7 +13,7 @@ import os, sys, importlib, inspect, json | |||
from .exceptions import * | |||
from .utils.jinja import get_jenv, get_template, render_template | |||
__version__ = '7.1.26' | |||
__version__ = '7.1.27' | |||
__title__ = "Frappe Framework" | |||
local = Local() | |||
@@ -31,10 +31,12 @@ frappe.ui.form.on('Integration Service', { | |||
}, | |||
setup_custom_buttons: function(frm) { | |||
frm.clear_custom_buttons(); | |||
frm.add_custom_button(__("{0} Settings", [frm.doc.service]), function(){ | |||
frappe.set_route("List", frm.doc.service + " Settings"); | |||
}); | |||
frm.add_custom_button(__("Show Log"), function(){ | |||
frappe.route_options = {"integration_request_service": frm.doc.service}; | |||
frappe.set_route("List", "Integration Request"); | |||
@@ -8,9 +8,9 @@ frappe.ui.form.on('Dropbox Settings', { | |||
frm.clear_custom_buttons(); | |||
frm.events.take_backup(frm); | |||
}, | |||
allow_dropbox_access: function(frm) { | |||
if (frm.doc.app_access_key && frm.doc.app_secret_key) { | |||
if ((frm.doc.app_access_key && frm.doc.app_secret_key) || frm.doc.dropbox_setup_via_site_config) { | |||
frappe.call({ | |||
method: "frappe.integrations.doctype.dropbox_settings.dropbox_settings.get_dropbox_authorize_url", | |||
freeze: true, | |||
@@ -41,16 +41,16 @@ frappe.ui.form.on('Dropbox Settings', { | |||
frappe.integration_service.dropbox_settings = Class.extend({ | |||
init: function(frm) { | |||
}, | |||
get_scheduler_job_info: function() { | |||
return { | |||
"Daily": "Take backup of database and files to dropbox on daily basis", | |||
"Weekly": "Take backup of database and files to dropbox on weekly basis" | |||
} | |||
}, | |||
get_service_info: function(frm) { | |||
frappe.call({ | |||
method: "frappe.integrations.doctype.dropbox_settings.dropbox_settings.get_service_details", | |||
@@ -22,6 +22,7 @@ | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"in_standard_filter": 0, | |||
"label": "Send Notifications To", | |||
"length": 0, | |||
"no_copy": 0, | |||
@@ -30,6 +31,7 @@ | |||
"print_hide": 0, | |||
"print_hide_if_no_value": 0, | |||
"read_only": 0, | |||
"remember_last_selected_value": 0, | |||
"report_hide": 0, | |||
"reqd": 1, | |||
"search_index": 0, | |||
@@ -48,6 +50,7 @@ | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"in_standard_filter": 0, | |||
"label": "Backup Frequency", | |||
"length": 0, | |||
"no_copy": 0, | |||
@@ -57,6 +60,7 @@ | |||
"print_hide": 0, | |||
"print_hide_if_no_value": 0, | |||
"read_only": 0, | |||
"remember_last_selected_value": 0, | |||
"report_hide": 0, | |||
"reqd": 1, | |||
"search_index": 0, | |||
@@ -68,6 +72,7 @@ | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"depends_on": "eval:!doc.dropbox_setup_via_site_config", | |||
"fieldname": "app_access_key", | |||
"fieldtype": "Data", | |||
"hidden": 0, | |||
@@ -75,6 +80,7 @@ | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"in_standard_filter": 0, | |||
"label": "App Access Key", | |||
"length": 0, | |||
"no_copy": 0, | |||
@@ -83,8 +89,9 @@ | |||
"print_hide": 0, | |||
"print_hide_if_no_value": 0, | |||
"read_only": 0, | |||
"remember_last_selected_value": 0, | |||
"report_hide": 0, | |||
"reqd": 1, | |||
"reqd": 0, | |||
"search_index": 0, | |||
"set_only_once": 0, | |||
"unique": 0 | |||
@@ -94,6 +101,7 @@ | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"depends_on": "eval:!doc.dropbox_setup_via_site_config", | |||
"fieldname": "app_secret_key", | |||
"fieldtype": "Password", | |||
"hidden": 0, | |||
@@ -101,6 +109,7 @@ | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"in_standard_filter": 0, | |||
"label": "App Secret Key", | |||
"length": 0, | |||
"no_copy": 0, | |||
@@ -109,8 +118,9 @@ | |||
"print_hide": 0, | |||
"print_hide_if_no_value": 0, | |||
"read_only": 0, | |||
"remember_last_selected_value": 0, | |||
"report_hide": 0, | |||
"reqd": 1, | |||
"reqd": 0, | |||
"search_index": 0, | |||
"set_only_once": 0, | |||
"unique": 0 | |||
@@ -127,6 +137,7 @@ | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"in_standard_filter": 0, | |||
"label": "Allow Dropbox Access", | |||
"length": 0, | |||
"no_copy": 0, | |||
@@ -135,6 +146,7 @@ | |||
"print_hide": 0, | |||
"print_hide_if_no_value": 0, | |||
"read_only": 0, | |||
"remember_last_selected_value": 0, | |||
"report_hide": 0, | |||
"reqd": 0, | |||
"search_index": 0, | |||
@@ -153,6 +165,7 @@ | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"in_standard_filter": 0, | |||
"label": "Dropbox Access Key", | |||
"length": 0, | |||
"no_copy": 0, | |||
@@ -161,6 +174,7 @@ | |||
"print_hide": 0, | |||
"print_hide_if_no_value": 0, | |||
"read_only": 1, | |||
"remember_last_selected_value": 0, | |||
"report_hide": 0, | |||
"reqd": 0, | |||
"search_index": 0, | |||
@@ -179,6 +193,7 @@ | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"in_standard_filter": 0, | |||
"label": "Dropbox Access Secret", | |||
"length": 0, | |||
"no_copy": 0, | |||
@@ -187,6 +202,35 @@ | |||
"print_hide": 0, | |||
"print_hide_if_no_value": 0, | |||
"read_only": 1, | |||
"remember_last_selected_value": 0, | |||
"report_hide": 0, | |||
"reqd": 0, | |||
"search_index": 0, | |||
"set_only_once": 0, | |||
"unique": 0 | |||
}, | |||
{ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"fieldname": "dropbox_setup_via_site_config", | |||
"fieldtype": "Check", | |||
"hidden": 1, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"in_standard_filter": 0, | |||
"label": "Dropbox Setup via Site Config", | |||
"length": 0, | |||
"no_copy": 0, | |||
"permlevel": 0, | |||
"precision": "", | |||
"print_hide": 0, | |||
"print_hide_if_no_value": 0, | |||
"read_only": 0, | |||
"remember_last_selected_value": 0, | |||
"report_hide": 0, | |||
"reqd": 0, | |||
"search_index": 0, | |||
@@ -204,7 +248,7 @@ | |||
"issingle": 1, | |||
"istable": 0, | |||
"max_attachments": 0, | |||
"modified": "2016-09-22 03:55:40.716643", | |||
"modified": "2016-12-19 02:10:05.231510", | |||
"modified_by": "Administrator", | |||
"module": "Integrations", | |||
"name": "Dropbox Settings", | |||
@@ -221,6 +265,7 @@ | |||
"export": 1, | |||
"if_owner": 0, | |||
"import": 0, | |||
"is_custom": 0, | |||
"permlevel": 0, | |||
"print": 1, | |||
"read": 1, | |||
@@ -24,6 +24,10 @@ class DropboxSettings(IntegrationService): | |||
] | |||
} | |||
def onload(self): | |||
if not self.app_access_key and frappe.conf.dropbox_access_key: | |||
self.dropbox_setup_via_site_config = 1 | |||
def validate(self): | |||
if not self.flags.ignore_mandatory: | |||
self.validate_dropbox_credentails() | |||
@@ -48,11 +52,14 @@ class DropboxSettings(IntegrationService): | |||
except: | |||
raise Exception(_("Please install dropbox python module")) | |||
if not (self.app_access_key or self.app_secret_key): | |||
app_access_key = self.app_access_key or frappe.conf.dropbox_access_key | |||
app_secret_key = self.get_password(fieldname="app_secret_key", | |||
raise_exception=False) if self.app_secret_key else frappe.conf.dropbox_secret_key | |||
if not (app_access_key or app_secret_key): | |||
raise Exception(_("Please set Dropbox access keys in your site config")) | |||
sess = session.DropboxSession(self.app_access_key, | |||
self.get_password(fieldname="app_secret_key", raise_exception=False), "app_folder") | |||
sess = session.DropboxSession(app_access_key, app_secret_key, "app_folder") | |||
return sess | |||
@@ -138,13 +145,17 @@ def dropbox_callback(oauth_token=None, not_approved=False): | |||
frappe.db.commit() | |||
else: | |||
frappe.respond_as_web_page(_("Dropbox Approval"), _("Illegal Access Token Please try again. <p>Please close this window.</p"), | |||
close = '<p class="text-muted">' + _('Please close this window') + '</p>' | |||
frappe.respond_as_web_page(_("Dropbox Setup"), | |||
_("Illegal Access Token. Please try again") + close, | |||
success=False, http_status_code=frappe.AuthenticationError.http_status_code) | |||
else: | |||
frappe.respond_as_web_page(_("Dropbox Approval"), _("Dropbox Access not approved. <p>Please close this window.</p"), | |||
frappe.respond_as_web_page(_("Dropbox Setup"), | |||
_("You did not apporve Dropbox Access.") + close, | |||
success=False, http_status_code=frappe.AuthenticationError.http_status_code) | |||
frappe.respond_as_web_page(_("Dropbox Approval"), _("Dropbox access allowed. <p>Please close this window.</p"), | |||
frappe.respond_as_web_page(_("Dropbox Setup"), | |||
_("Dropbox access is approved!") + close, | |||
success=False, http_status_code=frappe.AuthenticationError.http_status_code) | |||
# backup process | |||