From 7f155a07032caf916518beca5b33fa5a90300209 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Sat, 20 Jun 2015 19:47:15 -0400 Subject: [PATCH] Refs #25006 -- Added a '6 p.m.' option to the admin's time picker. --- .../admin/static/admin/js/admin/DateTimeShortcuts.js | 2 ++ docs/releases/1.9.txt | 4 ++++ tests/admin_widgets/tests.py | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js b/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js index 7026beac75..9b25b9df36 100644 --- a/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js +++ b/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js @@ -124,6 +124,7 @@ var DateTimeShortcuts = { //
  • Midnight
  • //
  • 6 a.m.
  • //
  • Noon
  • + //
  • 6 p.m.
  • // //

    Cancel

    // @@ -143,6 +144,7 @@ var DateTimeShortcuts = { quickElement("a", quickElement("li", time_list), gettext("Midnight"), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", 0);"); quickElement("a", quickElement("li", time_list), gettext("6 a.m."), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", 6);"); quickElement("a", quickElement("li", time_list), gettext("Noon"), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", 12);"); + quickElement("a", quickElement("li", time_list), gettext("6 p.m."), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", 18);"); var cancel_p = quickElement('p', clock_box); cancel_p.className = 'calendar-cancel'; diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt index 02dba8d2df..8f3c3bce4e 100644 --- a/docs/releases/1.9.txt +++ b/docs/releases/1.9.txt @@ -127,6 +127,7 @@ Minor features applications for the current user, has been added to the :meth:`AdminSite.each_context() ` method. + * :attr:`AdminSite.empty_value_display ` and :attr:`ModelAdmin.empty_value_display @@ -134,6 +135,9 @@ Minor features the display of empty values in admin change list. You can also customize the value for each field. +* The time picker widget includes a '6 p.m' option for consistency of having + predefined options every 6 hours. + :mod:`django.contrib.auth` ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py index 3ab7938ece..c42553a339 100644 --- a/tests/admin_widgets/tests.py +++ b/tests/admin_widgets/tests.py @@ -645,6 +645,13 @@ class DateTimePickerSeleniumFirefoxTests(SeleniumDataMixin, AdminSeleniumWebDriv # Check that the time picker is visible self.assertEqual( self.get_css_value('#clockbox0', 'display'), 'block') + self.assertEqual( + [ + x.text for x in + self.selenium.find_elements_by_xpath("//ul[@class='timelist']/li/a") + ], + ['Now', 'Midnight', '6 a.m.', 'Noon', '6 p.m.'] + ) # Press the ESC key self.selenium.find_element_by_tag_name('body').send_keys([Keys.ESCAPE]) # Check that the time picker is hidden again