Browse Source

Merge branch 'develop' into staging

version-14
Nabin Hait 7 years ago
parent
commit
5d3f41bb26
41 changed files with 565 additions and 114 deletions
  1. +1
    -0
      .eslintrc
  2. BIN
      .github/logo.png
  3. +2
    -0
      .gitignore
  4. +3
    -0
      .vscode/settings.json
  5. +21
    -0
      LICENSE
  6. +2
    -0
      Makefile
  7. +28
    -5
      README.md
  8. +2
    -2
      frappe/__init__.py
  9. +3
    -4
      frappe/build.js
  10. +25
    -6
      frappe/build.py
  11. +3
    -2
      frappe/commands/utils.py
  12. +2
    -1
      frappe/contacts/doctype/address/address.json
  13. +10
    -7
      frappe/core/doctype/communication/communication.py
  14. +0
    -3
      frappe/core/doctype/communication/email.py
  15. +115
    -1
      frappe/core/page/desktop/desktop.js
  16. +13
    -1
      frappe/defaults.py
  17. +13
    -0
      frappe/desk/doctype/desktop_icon/desktop_icon.py
  18. +23
    -0
      frappe/desk/doctype/todo/test_todo.js
  19. +9
    -9
      frappe/desk/doctype/todo/todo.json
  20. +1
    -2
      frappe/desk/reportview.py
  21. +0
    -1
      frappe/email/doctype/email_account/email_account.py
  22. +16
    -7
      frappe/email/doctype/email_alert/email_alert.js
  23. +1
    -1
      frappe/hooks.py
  24. +47
    -23
      frappe/model/document.py
  25. +2
    -0
      frappe/patches/v6_20x/remove_roles_from_website_user.py
  26. +8
    -1
      frappe/public/build.json
  27. +8
    -0
      frappe/public/css/report-rtl.css
  28. +4
    -2
      frappe/public/js/frappe/form/controls/color.js
  29. +44
    -5
      frappe/public/js/frappe/form/controls/text_editor.js
  30. +1
    -1
      frappe/public/js/frappe/socketio_client.js
  31. +94
    -0
      frappe/public/js/frappe/ui/capture.js
  32. +8
    -3
      frappe/public/js/frappe/upload.js
  33. +1
    -1
      frappe/public/js/legacy/clientscriptAPI.js
  34. +1
    -1
      frappe/public/js/legacy/form.js
  35. +2
    -0
      frappe/public/js/lib/jquery.jrumble.min.js
  36. +2
    -0
      frappe/public/js/lib/webcam.min.js
  37. +4
    -3
      frappe/test_runner.py
  38. +0
    -9
      license.txt
  39. +10
    -10
      package.json
  40. +1
    -1
      requirements.txt
  41. +35
    -2
      setup.py

+ 1
- 0
.eslintrc View File

@@ -54,6 +54,7 @@
"Taggle": true,
"Gantt": true,
"Slick": true,
"Webcam": true,
"PhotoSwipe": true,
"PhotoSwipeUI_Default": true,
"fluxify": true,


BIN
.github/logo.png View File

Before After
Width: 615  |  Height: 530  |  Size: 12 KiB

+ 2
- 0
.gitignore View File

@@ -9,3 +9,5 @@ locale
dist/
build/
frappe/docs/current
.vscode
node_modules

+ 3
- 0
.vscode/settings.json View File

@@ -0,0 +1,3 @@
{
"python.linting.pylintEnabled": false
}

+ 21
- 0
LICENSE View File

@@ -0,0 +1,21 @@
The MIT License

Copyright (c) 2016-2017 Frappé Technologies Pvt. Ltd. <developers@frappe.io>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

+ 2
- 0
Makefile View File

@@ -0,0 +1,2 @@
clean:
python setup.py clean

+ 28
- 5
README.md View File

@@ -1,9 +1,33 @@
## Frappé Framework

[![Build Status](https://travis-ci.org/frappe/frappe.png)](https://travis-ci.org/frappe/frappe)
<div align="center">
<img src=".github/logo.png" height="256">
<h1>
<a href="https://frappe.io">
frappé
</a>
</h1>
<h3>
a web framework with <a href="https://www.youtube.com/watch?v=LOjk3m0wTwg">"batteries included"
</h3>
<h5>
it's pronounced - <em>fra-pay</em>
</h5>
</div>

<div align="center">
<a href="https://travis-ci.org/frappe/frappe">
<img src="https://img.shields.io/travis/frappe/frappe.svg?style=flat-square">
</a>
<a href='https://frappe.io/docs'>
<img src='https://img.shields.io/badge/docs-📖-7575FF.svg?style=flat-square'/>
</a>
</div>

Full-stack web application framework that uses Python and MariaDB on the server side and a tightly integrated client side library. Built for [ERPNext](https://erpnext.com)

### Table of Contents
* [Installation](#installation)
* [License](#license)

### Installation

[Install via Frappé Bench](https://github.com/frappe/bench)
@@ -20,5 +44,4 @@ For details and documentation, see the website
[https://frappe.io](https://frappe.io)

### License

MIT License
This repository has been released under the [MIT License](LICENSE).

+ 2
- 2
frappe/__init__.py View File

@@ -602,7 +602,7 @@ def set_value(doctype, docname, fieldname, value=None):
import frappe.client
return frappe.client.set_value(doctype, docname, fieldname, value)

def get_doc(arg1, arg2=None):
def get_doc(*args, **kwargs):
"""Return a `frappe.model.document.Document` object of the given type and name.

:param arg1: DocType name as string **or** document JSON.
@@ -619,7 +619,7 @@ def get_doc(arg1, arg2=None):

"""
import frappe.model.document
return frappe.model.document.get_doc(arg1, arg2)
return frappe.model.document.get_doc(*args, **kwargs)

def get_last_doc(doctype):
"""Get last created document of this type."""


+ 3
- 4
frappe/build.js View File

@@ -123,10 +123,9 @@ function pack(output_path, inputs, minify) {
}

function babelify(content, path, minify) {
let presets = ['es2015', 'es2016'];
// if(minify) {
// presets.push('babili'); // new babel minifier
// }
let presets = ['env'];
// Minification doesn't work when loading Frappe Desk
// Avoid for now, trace the error and come back.
try {
return babel.transform(content, {
presets: presets,


+ 25
- 6
frappe/build.py View File

@@ -4,6 +4,7 @@
from __future__ import unicode_literals, print_function
from frappe.utils.minify import JavascriptMinify
import subprocess
import warnings

from six import iteritems, text_type

@@ -25,12 +26,12 @@ def setup():
except ImportError: pass
app_paths = [os.path.dirname(pymodule.__file__) for pymodule in pymodules]

def bundle(no_compress, make_copy=False, verbose=False):
def bundle(no_compress, make_copy=False, restore=False, verbose=False):
"""concat / minify js files"""
# build js files
setup()

make_asset_dirs(make_copy=make_copy)
make_asset_dirs(make_copy=make_copy, restore=restore)

# new nodejs build system
command = 'node --use_strict ../apps/frappe/frappe/build.js --build'
@@ -60,7 +61,8 @@ def watch(no_compress):

# time.sleep(3)

def make_asset_dirs(make_copy=False):
def make_asset_dirs(make_copy=False, restore=False):
# don't even think of making assets_path absolute - rm -rf ahead.
assets_path = os.path.join(frappe.local.sites_path, "assets")
for dir_path in [
os.path.join(assets_path, 'js'),
@@ -80,11 +82,28 @@ def make_asset_dirs(make_copy=False):

for source, target in symlinks:
source = os.path.abspath(source)
if not os.path.exists(target) and os.path.exists(source):
if make_copy:
shutil.copytree(source, target)
if os.path.exists(source):
if restore:
if os.path.exists(target):
if os.path.islink(target):
os.unlink(target)
else:
shutil.rmtree(target)
shutil.copytree(source, target)
elif make_copy:
if os.path.exists(target):
warnings.warn('Target {target} already exists.'.format(target = target))
else:
shutil.copytree(source, target)
else:
if os.path.exists(target):
if os.path.islink(target):
os.unlink(target)
else:
shutil.rmtree(target)
os.symlink(source, target)
else:
warnings.warn('Source {source} does not exists.'.format(source = source))

def build(no_compress=False, verbose=False):
assets_path = os.path.join(frappe.local.sites_path, "assets")


+ 3
- 2
frappe/commands/utils.py View File

@@ -8,13 +8,14 @@ from frappe.utils import update_progress_bar

@click.command('build')
@click.option('--make-copy', is_flag=True, default=False, help='Copy the files instead of symlinking')
@click.option('--restore', is_flag=True, default=False, help='Copy the files instead of symlinking with force')
@click.option('--verbose', is_flag=True, default=False, help='Verbose')
def build(make_copy=False, verbose=False):
def build(make_copy=False, restore = False, verbose=False):
"Minify + concatenate JS and CSS files, build translations"
import frappe.build
import frappe
frappe.init('')
frappe.build.bundle(False, make_copy=make_copy, verbose=verbose)
frappe.build.bundle(False, make_copy=make_copy, restore = restore, verbose=verbose)

@click.command('watch')
def watch():


+ 2
- 1
frappe/contacts/doctype/address/address.json View File

@@ -353,7 +353,8 @@
"label": "Email Address",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"options": "Email",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,


+ 10
- 7
frappe/core/doctype/communication/communication.py View File

@@ -25,7 +25,7 @@ class Communication(Document):
"""create email flag queue"""
if self.communication_type == "Communication" and self.communication_medium == "Email" \
and self.sent_or_received == "Received" and self.uid and self.uid != -1:
email_flag_queue = frappe.db.get_value("Email Flag Queue", {
"communication": self.name,
"is_completed": 0})
@@ -69,7 +69,7 @@ class Communication(Document):
def after_insert(self):
if not (self.reference_doctype and self.reference_name):
return
if self.reference_doctype == "Communication" and self.sent_or_received == "Sent":
frappe.db.set_value("Communication", self.reference_name, "status", "Replied")

@@ -94,9 +94,10 @@ class Communication(Document):

def on_update(self):
"""Update parent status as `Open` or `Replied`."""
update_parent_status(self)
update_comment_in_doc(self)
self.bot_reply()
if self.comment_type != 'Updated':
update_parent_status(self)
update_comment_in_doc(self)
self.bot_reply()

def on_trash(self):
if (not self.flags.ignore_permissions
@@ -264,7 +265,7 @@ def has_permission(doc, ptype, user):
if (doc.reference_doctype == "Communication" and doc.reference_name == doc.name) \
or (doc.timeline_doctype == "Communication" and doc.timeline_name == doc.name):
return
if doc.reference_doctype and doc.reference_name:
if frappe.has_permission(doc.reference_doctype, ptype="read", doc=doc.reference_name):
return True
@@ -277,7 +278,9 @@ def get_permission_query_conditions_for_communication(user):

if not user: user = frappe.session.user

if "Super Email User" in frappe.get_roles(user):
roles = frappe.get_roles(user)

if "Super Email User" in roles or "System Manager" in roles:
return None
else:
accounts = frappe.get_all("User Email", filters={ "parent": user },


+ 0
- 3
frappe/core/doctype/communication/email.py View File

@@ -166,9 +166,6 @@ def _notify(doc, print_html=None, print_format=None, attachments=None,

def update_parent_status(doc):
"""Update status of parent document based on who is replying."""
if doc.communication_type != "Communication":
return

parent = doc.get_parent_doc()
if not parent:
return


+ 115
- 1
frappe/core/page/desktop/desktop.js View File

@@ -112,13 +112,17 @@ $.extend(frappe.desktop, {
},

setup_module_click: function() {
frappe.desktop.wiggling = false;

if(frappe.list_desktop) {
frappe.desktop.wrapper.on("click", ".desktop-list-item", function() {
frappe.desktop.open_module($(this));
});
} else {
frappe.desktop.wrapper.on("click", ".app-icon", function() {
frappe.desktop.open_module($(this).parent());
if ( !frappe.desktop.wiggling ) {
frappe.desktop.open_module($(this).parent());
}
});
}
frappe.desktop.wrapper.on("click", ".circle", function() {
@@ -127,6 +131,116 @@ $.extend(frappe.desktop, {
frappe.ui.notifications.show_open_count_list(doctype);
}
});

frappe.desktop.setup_wiggle();
},

setup_wiggle: () => {
// Wiggle, Wiggle, Wiggle.
const DURATION_LONG_PRESS = 1000;
// lesser the antidode, more the wiggle (like your drunk uncle)
// 75 seems good to replicate the iOS feels.
const WIGGLE_ANTIDODE = 75;

var timer_id = 0;
const $cases = frappe.desktop.wrapper.find('.case-wrapper');
const $icons = frappe.desktop.wrapper.find('.app-icon');
const $notis = $(frappe.desktop.wrapper.find('.circle').toArray().filter((object) => {
// This hack is so bad, I should punch myself.
// Seriously, punch yourself.
const text = $(object).find('.circle-text').html();
return text;
}));
const clearWiggle = () => {
const $closes = $cases.find('.module-remove');
$closes.hide();
$notis.show();

$icons.trigger('stopRumble');

frappe.desktop.wiggling = false;
};

// initiate wiggling.
$icons.jrumble({
speed: WIGGLE_ANTIDODE // seems neat enough to match the iOS way
});

frappe.desktop.wrapper.on('mousedown', '.app-icon', () => {
timer_id = setTimeout(() => {
frappe.desktop.wiggling = true;
// hide all notifications.
$notis.hide();
$cases.each((i) => {
const $case = $($cases[i]);
const template =
`
<div class="circle module-remove" style="background-color:#E0E0E0; color:#212121">
<div class="circle-text">
<b>
&times
</b>
</div>
</div>
`;

$case.append(template);
const $close = $case.find('.module-remove');
const name = $case.attr('title');
$close.click(() => {
// good enough to create dynamic dialogs?
const dialog = new frappe.ui.Dialog({
title: __(`Hide ${name}?`)
});
dialog.set_primary_action(__('Hide'), () => {
frappe.call({
method: 'frappe.desk.doctype.desktop_icon.desktop_icon.hide',
args: { name: name },
freeze: true,
callback: (response) =>
{
if ( response.message ) {
location.reload();
}
}
})

dialog.hide();
clearWiggle();
});
// Hacks, Hacks and Hacks.
var $cancel = dialog.get_close_btn();
$cancel.click(() => {
clearWiggle();
});
$cancel.html(__(`Cancel`));

dialog.show();
});
});
$icons.trigger('startRumble');
}, DURATION_LONG_PRESS);
});
frappe.desktop.wrapper.on('mouseup mouseleave', '.app-icon', () => {
clearTimeout(timer_id);
});

// also stop wiggling if clicked elsewhere.
$('body').click((event) => {
if ( frappe.desktop.wiggling ) {
const $target = $(event.target);
// our target shouldn't be .app-icons or .close
const $parent = $target.parents('.case-wrapper');
if ( $parent.length == 0 )
clearWiggle();
}
});
// end wiggle
},

open_module: function(parent) {


+ 13
- 1
frappe/defaults.py View File

@@ -92,7 +92,19 @@ def set_default(key, value, parent, parenttype="__default"):
:param value: Default value.
:param parent: Usually, **User** to whom the default belongs.
:param parenttype: [optional] default is `__default`."""
frappe.db.sql("""delete from `tabDefaultValue` where defkey=%s and parent=%s""", (key, parent))
if frappe.db.sql('''
select
defkey
from
tabDefaultValue
where
defkey=%s and parent=%s
for update''', (key, parent)):
frappe.db.sql("""
delete from
`tabDefaultValue`
where
defkey=%s and parent=%s""", (key, parent))
if value != None:
add_default(key, value, parent)



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

@@ -404,3 +404,16 @@ palette = (
('#4F8EA8', 1),
('#428B46', 1)
)

@frappe.whitelist()
def hide(name, user = None):
if not user:
user = frappe.session.user

try:
set_hidden(name, user, hidden = 1)
clear_desktop_icons_cache()
except Exception:
return False

return True

+ 23
- 0
frappe/desk/doctype/todo/test_todo.js View File

@@ -0,0 +1,23 @@
/* eslint-disable */
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line

QUnit.test("test: ToDo", function (assert) {
let done = assert.async();

// number of asserts
assert.expect(1);

frappe.run_serially([
// insert a new ToDo
() => frappe.tests.make('ToDo', [
// values to be set
{key: 'value'}
]),
() => {
assert.equal(cur_frm.doc.key, 'value');
},
() => done()
]);

});

+ 9
- 9
frappe/desk/doctype/todo/todo.json View File

@@ -112,20 +112,18 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "color",
"fieldtype": "Color",
"fieldname": "column_break_2",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Color",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
@@ -142,18 +140,20 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_2",
"fieldtype": "Column Break",
"fieldname": "color",
"fieldtype": "Color",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Color",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
@@ -544,7 +544,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-09-05 12:54:58.044162",
"modified": "2017-09-30 13:57:29.398598",
"modified_by": "Administrator",
"module": "Desk",
"name": "ToDo",


+ 1
- 2
frappe/desk/reportview.py View File

@@ -259,7 +259,7 @@ def get_stats(stats, doctype, filters=[]):
stats[tag] = scrub_user_tags(tagcount)
stats[tag].append([_("No Tags"), frappe.get_list(doctype,
fields=[tag, "count(*)"],
filters=filters +["({0} = ',' or {0} is null)".format(tag)], as_list=True)[0][1]])
filters=filters +["({0} = ',' or {0} = '' or {0} is null)".format(tag)], as_list=True)[0][1]])
else:
stats[tag] = tagcount

@@ -269,7 +269,6 @@ def get_stats(stats, doctype, filters=[]):
except MySQLdb.OperationalError:
# raised when _user_tags column is added on the fly
pass

return stats

@frappe.whitelist()


+ 0
- 1
frappe/email/doctype/email_account/email_account.py View File

@@ -273,7 +273,6 @@ class EmailAccount(Document):
"uid_reindexed": uid_reindexed
}
communication = self.insert_communication(msg, args=args)
#self.notify_update()

except SentEmailInInbox:
frappe.db.rollback()


+ 16
- 7
frappe/email/doctype/email_alert/email_alert.js View File

@@ -6,13 +6,24 @@ frappe.email_alert = {
}

frappe.model.with_doctype(frm.doc.document_type, function() {
var get_select_options = function(df) {
let get_select_options = function(df) {
return {value: df.fieldname, label: df.fieldname + " (" + __(df.label) + ")"};
}

var fields = frappe.get_doc("DocType", frm.doc.document_type).fields;
let get_date_change_options = function() {
let date_options = $.map(fields, function(d) {
return (d.fieldtype=="Date" || d.fieldtype=="Datetime")?
get_select_options(d) : null;
});
// append creation and modified date to Date Change field
return date_options.concat([
{ value: "creation", label: `creation (${__('Created On')})` },
{ value: "modified", label: `modified (${__('Last Modified Date')})` }
]);
}

var options = $.map(fields,
let fields = frappe.get_doc("DocType", frm.doc.document_type).fields;
let options = $.map(fields,
function(d) { return in_list(frappe.model.no_value_type, d.fieldtype) ?
null : get_select_options(d); });

@@ -21,11 +32,9 @@ frappe.email_alert = {
frm.set_df_property("set_property_after_alert", "options", [""].concat(options));

// set date changed options
frm.set_df_property("date_changed", "options", $.map(fields,
function(d) { return (d.fieldtype=="Date" || d.fieldtype=="Datetime") ?
get_select_options(d) : null; }));
frm.set_df_property("date_changed", "options", get_date_change_options());

var email_fields = $.map(fields,
let email_fields = $.map(fields,
function(d) { return (d.options == "Email" ||
(d.options=='User' && d.fieldtype=='Link')) ?
get_select_options(d) : null; });


+ 1
- 1
frappe/hooks.py View File

@@ -11,7 +11,7 @@ app_color = "orange"
source_link = "https://github.com/frappe/frappe"
app_license = "MIT"

develop_version = '8.x.x-beta'
develop_version = '9.x.x-develop'

app_email = "info@frappe.io"



+ 47
- 23
frappe/model/document.py View File

@@ -20,13 +20,13 @@ from frappe.integrations.doctype.webhook import run_webhooks
# once_only validation
# methods

def get_doc(arg1, arg2=None):
def get_doc(*args, **kwargs):
"""returns a frappe.model.Document object.

:param arg1: Document dict or DocType name.
:param arg2: [optional] document name.

There are two ways to call `get_doc`
There are multiple ways to call `get_doc`

# will fetch the latest user object (with child table) from the database
user = get_doc("User", "test@example.com")
@@ -39,23 +39,39 @@ def get_doc(arg1, arg2=None):
{"role": "System Manager"}
]
})

# create new object with keyword arguments
user = get_doc(doctype='User', email_id='test@example.com')
"""
if isinstance(arg1, BaseDocument):
return arg1
elif isinstance(arg1, string_types):
doctype = arg1
else:
doctype = arg1.get("doctype")
if args:
if isinstance(args[0], BaseDocument):
# already a document
return args[0]
elif isinstance(args[0], string_types):
doctype = args[0]

elif isinstance(args[0], dict):
# passed a dict
kwargs = args[0]

else:
raise ValueError('First non keyword argument must be a string or dict')

if kwargs:
if 'doctype' in kwargs:
doctype = kwargs['doctype']
else:
raise ValueError('"doctype" is a required key')

controller = get_controller(doctype)
if controller:
return controller(arg1, arg2)
return controller(*args, **kwargs)

raise ImportError(arg1)
raise ImportError(doctype)

class Document(BaseDocument):
"""All controllers inherit from `Document`."""
def __init__(self, arg1, arg2=None):
def __init__(self, *args, **kwargs):
"""Constructor.

:param arg1: DocType name as string or document **dict**
@@ -68,29 +84,37 @@ class Document(BaseDocument):
self._default_new_docs = {}
self.flags = frappe._dict()

if arg1 and isinstance(arg1, string_types):
if not arg2:
if args and args[0] and isinstance(args[0], string_types):
# first arugment is doctype
if len(args)==1:
# single
self.doctype = self.name = arg1
self.doctype = self.name = args[0]
else:
self.doctype = arg1
if isinstance(arg2, dict):
self.doctype = args[0]
if isinstance(args[1], dict):
# filter
self.name = frappe.db.get_value(arg1, arg2, "name")
self.name = frappe.db.get_value(args[0], args[1], "name")
if self.name is None:
frappe.throw(_("{0} {1} not found").format(_(arg1), arg2), frappe.DoesNotExistError)
frappe.throw(_("{0} {1} not found").format(_(args[0]), args[1]),
frappe.DoesNotExistError)
else:
self.name = arg2
self.name = args[1]

self.load_from_db()
return

if args and args[0] and isinstance(args[0], dict):
# first argument is a dict
kwargs = args[0]

elif isinstance(arg1, dict):
super(Document, self).__init__(arg1)
if kwargs:
# init base document
super(Document, self).__init__(kwargs)
self.init_valid_columns()

else:
# incorrect arguments. let's not proceed.
raise frappe.DataError("Document({0}, {1})".format(arg1, arg2))
raise ValueError('Illegal arguments')

def reload(self):
"""Reload document from database"""
@@ -631,7 +655,7 @@ class Document(BaseDocument):
name=self.name))

def _validate_links(self):
if self.flags.ignore_links:
if self.flags.ignore_links or self._action == "cancel":
return

invalid_links, cancelled_links = self.get_invalid_links()


+ 2
- 0
frappe/patches/v6_20x/remove_roles_from_website_user.py View File

@@ -1,6 +1,8 @@
import frappe

def execute():
frappe.reload_doc("core", "doctype", "user_email")
frappe.reload_doc("core", "doctype", "user")
for user_name in frappe.get_all('User', filters={'user_type': 'Website User'}):
user = frappe.get_doc('User', user_name)
if user.roles:


+ 8
- 1
frappe/public/build.json View File

@@ -23,6 +23,7 @@
"public/js/frappe/misc/rating_icons.html"
],
"js/control.min.js": [
"public/js/frappe/ui/capture.js",
"public/js/frappe/form/controls/base_control.js",
"public/js/frappe/form/controls/base_input.js",
"public/js/frappe/form/controls/data.js",
@@ -55,12 +56,15 @@
"js/dialog.min.js": [
"public/js/frappe/dom.js",
"public/js/frappe/ui/modal.html",

"public/js/frappe/form/formatters.js",
"public/js/frappe/form/layout.js",
"public/js/frappe/ui/field_group.js",
"public/js/frappe/form/link_selector.js",
"public/js/frappe/form/multi_select_dialog.js",
"public/js/frappe/ui/dialog.js",
"public/js/frappe/ui/capture.js",

"public/js/frappe/form/controls/base_control.js",
"public/js/frappe/form/controls/base_input.js",
"public/js/frappe/form/controls/data.js",
@@ -130,7 +134,9 @@
"public/js/lib/jSignature.min.js",
"public/js/frappe/translate.js",
"public/js/lib/datepicker/datepicker.min.js",
"public/js/lib/datepicker/locale-all.js"
"public/js/lib/datepicker/locale-all.js",
"public/js/lib/jquery.jrumble.min.js",
"public/js/lib/webcam.min.js"
],
"js/desk.min.js": [
"public/js/frappe/class.js",
@@ -168,6 +174,7 @@
"public/js/frappe/form/link_selector.js",
"public/js/frappe/form/multi_select_dialog.js",
"public/js/frappe/ui/dialog.js",
"public/js/frappe/ui/capture.js",
"public/js/frappe/ui/app_icon.js",

"public/js/frappe/model/model.js",


+ 8
- 0
frappe/public/css/report-rtl.css View File

@@ -1,3 +1,11 @@
.grid-report {
direction: ltr;
}

.chart_area{
direction: ltr;
}

.grid-report .show-zero{
direction: rtl ;
}

+ 4
- 2
frappe/public/js/frappe/form/controls/color.js View File

@@ -36,9 +36,11 @@ frappe.ui.form.ControlColor = frappe.ui.form.ControlData.extend({
set_formatted_input: function(value) {
this._super(value);

if(!value) value = '#ffffff';
if (!value) value = '#FFFFFF';
const contrast = frappe.ui.color.get_contrast_color(value);

this.$input.css({
"background-color": value
"background-color": value, "color": contrast
});
},
bind_events: function () {


+ 44
- 5
frappe/public/js/frappe/form/controls/text_editor.js View File

@@ -6,6 +6,28 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({
this.setup_drag_drop();
this.setup_image_dialog();
this.setting_count = 0;

$(document).on('form-refresh', () => {
// reset last keystroke when a new form is loaded
this.last_keystroke_on = null;
})
},
render_camera_button: (context) => {
var ui = $.summernote.ui;
var button = ui.button({
contents: '<i class="fa fa-camera"/>',
tooltip: 'Camera',
click: () => {
const capture = new frappe.ui.Capture();
capture.open();

capture.click((data) => {
context.invoke('editor.insertImage', data);
});
}
});

return button.render();
},
make_editor: function() {
var me = this;
@@ -25,9 +47,12 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({
['color', ['color']],
['para', ['ul', 'ol', 'paragraph', 'hr']],
//['height', ['height']],
['media', ['link', 'picture', 'video', 'table']],
['media', ['link', 'picture', 'camera', 'video', 'table']],
['misc', ['fullscreen', 'codeview']]
],
buttons: {
camera: this.render_camera_button,
},
keyMap: {
pc: {
'CTRL+ENTER': ''
@@ -54,7 +79,7 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({
me.parse_validate_and_set_in_model(value);
},
onKeydown: function(e) {
me._last_change_on = new Date();
me.last_keystroke_on = new Date();
var key = frappe.ui.keys.get_key(e);
// prevent 'New DocType (Ctrl + B)' shortcut in editor
if(['ctrl+b', 'meta+b'].indexOf(key) !== -1) {
@@ -80,6 +105,7 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({
'outdent': 'fa fa-outdent',
'arrowsAlt': 'fa fa-arrows-alt',
'bold': 'fa fa-bold',
'camera': 'fa fa-camera',
'caret': 'caret',
'circle': 'fa fa-circle',
'close': 'fa fa-close',
@@ -184,20 +210,30 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({

if(this.setting_count > 2) {
// we don't understand how the internal triggers work,
// so if someone is setting the value third time, then quit
// so if someone is setting the value third time in 500ms,
// then quit
return;
}

this.setting_count += 1;

let time_since_last_keystroke = moment() - moment(this._last_change_on);
let time_since_last_keystroke = moment() - moment(this.last_keystroke_on);

if(!this._last_change_on || (time_since_last_keystroke > 3000)) {
if(!this.last_keystroke_on || (time_since_last_keystroke > 3000)) {
// if 3 seconds have passed since the last keystroke and
// we have not set any value in the last 1 second, do this
setTimeout(() => this.setting_count = 0, 500);
this.editor.summernote('code', value || '');
this.last_keystroke_on = null;
} else {
// user is probably still in the middle of typing
// so lets not mess up the html by re-updating it
// keep checking every second if our 3 second barrier
// has been completed, so that we can refresh the html
this._setting_value = setInterval(() => {
if(time_since_last_keystroke > 3000) {
// 3 seconds done! lets refresh
// safe to update
if(this.last_value !== this.get_input_value()) {
// if not already in sync, reset
this.editor.summernote('code', this.last_value || '');
@@ -205,6 +241,9 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({
clearInterval(this._setting_value);
this._setting_value = null;
this.setting_count = 0;

// clear timestamp of last keystroke
this.last_keystroke_on = null;
}
}, 1000);
}


+ 1
- 1
frappe/public/js/frappe/socketio_client.js View File

@@ -73,7 +73,7 @@ frappe.socketio = {
frappe.socketio.doc_subscribe(frm.doctype, frm.docname);
});

$(document).on("form_refresh", function(e, frm) {
$(document).on("form-refresh", function(e, frm) {
if (frm.is_new()) {
return;
}


+ 94
- 0
frappe/public/js/frappe/ui/capture.js View File

@@ -0,0 +1,94 @@
frappe.ui.Capture = class
{
constructor (options = { })
{
this.options = Object.assign({}, frappe.ui.Capture.DEFAULT_OPTIONS, options);
this.dialog = new frappe.ui.Dialog();
this.template =
`
<div class="text-center">
<div class="img-thumbnail" style="border: none;">
<div id="frappe-capture"/>
</div>
</div>

<div id="frappe-capture-btn-toolbar" style="padding-top: 15px; padding-bottom: 15px;">
<div class="text-center">
<div id="frappe-capture-btn-toolbar-snap">
<a id="frappe-capture-btn-snap">
<i class="fa fa-fw fa-2x fa-circle-o"/>
</a>
</div>
<div class="btn-group" id="frappe-capture-btn-toolbar-knap">
<button class="btn btn-default" id="frappe-capture-btn-discard">
<i class="fa fa-fw fa-arrow-left"/>
</button>
<button class="btn btn-default" id="frappe-capture-btn-accept">
<i class="fa fa-fw fa-arrow-right"/>
</button>
</div>
</div>
</div>
`;
$(this.dialog.body).append(this.template);

this.$btnBarSnap = $(this.dialog.body).find('#frappe-capture-btn-toolbar-snap');
this.$btnBarKnap = $(this.dialog.body).find('#frappe-capture-btn-toolbar-knap');
this.$btnBarKnap.hide();

Webcam.set(this.options);
}

open ( )
{
this.dialog.show();

Webcam.attach('#frappe-capture');
}

freeze ( )
{
this.$btnBarSnap.hide();
this.$btnBarKnap.show();
Webcam.freeze();
}

unfreeze ( )
{
this.$btnBarSnap.show();
this.$btnBarKnap.hide();

Webcam.unfreeze();
}

click (callback)
{
$(this.dialog.body).find('#frappe-capture-btn-snap').click(() => {
this.freeze();

$(this.dialog.body).find('#frappe-capture-btn-discard').click(() => {
this.unfreeze();
});

$(this.dialog.body).find('#frappe-capture-btn-accept').click(() => {
Webcam.snap((data) => {
callback(data);
});

this.hide();
});
});
}

hide ( )
{
Webcam.reset();

$(this.dialog.$wrapper).remove();
}
};
frappe.ui.Capture.DEFAULT_OPTIONS =
{
width: 480, height: 320, flip_horiz: true
};

+ 8
- 3
frappe/public/js/frappe/upload.js View File

@@ -12,7 +12,13 @@ frappe.upload = {

// whether to show public/private checkbox or not
opts.show_private = !("is_private" in opts);

// make private by default
if (!("options" in opts) || ("options" in opts &&
(!opts.options.toLowerCase()=="public" && !opts.options.toLowerCase()=="image"))) {
opts.is_private = 1;
}
var d = null;
// create new dialog if no parent given
if(!opts.parent) {
@@ -237,7 +243,6 @@ frappe.upload = {
if (args.file_size) {
frappe.upload.validate_max_file_size(args.file_size);
}

if(opts.on_attach) {
opts.on_attach(args)
} else {
@@ -252,7 +257,7 @@ frappe.upload = {
frappe.upload.upload_to_server(fileobj, args, opts);
}, __("Private or Public?"));
} else {
if ("is_private" in opts) {
if (!("is_private" in args) && "is_private" in opts) {
args["is_private"] = opts.is_private;
}



+ 1
- 1
frappe/public/js/legacy/clientscriptAPI.js View File

@@ -238,7 +238,7 @@ _f.Frm.prototype.set_query = function(fieldname, opt1, opt2) {
}

_f.Frm.prototype.set_value_if_missing = function(field, value) {
this.set_value(field, value, true);
return this.set_value(field, value, true);
}

_f.Frm.prototype.clear_table = function(fieldname) {


+ 1
- 1
frappe/public/js/legacy/form.js View File

@@ -497,7 +497,7 @@ _f.Frm.prototype.render_form = function(is_a_different_doc) {

// trigger global trigger
// to use this
$(document).trigger('form_refresh', [this]);
$(document).trigger('form-refresh', [this]);

// fields
this.refresh_fields();


+ 2
- 0
frappe/public/js/lib/jquery.jrumble.min.js View File

@@ -0,0 +1,2 @@
/* jRumble v1.3 - http://jackrugile.com/jrumble - MIT License */
(function(f){f.fn.jrumble=function(g){var a=f.extend({x:2,y:2,rotation:1,speed:15,opacity:false,opacityMin:0.5},g);return this.each(function(){var b=f(this),h=a.x*2,i=a.y*2,k=a.rotation*2,g=a.speed===0?1:a.speed,m=a.opacity,n=a.opacityMin,l,j,o=function(){var e=Math.floor(Math.random()*(h+1))-h/2,a=Math.floor(Math.random()*(i+1))-i/2,c=Math.floor(Math.random()*(k+1))-k/2,d=m?Math.random()+n:1,e=e===0&&h!==0?Math.random()<0.5?1:-1:e,a=a===0&&i!==0?Math.random()<0.5?1:-1:a;b.css("display")==="inline"&&(l=true,b.css("display","inline-block"));b.css({position:"relative",left:e+"px",top:a+"px","-ms-filter":"progid:DXImageTransform.Microsoft.Alpha(Opacity="+d*100+")",filter:"alpha(opacity="+d*100+")","-moz-opacity":d,"-khtml-opacity":d,opacity:d,"-webkit-transform":"rotate("+c+"deg)","-moz-transform":"rotate("+c+"deg)","-ms-transform":"rotate("+c+"deg)","-o-transform":"rotate("+c+"deg)",transform:"rotate("+c+"deg)"})},p={left:0,top:0,"-ms-filter":"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)",filter:"alpha(opacity=100)","-moz-opacity":1,"-khtml-opacity":1,opacity:1,"-webkit-transform":"rotate(0deg)","-moz-transform":"rotate(0deg)","-ms-transform":"rotate(0deg)","-o-transform":"rotate(0deg)",transform:"rotate(0deg)"};b.bind({startRumble:function(a){a.stopPropagation();clearInterval(j);j=setInterval(o,g)},stopRumble:function(a){a.stopPropagation();clearInterval(j);l&&b.css("display","inline");b.css(p)}})})}})(jQuery);

+ 2
- 0
frappe/public/js/lib/webcam.min.js
File diff suppressed because it is too large
View File


+ 4
- 3
frappe/test_runner.py View File

@@ -309,9 +309,10 @@ def make_test_objects(doctype, test_records=None, verbose=None, reset=False):
else:
d.set_new_name()

if d.name in (frappe.local.test_objects.get(d.doctype) or []) and not reset:
if frappe.db.exists(d.doctype, d.name) and not reset:
frappe.db.rollback()
# do not create test records, if already exists
return []
continue

# submit if docstatus is set to 1 for test record
docstatus = d.docstatus
@@ -336,7 +337,7 @@ def make_test_objects(doctype, test_records=None, verbose=None, reset=False):

records.append(d.name)

frappe.db.commit()
frappe.db.commit()

return records



+ 0
- 9
license.txt View File

@@ -1,9 +0,0 @@
The MIT License (MIT)

Copyright (c) 2016 Frappe Technologies Pvt. Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 10
- 10
package.json View File

@@ -14,20 +14,20 @@
},
"homepage": "https://frappe.io",
"dependencies": {
"babel-core": "^6.24.1",
"babel-preset-babili": "0.0.12",
"babel-preset-es2015": "^6.24.1",
"babel-preset-es2016": "^6.24.1",
"babel-preset-es2017": "^6.24.1",
"chokidar": "^1.7.0",
"chromedriver": "^2.30.1",
"cookie": "^0.3.1",
"express": "^4.15.3",
"less": "^2.7.2",
"nightwatch": "^0.9.16",
"redis": "^2.7.1",
"socket.io": "^2.0.1",
"superagent": "^3.5.2",
"touch": "^3.1.0"
"touch": "^3.1.0"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-preset-env": "^1.6.0",
"babel-preset-minify": "^0.2.0",
"chokidar": "^1.7.0",
"chromedriver": "^2.32.3",
"less": "^2.7.2",
"nightwatch": "^0.9.16"
}
}

+ 1
- 1
requirements.txt View File

@@ -6,7 +6,7 @@ httplib2
jinja2
markdown2
markupsafe
mysqlclient==1.3.10
-e git+https://github.com/frappe/mysqlclient-python.git@1.3.12#egg=mysqlclient
python-geoip
python-geoip-geolite2
python-dateutil


+ 35
- 2
setup.py View File

@@ -1,3 +1,7 @@
# imports - standard imports
import os, shutil
from distutils.command.clean import clean as Clean

from setuptools import setup, find_packages
from pip.req import parse_requirements
import re, ast
@@ -11,6 +15,31 @@ with open('frappe/__init__.py', 'rb') as f:

requirements = parse_requirements("requirements.txt", session="")

class CleanCommand(Clean):
def run(self):
Clean.run(self)

basedir = os.path.abspath(os.path.dirname(__file__))

for relpath in ['build', '.cache', '.coverage', 'dist', 'frappe.egg-info']:
abspath = os.path.join(basedir, relpath)
if os.path.exists(abspath):
if os.path.isfile(abspath):
os.remove(abspath)
else:
shutil.rmtree(abspath)

for dirpath, dirnames, filenames in os.walk(basedir):
for filename in filenames:
_, extension = os.path.splitext(filename)
if extension in ['.pyc']:
abspath = os.path.join(dirpath, filename)
os.remove(abspath)
for dirname in dirnames:
if dirname in ['__pycache__']:
abspath = os.path.join(dirpath, dirname)
shutil.rmtree(abspath)

setup(
name='frappe',
version=version,
@@ -21,5 +50,9 @@ setup(
zip_safe=False,
include_package_data=True,
install_requires=[str(ir.req) for ir in requirements],
dependency_links=[str(ir._link) for ir in requirements if ir._link]
)
dependency_links=[str(ir._link) for ir in requirements if ir._link],
cmdclass = \
{
'clean': CleanCommand
}
)

Loading…
Cancel
Save