aboutsummaryrefslogtreecommitdiff
blob: b33156b27ab33631ae07edeea8f5ae7aee95d3fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- coding: utf-8 -*-
"""
    grumpy.webapp
    ~~~~~~~~~~~~~

    This module contains web application data.

    :copyright: (c) by 2010 Priit Laes.
    :license: BSD, see LICENSE for details.
"""
from . import app
from .models import Category, Package
from .utils import requires_auth_basic

from flask import flash, jsonify, redirect, render_template, url_for

@app.route('/')
@app.route('/browse/')
def index():
    cats = Category.query.order_by(Category.cat.asc()).all()
    return render_template('index.html', cats=cats)


@app.route('/browse/<cat>/')
def browse_cat(cat):
    if cat:
        pkgs = Package.query.filter_by(cat=cat) \
                            .order_by(Package.pkg.asc()).all()
        if pkgs:
            return render_template('browse_cat.html', cat=cat, pkgs=pkgs)
    flash('Category "%s" does not exist' % cat)
    return redirect(url_for('index'))

@app.route('/browse/<cat>/<pkg>/')
def browse_pkg(cat, pkg):
    if cat and pkg:
        package = Package.query.filter_by(cat=cat) \
                               .filter_by(pkg=pkg).first()
        if package:
            return render_template('browse_pkg.html', cat=cat, pkg=package, \
                                   qa=package.qaissues)
    flash('Package "%s/%s" does not exist' % (cat, pkg))
    return redirect(url_for('browse_cat', cat=cat))

@app.route('/_api/1.0/tinderbox/')
@requires_auth_basic
def tinderbox_api():
    return jsonify(dict(success=False))