1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Standardized date/time displays; moved format declarations to configuration.py

This commit is contained in:
Jeremy Stretch
2016-06-22 13:22:59 -04:00
parent 5f0d52e59a
commit 8563e2aca3
8 changed files with 39 additions and 16 deletions

View File

@ -127,3 +127,20 @@ Determine how many objects to display per page within each list of objects.
Default: UTC Default: UTC
The time zone NetBox will use when dealing with dates and times. It is recommended to use UTC time unless you have a specific need to use a local time zone. [List of available time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). The time zone NetBox will use when dealing with dates and times. It is recommended to use UTC time unless you have a specific need to use a local time zone. [List of available time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
---
#### Date and Time Formatting
You may define custom formatting for date and times. For detailed instructions on writing format strings, please see [the Django documentation](https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date).
Defaults:
```
DATE_FORMAT = 'N j, Y' # June 26, 2016
SHORT_DATE_FORMAT = 'Y-m-d' # 2016-06-27
TIME_FORMAT = 'g:i a' # 1:23 p.m.
SHORT_TIME_FORMAT = 'H:i:s' # 13:23:00
DATETIME_FORMAT = 'N j, Y g:i a' # June 26, 2016 1:23 p.m.
SHORT_DATETIME_FORMAT = 'Y-m-d H:i' # 2016-06-27 13:23
```

View File

@ -64,3 +64,12 @@ PAGINATE_COUNT = 50
# Time zone (default: UTC) # Time zone (default: UTC)
TIME_ZONE = 'UTC' TIME_ZONE = 'UTC'
# Date/time formatting. See the following link for supported formats:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATE_FORMAT = 'N j, Y'
SHORT_DATE_FORMAT = 'Y-m-d'
TIME_FORMAT = 'g:i a'
SHORT_TIME_FORMAT = 'H:i:s'
DATETIME_FORMAT = 'N j, Y g:i a'
SHORT_DATETIME_FORMAT = 'Y-m-d H:i'

View File

@ -29,9 +29,14 @@ PAGINATE_COUNT = getattr(configuration, 'PAGINATE_COUNT', 50)
NETBOX_USERNAME = getattr(configuration, 'NETBOX_USERNAME', '') NETBOX_USERNAME = getattr(configuration, 'NETBOX_USERNAME', '')
NETBOX_PASSWORD = getattr(configuration, 'NETBOX_PASSWORD', '') NETBOX_PASSWORD = getattr(configuration, 'NETBOX_PASSWORD', '')
TIME_ZONE = getattr(configuration, 'TIME_ZONE', 'UTC') TIME_ZONE = getattr(configuration, 'TIME_ZONE', 'UTC')
DATE_FORMAT = getattr(configuration, 'DATE_FORMAT', 'N j, Y')
SHORT_DATE_FORMAT = getattr(configuration, 'SHORT_DATE_FORMAT', 'Y-m-d')
TIME_FORMAT = getattr(configuration, 'TIME_FORMAT', 'g:i a')
SHORT_TIME_FORMAT = getattr(configuration, 'SHORT_TIME_FORMAT', 'H:i:s')
DATETIME_FORMAT = getattr(configuration, 'DATETIME_FORMAT', 'N j, Y g:i a')
SHORT_DATETIME_FORMAT = getattr(configuration, 'SHORT_DATETIME_FORMAT', 'Y-m-d H:i')
CSRF_TRUSTED_ORIGINS = ALLOWED_HOSTS CSRF_TRUSTED_ORIGINS = ALLOWED_HOSTS
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Database # Database
@ -133,14 +138,6 @@ LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/' LOGIN_REDIRECT_URL = '/'
LOGOUT_URL = '/logout/' LOGOUT_URL = '/logout/'
# Default time formats
DATE_FORMAT = 'N j, Y'
SHORT_DATE_FORMAT = 'Y-m-d'
TIME_FORMAT = 'g:i:s a'
SHORT_TIME_FORMAT = 'H:i:s'
DATETIME_FORMAT = 'N j, Y \a\t g:i a'
SHORT_DATETIME_FORMAT = 'Y-m-d H:i'
# Secrets # Secrets
SECRETS_MIN_PUBKEY_SIZE = 2048 SECRETS_MIN_PUBKEY_SIZE = 2048

View File

@ -149,7 +149,7 @@
{% for a in recent_activity %} {% for a in recent_activity %}
<div class="list-group-item"> <div class="list-group-item">
{{ a.icon }} {{ a.message|safe }}<br /> {{ a.icon }} {{ a.message|safe }}<br />
<small class="text-muted">{{ a.user }} - {{ a.time|date:"Y-m-d H:i" }}</small> <small class="text-muted">{{ a.user }} - {{ a.time|date:'SHORT_DATETIME_FORMAT' }}</small>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>

View File

@ -49,7 +49,7 @@
<td>Date Added</td> <td>Date Added</td>
<td> <td>
{% if aggregate.date_added %} {% if aggregate.date_added %}
<span>{{ aggregate.date_added|date }}</span> <span>{{ aggregate.date_added }}</span>
{% else %} {% else %}
<span class="text-muted">Not defined</span> <span class="text-muted">Not defined</span>
{% endif %} {% endif %}

View File

@ -57,11 +57,11 @@
</tr> </tr>
<tr> <tr>
<td>Created</td> <td>Created</td>
<td>{{ secret.created|date }}</td> <td>{{ secret.created }}</td>
</tr> </tr>
<tr> <tr>
<td>Last Modified</td> <td>Last Updated</td>
<td>{{ secret.last_modified|date:'DATETIME_FORMAT' }}</td> <td>{{ secret.last_updated }}</td>
</tr> </tr>
</table> </table>
</div> </div>

View File

@ -21,7 +21,7 @@
<small class="text-muted">Email</small> <small class="text-muted">Email</small>
<h5>{{ request.user.email }}</h5> <h5>{{ request.user.email }}</h5>
<small class="text-muted">Registered</small> <small class="text-muted">Registered</small>
<h5>{{ request.user.date_joined|date }}</h5> <h5>{{ request.user.date_joined }}</h5>
<small class="text-muted">Groups</small> <small class="text-muted">Groups</small>
<h5>{{ request.user.groups.all|join:', ' }}</h5> <h5>{{ request.user.groups.all|join:', ' }}</h5>
<small class="text-muted">Admin access</small> <small class="text-muted">Admin access</small>

View File

@ -24,7 +24,7 @@
<tbody> <tbody>
{% for action in recent_activity %} {% for action in recent_activity %}
<tr> <tr>
<td>{{ action.time|date:"Y-m-d H:i" }}</td> <td>{{ action.time|date:'SHORT_DATETIME_FORMAT' }}</td>
<td>{{ action.icon }} {{ action.message|safe }}</td> <td>{{ action.icon }} {{ action.message|safe }}</td>
</tr> </tr>
{% endfor %} {% endfor %}