fix tworzenie admina
This commit is contained in:
parent
6bd6284f49
commit
79d777d9b3
10
app.py
10
app.py
@ -58,6 +58,7 @@ class Wplata(db.Model):
|
|||||||
def load_user(user_id):
|
def load_user(user_id):
|
||||||
return User.query.get(int(user_id))
|
return User.query.get(int(user_id))
|
||||||
|
|
||||||
|
|
||||||
# Dodaj filtr Markdown – pozwala na zagnieżdżanie linków i obrazków w opisie
|
# Dodaj filtr Markdown – pozwala na zagnieżdżanie linków i obrazków w opisie
|
||||||
@app.template_filter('markdown')
|
@app.template_filter('markdown')
|
||||||
def markdown_filter(text):
|
def markdown_filter(text):
|
||||||
@ -255,6 +256,15 @@ def toggle_visibility(zbiorka_id):
|
|||||||
flash('Zbiórka została ' + ('ukryta' if zb.ukryta else 'przywrócona'), 'success')
|
flash('Zbiórka została ' + ('ukryta' if zb.ukryta else 'przywrócona'), 'success')
|
||||||
return redirect(url_for('admin_dashboard'))
|
return redirect(url_for('admin_dashboard'))
|
||||||
|
|
||||||
|
def create_admin_account():
|
||||||
|
admin = User.query.filter_by(is_admin=True).first()
|
||||||
|
if not admin:
|
||||||
|
main_admin = User(username=app.config['MAIN_ADMIN_USERNAME'], is_admin=True)
|
||||||
|
main_admin.set_password(app.config['MAIN_ADMIN_PASSWORD'])
|
||||||
|
db.session.add(main_admin)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
from app import app, db
|
from app import app, db, create_admin_account
|
||||||
from waitress import serve
|
from waitress import serve
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
db.create_all()
|
db.create_all()
|
||||||
serve(app, host='0.0.0.0', port=8080)
|
create_admin_account()
|
||||||
|
serve(app, host='0.0.0.0', port=8080)
|
Loading…
x
Reference in New Issue
Block a user