예제 #1
0
def new_user():
	"""Display new user creation form or accept and process it"""
	require_auth('admin')

	if not ldap_up():
		return render_response('message.html',dict(
			message_type='error',
			title="Add New User - LDAP Problem",
			message="Cannot add a new user since LDAP is not accessible"
		))

	form = NewUserForm()

	if request.method == 'POST':
		values = request.form.copy()
		del values['_csrf_token']
		form.set(values)

		if form.validate():
			user = User(**(form.value))
			sess.add(user)
			sess.commit()
			flash('Successfully added new user')
			return redirect(url_for('display_user',username=form['user_name'].value))
		else:
			flash('Form Validation Failed','error')

	return render_response('add_user.html', dict(form=form,submit_url=url_for('new_user')))
예제 #2
0
def updates_context():
    """Render calls update the template context with context processors"""
    @current_app.context_processor
    def inject_rudolf():
        return dict(rudolf='The red-nosed reindeer')

    render_response('context.html')
예제 #3
0
def updates_context():
    """Render calls update the template context with context processors"""

    @current_app.context_processor
    def inject_rudolf():
        return dict(rudolf='The red-nosed reindeer')

    render_response('context.html')
예제 #4
0
파일: pages.py 프로젝트: doptio/you-owe-it
def admin_list_events():
    events = (app.db.session
                .query(Event)
                .order_by(Event.created.desc(),
                          Event.id.desc())
                .all())
    return render_response('admin/events.html', {'events': events})
예제 #5
0
파일: pages.py 프로젝트: doptio/you-owe-it
def home():
    show_closed = bool(request.args.get('show-closed'))
    events = Event.for_user(g.user.id, show_closed)
    return render_response('home.html', {
        'events': events,
        'show_closed': show_closed,
    })
예제 #6
0
파일: pages.py 프로젝트: doptio/you-owe-it
def admin_list_users():
    users = (app.db.session
                .query(app.db.User)
                .order_by(app.db.User.created.desc(),
                          app.db.User.id.desc())
                .all())
    return render_response('admin/users.html', {'users': users})
예제 #7
0
파일: pages.py 프로젝트: doptio/you-owe-it
def entry(external_id, slug, entry_id):
    event, entry = requested_entry(external_id, entry_id)
    return render_response('entry.html', {
        'form': EmptyForm(),
        'event': event,
        'entry': entry,
    })
예제 #8
0
파일: app.py 프로젝트: DerSaidin/vlasisku
def query(query):
    db = database.root
    query = query.replace('+', ' ')
    results = db.query(query)

    if not results['entry'] and len(results['matches']) == 1:
        return redirect(url_for('query', query=results['matches'].pop()))

    sourcemetaphor = []
    unknownaffixes = None
    similar = None
    if not results['matches']:
        sourcemetaphor = [e for a in compound2affixes(query)
                            if len(a) != 1
                            for e in db.entries.itervalues()
                            if a in e.searchaffixes]

        unknownaffixes = len(sourcemetaphor) != \
                         len([a for a in compound2affixes(query)
                                if len(a) != 1])

        similar = [e.word for e in db.entries.itervalues()
                          if dameraulevenshtein(query, e.word) == 1]

        similar += [g.gloss for g in db.glosses
                            if g.gloss not in similar
                            and dameraulevenshtein(query, g.gloss) == 1]

    results.update(locals())
    return render_response('query.html', results)
예제 #9
0
def renders_strings(context):
    """Strings can be rendered as templates directly"""

    rendered = Assert(render_response(string='The name is $name',
                                      context=context, method='text'))

    assert rendered.data == 'The name is Rudolf'
예제 #10
0
def renders_css(context):
    """A css extension results in no doctype and a text/css mimetype"""

    rendered = Assert(render_response('test.css', context))

    assert rendered.mimetype == 'text/css'
    assert rendered.data == 'h1:after { content: " Rudolf"; }\n'
예제 #11
0
def renders_text(context):
    """A txt extension results in no doctype and a text/plain mimetype"""

    rendered = Assert(render_response('test.txt', context))

    assert rendered.mimetype == 'text/plain'
    assert rendered.data == 'Hi Rudolf\n'
예제 #12
0
def view_schedule():
	schedule = sess.query(Schedule).one()
	assignments = schedule.assignments

	schedule = sess.query(Schedule).one()

	errors = []
	for assn in schedule.assignments:
		if assn.course is None:
			errors.append('%r missing course' % assn)

		if assn.mentor is None:
			errors.append('%r missing mentor' % assn)

		if assn.assn_id is None:
			errors.append('%r missing id' % assn)

	if errors:
		raise Exception('%r' % errors)

	#Calculate statistics
	total_cost = sum(map(lambda x: x.cost, assignments))
	avg_cost = total_cost/len(assignments)

	return render_response('view_schedule.html', locals())
예제 #13
0
def renders_text(context):
    """A txt extension results in no doctype and a text/plain mimetype"""

    rendered = Assert(render_response('test.txt', context))

    assert rendered.mimetype == 'text/plain'
    assert rendered.data == 'Hi Rudolf\n'
예제 #14
0
파일: shurts.py 프로젝트: habnabit/shurtapp
def shirt_edit(id):
    shirt = Shirt.query.get_or_404(id)
    form = EditShirtForm(obj=shirt)
    if form.validate_on_submit():
        form.populate_obj(shirt)
        db.session.commit()
    return render_response('shirt_edit.html', dict(form=form, shirt=shirt))
예제 #15
0
def query(query):
    db = database.root
    query = query.replace('+', ' ')
    results = db.query(query)

    if not results['entry'] and len(results['matches']) == 1:
        return redirect(url_for('query', query=results['matches'].pop()))

    sourcemetaphor = []
    unknownaffixes = None
    similar = None
    if not results['matches']:
        sourcemetaphor = [
            e for a in compound2affixes(query) if len(a) != 1
            for e in db.entries.itervalues() if a in e.searchaffixes
        ]

        unknownaffixes = len(sourcemetaphor) != \
                         len([a for a in compound2affixes(query)
                                if len(a) != 1])

        similar = [
            e.word for e in db.entries.itervalues()
            if dameraulevenshtein(query, e.word) == 1
        ]

        similar += [
            g.gloss for g in db.glosses if g.gloss not in similar
            and dameraulevenshtein(query, g.gloss) == 1
        ]

    results.update(locals())
    return render_response('query.html', results)
예제 #16
0
def renders_css(context):
    """A css extension results in no doctype and a text/css mimetype"""

    rendered = Assert(render_response('test.css', context))

    assert rendered.mimetype == 'text/css'
    assert rendered.data == 'h1:after { content: " Rudolf"; }\n'
예제 #17
0
파일: shurts.py 프로젝트: habnabit/shurtapp
def photo_delete(id):
    photo = Photo.query.get_or_404(id)
    form = DeleteForm()
    if form.validate_on_submit():
        db.session.delete(photo)
        db.session.commit()
        return redirect(url_for('index'))
    return render_response('confirm_delete.html', dict(form=form, type='photo', obj=photo))
예제 #18
0
파일: shurts.py 프로젝트: habnabit/shurtapp
def wearing_note(id):
    wearing = Wearing.query.get_or_404(id)
    form = AddPhotoNoteForm()
    if form.validate_on_submit():
        add_photo_note(form, Wearing, wearing=wearing)
        db.session.commit()
        return redirect(url_for('wearing_detail', id=id))
    return render_response('wearing_detail.html', dict(wearing=wearing, form=form))
예제 #19
0
파일: shurts.py 프로젝트: habnabit/shurtapp
def shirt_delete(id):
    shirt = Shirt.query.get_or_404(id)
    form = DeleteForm()
    if form.validate_on_submit():
        db.session.delete(shirt)
        db.session.commit()
        return redirect(url_for('shirts'))
    return render_response('confirm_delete.html', dict(form=form, type='shirt', obj=shirt))
예제 #20
0
파일: shurts.py 프로젝트: habnabit/shurtapp
def login():
    if g.user is not None:
        return redirect(oid.get_next_url())
    if request.method == 'POST':
        openid = request.form.get('openid')
        if openid:
            return oid.try_login(openid, ask_for=['email'])
    return render_response('login.html', dict(next=oid.get_next_url(), error=oid.fetch_error()))
예제 #21
0
파일: shurts.py 프로젝트: habnabit/shurtapp
def shirt_note(id):
    shirt = Shirt.query.get_or_404(id)
    form = AddPhotoNoteForm()
    if form.validate_on_submit():
        add_photo_note(form, Shirt, shirt=shirt)
        db.session.commit()
        return redirect(url_for('shirt_detail', id=id))
    return render_response('shirt_detail.html', dict(shirt=shirt, form=form))
예제 #22
0
파일: shurts.py 프로젝트: habnabit/shurtapp
def wearing_delete(id):
    wearing = Wearing.query.get_or_404(id)
    form = DeleteForm()
    if form.validate_on_submit():
        db.session.delete(wearing)
        db.session.commit()
        return redirect(url_for('index'))
    return render_response('confirm_delete.html', dict(form=form, type='wearing', obj=wearing))
예제 #23
0
파일: shurts.py 프로젝트: habnabit/shurtapp
def wearing_calendar(month, year, today=None):
    weeks = cal.monthdatescalendar(year, month)
    first_day, last_day = weeks[0][0], weeks[-1][-1]
    wearings = Wearing.query.filter(db.between(Wearing.when, first_day, last_day)).all()
    wearing_map = collections.defaultdict(list)
    for wearing in wearings:
        wearing_map[wearing.when].append(wearing)
    return render_response('calendar.html',
                           dict(weeks=weeks, month=month, year=year, today=today, wearing_map=wearing_map))
예제 #24
0
파일: __init__.py 프로젝트: dag/stutuz
def revisions(entry, language):
    entry = db['entries'][entry]
    return render_response('relvlast/revisions.html',
        dict(
            entry = entry,
            language = language,
            history = entry.history(language),
        )
    )
예제 #25
0
파일: app.py 프로젝트: DerSaidin/vlasisku
def index():
    db = database.root
    if 'query' in request.args:
        return redirect(request.args.get('query'))
    types = TYPES
    classes = set(e.grammarclass for e in db.entries.itervalues()
                                 if e.grammarclass)
    scales = db.class_scales
    return render_response('index.html', locals())
예제 #26
0
def renders_strings(context):
    """Strings can be rendered as templates directly"""

    rendered = Assert(
        render_response(string='The name is $name',
                        context=context,
                        method='text'))

    assert rendered.data == 'The name is Rudolf'
예제 #27
0
파일: shurts.py 프로젝트: habnabit/shurtapp
def photo_note(id):
    photo = Photo.query.get_or_404(id)
    form = AddNoteForm()
    if form.validate_on_submit():
        note = Photo.Note(photo=photo, note=form.note.data)
        db.session.add(note)
        db.session.commit()
        return redirect(url_for('photo_detail', id=id))
    return render_response('photo_detail.html', dict(photo=photo, form=form))
예제 #28
0
def index():
    db = database.root
    if 'query' in request.args:
        return redirect(request.args.get('query'))
    types = TYPES
    classes = set(e.grammarclass for e in db.entries.itervalues()
                  if e.grammarclass)
    scales = db.class_scales
    return render_response('index.html', locals())
예제 #29
0
def renders_js(context):
    """A js extension results in no doctype
    and a application/javascript mimetype

    """

    rendered = Assert(render_response('test.js', context))

    assert rendered.mimetype == 'application/javascript'
    assert rendered.data == 'alert("Rudolf");\n'
예제 #30
0
def list_mentors():
	require_auth('admin')

	pref_types = sess.query(PrefType) #.outerjoin(Pref).order_by(PrefType.pref_type_id).all()

	mentors = sess.query(Mentor).outerjoin(Choice).join(Pref).outerjoin(PrefWeight).filter(Choice.weight_id != None).order_by(Pref.pref_type_id).all()

	unattached_prefs = sess.query(Pref).filter(~Pref.pref_id.in_(sess.query(Choice.pref_id))).all()

	return render_response('list_mentors.html',locals())
예제 #31
0
def renders_html(context):
    """A html extension results in an HTML doctype and mimetype"""

    rendered = Assert(render_response('test.html', context))
    expected_data = ('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" '
                     '"http://www.w3.org/TR/html4/strict.dtd">\n'
                     '<body>Hi Rudolf</body>')

    assert rendered.mimetype == 'text/html'
    assert rendered.data == expected_data
예제 #32
0
def renders_html(context):
    """A html extension results in an HTML doctype and mimetype"""

    rendered = Assert(render_response('test.html', context))
    expected_data = ('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" '
                     '"http://www.w3.org/TR/html4/strict.dtd">\n'
                     '<body>Hi Rudolf</body>')

    assert rendered.mimetype == 'text/html'
    assert rendered.data == expected_data
예제 #33
0
def index():
    db = database.root
    if 'query' in request.args:
        return redirect(url_for('query', query=request.args.get('query')))
    types = [(t[0], t[1], t[0].replace('-', ' ')) for t in TYPES]
    classes = set(e.grammarclass for e in db.entries.itervalues()
                  if e.grammarclass)
    scales = db.class_scales
    root = request.script_root
    return render_response('index.html', locals())
예제 #34
0
def renders_js(context):
    """A js extension results in no doctype
    and a application/javascript mimetype

    """

    rendered = Assert(render_response('test.js', context))

    assert rendered.mimetype == 'application/javascript'
    assert rendered.data == 'alert("Rudolf");\n'
def edit(**kwargs):
    data = defaultdict(str)
    data.update(**kwargs)
    imagelist = sorted(glob.glob(config.imagedir + '/*.png'))
    data['images'] = [os.path.basename(f) for f in imagelist]
    templatelist = glob.glob(config.textemplatedir + '/*.tex')
    data['templates'] = [unicode(os.path.basename(f))
                         for f in sorted(templatelist)]
    data['imageextensions'] = config.allowed_extensions
    return render_response('edit.html', data)
예제 #36
0
def renders_xml(context):
    """An xml extension results in no doctype and a application/xml mimetype"""

    rendered = Assert(render_response('test.xml', context))
    assert rendered.mimetype == 'application/xml'
    assert rendered.data == '<name>Rudolf</name>'

    rendered = Assert(render('test.xml', **context))
    assert rendered.mimetype == 'application/xml'
    assert rendered.data == '<name>Rudolf</name>'
예제 #37
0
def renders_xml(context):
    """An xml extension results in no doctype and a application/xml mimetype"""

    rendered = Assert(render_response('test.xml', context))
    assert rendered.mimetype == 'application/xml'
    assert rendered.data == '<name>Rudolf</name>'

    rendered = Assert(render('test.xml', **context))
    assert rendered.mimetype == 'application/xml'
    assert rendered.data == '<name>Rudolf</name>'
예제 #38
0
파일: app.py 프로젝트: christiank/vlasisku
def index():
    db = database.root
    if 'query' in request.args:
        return redirect(request.args.get('query'))
    types = [(t[0], t[1], t[0].replace('-', ' ')) for t in TYPES]
    classes = set(e.grammarclass for e in db.entries.itervalues()
                                 if e.grammarclass)
    scales = db.class_scales
    root = request.script_root
    return render_response('index.html', locals())
예제 #39
0
def edit(**kwargs):
    data = defaultdict(str)
    data.update(**kwargs)
    imagelist = sorted(glob.glob(config.imagedir + '/*.png'))
    data['images'] = [os.path.basename(f) for f in imagelist]
    templatelist = glob.glob(config.textemplatedir + '/*.tex')
    data['templates'] = [
        unicode(os.path.basename(f)) for f in sorted(templatelist)
    ]
    data['imageextensions'] = config.allowed_extensions
    return render_response('edit.html', data)
예제 #40
0
def renders_svg(context):
    """An svg extension results in an SVG doctype and mimetype"""

    rendered = Assert(render_response('test.svg', context))
    expected_data = ('<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" '
                     '"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n'
                     '<svg viewBox="0 0 1000 300">\n'
                     '<text x="250" y="150" font-size="55">Hi Rudolf</text>\n'
                     '</svg>')

    assert rendered.mimetype == 'image/svg+xml'
    assert rendered.data == expected_data
예제 #41
0
파일: frontend.py 프로젝트: mitechie/logy
def view_record(host_ip, app_name):
    log_app = tables.App.query.filter_by(host_ip=host_ip, name=app_name).first()
    if log_app is None:
        abort(404)
    hosts = tables.Host.query
    records = log_app.records
    log_format = app.config['LOG_FORMAT']
    return render_response('view_record.html', 
                           dict(app=log_app, 
                                records=records, 
                                hosts=hosts, 
                                log_format=log_format))
예제 #42
0
def login():
    error = None
    if request.method == 'POST':
        if request.form['username'] != app.config['USERNAME']:
            error = 'Invalid username'
        elif request.form['password'] != app.config['PASSWORD']:
            error = 'Invalid password'
        else:
            session['logged_in'] = True
            flash('You were logged in')
            return redirect(url_for('show_entries'))
    return render_response('login.html', dict(error=error))
예제 #43
0
def index():
    text = request.args.get('text', "coi pilno mi'e camxes")
    try:
        ast = camxes.parse(text)
        grammatical = camxes.isgrammatical(text)
    except:
        return redirect(url_for('index'))
    if 'json' in request.args:
        return jsonify(html=render_template('box.html', dict(text=text,
                                                             ast=ast)),
                       grammatical=grammatical)
    return render_response('index.html',
                           dict(ast=ast, text=text, grammatical=grammatical))
예제 #44
0
파일: app.py 프로젝트: stardust66/vlasisku
def index():
    db = database.root
    if 'query' in request.args:
        query_str = request.args.get('query')

        # Manually escape '.' so it does not get interpreted as part of a
        # relative path.
        escaped_query = urllib.quote_plus(query_str).replace(".", "%2E")
        return redirect(url_for("query", query="") + escaped_query)
    types = [(t[0], t[1], t[0].replace('-', ' ')) for t in TYPES]
    classes = set(e.grammarclass for e in db.entries.itervalues()
                  if e.grammarclass)
    scales = db.class_scales
    root = request.script_root
    return render_response('index.html', locals())
예제 #45
0
def edit(**kwargs):
    data = defaultdict(str)
    data.update(**kwargs)
    #imagelist = sorted(glob.glob(config.imagedir + '/*.png')) #TODO
    #data['images'] = [os.path.basename(f) for f in imagelist] #TODO
    data['images'] = generateImagelist()
    data['logos'] = generateImagelist(config.logodir)
    data['standartLogo'] = config.standartLogo
    data['standartFooter'] = config.standartFooter
    templatelist = glob.glob(config.textemplatedir + '/*.tex')
    data['templates'] = [
        unicode(os.path.basename(f)) for f in sorted(templatelist)
    ]
    data['imageextensions'] = config.allowed_extensions
    return render_response('edit.html', data)
예제 #46
0
def help():
    return render_response('help.html',
                           {'website': current_app.config['WEBSITE']})
예제 #47
0
def opensearch():
    return render_response('opensearch.xml')
예제 #48
0
def help():
    return render_response('help.html')
예제 #49
0
def show_entries():
    cur = g.db.execute('select title, text from entries order by id desc')
    entries = [dict(title=row[0], text=row[1]) for row in cur.fetchall()]
    return render_response('show_entries.html', dict(entries=entries))
예제 #50
0
def schild(filename):
    return render_response(
        'schild.html', {
            'filename': filename,
            'printer': [unicode(f) for f in sorted(config.printers.keys())]
        })
예제 #51
0
def index():
    render_response('index.html')
예제 #52
0
def javascript():
    return render_response('custom.js')
예제 #53
0
def fails_without_template_or_string(context):
    """A template or string must be provided to render"""

    with Assert.raises(RuntimeError):
        render_response(context=context, method='text')
예제 #54
0
def index(**kwargs):
    data = defaultdict(str)
    data.update(**kwargs)
    filelist = glob.glob(config.datadir + '/*.schild')
    data['files'] = [unicode(os.path.basename(f)) for f in sorted(filelist)]
    return render_response('index.html', data)
예제 #55
0
def home():
    dataset_id = 'teina011'
    return render_response('index.html', dict(dataset_id=dataset_id))
예제 #56
0
def embed():
    dataset_id = request.args.get('datasetId', 'teina011')
    return render_response('embed.html', dict(dataset_id=dataset_id))