Cosas .w. se me fue la odna creo
This commit is contained in:
@@ -7,8 +7,9 @@ from werkzeug.wsgi import SharedDataMiddleware
|
||||
def create_app():
|
||||
app = Flask(__name__, instance_relative_config=True)
|
||||
app.config.from_mapping(
|
||||
SQLALCHEMY_DATABASE_URI=os.environ.get("SQLALCHEMY_DATABASE_URI"),
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS=os.environ.get("SQLALCHEMY_TRACK_MODIFICATIONS"),
|
||||
SQLALCHEMY_DATABASE_URI=os.environ.get("DATABASE_URI"),
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS=os.environ.get("TRACK_MODIFICATIONS"),
|
||||
SQLALCHEMY_POOL_RECYCLE=os.environ.get("POOL_RECYCLE"),
|
||||
USERNAME=os.environ.get("USERNAME"),
|
||||
PASSWORD=os.environ.get("PASSWORD"),
|
||||
SECRET_KEY=os.environ.get("SECRET_KEY"),
|
||||
@@ -18,11 +19,6 @@ def create_app():
|
||||
app.wsgi_app = SharedDataMiddleware(
|
||||
app.wsgi_app, {'/uploads': app.config['UPLOAD_FOLDER']})
|
||||
|
||||
try:
|
||||
os.makedirs(app.instance_path)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
from files.models import db
|
||||
db.init_app(app)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from flask import Blueprint, flash, request, redirect, url_for, render_template
|
||||
from flask import Blueprint, render_template
|
||||
from files.auth import admin_required
|
||||
from files.models import Category, FileType
|
||||
from files.models import Category, FileType
|
||||
|
||||
bp = Blueprint('admin', __name__, url_prefix='/admin')
|
||||
|
||||
|
||||
@@ -71,6 +71,15 @@ def init_db_command():
|
||||
add_defaults()
|
||||
add_files()
|
||||
|
||||
@click.command('generate-admin')
|
||||
@with_appcontext
|
||||
def generate_admin_command():
|
||||
"""
|
||||
Generates an account
|
||||
"""
|
||||
generate_admin()
|
||||
|
||||
|
||||
def init_app(app):
|
||||
app.cli.add_command(generate_admin_command)
|
||||
app.cli.add_command(init_db_command)
|
||||
|
||||
@@ -150,18 +150,19 @@ def preview_file(file_id):
|
||||
categories=categories,
|
||||
file_types=file_types,
|
||||
content=content)
|
||||
elif file.type.name == 'Image':
|
||||
|
||||
if file.type.name == 'Image':
|
||||
return render_template(
|
||||
'files/preview/image.html',
|
||||
file=file,
|
||||
categories=categories,
|
||||
file_types=file_types)
|
||||
else:
|
||||
return render_template(
|
||||
'files/preview/default.html',
|
||||
file=file,
|
||||
categories=categories,
|
||||
file_types=file_types)
|
||||
|
||||
return render_template(
|
||||
'files/preview/default.html',
|
||||
file=file,
|
||||
categories=categories,
|
||||
file_types=file_types)
|
||||
|
||||
return abort(404)
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class Message(db.Model):
|
||||
name = db.Column(db.String(255), nullable=False)
|
||||
email = db.Column(db.String(255), nullable=False)
|
||||
message = db.Column(db.Text, nullable=False)
|
||||
sended = db.Column(db.DateTime, default=datetime.utcnow())
|
||||
sended = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
|
||||
def __init__(self, name=None, email=None, message=None):
|
||||
self.name = name
|
||||
|
||||
Reference in New Issue
Block a user