Start to implemant delete image button on post
This commit is contained in:
parent
6e585c86f4
commit
0bcd4a5618
2
afpy.py
2
afpy.py
|
@ -178,7 +178,6 @@ def save_post_admin(name, timestamp):
|
|||
abort(e.http_code)
|
||||
return redirect(url_for('admin', name=name))
|
||||
|
||||
|
||||
@app.route('/posts/<name>')
|
||||
@app.route('/posts/<name>/page/<int:page>')
|
||||
def posts(name, page=1):
|
||||
|
@ -239,7 +238,6 @@ def post(name, timestamp):
|
|||
name=name
|
||||
)
|
||||
|
||||
|
||||
@app.route('/post_image/<path:path>')
|
||||
def post_image(path):
|
||||
if path.count('/') != 3:
|
||||
|
|
14
data_xml.py
14
data_xml.py
|
@ -1,8 +1,8 @@
|
|||
import email
|
||||
import time
|
||||
import os
|
||||
from pathlib import Path
|
||||
from xml.etree import ElementTree
|
||||
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
|
||||
|
@ -16,7 +16,12 @@ STATES = {STATE_WAITING: "En attente", STATE_PUBLISHED: "Publié"}
|
|||
|
||||
ACTION_PUBLISH = 'publish'
|
||||
ACTION_UNPUBLISH = 'unpublish'
|
||||
ACTIONS = {ACTION_PUBLISH: "Publier", ACTION_UNPUBLISH: "Dépublier"}
|
||||
ACTION_DELETE_IMAGE = 'delete_image'
|
||||
ACTIONS = {
|
||||
ACTION_PUBLISH: "Publier",
|
||||
ACTION_UNPUBLISH: "Dépublier",
|
||||
ACTION_DELETE_IMAGE: "Supprimer l'image"
|
||||
}
|
||||
|
||||
IMAGE = '_image'
|
||||
TIMESTAMP = '_timestamp'
|
||||
|
@ -113,6 +118,9 @@ def save_post(category, timestamp, admin, form, files):
|
|||
element = ElementTree.SubElement(tree, key)
|
||||
element.text = value
|
||||
|
||||
if ACTION_DELETE_IMAGE in form:
|
||||
os.remove(form['_image_path'])
|
||||
|
||||
if 'image' in files:
|
||||
post_image = files['image']
|
||||
filename = secure_filename(post_image.filename)
|
||||
|
@ -136,4 +144,6 @@ def save_post(category, timestamp, admin, form, files):
|
|||
root / category / STATE_WAITING / timestamp
|
||||
)
|
||||
|
||||
|
||||
|
||||
return get_post(category, timestamp)
|
||||
|
|
|
@ -37,7 +37,7 @@ label
|
|||
textarea
|
||||
height: 5em
|
||||
|
||||
input[type="submit"]
|
||||
.button
|
||||
background: $action
|
||||
border: 0
|
||||
color: $text
|
||||
|
|
|
@ -28,7 +28,7 @@ label {
|
|||
textarea {
|
||||
height: 5em; }
|
||||
|
||||
input[type="submit"] {
|
||||
.button {
|
||||
background: #2e5cfd;
|
||||
border: 0;
|
||||
color: #eaeaea;
|
||||
|
@ -39,7 +39,7 @@ input[type="submit"] {
|
|||
text-transform: uppercase;
|
||||
transition: background 250ms;
|
||||
width: auto; }
|
||||
input[type="submit"]:hover {
|
||||
.button:hover {
|
||||
background: #4770fd; }
|
||||
|
||||
.nicEdit-panelContain, .nicEdit-pane {
|
||||
|
|
|
@ -33,7 +33,9 @@
|
|||
<label>Image
|
||||
<img alt="" src="{{ url_for('post_image', path=post._image) }}" />
|
||||
<input name="image" id="image" type="file" value="{{ post.image }}" />
|
||||
<input name="_image_path" id="_image_path" value="{{ post._image }}" type="hidden"/>
|
||||
</label>
|
||||
<input type="submit" name="delete_image" value="Supprimer l'image" class="button" />
|
||||
<label>Contenu de l'article
|
||||
<textarea name="content" id="content">{{ post.content }}</textarea>
|
||||
</label>
|
||||
|
@ -54,12 +56,12 @@
|
|||
<label>Adresse e-mail
|
||||
<input name="email" type="email" value="{{ post.email }}" />
|
||||
</label>
|
||||
<input type="submit" value="Enregistrer" />
|
||||
<input type="submit" value="Enregistrer" class="button" />
|
||||
{% if admin %}
|
||||
{% if post.state == 'waiting' %}
|
||||
<input type="submit" name="publish" value="Publier" />
|
||||
<input type="submit" name="publish" value="Publier" class="button" />
|
||||
{% else %}
|
||||
<input type="submit" name="unpublish" value="Dépublier" />
|
||||
<input type="submit" name="unpublish" value="Dépublier" class="button" />
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</form>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
Il est possible de soutenir le développement de l'AFPy en cotisant ou en effectuant un don.
|
||||
</p>
|
||||
<form action="{{ url_for('pages', name='adhesions') }}">
|
||||
<input type="submit" value="S'inscrire" />
|
||||
<input type="submit" value="S'inscrire" class="button" />
|
||||
</form>
|
||||
|
||||
<h2>Actualités</h2>
|
||||
|
|
Loading…
Reference in New Issue
Block a user