forked from pyvec/python.cz
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.py
More file actions
92 lines (60 loc) · 2.1 KB
/
views.py
File metadata and controls
92 lines (60 loc) · 2.1 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# -*- coding: utf-8 -*-
from flask import (render_template as _render_template, url_for,
redirect, request)
from . import app
from .models import trello, jobs, photos, beginners
# Templating
def render_template(filename, **kwargs):
kwargs['template_url'] = app.config['TEMPLATES_DIR_URL'] + filename
return _render_template(filename, **kwargs)
@app.context_processor
def inject_context():
return {
'debug': app.debug,
'config': app.config,
'url': request.url,
'lang': 'cs',
}
# Regular views
@app.route('/')
def index_cs():
return render_template('index_cs.html',
photo_urls=photos.get_random_urls(5))
@app.route('/en/')
def index_en():
return render_template('index_en.html',
photo_urls=photos.get_random_urls(5), lang='en')
@app.route('/zapojse/')
def get_involved_cs():
trello_board_id = app.config['TRELLO_BOARD_ID']
context = {
'trello_board': trello.get_board(trello_board_id),
'trello_board_url': 'https://trello.com/b/{}/'.format(trello_board_id),
}
return render_template('get_involved_cs.html', **context)
@app.route('/zacatecnici/')
def beginners_cs():
return render_template('beginners_cs.html', data=beginners.data)
@app.route('/prace/')
def jobs_cs():
return render_template('jobs_cs.html', data=jobs.data)
@app.route('/en/jobs/')
def jobs_en():
return render_template('jobs_en.html', data=jobs.data, lang='en')
# Redirects of legacy stuff
@app.route('/index.html')
def index_legacy():
return redirect(url_for('index'), code=301)
@app.route('/english.html')
def index_en_legacy():
return redirect(url_for('index_en'), code=301)
@app.route('/pyladies/<path:target>')
def pyladies(target):
return redirect('http://pyladies.cz/v1/' + target, code=301)
@app.route('/pyladies/')
def pyladies_index():
return redirect('http://pyladies.cz/', code=301)
@app.route('/talks/<path:target>')
def talks(target):
base_url = 'https://github.com/pyvec/talks-archive/raw/master/'
return redirect(base_url + target, code=301)