Beispiel #1
0
def map_route(url, func, **kwargs):
    wrapped_func = func
    if 'decs' in kwargs:
        decs = kwargs.pop('decs')
    else:
        decs = []

    decs += DEFAULT_DECS

    if type(decs) is list:
        for dec in decs:
            wrapped_func = dec(wrapped_func)

    wrapped_func.__name__ = func.__module__ + "." + func.__name__

    app.add_url_rule(url, view_func=wrapped_func, **kwargs)
Beispiel #2
0
    def get_template_name(self):
        return 'import.html'
    
    @login_required
    def dispatch_request(self):

        logger = dlog.get_logger('imp0rt')

        if request.method == 'POST':
            importfile = request.files['airspace']
            if importfile:
                logger.info('parsing file')
                airspaceFile = parse(importfile.filename,importfile)
                logger.info('file parsed')
                try:
                    db.add(airspaceFile)
                    logger.info('added airspaces to database')
                    db.commit()
                    logger.info('commited data')
                except Exception as e:
                    logger.error(e.message)
                    logger.info(e)
                    raise

        model = self.get_objects()
        model['files'] = AirspaceFile.query.all()
        return self.render_template(model)


app.add_url_rule('/import', view_func=ImportView.as_view('importview'))
Beispiel #3
0
    'craft',
    'dcpu',
    'gps',
    'hirise',
    'imeme',
    'phrases',
    'ricochet',
    'scale',
    'star_rocket',
    # 'primitive',
]

for name in VIEWS:
    hyphenated = name.replace('_', '-')
    func = partial(render_template, '%s.html' % hyphenated)
    app.add_url_rule('/%s/' % hyphenated, name, func)

REDIRECTS = [
    ('allrgb', 'https://github.com/fogleman/AllRGB'),
    ('wang_tiling', 'https://github.com/fogleman/WangTiling'),
    ('dr_mario', 'https://github.com/fogleman/DrMario'),
    ('pt', 'https://github.com/fogleman/pt'),
    ('sync', 'http://www.michaelfogleman.com/static/fireflies/'),
    ('feed_notifier', 'http://www.feednotifier.com/'),
    ('game_frame', 'https://github.com/fogleman/GameFrame'),
    ('quads', 'https://github.com/fogleman/Quads'),
    ('tiling', 'https://github.com/fogleman/Tiling'),
    ('field', 'https://github.com/fogleman/Field'),
    ('manhattan', 'https://github.com/fogleman/Manhattan'),
    ('mapper', 'http://www.michaelfogleman.com/mapper/'),
    ('piet', 'https://github.com/fogleman/Piet'),
Beispiel #4
0
from web import app, baseurl
from flask import render_template, redirect, url_for
from ..Model.database import Activities


def index():
    acts = Activities.query.filter_by(hide=False).order_by(
        Activities.rank).all()
    return render_template('index/chosen_page.html', acts=acts)


app.add_url_rule(baseurl + '/', 'activity_chosen2', index)


def no_base_url():
    return redirect(url_for('index'))


if baseurl != '':
    app.add_url_rule(baseurl, view_func=index)
    app.add_url_rule('/', view_func=no_base_url)
else:
    app.add_url_rule('/', view_func=index)
Beispiel #5
0
    def delete(self):
        try:
            for key in ['identity.name', 'identity.auth_type', 'redirected_from']:
                del session[key]

            for key in ['user.username', 'user.password', 'user.email']:
                del session[key]

        except KeyError:
            pass

        return redirect(url_for('login'))


app.add_url_rule('/session',
                 view_func=SessionAPI.as_view('session'),
                 methods=['GET','POST','DELETE'])


@app.route("/session/new")
def login():
    if 'identity.name' in session:
        redirect(url_for('session'))

    form = LoginForm(request.form)

    return render_template('auth/login.html', form=form)

@app.route("/session/destroy")
def destroy():
    return redirect(url_for('session') + '?__METHOD_OVERRIDE__=DELETE')
Beispiel #6
0
from baseview import BaseView
from web import app
from model import User
from flask import Flask,session, request, flash, url_for, redirect, render_template, abort ,g
from flask.ext.login import login_user, logout_user, current_user, login_required

class LoginView(BaseView):
    methods = ['GET', 'POST']

    def get_template_name(self):
        return 'login.html'

    def dispatch_request(self):
        model = self.get_objects()
        if request.method == 'POST':
            username = request.form['username']
            password = request.form['password']
            registered_user = User.query.filter_by(username=username,password=password).first()
            if registered_user and registered_user.username == username:
                login_user(registered_user)
                flash("Logged in successfully.")
                return redirect(request.args.get("next") or url_for("mapview"))
            return self.render_template(model)

        return self.render_template(model)

app.add_url_rule('/login', view_func=LoginView.as_view('loginview'))
Beispiel #7
0
from baseview import BaseView
from web import app
from flask import request
from config import MAP_CENTER, MAP_TYPE, MAP_ZOOM

class MapView(BaseView):
    methods = ['GET']
    
    def get_template_name(self):
        return 'map.html'

    def dispatch_request(self):
        coords = MAP_CENTER.split(":")
        model = self.get_objects()
        model['home_coordinates'] = coords
        model['map_zoom'] = MAP_ZOOM
        model['map_type'] = MAP_TYPE
        return self.render_template(model)
   
app.add_url_rule('/', view_func=MapView.as_view('mapview'))
Beispiel #8
0
Datei: user.py Projekt: booo/gid
            response = self.rest.postForm(
                  form.toDict()
              ) 

            data = json.loads(response)

            flash("Account successfully created!", "success")

        return redirect(url_for('login'))


    def delete(self):
        raise NotYetImplemented()


app.add_url_rule('/<username>',
                    view_func=UserAPI.as_view('users'),
                    methods=['GET'])
app.add_url_rule('/users',
                    view_func=UserAPI.as_view('users'),
                    methods=['PUT','POST'])
app.add_url_rule('/users/<username>',
                    view_func=UserAPI.as_view('users'),
                    methods=['DELETE'])


@app.route('/api/users/new')
def userNewForm():
    form = RegistrationForm(request.form)
    return render_template('auth/register.html', form=form)
Beispiel #9
0
                    session['user.password'],
                    '/%s/%s' % (username, reponame)
                  )

                flash("Successfully deleted: " + reponame, 'success')

                return redirect(url_for('repos', username = username))

            except Unauthorized:
                flash("Unauthorized", "error"), 401

        return redirect(url_for('repos', username = username,reponame=reponame))


app.add_url_rule('/repos',\
                    view_func=RepositoriesAPI.as_view('repos'),
                    methods=['GET'])
app.add_url_rule('/repos/<username>',\
                    view_func=RepositoriesAPI.as_view('repos'),
                    methods=['GET','POST'])
app.add_url_rule('/repos/<username>/<reponame>',\
                    view_func=RepositoriesAPI.as_view('repos'),
                    methods=['GET','PUT','DELETE'])


@app.route('/repos/<username>/new')
def repoNewForm(username):
    form = RepositoryForm(request.form)
    action = url_for('repos', username=username)
    return render_template('repository/form.html', form=form,
                                username=username, action=action,
Beispiel #10
0
from baseview import BaseView
from web import app
from model import User
from flask import Flask,session, request, flash, url_for, redirect, render_template, abort ,g
from flask.ext.login import logout_user

class LogoutView(BaseView):
    methods = ['GET']

    def get_template_name(self):
        return None

    def dispatch_request(self):
        model = self.get_objects()
        logout_user()
        return redirect('/')

app.add_url_rule('/logout', view_func=LogoutView.as_view('logoutview'))