mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Added createsuperuser function, & execute it from configure. This
enables docker users to access the django administration site without requiring access to a cli
This commit is contained in:
10
configure
vendored
10
configure
vendored
@@ -1,7 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
from pathlib import Path
|
||||
from django.core.management.utils import get_random_secret_key
|
||||
from src.backend.lib.pyShelf import Admin
|
||||
|
||||
|
||||
def load_config():
|
||||
with open('config.json',"r") as file:
|
||||
@@ -9,11 +13,13 @@ def load_config():
|
||||
file.close()
|
||||
return config
|
||||
|
||||
|
||||
def write_config(config):
|
||||
with open('config.json',"w") as file:
|
||||
json.dump(config, file)
|
||||
file.close()
|
||||
|
||||
|
||||
def set_secret(config=load_config()):
|
||||
if config["SECRET"] == "":
|
||||
config["SECRET"] = get_random_secret_key()
|
||||
@@ -22,4 +28,6 @@ def set_secret(config=load_config()):
|
||||
else:
|
||||
print(config["SECRET"])
|
||||
|
||||
|
||||
set_secret()
|
||||
Admin(Path.cwd()).createsuperuser()
|
||||
|
||||
Reference in New Issue
Block a user