generated from moevm/nsql-clean-tempate
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from moevm/test-users
Test users
- Loading branch information
Showing
4 changed files
with
61 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from werkzeug.local import LocalProxy | ||
from flask import current_app as app | ||
from app.db import get_db | ||
|
||
db = LocalProxy(get_db) | ||
|
||
|
||
def get_admin(): | ||
admin = db.users.find_one({"login": app.config.get('INIT_ADMIN_LOGIN')}) | ||
if not admin: | ||
result = db.users.insert_one({ | ||
'login': app.config.get('INIT_ADMIN_LOGIN'), | ||
'password': app.config.get('INIT_ADMIN_PASSWORD'), | ||
'name': 'root', | ||
'role': 'admin' | ||
}) | ||
admin = db.users.find_one(result.inserted_id) | ||
return admin | ||
|
||
|
||
def get_test_user(): | ||
user = db.users.find_one({"login": 'user'}) | ||
if not user: | ||
result = db.users.insert_one({ | ||
'login': 'user', | ||
'password': '1234', | ||
'name': 'Ivan', | ||
'role': 'user' | ||
}) | ||
user = db.users.find_one(result.inserted_id) | ||
return user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters