Skip to content

Commit

Permalink
Corrige la résolution des dates
Browse files Browse the repository at this point in the history
- on utilise les objets de validation pour la first_publication_date
- on utilise le max(update_date, publication_date) pour la last_publication

Co-Authored-By: artragis <[email protected]>
  • Loading branch information
Situphen and artragis committed Mar 20, 2019
1 parent 222567d commit 8357aed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions templates/tutorialv2/stats/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,14 @@ <h3>{% trans "Échelle de temps" %}</h3>
{% endwith %}
</li>
<li>
{% with start_date=db_content.public_version.publication_date.date end_date=0|datedelta_from_day %}
{% with start_date=db_content.public_version.last_publication_date.date end_date=0|datedelta_from_day %}
<a class="{% if request.GET.start_date == start_date|date:'Y-m-d' %}selected{% endif %}"
href="{% append_query_params start_date=start_date,end_date=end_date %}{% if display == 'comparison' %}{% for url in urls %}&urls={{url.url}}{% endfor %}{% endif %}">
{% trans "Depuis la dernière publication" %}
</a>
{% endwith %}
</li>
{% if db_content.first_publication_date.date != public_version.publication_date.date %}
{% if db_content.first_publication_date.date != db_content.public_version.last_publication_date.date %}
<li>
{% with start_date=db_content.first_publication_date.date end_date=0|datedelta_from_day %}
<a class="{% if request.GET.start_date == start_date|date:'Y-m-d' %}selected{% endif %}"
Expand Down
8 changes: 6 additions & 2 deletions zds/tutorialv2/models/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ def first_publication_date(self):
:return: the first publication date
:rtype: datetime
"""
return PublishedContent.objects.filter(content=self).order_by('publication_date')\
.values_list('publication_date', flat=True)[0]
return Validation.objects.filter(content=self, status='ACCEPT').order_by('date_validation')\
.values_list('date_validation', flat=True)[0]

def load_version(self, sha=None, public=None):
"""Using git, load a specific version of the content. if ``sha`` is ``None``,
Expand Down Expand Up @@ -911,6 +911,10 @@ def get_char_count(self, md_file_path=None):
except OSError as e:
logger.warning('could not get file %s to compute nb letters (error=%s)', md_file_path, e)

@property
def last_publication_date(self):
return max(self.publication_date, self.update_date or datetime.min)

@classmethod
def get_es_mapping(cls):
mapping = Mapping(cls.get_es_document_type())
Expand Down

0 comments on commit 8357aed

Please sign in to comment.