mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[wip] Import users from csv
This commit is contained in:
parent
fdc2337e0f
commit
2ae0ec46f4
1 changed files with 20 additions and 1 deletions
|
@ -588,7 +588,7 @@ def user_import(operation_logger, csv, update=False, delete=False):
|
|||
existing_users = user_list()['users'].keys()
|
||||
reader = csv.DictReader(csv, delimiter=';', quotechar='"')
|
||||
for user in reader:
|
||||
if user['username']:#TODO better check
|
||||
if re.match(r'^[a-z0-9_]+$', user['username']:#TODO better check
|
||||
logger.error(m18n.n('user_import_bad_line', line=reader.line_num))
|
||||
is_well_formatted = False
|
||||
continue
|
||||
|
@ -636,6 +636,7 @@ def user_import(operation_logger, csv, update=False, delete=False):
|
|||
except Exception as e:
|
||||
on_failure(user['username'], e)
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
if update:
|
||||
for user in actions['updated']:
|
||||
try:
|
||||
|
@ -654,6 +655,24 @@ def user_import(operation_logger, csv, update=False, delete=False):
|
|||
result['deleted'] += 1
|
||||
except Exception as e:
|
||||
on_failure(user, e)
|
||||
=======
|
||||
for user in actions['updated']:
|
||||
try:
|
||||
user_update(operation_logger, user['username'],
|
||||
user['firstname'], user['lastname'],
|
||||
user['mail'], user['password'],
|
||||
mailbox_quota=user['mailbox_quota'])
|
||||
result['updated'] += 1
|
||||
except Exception as e:
|
||||
on_failure(user['username'], e)
|
||||
|
||||
for user in actions['deleted']:
|
||||
try:
|
||||
user_delete(operation_logger, user, purge=True)
|
||||
result['deleted'] += 1
|
||||
except Exception as e:
|
||||
on_failure(user, e)
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
if result['errors']:
|
||||
msg = m18n.n('user_import_partial_failed')
|
||||
|
|
Loading…
Add table
Reference in a new issue