"Basic menu management"
This commit is contained in:
parent
9d723deb3a
commit
d9ecf3bb5a
@ -3,7 +3,7 @@
|
||||
<article class='right'>
|
||||
<h3>TODO list</h3>
|
||||
<ul>
|
||||
<li>Menu management</li>
|
||||
<li><strike>Basic menu management</strike></li>
|
||||
<li>Installation wizard</li>
|
||||
<li>Back office for basic content management</li>
|
||||
<li>Basic Ajax support</li>
|
||||
|
@ -2,6 +2,7 @@
|
||||
# -*- coding: utf-8
|
||||
|
||||
# Required modules
|
||||
import inspect
|
||||
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash
|
||||
from functools import wraps
|
||||
|
||||
@ -24,6 +25,32 @@ app.secret_key = 'ce1d1c9ff0ff388a838b3a1e3207dd27'
|
||||
# Feel free to use SQLAlchemy (or not)
|
||||
db = SQLAlchemy(app)
|
||||
|
||||
########################################################################
|
||||
# Menu management
|
||||
########################################################################
|
||||
|
||||
def get_menu(page):
|
||||
menu = [['Accueil', '/', 0],
|
||||
['Articles', '/articles', 0],
|
||||
['Basics', '/basics', 0],
|
||||
['Inputs', '/inputs', 0],
|
||||
['Database', '/database', 0],
|
||||
['Todo', '/todo', 0],
|
||||
]
|
||||
# This is index page
|
||||
if page == 'index':
|
||||
menu[0][2] = 1
|
||||
return menu
|
||||
|
||||
# Let's look for the actual page
|
||||
page = '/%s' % page
|
||||
for item in menu:
|
||||
if item[1] == page:
|
||||
item[2] = 1
|
||||
return menu
|
||||
# This should never happen
|
||||
return menu
|
||||
|
||||
########################################################################
|
||||
# Routes
|
||||
########################################################################
|
||||
@ -35,70 +62,40 @@ def page_not_found(e):
|
||||
|
||||
@app.route("/", methods=['GET', 'POST'])
|
||||
def index():
|
||||
app.menu = [('Accueil', '/', 1),
|
||||
('Articles', '/articles', 0),
|
||||
('Basics', '/basics', 0),
|
||||
('Inputs', '/inputs', 0),
|
||||
('Database', '/database', 0),
|
||||
('Todo', '/todo', 0),
|
||||
]
|
||||
return render_template('index.html', menu=app.menu)
|
||||
page = inspect.currentframe().f_code.co_name
|
||||
menu = get_menu(page)
|
||||
return render_template('index.html', menu=menu)
|
||||
|
||||
@app.route("/articles", methods=['GET', 'POST'])
|
||||
def articles():
|
||||
app.menu = [('Accueil', '/', 0),
|
||||
('Articles', '/articles', 1),
|
||||
('Basics', '/basics', 0),
|
||||
('Inputs', '/inputs', 0),
|
||||
('Database', '/database', 0),
|
||||
('Todo', '/todo', 0),
|
||||
]
|
||||
return render_template('articles.html', menu=app.menu)
|
||||
page = inspect.currentframe().f_code.co_name
|
||||
menu = get_menu(page)
|
||||
return render_template('articles.html', menu=menu)
|
||||
|
||||
@app.route("/basics", methods=['GET', 'POST'])
|
||||
def basics():
|
||||
app.menu = [('Accueil', '/', 0),
|
||||
('Articles', '/articles', 0),
|
||||
('Basics', '/basics', 1),
|
||||
('Inputs', '/inputs', 0),
|
||||
('Database', '/database', 0),
|
||||
('Todo', '/todo', 0),
|
||||
]
|
||||
return render_template('basics.html', menu=app.menu)
|
||||
page = inspect.currentframe().f_code.co_name
|
||||
menu = get_menu(page)
|
||||
return render_template('basics.html', menu=menu)
|
||||
|
||||
|
||||
@app.route("/inputs", methods=['GET', 'POST'])
|
||||
def inputs():
|
||||
app.menu = [('Accueil', '/', 0),
|
||||
('Articles', '/articles', 0),
|
||||
('Basics', '/basics', 0),
|
||||
('Inputs', '/inputs', 1),
|
||||
('Database', '/database', 0),
|
||||
('Todo', '/todo', 0),
|
||||
]
|
||||
return render_template('inputs.html', menu=app.menu)
|
||||
page = inspect.currentframe().f_code.co_name
|
||||
menu = get_menu(page)
|
||||
return render_template('inputs.html', menu=menu)
|
||||
|
||||
@app.route("/database", methods=['GET', 'POST'])
|
||||
def database():
|
||||
app.menu = [('Accueil', '/', 0),
|
||||
('Articles', '/articles', 0),
|
||||
('Basics', '/basics', 0),
|
||||
('Inputs', '/inputs', 0),
|
||||
('Database', '/database', 1),
|
||||
('Todo', '/todo', 0),
|
||||
]
|
||||
return render_template('database.html', menu=app.menu)
|
||||
page = inspect.currentframe().f_code.co_name
|
||||
menu = get_menu(page)
|
||||
return render_template('database.html', menu=menu)
|
||||
|
||||
@app.route("/todo", methods=['GET', 'POST'])
|
||||
def todo():
|
||||
app.menu = [('Accueil', '/', 0),
|
||||
('Articles', '/articles', 0),
|
||||
('Basics', '/basics', 0),
|
||||
('Inputs', '/inputs', 0),
|
||||
('Database', '/database', 0),
|
||||
('Todo', '/todo', 1),
|
||||
]
|
||||
return render_template('todo.html', menu=app.menu)
|
||||
page = inspect.currentframe().f_code.co_name
|
||||
menu = get_menu(page)
|
||||
return render_template('todo.html', menu=menu)
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user