예제 #1
0
def page(version, p, subp):
    if version == 'latest':
        v = get_latest_version()
        pargs = [v, p]
        if subp:
            pargs.append(subp)
        redirect(url('.page', pargs))
    if subp:
        requested_page = subp
        parent = p
    else:
        requested_page = p
        parent = None
    if not is_page(version, requested_page, parent):
        abort(404)
    _sections = get_sections(version, requested_page, parent)
    sections = []
    for s in _sections:
        sections.append((s, Urlify(keep_underscores=True)(s)[0]))
    body = asis(get_html(version, requested_page, parent))
    title = get_chapter(version, requested_page, parent)
    response.meta.title = "weppy - Docs - " + title
    # for navigator
    prev, after = get_navigation(version, requested_page, parent)
    return dict(body=body, sections=sections, prev=prev, after=after)
예제 #2
0
def page(version, p, subp):
    if version == 'latest':
        v = get_latest_version()
        pargs = [v, p]
        if subp:
            pargs.append(subp)
        redirect(url('.page', pargs))
    if subp:
        requested_page = subp
        parent = p
    else:
        requested_page = p
        parent = None
    if not is_page(version, requested_page, parent):
        abort(404)
    _sections = get_sections(version, requested_page, parent)
    sections = []
    for s in _sections:
        sections.append((s, Urlify(keep_underscores=True)(s)[0]))
    body = asis(get_html(version, requested_page, parent))
    title = get_chapter(version, requested_page, parent)
    response.meta.title = "weppy - Docs - " + title
    # for navigator
    prev, after = get_navigation(version, requested_page, parent)
    return dict(body=body, sections=sections, prev=prev, after=after)
예제 #3
0
파일: main.py 프로젝트: wiredmind/h-funding
def charge():
    response.meta.title = "HFunding | Charge account"
    form = Form(amount=Field("int"))
    if form.accepted:
        auth.user.update_record(
            money=auth.user.money + int(form.params.amount))
        redirect(url('main.profile', auth.user.id))
    return dict(form=form)
예제 #4
0
파일: main.py 프로젝트: gi0baro/h-funding
def charge():
    response.meta.title = "HFunding | Charge account"
    form = Form(amount=Field.int())
    if form.accepted:
        auth.user.update_record(
            money=auth.user.money + int(form.params.amount))
        redirect(url('main.profile', auth.user.id))
    return dict(form=form)
def new():
    def set_owner(form):
        form.vars.owner = auth.user.id

    form = Campaign.form(onvalidation=set_owner)
    if form.accepted:
        redirect(url('main.profile', auth.user.id))
    return locals()
예제 #6
0
def charge():
    from weppy import Form, Field, redirect
    response.meta.title = "HFunding | Charge account"
    form = Form(Field("amount", "integer"))
    if form.accepted:
        db.User(id=auth.user.id).update_record(money=auth.user.money +
                                               int(form.vars.amount))
        auth.user.update(money=auth.user.money + int(form.vars.amount))
        redirect(url('main.profile', auth.user.id))
    return dict(form=form)
예제 #7
0
def charge():
    from weppy import Form, Field, redirect
    response.meta.title = "HFunding | Charge account"
    form = Form(
        Field("amount", "integer")
    )
    if form.accepted:
        db.User(id=auth.user.id).update_record(
            money=auth.user.money+int(form.vars.amount))
        auth.user.update(money=auth.user.money+int(form.vars.amount))
        redirect(url('main.profile', auth.user.id))
    return dict(form=form)
def detail(cid):
    def validate_cost(form):
        form.vars.campaign = campaign.id
        if form.vars.amount > (campaign.pledged()-campaign.spended()):
            form.errors.amount = \
                "The amount inserted is bigger than the amount pledged."

    campaign = db.Campaign(id=cid)
    cost_form = Cost.form(onvalidation=validate_cost)
    if cost_form.accepted:
        redirect(url('campaigns.detail', cid))
    return dict(campaign=campaign, cost_form=cost_form, graph=graph_data)
예제 #9
0
파일: costs.py 프로젝트: gi0baro/h-funding
def add(campaign):
    def validate(form):
        if form.params.amount > record.pledged():
            form.errors.amount = ""
    message = None
    record = Campaign.get(id=campaign, user=auth.user.id)
    if not record:
        message = "Bad campaign id"
    form = Cost.form(onvalidation=validate)
    form.params.campaign = record.id
    if form.accepted:
        redirect(url('campaigns.detail', record.id))
    return dict(msg=message, form=form)
예제 #10
0
def add(campaign):
    def set_form(form):
        form.params.user = auth.user.id
        form.params.campaign = record.id

    message = None
    record = Campaign.get(campaign)
    if not record:
        message = "Bad campaign id"
    form = Donation.form(onvalidation=set_form)
    if form.accepted:
        redirect(url('campaigns.detail', record.id))
    return dict(msg=message, form=form, campaign=record)
예제 #11
0
def add(campaign):
    def validate(form):
        if form.vars.amount > record.pledged():
            form.errors.amount = ""
    message = None
    record = db.Campaign(id=campaign, owner=auth.user.id)
    if not record:
        message = "Bad campaign id"
    form = Cost.form(onvalidation=validate)
    form.vars.campaign = record.id
    if form.accepted:
        redirect(url('campaigns.detail', record.id))
    return dict(msg=message, form=form)
예제 #12
0
def add(campaign):
    def set_form(form):
        form.params.user = auth.user.id
        form.params.campaign = record.id

    message = None
    record = Campaign.get(campaign)
    if not record:
        message = "Bad campaign id"
    form = Donation.form(onvalidation=set_form)
    if form.accepted:
        redirect(url('campaigns.detail', record.id))
    return dict(msg=message, form=form, campaign=record)
예제 #13
0
def one(pid):
    def _validate_comment(form):
        # manually set post id in comment form
        form.params.post = pid
    # get post and return 404 if doesn't exist
    post = Post.get(pid)
    if not post:
        abort(404)
    # get comments and create a form for commenting
    comments = post.comments(orderby=~Comment.date)
    form = Comment.form(onvalidation=_validate_comment)
    if form.accepted:
        redirect(url('one', pid))
    return locals()
예제 #14
0
파일: bloggy.py 프로젝트: ahoasoul/weppy
def one(pid):
    def _validate_comment(form):
        # manually set post id in comment form
        form.params.post = pid
    # get post and return 404 if doesn't exist
    post = db.Post(id=pid)
    if not post:
        abort(404)
    # get comments and create a form for commenting
    comments = post.comments(orderby=~Comment.date)
    form = Comment.form(onvalidation=_validate_comment)
    if form.accepted:
        redirect(url('one', pid))
    return locals()
예제 #15
0
파일: ext.py 프로젝트: gi0baro/weppy-oauth2
    def __oauth_login(self):
        """
        This method redirects the user to the authenticating form
        on authentication server if the authentication code
        and the authentication token are not available to the
        application yet.

        Once the authentication code has been received this method is
        called to set the access token into the session by calling
        accessToken()
        """

        token = self.accessToken()
        if not token:
            session.redirect_uri = self.__redirect_uri()
            data = dict(redirect_uri=session.redirect_uri,
                        response_type='code',
                        client_id=self.env.client_id)
            auth_request_url = self.env.auth_url + "?" + urlencode(data)
            redirect(auth_request_url)
        return
예제 #16
0
def home(version):
    if version == 'latest':
        v = get_latest_version()
        redirect(url('.home', v))
    if version not in get_versions() + ["dev"]:
        redirect(url('.page', 'latest'))
    tree = build_tree(version)
    if not tree:
        abort(404)
    pages = []
    for v in tree:
        u = url('.page', [version, v[1]])
        sub_v = []
        if v[2]:
            for sv in v[2]:
                sub_v.append((sv[0], url('.page', [version, v[1], sv[1]])))
        else:
            for sv in v[3]:
                slug = Urlify(keep_underscores=True)(sv)[0]
                sub_v.append((sv, u + "#" + slug))
        pages.append((v[0], u, sub_v))
    response.meta.title = "weppy - Docs"
    return dict(tree=pages, version=version, versions=["dev"] + get_versions())
예제 #17
0
def home(version):
    if version == 'latest':
        v = get_latest_version()
        redirect(url('.home', v))
    if version not in get_versions() + ["dev"]:
        redirect(url('.page', 'latest'))
    tree = build_tree(version)
    if not tree:
        abort(404)
    pages = []
    for v in tree:
        u = url('.page', [version, v[1]])
        sub_v = []
        if v[2]:
            for sv in v[2]:
                sub_v.append((sv[0], url('.page', [version, v[1], sv[1]])))
        else:
            for sv in v[3]:
                slug = Urlify(keep_underscores=True)(sv)[0]
                sub_v.append((sv, u + "#" + slug))
        pages.append((v[0], u, sub_v))
    response.meta.title = "weppy - Docs"
    return dict(tree=pages, version=version, versions=["dev"] + get_versions())
예제 #18
0
def logout():
    current.session.auth.expiration = -1
    redirect(location='/system/login', status_code=302)
예제 #19
0
def index():
    redirect(url('.home', 'latest'))
예제 #20
0
def index():
    redirect(url('.home', 'latest'))
예제 #21
0
def new_post():
    form = Post.form()
    if form.accepted:
        redirect(url('one', form.params.id))
    return dict(form=form)
예제 #22
0
def not_authorized():
    redirect(location='/system/login', status_code=302)
예제 #23
0
파일: bloggy.py 프로젝트: ahoasoul/weppy
def new_post():
    form = Post.form()
    if form.accepted:
        redirect(url('one', form.params.id))
    return dict(form=form)