Finalize version 3.0
This commit is contained in:
parent
04c2d8f685
commit
de07987ed1
10 changed files with 118 additions and 144 deletions
|
|
@ -12,13 +12,13 @@ class BaseModel(Model):
|
|||
database = db
|
||||
|
||||
|
||||
class Database:
|
||||
def get_db(self):
|
||||
return db
|
||||
def setup(db_url):
|
||||
db.init(db_url)
|
||||
db.connect()
|
||||
|
||||
def setup(self, db_url):
|
||||
db.init(db_url)
|
||||
db.connect()
|
||||
from stacosys.model.comment import Comment
|
||||
db.create_tables([Comment], safe=True)
|
||||
|
||||
from stacosys.model.comment import Comment
|
||||
db.create_tables([Comment], safe=True)
|
||||
|
||||
def get_db():
|
||||
return db
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
</form>
|
||||
</main>
|
||||
<footer>
|
||||
<p>Cette page a été conçue par Yax avec <a href="https://simplecss.org">Simple.css</a>.</p>
|
||||
<p>Cette page a été conçue avec <a href="https://simplecss.org">Simple.css</a>.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ def login():
|
|||
if is_login_ok(username, password):
|
||||
session['user'] = username
|
||||
return redirect('/web/admin')
|
||||
|
||||
# TODO localization
|
||||
flash("Identifiant ou mot de passe incorrect")
|
||||
return redirect('/web/login')
|
||||
|
||||
# GET
|
||||
return render_template("login_" + app.config.get("LANG") + ".html")
|
||||
|
||||
|
||||
|
|
@ -49,6 +49,7 @@ def logout():
|
|||
@app.route("/web/admin", methods=["GET"])
|
||||
def admin_homepage():
|
||||
if not ('user' in session and session['user'] == app.config.get("WEB_USERNAME")):
|
||||
# TODO localization
|
||||
flash("Vous avez été déconnecté.")
|
||||
return redirect('/web/login')
|
||||
|
||||
|
|
@ -59,8 +60,17 @@ def admin_homepage():
|
|||
|
||||
@app.route("/web/admin", methods=["POST"])
|
||||
def admin_action():
|
||||
flash(request.form.get("comment") + " " + request.form.get("action"))
|
||||
# TODO process action
|
||||
# rebuild RSS
|
||||
app.config.get("RSS").generate()
|
||||
comment = dao.find_comment_by_id(request.form.get("comment"))
|
||||
if comment is None:
|
||||
# TODO localization
|
||||
flash("Commentaire introuvable")
|
||||
elif request.form.get("action") == "APPROVE":
|
||||
dao.publish_comment(comment)
|
||||
app.config.get("RSS").generate()
|
||||
# TODO localization
|
||||
flash("Commentaire publié")
|
||||
else:
|
||||
dao.delete_comment(comment)
|
||||
# TODO localization
|
||||
flash("Commentaire supprimé")
|
||||
return redirect('/web/admin')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue