#142 Localized date improved

* fixes bug where created timestamp has been displayed on modified attribute on detail views
* enhances localized date and datetime rendering
* reorders sub menus in user's profile hub
pull/143/head
mpeltriaux 3 years ago
parent a22f52ddd4
commit 250189d895

@ -90,9 +90,15 @@
<tr> <tr>
<th scope="row">{% trans 'Last modified' %}</th> <th scope="row">{% trans 'Last modified' %}</th>
<td class="align-middle"> <td class="align-middle">
{{obj.modified.timestamp|default_if_none:""|naturalday}} {% if obj.modified %}
{{obj.modified.timestamp|default_if_none:""}}
<br> <br>
{{obj.modified.user.username}} {{obj.modified.user.username}}
{% else %}
{{obj.created.timestamp|default_if_none:""}}
<br>
{{obj.created.user.username}}
{% endif %}
</td> </td>
</tr> </tr>
<tr> <tr>

@ -73,9 +73,15 @@
<tr> <tr>
<th scope="row">{% trans 'Last modified' %}</th> <th scope="row">{% trans 'Last modified' %}</th>
<td class="align-middle"> <td class="align-middle">
{{obj.modified.timestamp|default_if_none:""|naturalday}} {% if obj.modified %}
{{obj.modified.timestamp|default_if_none:""}}
<br> <br>
{{obj.modified.user.username}} {{obj.modified.user.username}}
{% else %}
{{obj.created.timestamp|default_if_none:""}}
<br>
{{obj.created.user.username}}
{% endif %}
</td> </td>
</tr> </tr>
<tr> <tr>

@ -60,14 +60,13 @@
<th scope="row">{% trans 'Last modified' %}</th> <th scope="row">{% trans 'Last modified' %}</th>
<td class="align-middle"> <td class="align-middle">
{% if obj.modified %} {% if obj.modified %}
{{obj.modified.timestamp|default_if_none:""|naturalday}} {{obj.modified.timestamp|default_if_none:""}}
<br> <br>
{{obj.modified.user.username}} {{obj.modified.user.username}}
{% else %} {% else %}
{{obj.created.timestamp|default_if_none:""|naturalday}} {{obj.created.timestamp|default_if_none:""}}
<br> <br>
{{obj.created.user.username}} {{obj.created.user.username}}
{% endif %} {% endif %}
</td> </td>
</tr> </tr>

@ -1,5 +1,5 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load i18n l10n static fontawesome_5 humanize %} {% load i18n l10n static fontawesome_5 %}
{% block head %} {% block head %}
{% comment %} {% comment %}
@ -106,9 +106,15 @@
<tr> <tr>
<th scope="row">{% trans 'Last modified' %}</th> <th scope="row">{% trans 'Last modified' %}</th>
<td class="align-middle"> <td class="align-middle">
{{obj.created.timestamp|default_if_none:""|naturalday}} {% if obj.modified %}
{{obj.modified.timestamp|default_if_none:""}}
<br>
{{obj.modified.user.username}}
{% else %}
{{obj.created.timestamp|default_if_none:""}}
<br> <br>
{{obj.created.user.username}} {{obj.created.user.username}}
{% endif %}
</td> </td>
</tr> </tr>
<tr> <tr>

@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/3.1/ref/settings/
""" """
import os import os
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from django.conf.locale.de import formats as de_formats
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = os.path.dirname( BASE_DIR = os.path.dirname(
@ -162,9 +163,15 @@ LANGUAGES = [
USE_THOUSAND_SEPARATOR = True USE_THOUSAND_SEPARATOR = True
# Regular python relevant date/datetime formatting
DEFAULT_DATE_TIME_FORMAT = '%d.%m.%Y %H:%M:%S' DEFAULT_DATE_TIME_FORMAT = '%d.%m.%Y %H:%M:%S'
DEFAULT_DATE_FORMAT = '%d.%m.%Y' DEFAULT_DATE_FORMAT = '%d.%m.%Y'
# Template relevant date/datetime formatting
# See the Note on here: https://docs.djangoproject.com/en/3.2/ref/templates/builtins/#date
de_formats.DATETIME_FORMAT = "d.m.Y, H:i"
de_formats.DATE_FORMAT = "d.m.Y"
TIME_ZONE = 'Europe/Berlin' TIME_ZONE = 'Europe/Berlin'
USE_I18N = True USE_I18N = True

@ -10,7 +10,7 @@ import uuid
from django.db import models from django.db import models
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from konova.sub_settings.django_settings import DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT from konova.sub_settings.django_settings import DEFAULT_DATE_TIME_FORMAT
class UserAction(models.TextChoices): class UserAction(models.TextChoices):

@ -55,18 +55,18 @@
</a> </a>
</div> </div>
<div class="row mb-2"> <div class="row mb-2">
<a href="{% url 'user:api-token' %}" title="{% trans 'See or edit your API token' %}"> <a href="{% url 'user:team-index' %}" title="{% trans 'Manage teams' %}">
<button class="btn btn-default"> <button class="btn btn-default">
{% fa5_icon 'code' %} {% fa5_icon 'users' %}
<span>{% trans 'API' %}</span> <span>{% trans 'Teams' %}</span>
</button> </button>
</a> </a>
</div> </div>
<div class="row mb-2"> <div class="row mb-2">
<a href="{% url 'user:team-index' %}" title="{% trans 'Manage teams' %}"> <a href="{% url 'user:api-token' %}" title="{% trans 'See or edit your API token' %}">
<button class="btn btn-default"> <button class="btn btn-default">
{% fa5_icon 'users' %} {% fa5_icon 'code' %}
<span>{% trans 'Teams' %}</span> <span>{% trans 'API' %}</span>
</button> </button>
</a> </a>
</div> </div>

Loading…
Cancel
Save