Commit 93157b54 authored by cynddl's avatar cynddl

Polish edit and preview link

parent 6a49f62e
......@@ -17,12 +17,20 @@
<a class="btn btn-outline-primary" href="{% url 'rp:article-list' filter_view='draft' %}">
<i class="fa fa-chevron-left" aria-hidden="true"></i> Pending articles
</a>
{% if object.status == 'PUBLISHED' %}
<span class="ml-2"><strong>Article ID #{{object.id}} published on {{ object.published_at|date:"DATETIME_FORMAT" }}</strong></span>
{% else %}
<span class="ml-2"><strong>Article ID #{{object.id}}</strong></span>
{% endif %}
</p>
<div class="ml-auto">
<span class="btn-group" role="group" aria-label="Actions">
<a class="btn btn-outline-primary" href="{% url 'rp:article-edit' object.id %}">Éditer</a>
<input type="submit" class="btn btn-outline-warning" name="publish" value="Publier">
{% if object.status == 'PUBLISHED' %}
<a class="btn btn-outline-danger" href="{% url 'rp:article-edit' object.id %}">Edit</a>
{% else %}
<a class="btn btn-outline-primary" href="{% url 'rp:article-edit' object.id %}">Edit</a>
<a class="btn btn-outline-warning" href="#">Publish</a>
{% endif %}
</span>
</div>
</div>
......@@ -35,7 +43,7 @@
{% endif %}
</div>
<div class="col-sm-9 lead">
<h4>{{object.title}}</h4>
<h4><a target="_blank" href="{{object.url}}">{{object.title}}</a></h4>
<p>{{article.created_at.date}}
{% for t in article.tags.all %}
<span class="badge badge-default ml-1">{{t}}</span>
......
......@@ -17,13 +17,21 @@
<div class="d-flex justify-content-start align-items-baseline mb-4">
<p class="lead">
<a class="btn btn-outline-primary" href="{{request.META.HTTP_REFERER}}"><i class="fa fa-chevron-left" aria-hidden="true"></i> Go back</a>
<span class="ml-2"><strong>Article ID #{{object.id}}</strong> – proposé par XXX</span></span>
{% if object.status == 'PUBLISHED' %}
<span class="ml-2"><strong>Article ID #{{object.id}} published on {{ object.published_at|date:"DATETIME_FORMAT" }}</strong></span>
{% else %}
<span class="ml-2"><strong>Article ID #{{object.id}}</strong></span>
{% endif %}
</p>
<div class="ml-auto">
<span>Save and&nbsp;</span>
<span class="btn-group" role="group" aria-label="Actions">
<input type="submit" class="btn btn-outline-primary" name="preview" value="Prévisualiser">
<input type="submit" class="btn btn-outline-warning" name="publish" value="Publier">
{% if object.status == 'PUBLISHED' %}
<input type="submit" class="btn btn-outline-danger" name="view" value="View">
{% else %}
<input type="submit" class="btn btn-outline-primary" name="preview" value="Preview">
<input type="submit" class="btn btn-outline-warning" name="publish" value="Publish">
{% endif %}
</span>
</div>
</div>
......
......@@ -2,7 +2,7 @@ from django.http import HttpResponseRedirect
from django.views.generic.detail import DetailView
from django.views.generic.edit import UpdateView
from django.utils.translation import ugettext_lazy as _
from django.urls import reverse
from django.urls import reverse, reverse_lazy
from django import forms
from crispy_forms.helper import FormHelper
......@@ -58,16 +58,17 @@ class ArticleDetailView(DetailView):
class ArticleEdit(UpdateView):
model = Article
fields = ['screenshot', 'url', 'lang', 'title', 'tags', 'extracts']
success_url = 'article-list'
success_url = reverse_lazy("rp:article-list")
def form_valid(self, form):
self.object = form.save()
if "preview" in self.request.POST:
self.success_url = reverse("rp:article-preview", args=[self.object.id])
elif "view" in self.request.POST:
self.success_url = reverse("rp:article-view", args=[self.object.id])
elif "publish" in self.request.POST:
self.object.publish()
self.success_url = reverse("rp:article-list")
return HttpResponseRedirect(self.get_success_url())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment