Просмотр исходного кода

Do not use annotated_date on custom date fields to avoid date parsing

@jeremystretch:

> It'd be better to have the custom field return a date object than to
> accommodate string values in the template filter. Let's just omit custom
> field dates for now to keep this from getting any more complex.
Robin Schneider 4 лет назад
Родитель
Сommit
a479c867c4

+ 0 - 3
netbox/templates/inc/custom_fields_panel.html

@@ -1,4 +1,3 @@
-{% load helpers %}
 {% with custom_fields=object.get_custom_fields %}
     {% if custom_fields %}
         <div class="panel panel-default">
@@ -18,8 +17,6 @@
                                 <a href="{{ value }}">{{ value|truncatechars:70 }}</a>
                             {% elif field.type == 'multiselect' and value %}
                                 {{ value|join:", " }}
-                            {% elif field.type == 'date' and value %}
-                                {{ value|annotated_date }}
                             {% elif value is not None %}
                                 {{ value }}
                             {% elif field.required %}

+ 0 - 4
netbox/utilities/templatetags/helpers.py

@@ -162,10 +162,6 @@ def annotated_date(date_value):
     if not date_value:
         return ''
 
-    # ../../templates/inc/custom_fields_panel.html passes a string.
-    if type(date_value) == str:
-        date_value = datetime.datetime.strptime(date_value, "%Y-%m-%d").date()
-
     if type(date_value) == datetime.date:
         long_ts = date(date_value, 'DATE_FORMAT')
         short_ts = date(date_value, 'SHORT_DATE_FORMAT')