[Rt-commit] rt branch, development, updated. 0e0a3367d7fe650e7c4bdbb0ae778242050ee922

Thomas Sibley trs at bestpractical.com
Fri Jul 9 16:33:13 EDT 2010


The branch, development has been updated
       via  0e0a3367d7fe650e7c4bdbb0ae778242050ee922 (commit)
       via  c6d0d2d1ebf7bdf335768d901d563687d77aed7c (commit)
      from  c0dee1923332ac8e3e66691f7eb335c8d9c809c9 (commit)

Summary of changes:
 lib/RT/Action/ConfigSystem.pm  |    8 ++++++++
 lib/RT/Model/Config.pm         |   35 +++++++++++++++++++++++++++++++++++
 share/web/static/css/login.css |    5 +++--
 3 files changed, 46 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit c6d0d2d1ebf7bdf335768d901d563687d77aed7c
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Jul 9 16:33:42 2010 -0400

    Fix positioning nit on login box

diff --git a/share/web/static/css/login.css b/share/web/static/css/login.css
index 5aa0c51..6fa6e10 100644
--- a/share/web/static/css/login.css
+++ b/share/web/static/css/login.css
@@ -34,8 +34,9 @@ margin-right:auto;margin-left:auto;
 }
 
 #login-box .form_field .hints {
- position: absolute;
- left: 12em;
+ position: relative;
+ left: 7.5em;
  font-size: 0.8em;
+ top: 0.2em;
 }
 

commit 0e0a3367d7fe650e7c4bdbb0ae778242050ee922
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Jul 9 16:34:09 2010 -0400

    Show time_zone as a user-friendly select

diff --git a/lib/RT/Action/ConfigSystem.pm b/lib/RT/Action/ConfigSystem.pm
index 53ff684..5f9c203 100644
--- a/lib/RT/Action/ConfigSystem.pm
+++ b/lib/RT/Action/ConfigSystem.pm
@@ -28,6 +28,14 @@ sub arguments {
             },
             ref $value ? ( render_as => 'textarea' ) : (),
         };
+
+        if ( $config->name eq 'time_zone' ) {
+            # Populate with offsets and TZs
+            $args->{$config->name}{'valid_values'} = lazy {
+                RT::Model::Config->formatted_timezones();
+            };
+            $args->{$config->name}{'render_as'} = 'Select';
+        }
     }
     return $self->{__cached_arguments} = $args;
 }
diff --git a/lib/RT/Model/Config.pm b/lib/RT/Model/Config.pm
index 97b0c12..6239a78 100644
--- a/lib/RT/Model/Config.pm
+++ b/lib/RT/Model/Config.pm
@@ -50,6 +50,8 @@ use strict;
 package RT::Model::Config;
 use base qw/RT::Record/;
 use FreezeThaw qw/cmpStr/;
+use DateTime;
+use DateTime::TimeZone;
 
 sub table {'Configs'}
 
@@ -139,5 +141,38 @@ sub _empty_string {
     return '[empty string]';
 }
 
+=head2 formatted_timezones
+
+Returns a listref of hashrefs with display set to "offset from gmt timezone"
+but value to the normal "timezone".  This way we show "-0500 America/New York"
+but still work with the "America/New York" timezone we expect to be saved in the DB.
+
+=cut
+
+sub formatted_timezones {
+    my @positive;
+    my @negative;
+    for my $tz ( DateTime::TimeZone->all_names ) {
+        my $now = DateTime->now( time_zone => $tz );
+        my $offset = $now->strftime("%z");
+        my $zone_data = { offset => $offset, name => $tz };
+        if ($offset =~ /^-/) {
+            push @negative, $zone_data;
+        } else {
+            push @positive, $zone_data;
+        }
+    }
+
+    @negative = sort { $b->{offset} cmp $a->{offset} ||
+                       $a->{name} cmp $b->{name} } @negative;
+    @positive = sort { $a->{offset} cmp $b->{offset} ||
+                       $a->{name} cmp $b->{name} } @positive;;
+
+    return [ map { { display => "$_->{offset} $_->{name}",
+                    value => $_->{name}
+                  }
+               } (@negative, at positive)];
+}
+
 1;
 

-----------------------------------------------------------------------


More information about the Rt-commit mailing list