Merge branch 'develop' into date-field-fix
This commit is contained in:
commit
fe607f6e44
4 changed files with 48 additions and 26 deletions
|
|
@ -28,6 +28,7 @@ from frappe.utils import (
|
|||
now_datetime,
|
||||
today,
|
||||
)
|
||||
from frappe.utils.deprecations import deprecated
|
||||
from frappe.utils.password import check_password, get_password_reset_limit
|
||||
from frappe.utils.password import update_password as _update_password
|
||||
from frappe.utils.user import get_system_managers
|
||||
|
|
@ -75,6 +76,7 @@ class User(Document):
|
|||
self.validate_email_type(self.email)
|
||||
self.validate_email_type(self.name)
|
||||
self.add_system_manager_role()
|
||||
self.populate_role_profile_roles()
|
||||
self.check_roles_added()
|
||||
self.set_system_user()
|
||||
self.set_full_name()
|
||||
|
|
@ -85,7 +87,6 @@ class User(Document):
|
|||
self.remove_disabled_roles()
|
||||
self.validate_user_email_inbox()
|
||||
ask_pass_update()
|
||||
self.validate_roles()
|
||||
self.validate_allowed_modules()
|
||||
self.validate_user_image()
|
||||
self.set_time_zone()
|
||||
|
|
@ -98,12 +99,16 @@ class User(Document):
|
|||
):
|
||||
self.set_social_login_userid("frappe", frappe.generate_hash(length=39))
|
||||
|
||||
def validate_roles(self):
|
||||
def populate_role_profile_roles(self):
|
||||
if self.role_profile_name:
|
||||
role_profile = frappe.get_doc("Role Profile", self.role_profile_name)
|
||||
self.set("roles", [])
|
||||
self.append_roles(*[role.role for role in role_profile.roles])
|
||||
|
||||
@deprecated
|
||||
def validate_roles(self):
|
||||
self.populate_role_profile_roles()
|
||||
|
||||
def validate_allowed_modules(self):
|
||||
if self.module_profile:
|
||||
module_profile = frappe.get_doc("Module Profile", self.module_profile)
|
||||
|
|
|
|||
|
|
@ -573,18 +573,17 @@ class CustomizeForm(Document):
|
|||
if not self.doc_type:
|
||||
return
|
||||
|
||||
property_setter = frappe.db.get_value(
|
||||
property_setters = frappe.get_all(
|
||||
"Property Setter",
|
||||
filters={
|
||||
"doc_type": self.doc_type,
|
||||
"property": "field_order",
|
||||
},
|
||||
filters={"doc_type": self.doc_type, "property": ("in", ("field_order", "insert_after"))},
|
||||
pluck="name",
|
||||
)
|
||||
|
||||
if not property_setter:
|
||||
if not property_setters:
|
||||
return
|
||||
|
||||
frappe.delete_doc("Property Setter", property_setter)
|
||||
frappe.db.delete("Property Setter", {"name": ("in", property_setters)})
|
||||
frappe.clear_cache(doctype=self.doc_type)
|
||||
self.fetch_to_customize()
|
||||
|
||||
@classmethod
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ def get_point_logs(doctype, docname):
|
|||
)
|
||||
|
||||
|
||||
def _get_communications(doctype, name, start=0, limit=20):
|
||||
def _get_communications(doctype, name, start=0, limit=100):
|
||||
communications = get_communication_data(doctype, name, start, limit)
|
||||
for c in communications:
|
||||
if c.communication_type == "Communication":
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
import os
|
||||
|
||||
import click
|
||||
|
||||
import frappe
|
||||
from frappe.core.doctype.data_import.data_import import export_json, import_doc
|
||||
|
||||
|
|
@ -17,29 +19,45 @@ def sync_fixtures(app=None):
|
|||
frappe.flags.in_fixtures = True
|
||||
|
||||
for app in apps:
|
||||
fixtures_path = frappe.get_app_path(app, "fixtures")
|
||||
if os.path.exists(fixtures_path):
|
||||
import_doc(fixtures_path)
|
||||
|
||||
import_fixtures(app)
|
||||
import_custom_scripts(app)
|
||||
|
||||
frappe.flags.in_fixtures = False
|
||||
|
||||
|
||||
def import_fixtures(app):
|
||||
fixtures_path = frappe.get_app_path(app, "fixtures")
|
||||
if not os.path.exists(fixtures_path):
|
||||
return
|
||||
|
||||
fixture_files = os.listdir(fixtures_path)
|
||||
|
||||
for fname in fixture_files:
|
||||
if not fname.endswith(".json"):
|
||||
continue
|
||||
|
||||
file_path = frappe.get_app_path(app, "fixtures", fname)
|
||||
try:
|
||||
import_doc(file_path)
|
||||
except (ImportError, frappe.DoesNotExistError) as e:
|
||||
# fixture syncing for missing doctypes
|
||||
print(f"Skipping fixture syncing from the file {fname}. Reason: {e}")
|
||||
|
||||
|
||||
def import_custom_scripts(app):
|
||||
"""Import custom scripts from `[app]/fixtures/custom_scripts`"""
|
||||
if os.path.exists(frappe.get_app_path(app, "fixtures", "custom_scripts")):
|
||||
for fname in os.listdir(frappe.get_app_path(app, "fixtures", "custom_scripts")):
|
||||
if fname.endswith(".js"):
|
||||
with open(frappe.get_app_path(app, "fixtures", "custom_scripts") + os.path.sep + fname) as f:
|
||||
doctype = fname.rsplit(".", 1)[0]
|
||||
script = f.read()
|
||||
if frappe.db.exists("Client Script", {"dt": doctype}):
|
||||
custom_script = frappe.get_doc("Client Script", {"dt": doctype})
|
||||
custom_script.script = script
|
||||
custom_script.save()
|
||||
else:
|
||||
frappe.get_doc({"doctype": "Client Script", "dt": doctype, "script": script}).insert()
|
||||
scripts_folder = frappe.get_app_path(app, "fixtures", "custom_scripts")
|
||||
if not os.path.exists(scripts_folder):
|
||||
return
|
||||
|
||||
for fname in os.listdir(scripts_folder):
|
||||
if not fname.endswith(".js"):
|
||||
continue
|
||||
|
||||
click.secho(
|
||||
f"Importing Client Script `{fname}` from `{scripts_folder}` is not supported. Convert the client script to fixture.",
|
||||
fg="red",
|
||||
)
|
||||
|
||||
|
||||
def export_fixtures(app=None):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue