cccs-web / core

CCCS' customized django web application
4 stars 11 forks source link

default value of 'to date' as "current" when empty #163

Open cccs-ip opened 10 years ago

cccs-ip commented 10 years ago

For the "to date" on projects, we will often leave this field empty where a project is on-going. Could we make it so that the default value is shown as the word 'current' where no data is supplied? Also, could we make it so that an empty value is automatically assumed to be the the current date (for ordering purposes)?

screenshot from 2014-09-21 22 07 19

pwhipp commented 10 years ago

I believe the ordering is already correct and this issue is largely subsumed by the discussion in #162.

Anywhere in a template you can use the built in filter 'default_if_none' to display a value thus: {% obj.to_date|default_if_none:"present" %}

You can chain filters so to format the date you can add the usual date presentation e.g. {% obj.to_date|default_if_none:"present"|date:"b Y"|title %} In words, this says "present obj.to_date as 'present' if it is none, as a date formatted as 'b Y', formatted as a title"