Commit 319c9a87 authored by Okhin's avatar Okhin
Browse files

En modifiant la classe __str__ on peut afficher l'URL si le titre est absent...

En modifiant la classe __str__ on peut afficher l'URL si le titre est absent ou vide, partout ou il est fait référence à l'article
parent 369c72a9
Pipeline #2684 passed with stages
in 3 minutes and 44 seconds
...@@ -123,8 +123,8 @@ class Article(models.Model): ...@@ -123,8 +123,8 @@ class Article(models.Model):
ordering = ["-published_at", "-updated_at", "-created_at"] ordering = ["-published_at", "-updated_at", "-created_at"]
def __str__(self): def __str__(self):
""" Returns article title. """ """ Returns article title. Or URL if title is empty"""
return self.title return self.title if self.title else self.url
# Finite state logic # Finite state logic
@transition(field=status, source='DRAFT', target='PUBLISHED', @transition(field=status, source='DRAFT', target='PUBLISHED',
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
<td>{{}}</td> <td>{{}}</td>
<td>{{article.created_at |date:'d/m/y'}}<br />{{article.created_at |date:'H:i'}}</td> <td>{{article.created_at |date:'d/m/y'}}<br />{{article.created_at |date:'H:i'}}</td>
<td>{{article.lang}}</td> <td>{{article.lang}}</td>
<td class="title-cell"><a target="_blank" href="{{article.url}}"><strong>{{article.title}}</strong></a></td> <td class="title-cell"><a target="_blank" href="{{article.url}}"><strong>{{article}}</strong></a></td>
<td> <td>
<span id="score_{{}}">{{article.score}}</span> <span id="score_{{}}">{{article.score}}</span>
{% if filter_view != "published" %} {% if filter_view != "published" %}
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