Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Create and reset the admin user with a fixture

Roland Geider4d128bfe8f7d
diff --git a/wger/main.py b/wger/main.py
index 584775eb2..3d5525d9e 100755
--- a/wger/main.py
+++ b/wger/main.py
@@ -409,16 +409,9 @@ def create_or_reset_admin_user():
admin = User.objects.get(username="admin")
print("Password for user admin was reset to 'admin'")
except User.DoesNotExist:
- admin = User()
- admin.username = 'admin'
- admin.last_name = 'Administrator'
print("Created default admin user")
- admin.is_superuser = True
- admin.is_staff = True
- admin.default_password = 'admin'
- admin.set_password(admin.default_password)
- admin.save()
+ execute_from_command_line(["", "loaddata", "users"])
def start_wger(addr, port, start_browser_url=None, extra_args=[]):
diff --git a/wger/manager/fixtures/users.json b/wger/manager/fixtures/users.json
new file mode 100644
index 000000000..aaef3a967
--- /dev/null
+++ b/wger/manager/fixtures/users.json
@@ -0,0 +1,30 @@
+[
+ {
+ "pk": 1,
+ "model": "auth.user",
+ "fields": {
+ "username": "admin",
+ "first_name": "",
+ "last_name": "Administrator",
+ "is_active": true,
+ "is_superuser": true,
+ "is_staff": true,
+ "last_login": "2013-05-18T07:20:26.626Z",
+ "groups": [],
+ "user_permissions": [],
+ "password": "pbkdf2_sha256$10000$JHJGtYzk49FZ$n3oT+lcfGB3al1I8spSwo6JlJqu4rXwHHsPmeJup/z8=",
+ "email": "",
+ "date_joined": "2013-04-27T17:52:38.867Z"
+ }
+ },
+ {
+ "pk": 1,
+ "model": "manager.userprofile",
+ "fields": {
+ "is_temporary": false,
+ "show_comments": false,
+ "show_english_ingredients": false,
+ "user": 1
+ }
+ }
+]