Add EN translations
This commit is contained in:
parent
708b84987c
commit
4d52229e4d
3 changed files with 126 additions and 10 deletions
64
src/stacosys/interface/templates/admin_en.html
Normal file
64
src/stacosys/interface/templates/admin_en.html
Normal file
|
@ -0,0 +1,64 @@
|
|||
<!doctype html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Stacosys Comment Moderation</title>
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h2>Comment Moderation</h2>
|
||||
<nav>
|
||||
<a href="/web/logout">Log out</a>
|
||||
</nav>
|
||||
</header>
|
||||
<main>
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
<blockquote>
|
||||
{% for message in messages %}
|
||||
<p>{{ message }}</p>
|
||||
{% endfor %}
|
||||
</blockquote>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Author</th>
|
||||
<th>Comment</th>
|
||||
<th>Article</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for comment in comments %}
|
||||
<tr>
|
||||
<td>{{ comment.created }}</td>
|
||||
<td>{{ comment.author_name }}</td>
|
||||
<td>{{ comment.content }}</td>
|
||||
<td><a href="{{ baseurl + comment.url }}">{{ comment.url }}</a></td>
|
||||
<td>
|
||||
<form action="/web/admin" method="post">
|
||||
<input type="hidden" name="comment" value="{{comment.id}}">
|
||||
<input type="hidden" name="action" value="APPROVE">
|
||||
<button type="submit">Approve</button>
|
||||
</form>
|
||||
<form action="/web/admin" method="post">
|
||||
<input type="hidden" name="comment" value="{{comment.id}}">
|
||||
<input type="hidden" name="action" value="REJECT">
|
||||
<button type="submit">Reject</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</main>
|
||||
<footer>
|
||||
<p>This page was designed by Yax with <a href="https://simplecss.org">Simple.css</a>.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
42
src/stacosys/interface/templates/login_en.html
Normal file
42
src/stacosys/interface/templates/login_en.html
Normal file
|
@ -0,0 +1,42 @@
|
|||
<!doctype html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Stacosys</title>
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
<style>
|
||||
form {
|
||||
width: 350px;
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h2>Comment Moderation Login</h2>
|
||||
</header>
|
||||
<main>
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
<blockquote>
|
||||
{% for message in messages %}
|
||||
<p>{{ message }}</p>
|
||||
{% endfor %}
|
||||
</blockquote>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
<form action="/web/login" method="POST">
|
||||
<p><label>Username:</label></p>
|
||||
<p><input type="text" name="username" /></p>
|
||||
<p><label>Password:</label></p>
|
||||
<p><input type="password" name="password" /></p>
|
||||
<input type="submit" value="Log in" />
|
||||
</form>
|
||||
</main>
|
||||
<footer>
|
||||
<p>This page was designed with <a href="https://simplecss.org">Simple.css</a>.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
|
@ -37,8 +37,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")
|
||||
if app.config["CONFIG"].get(ConfigParameter.LANG) == "fr":
|
||||
flash("Identifiant ou mot de passe incorrect")
|
||||
else:
|
||||
flash("Username or password incorrect")
|
||||
return redirect("/web/login")
|
||||
# GET
|
||||
return render_template(
|
||||
|
@ -49,6 +51,10 @@ def login():
|
|||
@app.route("/web/logout", methods=["GET"])
|
||||
def logout():
|
||||
session.pop("user")
|
||||
if app.config["CONFIG"].get(ConfigParameter.LANG) == "fr":
|
||||
flash("Vous avez été déconnecté.")
|
||||
else:
|
||||
flash("You have been logged out.")
|
||||
return redirect("/web/admin")
|
||||
|
||||
|
||||
|
@ -58,8 +64,6 @@ def admin_homepage():
|
|||
"user" in session
|
||||
and session["user"] == app.config["CONFIG"].get(ConfigParameter.WEB_USERNAME)
|
||||
):
|
||||
# TODO localization
|
||||
flash("Vous avez été déconnecté.")
|
||||
return redirect("/web/login")
|
||||
|
||||
comments = dao.find_not_published_comments()
|
||||
|
@ -74,15 +78,21 @@ def admin_homepage():
|
|||
def admin_action():
|
||||
comment = dao.find_comment_by_id(request.form.get("comment"))
|
||||
if comment is None:
|
||||
# TODO localization
|
||||
flash("Commentaire introuvable")
|
||||
if app.config["CONFIG"].get(ConfigParameter.LANG) == "fr":
|
||||
flash("Commentaire introuvable")
|
||||
else:
|
||||
flash("Comment not found.")
|
||||
elif request.form.get("action") == "APPROVE":
|
||||
dao.publish_comment(comment)
|
||||
app.config["RSS"].generate()
|
||||
# TODO localization
|
||||
flash("Commentaire publié")
|
||||
if app.config["CONFIG"].get(ConfigParameter.LANG) == "fr":
|
||||
flash("Commentaire publié")
|
||||
else:
|
||||
flash("Comment published.")
|
||||
else:
|
||||
dao.delete_comment(comment)
|
||||
# TODO localization
|
||||
flash("Commentaire supprimé")
|
||||
if app.config["CONFIG"].get(ConfigParameter.LANG) == "fr":
|
||||
flash("Commentaire supprimé")
|
||||
else:
|
||||
flash("Comment deleted.")
|
||||
return redirect("/web/admin")
|
||||
|
|
Loading…
Add table
Reference in a new issue