Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
b5d7a16f
Commit
b5d7a16f
authored
May 06, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add management command to import list of users
parent
340401e0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
0 deletions
+58
-0
accounts/management/commands/importusers.py
accounts/management/commands/importusers.py
+49
-0
docs/install.rst
docs/install.rst
+2
-0
docs/management.rst
docs/management.rst
+7
-0
No files found.
accounts/management/commands/importusers.py
0 → 100644
View file @
b5d7a16f
# -*- coding: utf-8 -*-
#
# Copyright © 2012 - 2013 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <http://weblate.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.contrib.auth.models
import
Group
,
Permission
,
User
import
json
class
Command
(
BaseCommand
):
help
=
'imports users from JSON dump of database'
def
handle
(
self
,
*
args
,
**
options
):
'''
Creates default set of groups and optionally updates them and moves
users around to default group.
'''
if
len
(
args
)
!=
1
:
raise
CommandError
(
'Please specify JSON file to import!'
)
data
=
json
.
load
(
open
(
args
[
0
]))
for
line
in
data
:
if
User
.
objects
.
filter
(
username
=
line
[
'username'
]).
exists
():
print
'Skipping %s'
%
line
[
'username'
]
continue
User
.
objects
.
create
(
username
=
line
[
'username'
],
first_name
=
line
[
'first_name'
],
last_name
=
line
[
'last_name'
],
password
=
line
[
'password'
],
email
=
line
[
'email'
]
)
docs/install.rst
View file @
b5d7a16f
...
...
@@ -534,3 +534,5 @@ As Weblate was originally written as replacement from Pootle, it is supported
to migrate user accounts from Pootle. All you need to do is to copy
``auth_user`` table from Pootle, user profiles will be automatically created
for users as they log in and they will be asked to update their settings.
Alternatively you can use :djadmin:`importusers` to import dumped user
credentials.
docs/management.rst
View file @
b5d7a16f
...
...
@@ -87,6 +87,13 @@ For example:
./manage.py import_project debian-handbook git://anonscm.debian.org/debian-handbook/debian-handbook.git squeeze/master '*/**.po'
importusers <file.json>
-----------------------
.. django-admin:: importusers
Imports users from JSON dump of Django auth_users database.
loadpo <project|project/subproject>
-----------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment