Exemplo n.º 1
0
    def setUp(self):
        app = create_app({
            'SQLALCHEMY_DATABASE_URI': DATABASE,
            'ZERQU_CACHE_TYPE': 'simple',
            'OAUTH_CACHE_TYPE': 'simple',
            'RATE_LIMITER_TYPE': 'cache',
            'SECRET_KEY': 'secret',
        })
        app.testing = True
        self._ctx = app.app_context()
        self._ctx.push()

        db.init_app(app)

        db.drop_all()
        db.create_all()

        self.app = app
        self.client = app.test_client()
        self.prepare_data()
Exemplo n.º 2
0
    def setUp(self):
        app = create_app(
            {
                "SQLALCHEMY_DATABASE_URI": DATABASE,
                "ZERQU_CACHE_TYPE": "simple",
                "OAUTH_CACHE_TYPE": "simple",
                "RATE_LIMITER_TYPE": "cache",
                "SECRET_KEY": "secret",
            }
        )
        app.testing = True
        self._ctx = app.app_context()
        self._ctx.push()

        db.init_app(app)

        db.drop_all()
        db.create_all()

        self.app = app
        self.client = app.test_client()
        self.prepare_data()
Exemplo n.º 3
0
# coding: utf-8
from __future__ import print_function
import os

from flask.ext.script import Manager

from zerqu import create_app
from zerqu.models.base import db
from zerqu.models.user import User


CONFIG = os.path.abspath('./local_config.py')

app = create_app(CONFIG)
manager = Manager(app)


@manager.command
def adduser(username, password, role=User.ROLE_ACTIVE, **kwargs):
    """Used to add new user into database.
    Usage::
        $ python manage.py adduser YOUR_USERNAME YOUR_PASSWORD [--role=YOUR_ROLE]

    :param username: requied as username of new user.
    :param password: requied as password of new user.
    :param role: role of new user which should be 1, 4, 7, 8, 9 or -4.
                 Greater indicates more powerful.
    """
    userdata = dict(username=username, password=password, role=role)
    userdata.update(kwargs)
    user = User(**userdata)
Exemplo n.º 4
0
# coding: utf-8
from __future__ import print_function
import os

from flask.ext.script import Manager

from zerqu import create_app
from zerqu.models.base import db
from zerqu.models.user import User

CONFIG = os.path.abspath('./local_config.py')

app = create_app(CONFIG)
manager = Manager(app)


@manager.command
def adduser(username, password, role=User.ROLE_ACTIVE, **kwargs):
    """Used to add new user into database.
    Usage::
        $ python manage.py adduser YOUR_USERNAME YOUR_PASSWORD [--role=YOUR_ROLE]

    :param username: requied as username of new user.
    :param password: requied as password of new user.
    :param role: role of new user which should be 1, 4, 7, 8, 9 or -4.
                 Greater indicates more powerful.
    """
    userdata = dict(username=username, password=password, role=role)
    userdata.update(kwargs)
    user = User(**userdata)
Exemplo n.º 5
0
# coding: utf-8
from werkzeug.contrib.fixers import ProxyFix
from flask import redirect
from zerqu import create_app
from zerqu.ext.sentry import FlaskSentry
app = create_app()
FlaskSentry(app, logging=False, wrap_wsgi=False)
app.wsgi_app = ProxyFix(app.wsgi_app)


@app.route('/topic/<int:tid>')
def redirect_topic(tid):
    return redirect('/t/%d' % tid, code=301)


@app.route('/node/')
def redirect_node_list():
    return redirect('/c/', code=301)


@app.route('/node/<slug>')
def redirect_node(slug):
    return redirect('/c/%s' % slug, code=301)


@app.route('/user/<name>')
@app.route('/user/<name>/topics')
@app.route('/member/<name>')
@app.route('/~<name>')
def redirect_user(name):
    return redirect('/u/%s' % name.lower(), code=301)
Exemplo n.º 6
0
# coding: utf-8

import sys
import logging
from zerqu import create_app
from zerqu.models import db

app = create_app({'DEBUG': True})


def show_verbose_log():
    formatter = logging.Formatter(
        '[%(levelname)s %(funcName)s %(filename)s:%(lineno)d]: %(message)s')
    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(formatter)

    log = logging.getLogger('flask_oauthlib')
    log.addHandler(handler)
    log.setLevel(logging.DEBUG)

    log = logging.getLogger('oauthlib')
    log.addHandler(handler)
    log.setLevel(logging.DEBUG)


def create_database():
    import fixtures
    with app.app_context():
        db.drop_all()
        db.create_all()
        fixtures.run()
Exemplo n.º 7
0
# coding: utf-8

import sys
import logging
from zerqu import create_app
from zerqu.models import db


app = create_app({'DEBUG': True})


def show_verbose_log():
    formatter = logging.Formatter(
        '[%(levelname)s %(funcName)s %(filename)s:%(lineno)d]: %(message)s'
    )
    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(formatter)

    log = logging.getLogger('flask_oauthlib')
    log.addHandler(handler)
    log.setLevel(logging.DEBUG)

    log = logging.getLogger('oauthlib')
    log.addHandler(handler)
    log.setLevel(logging.DEBUG)


def create_database():
    import fixtures
    with app.app_context():
        db.drop_all()