Merge branch 'develop' into patch-1

This commit is contained in:
Suraj Shetty 2020-04-24 23:07:12 +05:30 committed by GitHub
commit 2aee5f64ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 18 deletions

View file

@ -895,7 +895,7 @@ def validate_fields(meta):
field.fetch_from = field.fetch_from.strip('\n').strip()
def validate_data_field_type(docfield):
if docfield.fieldtype == "Data":
if docfield.fieldtype == "Data" and not (docfield.oldfieldtype and docfield.oldfieldtype != "Data"):
if docfield.options and (docfield.options not in data_field_options):
df_str = frappe.bold(_(docfield.label))
text_str = _("{0} is an invalid Data field.").format(df_str) + "<br>" * 2 + _("Only Options allowed for Data field are:") + "<br>"

View file

@ -551,6 +551,7 @@ def update_password(new_password, logout_all_sessions=0, key=None, old_password=
res = _get_user_for_update_password(key, old_password)
if res.get('message'):
frappe.local.response.http_status_code = 410
return res['message']
else:
user = res['user']
@ -718,7 +719,7 @@ def _get_user_for_update_password(key, old_password):
user = frappe.db.get_value("User", {"reset_password_key": key})
if not user:
return {
'message': _("Cannot Update: Incorrect / Expired Link.")
'message': _("The Link specified has either been used before or Invalid")
}
elif old_password:

View file

@ -565,10 +565,14 @@ class BaseDocument(object):
for data_field in self.meta.get_data_fields():
data = self.get(data_field.fieldname)
data_field_options = data_field.get("options")
old_fieldtype = data_field.get("oldfieldtype")
if old_fieldtype and old_fieldtype != "Data":
continue
if data_field_options == "Email":
if (self.owner in STANDARD_USERS) and (data in STANDARD_USERS):
return
continue
for email_address in frappe.utils.split_emails(data):
frappe.utils.validate_email_address(email_address, throw=True)

View file

@ -9,7 +9,7 @@
<span class='indicator blue password-box'>{{ _("Reset Password") if frappe.db.get_default('company') else _("Set Password")}}</span>
</div>
<form id="reset-password">
<div class="form-group">
<div class="form-group" style="display: none;">
<input id="old_password" type="password"
class="form-control" placeholder="{{ _("Old Password") }}">
</div>
@ -32,8 +32,8 @@
<script>
frappe.ready(function() {
if(frappe.utils.get_url_arg("key")) {
$("#old_password").parent().toggle(false);
if(!frappe.utils.get_url_arg("key")) {
$("#old_password").parent().toggle();
}
if(frappe.utils.get_url_arg("password_expired")) {
@ -57,12 +57,10 @@ frappe.ready(function() {
}
if(!args.old_password && !args.key) {
frappe.msgprint("{{ _("Old Password Required.") }}");
return;
frappe.msgprint(__("Old Password Required."));
}
if(!args.new_password) {
frappe.msgprint("{{ _("New Password Required.") }}");
return;
frappe.msgprint(__("New Password Required."));
}
frappe.call({
type: "POST",
@ -71,19 +69,24 @@ frappe.ready(function() {
args: args,
statusCode: {
401: function() {
$('.page-card-head .indicator').removeClass().addClass('indicator red')
.text("{{ _('Invalid Password') }}");
$(".page-card-head .indicator").removeClass().addClass("indicator red").text(__("Invalid Password"));
},
410: function({ responseJSON }) {
const title = __("Invalid Link");
const message = responseJSON.message;
$(".page-card-head .indicator").removeClass().addClass("indicator grey").text(title);
frappe.msgprint({ title: title, message: message, clear: true });
},
200: function(r) {
$("input").val("");
strength_indicator.addClass('hidden');
strength_message.addClass('hidden');
$('.page-card-head .indicator')
.removeClass().addClass('indicator green')
.html("{{ _('Password Updated') }}");
strength_indicator.addClass("hidden");
strength_message.addClass("hidden");
$(".page-card-head .indicator")
.removeClass().addClass("indicator blue")
.html(__("Status Updated"));
if(r.message) {
frappe.msgprint({
message: "{{ _("Password Updated") }}",
message: __("Password Updated"),
// password is updated successfully
// clear any server message
clear: true