Parcourir la source

Merge branch 'develop'

version-14
Nabin Hait il y a 8 ans
Parent
révision
3494f12b8d
15 fichiers modifiés avec 174 ajouts et 85 suppressions
  1. +1
    -1
      frappe/__init__.py
  2. +54
    -30
      frappe/boot.py
  3. +32
    -2
      frappe/core/doctype/page/page.json
  4. +14
    -0
      frappe/core/doctype/role_permission_for_page_and_report/role_permission_for_page_and_report.js
  5. +3
    -0
      frappe/core/doctype/role_permission_for_page_and_report/role_permission_for_page_and_report.py
  6. +5
    -5
      frappe/core/doctype/user/test_user.py
  7. +2
    -1
      frappe/core/page/modules_setup/modules_setup.json
  8. +17
    -16
      frappe/desk/page/setup_wizard/setup_wizard.json
  9. +1
    -2
      frappe/email/doctype/email_account/email_account.js
  10. +7
    -1
      frappe/limits.py
  11. +2
    -1
      frappe/patches.txt
  12. +1
    -1
      frappe/patches/v4_0/create_custom_field_for_owner_match.py
  13. +6
    -25
      frappe/patches/v8_0/fix_non_english_desktop_icons.py
  14. +13
    -0
      frappe/patches/v8_0/set_doctype_values_in_custom_role.py
  15. +16
    -0
      frappe/tests/test_patches.py

+ 1
- 1
frappe/__init__.py Voir le fichier

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

__version__ = '8.0.13'
__version__ = '8.0.14'
__title__ = "Frappe Framework"

local = Local()


+ 54
- 30
frappe/boot.py Voir le fichier

@@ -95,46 +95,70 @@ def get_allowed_pages():

def get_allowed_reports():
return get_user_page_or_report('Report')
def get_user_page_or_report(parent):
roles = frappe.get_roles()
has_role = {}
column = get_column(parent)
# get pages or reports set on custom role
for p in frappe.db.sql("""select `tabCustom Role`.{field} as name, `tabCustom Role`.modified, `tabCustom Role`.ref_doctype
from `tabCustom Role`, `tabHas Role` where
`tabHas Role`.parent = `tabCustom Role`.name and
`tabCustom Role`.{field} is not null and `tabHas Role`.role in ({roles})
""".format(field=parent.lower(), roles = ', '.join(['%s']*len(roles))), roles, as_dict=1):

# get pages or reports set on custom role
custom_roles = frappe.db.sql("""
select
`tabCustom Role`.{field} as name,
`tabCustom Role`.modified,
`tabCustom Role`.ref_doctype
from `tabCustom Role`, `tabHas Role`
where
`tabHas Role`.parent = `tabCustom Role`.name
and `tabCustom Role`.{field} is not null
and `tabHas Role`.role in ({roles})
""".format(field=parent.lower(), roles = ', '.join(['%s']*len(roles))), roles, as_dict=1)
for p in custom_roles:
has_role[p.name] = {"modified":p.modified, "title": p.name, "ref_doctype": p.ref_doctype}

for p in frappe.db.sql("""select distinct
tab{parent}.name, tab{parent}.modified, {column}
from `tabHas Role`, `tab{parent}`
where `tabHas Role`.role in ({roles})
and `tabHas Role`.parent = `tab{parent}`.name
""".format(parent=parent, column=column, roles = ', '.join(['%s']*len(roles))), roles, as_dict=True):
standard_roles = frappe.db.sql("""
select distinct
tab{parent}.name,
tab{parent}.modified,
{column}
from `tabHas Role`, `tab{parent}`
where
`tabHas Role`.role in ({roles})
and `tabHas Role`.parent = `tab{parent}`.name
and tab{parent}.name not in (
select `tabCustom Role`.{field} from `tabCustom Role`
where `tabCustom Role`.{field} is not null)
""".format(parent=parent, column=column,
roles = ', '.join(['%s']*len(roles)), field=parent.lower()), roles, as_dict=True)
for p in standard_roles:
if p.name not in has_role:
has_role[p.name] = {"modified":p.modified, "title": p.title}
if parent == "Report":
has_role[p.name].update({'ref_doctype': p.ref_doctype})

# pages with no role are allowed
if parent =="Page":
pages_with_no_roles = frappe.db.sql("""
select
`tab{parent}`.name, `tab{parent}`.modified, {column}
from `tab{parent}`
where
(select count(*) from `tabHas Role`
where `tabHas Role`.parent=tab{parent}.name) = 0
""".format(parent=parent, column=column), as_dict=1)
for p in pages_with_no_roles:
if p.name not in has_role:
has_role[p.name] = {"modified":p.modified, "title": p.title}
if parent == "Report":
has_role[p.name].update({'ref_doctype': p.ref_doctype})
has_role[p.name].update({'report_type': p.report_type})

# pages or reports where role is not set are also allowed
for p in frappe.db.sql("""select `tab{parent}`.name, `tab{parent}`.modified, {column}
from `tab{parent}` where
(select count(*) from `tabHas Role`
where `tabHas Role`.parent=tab{parent}.name) = 0""".format(parent=parent, column=column), as_dict=1):
if p.name not in has_role:
has_role[p.name] = {"modified":p.modified, "title": p.title}
if parent == "Report":
has_role[p.name].update({'ref_doctype': p.ref_doctype})
has_role[p.name].update({'report_type': p.report_type})
has_role[p.name] = {"modified": p.modified, "title": p.title}
elif parent == "Report":
for report_name in has_role:
has_role[report_name]["report_type"] = frappe.db.get_value("Report", report_name, "report_type")

return has_role

def get_column(doctype):
column = "`tabPage`.title as title"
if doctype == "Report":


+ 32
- 2
frappe/core/doctype/page/page.json Voir le fichier

@@ -1,5 +1,6 @@
{
"allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 1,
"autoname": "field:page_name",
@@ -12,6 +13,35 @@
"editable_grid": 0,
"engine": "InnoDB",
"fields": [
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "system_page",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "System Page",
"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,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@@ -276,18 +306,18 @@
"unique": 0
}
],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "fa fa-file",
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-02-22 14:42:19.434501",
"modified": "2017-04-12 16:39:15.179130",
"modified_by": "Administrator",
"module": "Core",
"name": "Page",


+ 14
- 0
frappe/core/doctype/role_permission_for_page_and_report/role_permission_for_page_and_report.js Voir le fichier

@@ -2,6 +2,10 @@
// For license information, please see license.txt

frappe.ui.form.on('Role Permission for Page and Report', {
setup: function(frm) {
frm.trigger("set_queries")
},

refresh: function(frm) {
frm.disable_save();
frm.role_area.hide();
@@ -19,6 +23,16 @@ frappe.ui.form.on('Role Permission for Page and Report', {
}
},

set_queries: function(frm) {
frm.set_query("page", function() {
return {
filters: {
system_page: 0
}
}
});
},

set_role_for: function(frm) {
frm.trigger("clear_fields")
frm.toggle_display('roles_html', false)


+ 3
- 0
frappe/core/doctype/role_permission_for_page_and_report/role_permission_for_page_and_report.py Voir le fichier

@@ -40,6 +40,9 @@ class RolePermissionforPageandReport(Document):
'roles': self.get_roles()
})

if self.report:
args.update({'ref_doctype': frappe.db.get_value('Report', self.report, 'ref_doctype')})

if name:
custom_role = frappe.get_doc("Custom Role", name)
custom_role.set('roles', self.get_roles())


+ 5
- 5
frappe/core/doctype/user/test_user.py Voir le fichier

@@ -181,7 +181,7 @@ class TestUser(unittest.TestCase):
user.new_password = 'testpassword'
user.save()

update_limits({'expiry': add_to_date(today(), days=-1)})
update_limits({'expiry': add_to_date(today(), days=-1), 'support_email': 'support@example.com'})
frappe.local.conf = _dict(frappe.get_site_config())

frappe.db.commit()
@@ -194,10 +194,10 @@ class TestUser(unittest.TestCase):

clear_limit("expiry")
frappe.local.conf = _dict(frappe.get_site_config())
def test_deactivate_additional_users(self):
update_limits({'users': get_total_users()+1})
if not frappe.db.exists("User", "test_deactivate_additional_users@example.com"):
user = frappe.new_doc('User')
user.email = 'test_deactivate_additional_users@example.com'
@@ -207,10 +207,10 @@ class TestUser(unittest.TestCase):
#update limits
update_limits({"users": get_total_users()-1})
self.assertEqual(frappe.db.get_value("User", "test_deactivate_additional_users@example.com", "enabled"), 0)
if frappe.db.exists("User", "test_deactivate_additional_users@example.com"):
frappe.delete_doc('User', 'test_deactivate_additional_users@example.com')

# Clear the user limit
clear_limit('users')

+ 2
- 1
frappe/core/page/modules_setup/modules_setup.json Voir le fichier

@@ -5,7 +5,7 @@
"doctype": "Page",
"icon": "fa fa-cog",
"idx": 1,
"modified": "2016-02-26 00:21:05.501007",
"modified": "2017-04-12 18:44:53.283640",
"modified_by": "Administrator",
"module": "Core",
"name": "modules_setup",
@@ -15,5 +15,6 @@
"script": null,
"standard": "Yes",
"style": null,
"system_page": 1,
"title": "Modules Setup"
}

+ 17
- 16
frappe/desk/page/setup_wizard/setup_wizard.json Voir le fichier

@@ -1,22 +1,23 @@
{
"content": null,
"creation": "2013-10-04 13:49:33",
"docstatus": 0,
"doctype": "Page",
"idx": 1,
"modified": "2016-06-15 13:07:32.651565",
"modified_by": "Administrator",
"module": "Desk",
"name": "setup-wizard",
"owner": "Administrator",
"page_name": "setup-wizard",
"content": null,
"creation": "2013-10-04 13:49:33",
"docstatus": 0,
"doctype": "Page",
"idx": 1,
"modified": "2017-04-12 18:45:00.774654",
"modified_by": "Administrator",
"module": "Desk",
"name": "setup-wizard",
"owner": "Administrator",
"page_name": "setup-wizard",
"roles": [
{
"role": "System Manager"
}
],
"script": null,
"standard": "Yes",
"style": null,
],
"script": null,
"standard": "Yes",
"style": null,
"system_page": 1,
"title": "Setup Wizard"
}
}

+ 1
- 2
frappe/email/doctype/email_account/email_account.js Voir le fichier

@@ -69,7 +69,6 @@ frappe.email_defaults_pop = {

frappe.ui.form.on("Email Account", {
service: function(frm) {
console.log(frm.doc.service, frappe.email_defaults[frm.doc.service])
$.each(frappe.email_defaults[frm.doc.service], function(key, value) {
frm.set_value(key, value);
})
@@ -189,4 +188,4 @@ frappe.ui.form.on("Email Account", {
});
}
}
});
});

+ 7
- 1
frappe/limits.py Voir le fichier

@@ -18,6 +18,11 @@ def check_if_expired():
return

limits = get_limits()
expiry = limits.get("expiry")

if not expiry:
return

expires_on = formatdate(limits.get("expiry"))
support_email = limits.get("support_email")

@@ -28,7 +33,8 @@ def check_if_expired():
message = _("""Your subscription expired on {0}. To renew, please send an email to {1}.""").format(expires_on, support_email)

else:
message = _("""Your subscription expired on {0}""").format(expires_on)
# no recourse just quit
return

frappe.throw(message, SiteExpiredError)



+ 2
- 1
frappe/patches.txt Voir le fichier

@@ -175,4 +175,5 @@ frappe.patches.v8_0.setup_email_inbox #2017-03-29
frappe.patches.v8_0.newsletter_childtable_migrate
execute:frappe.db.sql("delete from `tabDesktop Icon` where module_name='Communication'")
execute:frappe.db.sql("update `tabDesktop Icon` set type='list' where _doctype='Communication'")
frappe.patches.v8_0.fix_non_english_desktop_icons
frappe.patches.v8_0.fix_non_english_desktop_icons # 2017-04-12
frappe.patches.v8_0.set_doctype_values_in_custom_role

+ 1
- 1
frappe/patches/v4_0/create_custom_field_for_owner_match.py Voir le fichier

@@ -3,7 +3,7 @@

from __future__ import unicode_literals
import frappe
from frappe.core.doctype.custom_field.custom_field import create_custom_field
from frappe.custom.doctype.custom_field.custom_field import create_custom_field

def execute():
if "match" in frappe.db.get_table_columns("DocPerm"):


+ 6
- 25
frappe/patches/v8_0/fix_non_english_desktop_icons.py Voir le fichier

@@ -6,28 +6,9 @@ from __future__ import unicode_literals
import frappe
from frappe.desk.doctype.desktop_icon.desktop_icon import clear_desktop_icons_cache

def execute():
desktop_icons = frappe.db.sql("""
select name, label
from
`tabDesktop Icon`
where
_doctype is not null
and _doctype != ''
and _doctype != label""", as_dict=1)
for d in desktop_icons:
if not is_english(d.label):
frappe.db.sql("""update `tabDesktop Icon`
set module_name=_doctype, label=_doctype where name=%s""", d.name)
clear_desktop_icons_cache()

def is_english(s):
try:
s.decode('ascii')
except (UnicodeDecodeError, UnicodeEncodeError):
return False
else:
return True
def execute():
frappe.db.sql("""
update `tabDesktop Icon`
set module_name=_doctype, label=_doctype
where type = 'link' and _doctype != label and link like 'List/%'
""")

+ 13
- 0
frappe/patches/v8_0/set_doctype_values_in_custom_role.py Voir le fichier

@@ -0,0 +1,13 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt

from __future__ import unicode_literals
import frappe

def execute():
frappe.reload_doctype('Custom Role')
# set ref doctype in custom role for reports
frappe.db.sql(""" update `tabCustom Role` set
`tabCustom Role`.ref_doctype = (select ref_doctype from `tabReport` where name = `tabCustom Role`.report)
where `tabCustom Role`.report is not null""")

+ 16
- 0
frappe/tests/test_patches.py Voir le fichier

@@ -0,0 +1,16 @@
import unittest, frappe
from frappe.modules import patch_handler

class TestPatches(unittest.TestCase):
def test_patch_module_names(self):
frappe.flags.final_patches = []
frappe.flags.in_install = True
for patchmodule in patch_handler.get_all_patches():
if patchmodule.startswith("execute:"):
pass
else:
if patchmodule.startswith("finally:"):
patchmodule = patchmodule.split('finally:')[-1]
self.assertTrue(frappe.get_attr(patchmodule.split()[0] + ".execute"))

frappe.flags.in_install = False

Chargement…
Annuler
Enregistrer