[fix] Prompt naming and add-system-manager --send-welcome-email
This commit is contained in:
parent
3dd929c81e
commit
26eafaec13
4 changed files with 11 additions and 8 deletions
|
|
@ -260,6 +260,7 @@ def msgprint(msg, title=None, raise_exception=0, as_table=False, indicator=None,
|
|||
if flags.rollback_on_exception:
|
||||
db.rollback()
|
||||
import inspect
|
||||
|
||||
if inspect.isclass(raise_exception) and issubclass(raise_exception, Exception):
|
||||
raise raise_exception, encode(msg)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -138,14 +138,15 @@ def list_apps(context):
|
|||
@click.argument('email')
|
||||
@click.option('--first-name')
|
||||
@click.option('--last-name')
|
||||
@click.option('--send-welcome-email', default=False, is_flag=True)
|
||||
@pass_context
|
||||
def add_system_manager(context, email, first_name, last_name):
|
||||
def add_system_manager(context, email, first_name, last_name, send_welcome_email):
|
||||
"Add a new system manager to a site"
|
||||
import frappe.utils.user
|
||||
for site in context.sites:
|
||||
frappe.connect(site=site)
|
||||
try:
|
||||
frappe.utils.user.add_system_manager(email, first_name, last_name)
|
||||
frappe.utils.user.add_system_manager(email, first_name, last_name, send_welcome_email)
|
||||
frappe.db.commit()
|
||||
finally:
|
||||
frappe.destroy()
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ def set_new_name(doc):
|
|||
|
||||
doc.run_method("before_naming")
|
||||
|
||||
autoname = frappe.get_meta(doc.doctype).autoname
|
||||
autoname = frappe.get_meta(doc.doctype).autoname or ""
|
||||
|
||||
if autoname != "Prompt" and not frappe.flags.in_import:
|
||||
if autoname.lower() != "prompt" and not frappe.flags.in_import:
|
||||
doc.name = None
|
||||
|
||||
if getattr(doc, "amended_from", None):
|
||||
|
|
@ -48,10 +48,10 @@ def set_new_name(doc):
|
|||
set_name_by_naming_series(doc)
|
||||
elif "#" in autoname:
|
||||
doc.name = make_autoname(autoname)
|
||||
elif autoname=='Prompt':
|
||||
elif autoname.lower()=='prompt':
|
||||
# set from __newname in save.py
|
||||
if not doc.name:
|
||||
frappe.throw(_("Name not set via Prompt"))
|
||||
frappe.throw(_("Name not set via prompt"))
|
||||
|
||||
if not doc.name or autoname=='hash':
|
||||
doc.name = make_autoname('hash', doc.doctype)
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ def get_system_managers(only_name=False):
|
|||
def add_role(user, role):
|
||||
frappe.get_doc("User", user).add_roles(role)
|
||||
|
||||
def add_system_manager(email, first_name=None, last_name=None):
|
||||
def add_system_manager(email, first_name=None, last_name=None, send_welcome_email=False):
|
||||
# add user
|
||||
user = frappe.new_doc("User")
|
||||
user.update({
|
||||
|
|
@ -253,7 +253,8 @@ def add_system_manager(email, first_name=None, last_name=None):
|
|||
"enabled": 1,
|
||||
"first_name": first_name or email,
|
||||
"last_name": last_name,
|
||||
"user_type": "System User"
|
||||
"user_type": "System User",
|
||||
"send_welcome_email": 1 if send_welcome_email else 0
|
||||
})
|
||||
user.insert()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue