Merge branch 'staging-fixes' of https://github.com/frappe/frappe into staging-fixes
This commit is contained in:
commit
574b970afd
18 changed files with 104 additions and 22 deletions
|
|
@ -45,6 +45,7 @@ class _dict(dict):
|
|||
def _(msg, lang=None):
|
||||
"""Returns translated string in current lang, if exists."""
|
||||
from frappe.translate import get_full_dict
|
||||
from frappe.utils import strip_html_tags, is_html
|
||||
|
||||
if not hasattr(local, 'lang'):
|
||||
local.lang = lang or 'en'
|
||||
|
|
@ -52,11 +53,16 @@ def _(msg, lang=None):
|
|||
if not lang:
|
||||
lang = local.lang
|
||||
|
||||
non_translated_msg = msg
|
||||
|
||||
if is_html(msg):
|
||||
msg = strip_html_tags(msg)
|
||||
|
||||
# msg should always be unicode
|
||||
msg = as_unicode(msg).strip()
|
||||
|
||||
# return lang_full_dict according to lang passed parameter
|
||||
return get_full_dict(lang).get(msg) or msg
|
||||
return get_full_dict(lang).get(msg) or non_translated_msg
|
||||
|
||||
def as_unicode(text, encoding='utf-8'):
|
||||
'''Convert to unicode if required'''
|
||||
|
|
|
|||
|
|
@ -660,7 +660,7 @@
|
|||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-11-27 17:57:21.913972",
|
||||
"modified": "2018-11-27 17:57:22.913973",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Contacts",
|
||||
"name": "Address",
|
||||
|
|
@ -773,4 +773,4 @@
|
|||
"track_changes": 0,
|
||||
"track_seen": 0,
|
||||
"track_views": 0
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class TestReport(unittest.TestCase):
|
|||
self.assertTrue('User' in [d[0] for d in data])
|
||||
|
||||
def test_report_permisisons(self):
|
||||
frappe.db.sql("""delete from `tabHas Role` where parent = %s
|
||||
frappe.db.sql("""delete from `tabHas Role` where parent = %s
|
||||
and role = 'Test Has Role'""", frappe.session.user, auto_commit=1)
|
||||
|
||||
if not frappe.db.exists('Role', 'Test Has Role'):
|
||||
|
|
@ -61,6 +61,7 @@ class TestReport(unittest.TestCase):
|
|||
with open(os.path.join(os.path.dirname(__file__), 'user_activity_report_without_sort.json'), 'r') as f:
|
||||
frappe.get_doc(json.loads(f.read())).insert()
|
||||
|
||||
report = frappe.get_doc('Report', 'User Activity Report Without Sort')
|
||||
columns, data = report.get_data()
|
||||
|
||||
self.assertEqual(columns[0].get('label'), 'ID')
|
||||
|
|
|
|||
|
|
@ -57,6 +57,37 @@ class TestTranslation(unittest.TestCase):
|
|||
frappe.local.lang_full_dict=None
|
||||
self.assertTrue(_(data[1][0]), data[1][1])
|
||||
|
||||
def test_html_content_data_translation(self):
|
||||
source = """
|
||||
<span style="color: rgb(51, 51, 51); font-family: "Amazon Ember", Arial, sans-serif; font-size:
|
||||
small;">MacBook Air lasts up to an incredible 12 hours between charges. So from your morning coffee to
|
||||
your evening commute, you can work unplugged. When it’s time to kick back and relax,
|
||||
you can get up to 12 hours of iTunes movie playback. And with up to 30 days of standby time,
|
||||
you can go away for weeks and pick up where you left off.Whatever the task,
|
||||
fifth-generation Intel Core i5 and i7 processors with Intel HD Graphics 6000 are up to it.</span><br>
|
||||
"""
|
||||
|
||||
target = """
|
||||
MacBook Air dura hasta 12 horas increíbles entre cargas. Por lo tanto,
|
||||
desde el café de la mañana hasta el viaje nocturno, puede trabajar desconectado.
|
||||
Cuando es hora de descansar y relajarse, puede obtener hasta 12 horas de reproducción de películas de iTunes.
|
||||
Y con hasta 30 días de tiempo de espera, puede irse por semanas y continuar donde lo dejó. Sea cual sea la tarea,
|
||||
los procesadores Intel Core i5 e i7 de quinta generación con Intel HD Graphics 6000 son capaces de hacerlo.
|
||||
"""
|
||||
|
||||
create_translation('es', [source, target])
|
||||
|
||||
source = """
|
||||
<span style="font-family: "Amazon Ember", Arial, sans-serif; font-size:
|
||||
small; color: rgb(51, 51, 51);">MacBook Air lasts up to an incredible 12 hours between charges. So from your morning coffee to
|
||||
your evening commute, you can work unplugged. When it’s time to kick back and relax,
|
||||
you can get up to 12 hours of iTunes movie playback. And with up to 30 days of standby time,
|
||||
you can go away for weeks and pick up where you left off.Whatever the task,
|
||||
fifth-generation Intel Core i5 and i7 processors with Intel HD Graphics 6000 are up to it.</span><br>
|
||||
"""
|
||||
|
||||
self.assertTrue(_(source), target)
|
||||
|
||||
def get_translation_data():
|
||||
html_source_data = """<font color="#848484" face="arial, tahoma, verdana, sans-serif">
|
||||
<span style="font-size: 11px; line-height: 16.9px;">Test Data</span></font>"""
|
||||
|
|
|
|||
|
|
@ -6,8 +6,16 @@ from __future__ import unicode_literals
|
|||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe.translate import clear_cache
|
||||
from frappe.utils import strip_html_tags, is_html
|
||||
|
||||
class Translation(Document):
|
||||
def validate(self):
|
||||
if is_html(self.source_name):
|
||||
self.remove_html_from_source()
|
||||
|
||||
def remove_html_from_source(self):
|
||||
self.source_name = strip_html_tags(self.source_name).strip()
|
||||
|
||||
def on_update(self):
|
||||
clear_cache()
|
||||
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ $.extend(frappe.desktop, {
|
|||
|
||||
// if module found
|
||||
if(module._id.indexOf('/')===-1 && !module._report) {
|
||||
var notifier = $(".module-count-" + module._id);
|
||||
var notifier = $(".module-count-" + frappe.scrub(module._id));
|
||||
if(notifier.length) {
|
||||
notifier.toggle(sum ? true : false);
|
||||
var circle = notifier.find(".circle-text");
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
data-name="{{ module_name }}" data-link="{{ link }}" title="{{ _label }}">
|
||||
{{ app_icon }}
|
||||
<div class="case-label ellipsis">
|
||||
<div class="circle module-count-{{ _id }}" data-doctype="{{ _doctype }}" style="display: none;">
|
||||
<div class="circle module-count-{{ frappe.scrub(_id) }}" data-doctype="{{ _doctype }}" style="display: none;">
|
||||
<span class="circle-text"></span>
|
||||
</div>
|
||||
<!-- <span id="module-count-{{ _id }}" class="octicon octicon-primitive-dot circle" style="display: None"></span> -->
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ source_link = "https://github.com/frappe/frappe"
|
|||
app_license = "MIT"
|
||||
|
||||
develop_version = '12.x.x-develop'
|
||||
staging_version = '11.0.3-beta.39'
|
||||
staging_version = '11.0.3-beta.40'
|
||||
|
||||
app_email = "info@frappe.io"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,17 @@ frappe.ui.form.ControlGeolocation = frappe.ui.form.ControlCode.extend({
|
|||
);
|
||||
this.map_area.prependTo($input_wrapper);
|
||||
this.$wrapper.find('.control-input').addClass("hidden");
|
||||
|
||||
if ($input_wrapper.is(':visible')) {
|
||||
this.make_map();
|
||||
} else {
|
||||
$(document).on('quick-entry-dialog-open', () => {
|
||||
this.make_map();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
make_map() {
|
||||
this.bind_leaflet_map();
|
||||
this.bind_leaflet_draw_control();
|
||||
this.bind_leaflet_locate_control();
|
||||
|
|
@ -19,6 +30,7 @@ frappe.ui.form.ControlGeolocation = frappe.ui.form.ControlCode.extend({
|
|||
},
|
||||
|
||||
format_for_input(value) {
|
||||
if (!this.map) return;
|
||||
// render raw value from db into map
|
||||
this.clear_editable_layers();
|
||||
if(value) {
|
||||
|
|
@ -52,7 +64,6 @@ frappe.ui.form.ControlGeolocation = frappe.ui.form.ControlCode.extend({
|
|||
},
|
||||
|
||||
bind_leaflet_map() {
|
||||
|
||||
var circleToGeoJSON = L.Circle.prototype.toGeoJSON;
|
||||
L.Circle.include({
|
||||
toGeoJSON: function() {
|
||||
|
|
|
|||
|
|
@ -116,6 +116,10 @@ frappe.ui.form.QuickEntryForm = Class.extend({
|
|||
|
||||
this.dialog.onhide = () => frappe.quick_entry = null;
|
||||
this.dialog.show();
|
||||
this.dialog.$wrapper.on('shown.bs.modal', function() {
|
||||
$(document).trigger('quick-entry-dialog-open');
|
||||
});
|
||||
|
||||
this.dialog.refresh_dependency();
|
||||
this.set_defaults();
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ frappe.ui.toolbar.Toolbar = Class.extend({
|
|||
make: function() {
|
||||
this.setup_sidebar();
|
||||
this.setup_help();
|
||||
this.setup_modules_dialog();
|
||||
|
||||
this.bind_events();
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,12 @@ frappe.views.FileView = class FileView extends frappe.views.ListView {
|
|||
|
||||
file_menu_items() {
|
||||
const items = [
|
||||
{
|
||||
label: __('Home'),
|
||||
action: () => {
|
||||
frappe.set_route('List', 'File', 'Home');
|
||||
},
|
||||
},
|
||||
{
|
||||
label: __('Cut'),
|
||||
action: () => {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ frappe.views.TranslationManager = class TranslationManager {
|
|||
{
|
||||
label: 'Translation',
|
||||
fieldname: 'translation',
|
||||
fieldtype: 'Data',
|
||||
fieldtype: 'Text',
|
||||
in_list_view: 1,
|
||||
columns: 7
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ frappe.views.TranslationManager = class TranslationManager {
|
|||
return frappe.db.get_list('Translation', {
|
||||
fields: ['name', 'language', 'target_name as translation'],
|
||||
filters: {
|
||||
source_name: this.source_name
|
||||
source_name: strip_html(this.source_name)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,13 @@
|
|||
font-family: inherit;
|
||||
}
|
||||
|
||||
.ql-editor {
|
||||
h1, h2, h3, h4, h5 {
|
||||
margin-top: 0.5em;
|
||||
margin-bottom: 0.25em;
|
||||
}
|
||||
}
|
||||
|
||||
.ql-toolbar.ql-snow {
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from six import iteritems, text_type, string_types, PY2
|
|||
|
||||
import frappe, os, re, io, codecs, json
|
||||
from frappe.model.utils import render_include, InvalidIncludePath
|
||||
from frappe.utils import strip
|
||||
from frappe.utils import strip, strip_html_tags, is_html
|
||||
from jinja2 import TemplateError
|
||||
import itertools, operator
|
||||
|
||||
|
|
@ -741,3 +741,15 @@ def update_translations_for_source(source=None, translation_dict=None):
|
|||
doc.save()
|
||||
|
||||
return translation_records
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_translations(source_name):
|
||||
if is_html(source_name):
|
||||
source_name = strip_html_tags(source_name)
|
||||
|
||||
return frappe.db.get_list('Translation',
|
||||
fields = ['name', 'language', 'target_name as translation'],
|
||||
filters = {
|
||||
'source_name': source_name
|
||||
}
|
||||
)
|
||||
|
|
@ -568,12 +568,7 @@ def in_words(integer, in_million=True):
|
|||
return ret.replace('-', ' ')
|
||||
|
||||
def is_html(text):
|
||||
out = False
|
||||
for key in ["<br>", "<p", "<img", "<div"]:
|
||||
if key in text:
|
||||
out = True
|
||||
break
|
||||
return out
|
||||
return re.search('<[^>]+>', text)
|
||||
|
||||
def is_image(filepath):
|
||||
from mimetypes import guess_type
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
"awesomplete": "^1.1.2",
|
||||
"cookie": "^0.3.1",
|
||||
"express": "^4.16.2",
|
||||
"frappe-datatable": "^1.7.1",
|
||||
"frappe-datatable": "^1.7.2",
|
||||
"frappe-gantt": "^0.1.0",
|
||||
"fuse.js": "^3.2.0",
|
||||
"highlight.js": "^9.12.0",
|
||||
|
|
|
|||
|
|
@ -1219,10 +1219,10 @@ forwarded@~0.1.2:
|
|||
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84"
|
||||
integrity sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=
|
||||
|
||||
frappe-datatable@^1.7.1:
|
||||
version "1.7.1"
|
||||
resolved "https://registry.yarnpkg.com/frappe-datatable/-/frappe-datatable-1.7.1.tgz#5badb1138c7019e9dce50d6cbbd81c2fdc97e391"
|
||||
integrity sha512-ePD4IDaLDCZCrchqT+TsPquOdnm72oYxh/KYMPfYBxUGSzWUoi2uRgzQD4MBR+uq1WxJhFQNoXe/fD3yOqNNUQ==
|
||||
frappe-datatable@^1.7.2:
|
||||
version "1.7.2"
|
||||
resolved "https://registry.yarnpkg.com/frappe-datatable/-/frappe-datatable-1.7.2.tgz#9a2cb3d643959b759b6bc3a883667b58d2ba78fe"
|
||||
integrity sha512-yUSBy46Bkbo4evP4nEcXzPVC0cMLBIcOLV6J509RJfmM+IEoQbhEeOcxta0fQ9RcgvzRHbL+TX+wkib53HsfSw==
|
||||
dependencies:
|
||||
hyperlist "^1.0.0-beta"
|
||||
lodash "^4.17.5"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue