mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-14 05:55:06 +00:00
New user login/logoff system using standard Dj
This commit is contained in:
@@ -6,7 +6,6 @@ import json
|
||||
import resource
|
||||
|
||||
import settings
|
||||
import credentials
|
||||
""" Command-line utility for loading cave data files into troggle's database.
|
||||
|
||||
The command line options select which combination of classes of data will be imported,
|
||||
@@ -56,9 +55,13 @@ if os.geteuid() == 0:
|
||||
exit()
|
||||
|
||||
expouser=settings.EXPOUSER
|
||||
expouserpass=credentials.EXPOUSERPASS
|
||||
expouserpass=settings.EXPOUSERPASS
|
||||
expouseremail=settings.EXPOUSER_EMAIL
|
||||
|
||||
expoadminuser=settings.EXPOADMINUSER
|
||||
expoadminuserpass=settings.EXPOADMINUSERPASS
|
||||
expoadminuseremail=settings.EXPOADMINUSER_EMAIL
|
||||
|
||||
def reinit_db():
|
||||
"""Rebuild database from scratch. Deletes the file first if sqlite is used,
|
||||
otherwise it drops the database and creates it.
|
||||
@@ -109,9 +112,28 @@ def reinit_db():
|
||||
print("users in db already: ",len(User.objects.all()))
|
||||
with transaction.atomic():
|
||||
try:
|
||||
print(" - Setting up admin user on: " + django.db.connections.databases['default']['NAME'])
|
||||
print(" - Setting up expo user on: " + django.db.connections.databases['default']['NAME'])
|
||||
print(" - user: {} ({:.5}...) <{}> ".format(expouser, expouserpass, expouseremail))
|
||||
user = User.objects.create_user(expouser, expouseremail, expouserpass)
|
||||
user.is_staff = False
|
||||
user.is_superuser = False
|
||||
user.save()
|
||||
except:
|
||||
print(" ! INTEGRITY ERROR user on: " + settings.DATABASES['default']['NAME'])
|
||||
print(django.db.connections.databases['default']['NAME'])
|
||||
print(" ! You probably have not got a clean db when you thought you had.\n")
|
||||
print(" ! Also you are probably NOT running an in-memory db now.\n")
|
||||
print("users in db: ",len(User.objects.all()))
|
||||
print("tables in db: ",len(connection.introspection.table_names()))
|
||||
memdumpsql(fn='integrityfail.sql')
|
||||
django.db.connections.databases['default']['NAME'] = ':memory:'
|
||||
#raise
|
||||
|
||||
with transaction.atomic():
|
||||
try:
|
||||
print(" - Setting up expoadmin user on: " + django.db.connections.databases['default']['NAME'])
|
||||
print(" - user: {} ({:.5}...) <{}> ".format(expoadminuser, expoadminuserpass, expoadminuseremail))
|
||||
user = User.objects.create_user(expoadminuser, expoadminuseremail, expoadminuserpass)
|
||||
user.is_staff = True
|
||||
user.is_superuser = True
|
||||
user.save()
|
||||
|
||||
Reference in New Issue
Block a user