Browse Source

Merge branch 'hotfix'

version-14
Nabin Hait 8 years ago
parent
commit
02f98ab56c
7 changed files with 66 additions and 44 deletions
  1. +1
    -1
      frappe/__init__.py
  2. +4
    -0
      frappe/desk/doctype/desktop_icon/desktop_icon.py
  3. +4
    -3
      frappe/desk/page/backups/backups.py
  4. +1
    -1
      frappe/integrations/doctype/dropbox_settings/dropbox_settings.py
  5. +33
    -11
      frappe/print/page/print_format_builder/print_format_builder.js
  6. +1
    -2
      frappe/print/page/print_format_builder/print_format_builder_field.html
  7. +22
    -26
      frappe/print/page/print_format_builder/print_format_builder_layout.html

+ 1
- 1
frappe/__init__.py View File

@@ -13,7 +13,7 @@ import os, sys, importlib, inspect, json
from .exceptions import * from .exceptions import *
from .utils.jinja import get_jenv, get_template, render_template from .utils.jinja import get_jenv, get_template, render_template


__version__ = '7.1.14'
__version__ = '7.1.15'
__title__ = "Frappe Framework" __title__ = "Frappe Framework"


local = Local() local = Local()


+ 4
- 0
frappe/desk/doctype/desktop_icon/desktop_icon.py View File

@@ -193,6 +193,10 @@ def set_desktop_icons(visible_list, ignore_duplicate=True):
except frappe.UniqueValidationError, e: except frappe.UniqueValidationError, e:
if not ignore_duplicate: if not ignore_duplicate:
raise e raise e
else:
visible_list.remove(module_name)
if frappe.message_log:
frappe.message_log.pop()


# set the order # set the order
set_order(visible_list) set_order(visible_list)


+ 4
- 3
frappe/desk/page/backups/backups.py View File

@@ -25,7 +25,7 @@ def get_context(context):


files = [('/backups/' + _file, files = [('/backups/' + _file,
get_time(os.path.join(path, _file)), get_time(os.path.join(path, _file)),
get_size(os.path.join(path, _file))) for _file in files]
get_size(os.path.join(path, _file))) for _file in files if _file.endswith('sql.gz')]
files.sort(key=lambda x: x[1], reverse=True) files.sort(key=lambda x: x[1], reverse=True)


return {"files": files} return {"files": files}
@@ -37,8 +37,9 @@ def get_scheduled_backup_limit():
def cleanup_old_backups(site_path, files, limit): def cleanup_old_backups(site_path, files, limit):
backup_paths = [] backup_paths = []
for f in files: for f in files:
_path = os.path.abspath(os.path.join(site_path, f))
backup_paths.append(_path)
if f.endswith('sql.gz'):
_path = os.path.abspath(os.path.join(site_path, f))
backup_paths.append(_path)


backup_paths = sorted(backup_paths, key=os.path.getctime) backup_paths = sorted(backup_paths, key=os.path.getctime)
files_to_delete = len(backup_paths) - limit files_to_delete = len(backup_paths) - limit


+ 1
- 1
frappe/integrations/doctype/dropbox_settings/dropbox_settings.py View File

@@ -198,7 +198,7 @@ def send_email(success, service_name, error_status=None):
if not frappe.db: if not frappe.db:
frappe.connect() frappe.connect()


recipients = split_emails(frappe.db.get_value("Dropbox Backup", None, "send_notifications_to"))
recipients = split_emails(frappe.db.get_value("Dropbox Settings", None, "send_notifications_to"))
frappe.sendmail(recipients=recipients, subject=subject, message=message) frappe.sendmail(recipients=recipients, subject=subject, message=message)


def backup_to_dropbox(): def backup_to_dropbox():


+ 33
- 11
frappe/print/page/print_format_builder/print_format_builder.js View File

@@ -198,10 +198,12 @@ frappe.PrintFormatBuilder = Class.extend({
this.setup_add_section(); this.setup_add_section();
this.setup_edit_heading(); this.setup_edit_heading();
this.setup_field_settings(); this.setup_field_settings();
this.setup_html_data();
}, },
prepare_data: function() { prepare_data: function() {
this.print_heading_template = null; this.print_heading_template = null;
this.data = JSON.parse(this.print_format.format_data || "[]"); this.data = JSON.parse(this.print_format.format_data || "[]");
this.fields_dict = {};
if(!this.data.length) { if(!this.data.length) {
// new layout // new layout
this.data = this.meta.fields; this.data = this.meta.fields;
@@ -212,6 +214,15 @@ frappe.PrintFormatBuilder = Class.extend({
this.data = this.data.splice(1); this.data = this.data.splice(1);
} }
} }

if(!this.print_heading_template) {
// default print heading template
this.print_heading_template = '<div class="print-heading">\
<h2>'+__(this.print_format.doc_type)
+'<br><small>{{ doc.name }}</small>\
</h2></div>';
}

this.layout_data = []; this.layout_data = [];
var section = null, column = null, me = this; var section = null, column = null, me = this;


@@ -234,6 +245,7 @@ frappe.PrintFormatBuilder = Class.extend({
// break the layout into sections and columns // break the layout into sections and columns
// so that it is easier to render in a template // so that it is easier to render in a template
$.each(this.data, function(i, f) { $.each(this.data, function(i, f) {
me.fields_dict[f.fieldname] = f;
if(!f.name && f.fieldname) { if(!f.name && f.fieldname) {
// from format_data (designed format) // from format_data (designed format)
// print_hide should always be false // print_hide should always be false
@@ -467,6 +479,14 @@ frappe.PrintFormatBuilder = Class.extend({
return false; return false;
}); });
}, },
setup_html_data: function() {
// set `data` for Custom HTML fields
var me = this;
this.page.main.find('[data-fieldtype="Custom HTML"]').each(function() {
$(this).find('.html-content')
.data('content', me.fields_dict[$(this).attr('data-fieldname')].options);
})
},
update_columns_in_section: function(section, no_of_columns, new_no_of_columns) { update_columns_in_section: function(section, no_of_columns, new_no_of_columns) {
var col_size = 12 / new_no_of_columns, var col_size = 12 / new_no_of_columns,
me = this, me = this,
@@ -527,12 +547,12 @@ frappe.PrintFormatBuilder = Class.extend({
}, },
setup_edit_heading: function() { setup_edit_heading: function() {
var me = this; var me = this;
if (!me.print_heading_template) {
$(this.page.main.find(".print-heading")).html('<h2>'+me.print_format.doc_type+'<br><small>{{ doc.name }}</small></h2>')
}
var $heading = this.page.main.find(".print-format-builder-print-heading");

// set content property
$heading.data('content', this.print_heading_template);

this.page.main.find(".edit-heading").on("click", function() { this.page.main.find(".edit-heading").on("click", function() {
var $heading = $(this).parents(".print-format-builder-header:first")
.find(".print-format-builder-print-heading");
var d = me.get_edit_html_dialog(__("Edit Heading"), __("Heading"), $heading); var d = me.get_edit_html_dialog(__("Edit Heading"), __("Heading"), $heading);
}) })
}, },
@@ -657,12 +677,12 @@ frappe.PrintFormatBuilder = Class.extend({
}); });


// set existing content in input // set existing content in input
content = $content.attr('data-html-content');
content = $content.data('content') || "";
if(content.indexOf(me.get_no_content())!==-1) content = ""; if(content.indexOf(me.get_no_content())!==-1) content = "";
d.set_input("content", content); d.set_input("content", content);


d.set_primary_action(__("Update"), function() { d.set_primary_action(__("Update"), function() {
$content.attr('data-html-content', d.get_value("content"));
$content.data('content', d.get_value("content"));
$content.html(d.get_value("content")); $content.html(d.get_value("content"));
d.hide(); d.hide();
}); });
@@ -678,9 +698,11 @@ frappe.PrintFormatBuilder = Class.extend({
// add print heading as the first field // add print heading as the first field
// this will be removed and set as a doc property // this will be removed and set as a doc property
// before rendering // before rendering
data.push({"fieldname": "print_heading_template",
fieldtype:"HTML",
options: this.page.main.find(".print-format-builder-print-heading").html()});
data.push({
fieldname: "print_heading_template",
fieldtype:"Custom HTML",
options: this.page.main.find(".print-format-builder-print-heading").data('content')
});


// add pages // add pages
this.page.main.find(".print-format-builder-section").each(function() { this.page.main.find(".print-format-builder-section").each(function() {
@@ -722,7 +744,7 @@ frappe.PrintFormatBuilder = Class.extend({
if(fieldtype==="Custom HTML") { if(fieldtype==="Custom HTML") {
// custom html as HTML field // custom html as HTML field
df.fieldtype = "HTML"; df.fieldtype = "HTML";
df.options = $this.find(".html-content").attr('data-html-content');
df.options = $this.find(".html-content").data('content');
} }
data.push(df); data.push(df);
}); });


+ 1
- 2
frappe/print/page/print_format_builder/print_format_builder_field.html View File

@@ -20,8 +20,7 @@
<a class="edit-html btn btn-default btn-xs"> <a class="edit-html btn btn-default btn-xs">
{%= __("Edit HTML") %}</a> {%= __("Edit HTML") %}</a>
</div> </div>
<div class="html-content"
data-html-content="{{ field.options || me.get_no_content() }}">
<div class="html-content">
{{ field.options || me.get_no_content() }}</div> {{ field.options || me.get_no_content() }}</div>
{% } else { %} {% } else { %}
<span class="field-label">{{ field.label }}</span> <span class="field-label">{{ field.label }}</span>


+ 22
- 26
frappe/print/page/print_format_builder/print_format_builder_layout.html View File

@@ -1,28 +1,24 @@
<div class="padding"> <div class="padding">
<div class="text-muted text-center">
{%= __("Drag elements from the sidebar to add. Drag them back to trash.") %}<br><br>
</div>
<div class="print-format-builder-header">
<div class="text-right">
<a class="edit-heading btn btn-default btn-xs">
{%= __("Edit Heading") %}</a>
</div>
<div class="print-format-builder-print-heading">
{% if (me.print_heading_template ){ %}
{%= me.print_heading_template %}
{% } else { %}
<div class="print-heading"></div>
{% } %}
</div>
</div>
<div class="print-format-builder-layout">
{% for(var i=0; i < data.length; i++) { %}
{%= frappe.render_template("print_format_builder_section",
{section: data[i], me:me}) %}
{% } %}
</div>
<div class="print-format-builder-add-section text-muted text-center">
<span class="octicon octicon-plus"></span>
<a class="grey">Add a new section</a>
</div>
<div class="text-muted text-center">
{%= __("Drag elements from the sidebar to add. Drag them back to trash.") %}<br><br>
</div>
<div class="print-format-builder-header">
<div class="text-right">
<a class="edit-heading btn btn-default btn-xs">
{%= __("Edit Heading") %}</a>
</div>
<div class="print-format-builder-print-heading">
{{ me.print_heading_template }}
</div>
</div>
<div class="print-format-builder-layout">
{% for(var i=0; i < data.length; i++) { %}
{%= frappe.render_template("print_format_builder_section",
{section: data[i], me:me}) %}
{% } %}
</div>
<div class="print-format-builder-add-section text-muted text-center">
<span class="octicon octicon-plus"></span>
<a class="grey">Add a new section</a>
</div>
</div> </div>

Loading…
Cancel
Save