Example #1
0
import os
import settings
from datetime import date, timedelta
from flask import Flask, request, session
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.markdown import Markdown
from standup.errors import register_error_handlers
from standup.filters import register_filters

app = Flask(__name__)
app.debug = getattr(settings, "DEBUG", False)
app.config["SITE_TITLE"] = getattr(settings, "SITE_TITLE", "Standup")
app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get("DATABASE_URL", "sqlite:///standup_app.db")
app.secret_key = settings.SESSION_SECRET
db = SQLAlchemy(app)
Markdown(app)

# Register error handlers
register_error_handlers(app)

# Register template filters
register_filters(app)

# Register blueprints
for blueprint in settings.BLUEPRINTS:
    app.register_blueprint(getattr(__import__(blueprint, fromlist=["blueprint"]), "blueprint"))


@app.context_processor
def inject_page():
    return dict(page=int(request.args.get("page", 1)))
Example #2
0
app = Flask(__name__)

app.config["DEBUG"] = True

app.config["MONGODB_SETTINGS"] = {
    "DB": os.environ.get("OPENSHIFT_APP_NAME"),
    "HOST": os.environ.get("OPENSHIFT_MONGODB_DB_URL"),
    "PORT": int(os.environ.get("OPENSHIFT_MONGODB_DB_PORT")),
    "USERNAME": os.environ.get("OPENSHIFT_MONGODB_DB_USERNAME"),
    "PASSWORD": os.environ.get("OPENSHIFT_MONGODB_DB_PASSWORD")
}

app.config["SECRET_KEY"] = os.environ.get("SECRET_KEY")

app.config["SITE_TITLE"] = "PythonRS"
app.config["SITE_SUBTITLE"] = "Programando Python no Rio Grande do Sul"
app.config["POSTS_PER_PAGE"] = 7

db = MongoEngine(app)

lm = LoginManager()
lm.init_app(app)

# Create customized index view class
class AuthAdminIndexView(admin.AdminIndexView):

    @expose('/')
    def index(self):
        if not current_user.is_authenticated():
            return redirect(url_for('.login_view'))