Edition / suppression pour l'utilisateur ayant posté.
This commit is contained in:
parent
90edf63db5
commit
f153e44a52
7
afpy.py
7
afpy.py
|
@ -110,8 +110,8 @@ def edit_post(name, token=None):
|
|||
abort(404)
|
||||
else:
|
||||
post = {data.STATE: data.STATE_WAITING}
|
||||
if post[data.STATE] != data.STATE_WAITING:
|
||||
return redirect(url_for('rest', name='already_published'))
|
||||
if post[data.STATE] == data.STATE_TRASHED:
|
||||
return redirect(url_for('rest', name='already_trashed'))
|
||||
return render_template(
|
||||
'edit_post.html',
|
||||
body_id='edit-post',
|
||||
|
@ -158,6 +158,9 @@ def save_post(name, token=None):
|
|||
edit_post_url = url_for(
|
||||
'edit_post', name=name, token=signer.dumps(post['_timestamp'])
|
||||
)
|
||||
|
||||
if post[data.STATE] == data.STATE_TRASHED:
|
||||
return redirect(url_for('rest', name='already_trashed'))
|
||||
return render_template(
|
||||
'confirmation.html',
|
||||
edit_post_url=edit_post_url
|
||||
|
|
|
@ -10,7 +10,6 @@ POSTS = {POST_ACTUALITIES: "Actualités", POST_JOBS: "Offres d’emploi"}
|
|||
|
||||
STATE_WAITING = 'waiting'
|
||||
STATE_PUBLISHED = 'published'
|
||||
|
||||
STATE_TRASHED = 'trashed'
|
||||
STATES = {
|
||||
STATE_WAITING: "En attente",
|
||||
|
@ -22,11 +21,13 @@ ACTION_PUBLISH = 'publish'
|
|||
ACTION_UNPUBLISH = 'unpublish'
|
||||
ACTION_REPUBLISH = 'republish'
|
||||
ACTION_TRASH = 'trash'
|
||||
ACTION_EDIT = 'edit'
|
||||
ACTIONS = {
|
||||
ACTION_PUBLISH: "Publier",
|
||||
ACTION_UNPUBLISH: "Dépublier",
|
||||
ACTION_REPUBLISH: "Republier",
|
||||
ACTION_TRASH: "Supprimer",
|
||||
ACTION_EDIT: 'Editer',
|
||||
}
|
||||
|
||||
IMAGE = '_image'
|
||||
|
@ -114,7 +115,7 @@ def save_post(category, timestamp, admin, form):
|
|||
status = STATE_TRASHED
|
||||
else:
|
||||
raise DataException(http_code=404)
|
||||
if status == STATE_PUBLISHED and not admin:
|
||||
if status == STATE_TRASHED and not admin:
|
||||
raise DataException(http_code=401)
|
||||
|
||||
post = get_path(category, status, timestamp, BASE_FILE, create_dir=True)
|
||||
|
@ -134,6 +135,10 @@ def save_post(category, timestamp, admin, form):
|
|||
(root / category / STATE_PUBLISHED / timestamp).rename(
|
||||
root / category / STATE_TRASHED / timestamp
|
||||
)
|
||||
if not admin and ACTION_EDIT in form and status == STATE_PUBLISHED:
|
||||
(root / category / STATE_PUBLISHED / timestamp).rename(
|
||||
root / category / STATE_WAITING / timestamp
|
||||
)
|
||||
|
||||
if admin:
|
||||
if ACTION_PUBLISH in form and status == STATE_WAITING:
|
||||
|
|
9
templates/already_trashed.rst
Normal file
9
templates/already_trashed.rst
Normal file
|
@ -0,0 +1,9 @@
|
|||
===================================
|
||||
Cet article ne peut plus être édité
|
||||
===================================
|
||||
|
||||
Article supprimé
|
||||
===================
|
||||
|
||||
Seuls les administrateurs ont le droit d'éditer un article supprimé.
|
||||
En cas de besoin, n'hésitez pas à nous contacter sur la page `Discussion </discussion>`_.
|
|
@ -50,7 +50,7 @@
|
|||
<label>Adresse e-mail
|
||||
<input name="email" type="email" value="{{ post.email }}" />
|
||||
</label>
|
||||
<input type="submit" value="Enregistrer" />
|
||||
<input type="submit" name="edit" value="Enregistrer" />
|
||||
{% if admin %}
|
||||
{% if post._state == 'waiting' %}
|
||||
<input type="submit" name="publish" value="Publier" />
|
||||
|
|
Loading…
Reference in New Issue
Block a user