Ejemplo n.º 1
0
        Field("post", "reference posts"),
        Field("text", "text"),
        Field("date", "datetime", default=lambda: request.now)
    ]
    visibility = {
        "author": (False, False),
        "post": (False, False),
        "date": (False, False)
    }
    validators = {
        "text": isntEmpty()
    }

#: init db and auth
db = DAL(app)
auth = Auth(app, db, usermodel=User)
db.define_models([Post, Comment])


#: setup helping function
def setup():
    # create the user
    user = db.User.validate_and_insert(
        email="*****@*****.**",
        first_name="Walter",
        last_name="Bishop",
        password="******"
    )
    # create an admin group
    admins = auth.add_group("admin")
    # add user to admins group
Ejemplo n.º 2
0
def auth(app, _db, mailer):
    auth = Auth(app, _db, user_model=User)
    app.pipeline.append(auth.pipe)
    authroutes = auth.module(__name__)
    return auth
Ejemplo n.º 3
0
## language settings
app.languages = ['en', 'it']
app.language_default = 'en'
app.language_force_on_url = True
app.language_write = True

## init database and auth
from models.user import User
from models.campaign import Campaign
from models.donation import Donation
from models.cost import Cost
## init auth before passing db models due to dependencies
## on auth tables in the other models
db = Database(app, auto_migrate=True)
auth = Auth(app, db, user_model=User)
# auth.settings.update(download_url='/download')
db.define_models(Campaign, Donation, Cost)

## adding sessions and authorization handlers
app.pipeline = [
    SessionManager.cookies('verySecretKey'),
    db.pipe,
    auth.pipe
]

## add esxtensions
from weppy_haml import Haml
from weppy_assets import Assets
from weppy_bs3 import BS3
app.config.Haml.set_as_default = True
Ejemplo n.º 4
0
## language settings
app.languages = ['en', 'it']
app.language_default = 'en'
app.language_force_on_url = True
app.language_write = True

## init database and auth
from models.user import User
from models.campaign import Campaign
from models.donation import Donation
from models.cost import Cost
## init auth before passing db models due to dependencies
## on auth tables in the other models
db = DAL(app)
auth = Auth(app, db, usermodel=User, mailer=None, base_url="/account")
auth.settings.update(download_url='/download')
db.define_models([Campaign, Donation, Cost])

## adding sessions and authorization handlers
app.expose.common_handlers = [
    SessionCookieManager('verySecretKey'), db.handler, auth.handler
]

## exposing functions from controllers
from controllers import main, campaigns, donations, costs

## add esxtensions
from weppy_haml import Haml
from weppy_assets import Assets
from weppy_bs3 import BS3
Ejemplo n.º 5
0
## language settings
app.languages = ['en', 'it']
app.language_default = 'en'
app.language_force_on_url = True
app.language_write = True

## init database and auth
from models.user import User
from models.campaign import Campaign
from models.donation import Donation
from models.cost import Cost
## init auth before passing db models due to dependencies
## on auth tables in the other models
db = DAL(app)
auth = Auth(
    app, db, usermodel=User, base_url="account"
)
auth.settings.update(download_url='/download')
db.define_models(Campaign, Donation, Cost)

## adding sessions and authorization handlers
app.common_handlers = [
    SessionCookieManager('verySecretKey'),
    db.handler,
    auth.handler
]

## add esxtensions
from weppy_haml import Haml
from weppy_assets import Assets
from weppy_bs3 import BS3
Ejemplo n.º 6
0
def auth(app, _db, mailer):
    auth = Auth(app, _db, user_model=User)
    app.pipeline.append(auth.pipe)
    authroutes = auth.module(__name__)
    return auth
Ejemplo n.º 7
0
from weppy.sessions import SessionManager, current
from weppy.tools import service

from weppy.orm import Database
from weppy.tools import Auth, requires
from models.Models import User, Issue

app = App(__name__)
app.config.db.uri = 'postgres://*****:*****@localhost/bazinga'

app.config.auth.single_template = True
app.config.auth.registration_verification = False
app.config.auth.hmac_key = "SomedayWholePeopleWillbeFucked"

db = Database(app, auto_migrate=True)
auth = Auth(app, db, user_model=User)

app.pipeline = [
    SessionManager.cookies('SomedayWholePeopleWillbeFucked'), db.pipe,
    auth.pipe
]

db.define_models(User, Issue)

auth_routes = auth.module(__name__)


def not_authorized():
    redirect(location='/system/login', status_code=302)

Ejemplo n.º 8
0
## language settings
app.languages = ['en', 'it']
app.language_default = 'en'
app.language_force_on_url = True
app.language_write = True

## init database and auth
from models.user import User
from models.campaign import Campaign
from models.donation import Donation
from models.cost import Cost
## init auth before passing db models due to dependencies
## on auth tables in the other models
db = Database(app, auto_migrate=True)
auth = Auth(app, db, user_model=User)
# auth.settings.update(download_url='/download')
db.define_models(Campaign, Donation, Cost)

## adding sessions and authorization handlers
app.pipeline = [SessionManager.cookies('verySecretKey'), db.pipe, auth.pipe]

## add esxtensions
from weppy_haml import Haml
from weppy_assets import Assets
from weppy_bs3 import BS3
app.config.Haml.set_as_default = True
# app.config.Haml.auto_reload = True
app.use_extension(Haml)
app.config.Assets.out_folder = 'gen'
app.use_extension(Assets)
Ejemplo n.º 9
0
def db():
    app = App(__name__)
    db = Database(app, config=sdict(uri='sqlite:memory'))
    auth = Auth(app, db, usermodel=User)
    db.define_models(Thing)
    return db
Ejemplo n.º 10
0
app.config.db.host = "127.0.0.1"

# Language settings
app.languages = ['en']
app.language_default = 'en'
app.language_force_on_url = True
app.language_write = True

# init database and auth
from <%= appName %>.models.user import User

# init auth before passing db models due to dependencies
# on auth tables in the other models
db = DAL(app)
auth = Auth(
        app, db, usermodel=User
)

# adding sessions and authorization handlers
from <%= appName %>.utils import get_cryptogen_string
app.route.common_handlers = [
    SessionCookieManager(get_cryptogen_string(16)),
    db.handler,
    auth.handler
]

# Extensions
from weppy_haml import Haml
app.config.Haml.set_as_default = True
app.config.Haml.auto_reload = True
app.use_extension(Haml)
Ejemplo n.º 11
0
        'user': lambda: session.auth.user.id,
        'date': lambda: request.now
    }

    validation = {
        'text': {'presence': True}
    }

    form_rw = {
        'user': False,
        'post': False,
        'date': False
    }

db = DAL(app)
auth = Auth(app, db, usermodel=User)
db.define_models(Post, Comment)
user = db.User.validate_and_insert(
    email="*****@*****.**",
    first_name="Abdul Hamid",
    last_name="Achik Lopez",
    password="******"
)
# create an admin group
admins = auth.add_group("admin")
# add user to admins group
auth.add_membership(admins, user.id)
db.commnit()

@app.command('setup')
def setup():