mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
user imports: misc formating, comments
This commit is contained in:
parent
1b57435910
commit
b1102ba56e
2 changed files with 9 additions and 5 deletions
|
@ -638,7 +638,7 @@
|
||||||
"user_import_partial_failed": "The users import operation partially failed",
|
"user_import_partial_failed": "The users import operation partially failed",
|
||||||
"user_import_failed": "The users import operation completely failed",
|
"user_import_failed": "The users import operation completely failed",
|
||||||
"user_import_nothing_to_do": "No user needs to be imported",
|
"user_import_nothing_to_do": "No user needs to be imported",
|
||||||
"user_import_success": "Users have been imported",
|
"user_import_success": "Users successfully imported",
|
||||||
"yunohost_already_installed": "YunoHost is already installed",
|
"yunohost_already_installed": "YunoHost is already installed",
|
||||||
"yunohost_configured": "YunoHost is now configured",
|
"yunohost_configured": "YunoHost is now configured",
|
||||||
"yunohost_installing": "Installing YunoHost...",
|
"yunohost_installing": "Installing YunoHost...",
|
||||||
|
|
|
@ -96,11 +96,11 @@ def user_list(fields=None):
|
||||||
users = {}
|
users = {}
|
||||||
|
|
||||||
if not fields:
|
if not fields:
|
||||||
fields = ['username', 'fullname', 'mail', 'mailbox-quota', 'shell']
|
fields = ['username', 'fullname', 'mail', 'mailbox-quota']
|
||||||
|
|
||||||
for field in fields:
|
for field in fields:
|
||||||
if field in ldap_attrs:
|
if field in ldap_attrs:
|
||||||
attrs |= set([ldap_attrs[field]])
|
attrs.add(ldap_attrs[field])
|
||||||
else:
|
else:
|
||||||
raise YunohostError('field_invalid', field)
|
raise YunohostError('field_invalid', field)
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ def user_create(
|
||||||
# Attempt to create user home folder
|
# Attempt to create user home folder
|
||||||
subprocess.check_call(["mkhomedir_helper", username])
|
subprocess.check_call(["mkhomedir_helper", username])
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
home = '/home/{0}'.format(username)
|
home = f'/home/{username}'
|
||||||
if not os.path.isdir(home):
|
if not os.path.isdir(home):
|
||||||
logger.warning(m18n.n('user_home_creation_failed', home=home),
|
logger.warning(m18n.n('user_home_creation_failed', home=home),
|
||||||
exc_info=1)
|
exc_info=1)
|
||||||
|
@ -427,8 +427,10 @@ def user_update(
|
||||||
main_domain = _get_maindomain()
|
main_domain = _get_maindomain()
|
||||||
aliases = [alias + main_domain for alias in FIRST_ALIASES]
|
aliases = [alias + main_domain for alias in FIRST_ALIASES]
|
||||||
|
|
||||||
|
# If the requested mail address is already as main address or as an alias by this user
|
||||||
if mail in user['mail']:
|
if mail in user['mail']:
|
||||||
user['mail'].remove(mail)
|
user['mail'].remove(mail)
|
||||||
|
# Othewise, check that this mail address is not already used by this user
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
ldap.validate_uniqueness({'mail': mail})
|
ldap.validate_uniqueness({'mail': mail})
|
||||||
|
@ -445,6 +447,7 @@ def user_update(
|
||||||
if not isinstance(add_mailalias, list):
|
if not isinstance(add_mailalias, list):
|
||||||
add_mailalias = [add_mailalias]
|
add_mailalias = [add_mailalias]
|
||||||
for mail in add_mailalias:
|
for mail in add_mailalias:
|
||||||
|
# (c.f. similar stuff as before)
|
||||||
if mail in user["mail"]:
|
if mail in user["mail"]:
|
||||||
user["mail"].remove(mail)
|
user["mail"].remove(mail)
|
||||||
else:
|
else:
|
||||||
|
@ -647,7 +650,7 @@ def user_import(operation_logger, csvfile, update=False, delete=False):
|
||||||
Import users from CSV
|
Import users from CSV
|
||||||
|
|
||||||
Keyword argument:
|
Keyword argument:
|
||||||
csv -- CSV file with columns username;firstname;lastname;password;mailbox_quota;mail;alias;forward;groups
|
csvfile -- CSV file with columns username;firstname;lastname;password;mailbox_quota;mail;alias;forward;groups
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -655,6 +658,7 @@ def user_import(operation_logger, csvfile, update=False, delete=False):
|
||||||
from moulinette.utils.text import random_ascii
|
from moulinette.utils.text import random_ascii
|
||||||
from yunohost.permission import permission_sync_to_user
|
from yunohost.permission import permission_sync_to_user
|
||||||
from yunohost.app import app_ssowatconf
|
from yunohost.app import app_ssowatconf
|
||||||
|
|
||||||
# Pre-validate data and prepare what should be done
|
# Pre-validate data and prepare what should be done
|
||||||
actions = {
|
actions = {
|
||||||
'created': [],
|
'created': [],
|
||||||
|
|
Loading…
Add table
Reference in a new issue