Ver código fonte

Merge branch 'master' into develop

version-14
Nabin Hait 7 anos atrás
pai
commit
823366e6b9
3 arquivos alterados com 25 adições e 18 exclusões
  1. +1
    -1
      frappe/__init__.py
  2. +10
    -6
      frappe/desk/notifications.py
  3. +14
    -11
      frappe/utils/password_strength.py

+ 1
- 1
frappe/__init__.py Ver arquivo

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


__version__ = '9.1.10'
__version__ = '9.1.11'
__title__ = "Frappe Framework" __title__ = "Frappe Framework"


local = Local() local = Local()


+ 10
- 6
frappe/desk/notifications.py Ver arquivo

@@ -161,7 +161,9 @@ def clear_notifications(user=None):
return return


config = get_notification_config() config = get_notification_config()
groups = list(config.get("for_doctype").keys()) + list(config.get("for_module").keys())
for_doctype = config.get('for_doctype').keys() if config.get('for_doctype') else []
for_module = list(config.get('for_module').keys()) if config.get('for_module') else []
groups = for_doctype + for_module
cache = frappe.cache() cache = frappe.cache()


for name in groups: for name in groups:
@@ -206,11 +208,13 @@ def get_notification_info_for_boot():
def get_notification_config(): def get_notification_config():
def _get(): def _get():
config = frappe._dict() config = frappe._dict()
for notification_config in frappe.get_hooks().notification_config:
nc = frappe.get_attr(notification_config)()
for key in ("for_doctype", "for_module", "for_other", "targets"):
config.setdefault(key, {})
config[key].update(nc.get(key, {}))
hooks = frappe.get_hooks()
if hooks:
for notification_config in hooks.notification_config:
nc = frappe.get_attr(notification_config)()
for key in ("for_doctype", "for_module", "for_other", "targets"):
config.setdefault(key, {})
config[key].update(nc.get(key, {}))
return config return config


return frappe.cache().get_value("notification_config", _get) return frappe.cache().get_value("notification_config", _get)


+ 14
- 11
frappe/utils/password_strength.py Ver arquivo

@@ -7,6 +7,7 @@ from zxcvbn import zxcvbn
import frappe import frappe
from frappe import _ from frappe import _



def test_password_strength(password, user_inputs=None): def test_password_strength(password, user_inputs=None):
'''Wrapper around zxcvbn.password_strength''' '''Wrapper around zxcvbn.password_strength'''
result = zxcvbn(password, user_inputs) result = zxcvbn(password, user_inputs)
@@ -35,6 +36,7 @@ default_feedback = {
], ],
} }



def get_feedback(score, sequence): def get_feedback(score, sequence):
""" """
Returns the feedback dictionary consisting of ("warning","suggestions") for the given sequences. Returns the feedback dictionary consisting of ("warning","suggestions") for the given sequences.
@@ -66,6 +68,7 @@ def get_feedback(score, sequence):
} }
return feedback return feedback



def get_match_feedback(match, is_sole_match): def get_match_feedback(match, is_sole_match):
""" """
Returns feedback as a dictionary for a certain match Returns feedback as a dictionary for a certain match
@@ -81,32 +84,32 @@ def get_match_feedback(match, is_sole_match):
def fun_spatial(): def fun_spatial():
feedback = { feedback = {
"warning": _('Short keyboard patterns are easy to guess'), "warning": _('Short keyboard patterns are easy to guess'),
"suggestions":[
_("Make use of longer keyboard patterns")
"suggestions": [
_("Make use of longer keyboard patterns")
], ],
} }


if match.get("turns") == 1: if match.get("turns") == 1:
feedback = { feedback = {
"warning": _('Straight rows of keys are easy to guess'), "warning": _('Straight rows of keys are easy to guess'),
"suggestions":[
_("Try to use a longer keyboard pattern with more turns")
"suggestions": [
_("Try to use a longer keyboard pattern with more turns")
], ],
} }


return feedback return feedback


def fun_repeat(): def fun_repeat():
feedback ={
feedback = {
"warning": _('Repeats like "abcabcabc" are only slightly harder to guess than "abc"'), "warning": _('Repeats like "abcabcabc" are only slightly harder to guess than "abc"'),
"suggestions":[
"suggestions": [
_("Try to avoid repeated words and characters") _("Try to avoid repeated words and characters")
], ],
} }
if len(match["repeated_char"]) == 1:
if len(match.get("repeated_char")) == 1:
feedback = { feedback = {
"warning": _('Repeats like "aaa" are easy to guess'), "warning": _('Repeats like "aaa" are easy to guess'),
"suggestions":[
"suggestions": [
_("Let's avoid repeated words and characters") _("Let's avoid repeated words and characters")
], ],
} }
@@ -114,7 +117,7 @@ def get_match_feedback(match, is_sole_match):


def fun_sequence(): def fun_sequence():
return { return {
"suggestions":[
"suggestions": [
_("Avoid sequences like abc or 6543 as they are easy to guess") _("Avoid sequences like abc or 6543 as they are easy to guess")
], ],
} }
@@ -123,7 +126,7 @@ def get_match_feedback(match, is_sole_match):
if match["regex_name"] == "recent_year": if match["regex_name"] == "recent_year":
return { return {
"warning": _("Recent years are easy to guess."), "warning": _("Recent years are easy to guess."),
"suggestions":[
"suggestions": [
_("Avoid recent years."), _("Avoid recent years."),
_("Avoid years that are associated with you.") _("Avoid years that are associated with you.")
], ],
@@ -132,7 +135,7 @@ def get_match_feedback(match, is_sole_match):
def fun_date(): def fun_date():
return { return {
"warning": _("Dates are often easy to guess."), "warning": _("Dates are often easy to guess."),
"suggestions":[
"suggestions": [
_("Avoid dates and years that are associated with you.") _("Avoid dates and years that are associated with you.")
], ],
} }


Carregando…
Cancelar
Salvar