[Jifty-commit] r1575 - in jifty/branches/moose: . lib/Jifty lib/Jifty/Action lib/Jifty/Script lib/Jifty/Web/Form share/web/static/js share/web/templates/__jifty/webservices t/TestApp/t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Fri Jul 14 19:23:32 EDT 2006


Author: audreyt
Date: Fri Jul 14 19:23:30 2006
New Revision: 1575

Added:
   jifty/branches/moose/t/TestApp/t/08-notifications.t
Modified:
   jifty/branches/moose/   (props changed)
   jifty/branches/moose/lib/Jifty/Action/Record.pm
   jifty/branches/moose/lib/Jifty/Notification.pm
   jifty/branches/moose/lib/Jifty/Script/Schema.pm
   jifty/branches/moose/lib/Jifty/Web.pm
   jifty/branches/moose/lib/Jifty/Web/Form/Clickable.pm
   jifty/branches/moose/lib/Jifty/Web/Menu.pm
   jifty/branches/moose/share/web/static/js/calendar.js
   jifty/branches/moose/share/web/static/js/context_menu.js
   jifty/branches/moose/share/web/static/js/jifty.js
   jifty/branches/moose/share/web/static/js/jifty_utils.js
   jifty/branches/moose/share/web/templates/__jifty/webservices/xml

Log:
 r16009 at T (orig r1564):  trs | 2006-07-13 19:24:25 -0400
  r14371 at zot:  tom | 2006-07-13 19:24:06 -0400
  More serious failure message, and don't imply that it's necessarily the server's fault.
 
 r16010 at T (orig r1565):  trs | 2006-07-13 19:37:20 -0400
  r14373 at zot:  tom | 2006-07-13 19:37:09 -0400
  scrollToShow the calendar widget
 
 r16011 at T (orig r1566):  clkao | 2006-07-13 20:33:42 -0400
 Misc cleanups.
 r16021 at T (orig r1568):  trs | 2006-07-14 00:19:42 -0400
  r14414 at zot:  tom | 2006-07-14 00:19:28 -0400
  Only set active child on create if we have a request
 
 r16022 at T (orig r1569):  jesse | 2006-07-14 04:11:02 -0400
  r13922 at pinglin:  jesse | 2006-07-14 03:28:08 -0400
  * Stop notification from flipping out if you use a scalar as the to
  r13923 at pinglin:  jesse | 2006-07-14 03:42:07 -0400
  * fix the compile failure
  r13924 at pinglin:  jesse | 2006-07-14 03:42:34 -0400
  * basic smoke test for jifty's notifications 
 
 r16023 at T (orig r1570):  nelhage | 2006-07-14 15:09:11 -0400
 Don't upgrade the database versions with schema --print. I'm not sure
 if there's a good way to persuade JDBI to give us the SQL to print, so
 we're just spitting out a warning for now, but that's better than the
 old behavior.
 r16024 at T (orig r1571):  nelhage | 2006-07-14 15:09:58 -0400
 Accidentally checked in a warn
 r16025 at T (orig r1572):  nelhage | 2006-07-14 15:13:58 -0400
 Let's not blow up if an action has a result that's an unblessed
 reference.
 r16026 at T (orig r1573):  nelhage | 2006-07-14 15:18:42 -0400
 Jesse informs me UNIVERSAL::isa is the wrong thing. This should have the right effect.
 r16045 at T (orig r1574):  jesse | 2006-07-14 19:12:17 -0400
  r13964 at pinglin:  jesse | 2006-07-14 19:12:07 -0400
  * Switched Jifty::Web::url to use uri.pm rather than "heuristics"
 


Modified: jifty/branches/moose/lib/Jifty/Action/Record.pm
==============================================================================
--- jifty/branches/moose/lib/Jifty/Action/Record.pm	(original)
+++ jifty/branches/moose/lib/Jifty/Action/Record.pm	Fri Jul 14 19:23:30 2006
@@ -119,7 +119,9 @@
 sub arguments {
     my $self = shift;
 
-    unless ( $self->_cached_arguments ) {
+    return $self->_cached_arguments if $self->_cached_arguments;
+
+
         my $field_info = {};
 
         my @fields = $self->possible_fields;
@@ -144,13 +146,16 @@
                 $info->{default_value} = $current_value if $self->record->id;
             }
 
-            if ( defined $column->valid_values && $column->valid_values ) {
-                $info->{valid_values} = [ @{ $column->valid_values } ];
+	    ##################
+	    my $render_as = $column->render_as;
+	    $render_as = defined $render_as ? lc($render_as) : '';
+
+            if ( defined (my $valid_values = $column->valid_values)) {
+                $info->{valid_values} = [ @$valid_values ];
                 $info->{render_as}    = 'Select';
             } elsif ( defined $column->type && $column->type =~ /^bool/i ) {
                 $info->{render_as} = 'Checkbox';
-            } elsif ( defined $column->render_as
-                && $column->render_as =~ /^password$/i )
+            } elsif ( $render_as eq 'password' )
             {
                 my $same = sub {
                     my ( $self, $value ) = @_;
@@ -171,8 +176,7 @@
                 };
             }
 
-            elsif ( defined $column->refers_to ) {
-                my $refers_to = $column->refers_to;
+            elsif ( defined (my $refers_to = $column->refers_to) ) {
                 if ( UNIVERSAL::isa( $refers_to, 'Jifty::Record' ) ) {
 
                     my $collection = Jifty::Collection->new(
@@ -195,6 +199,9 @@
                 }
             }
 
+	    #########
+
+
             # build up a validator sub if the column implements validation
             # and we're not overriding it at the action level
             my $validate_method = "validate_" . $field;
@@ -243,8 +250,7 @@
                     my ( $self, $value ) = @_;
                     return $self->record->$canonicalize_method($value);
                 };
-            } elsif ( defined $column->render_as
-                and $column->render_as eq "Date" )
+            } elsif ( $render_as eq 'date')
             {
                 $info->{'ajax_canonicalizes'} = 1;
             }
@@ -252,15 +258,14 @@
             # If we're hand-coding a render_as, hints or label, let's use it.
             for (qw(render_as label hints length mandatory sort_order)) {
 
-                if ( defined $column->$_ ) {
-                    $info->{$_} = $column->$_;
+                if ( defined (my $val = $column->$_) ) {
+                    $info->{$_} = $val;
                 }
             }
             $field_info->{$field} = $info;
         }
 
-        $self->_cached_arguments($field_info);
-    }
+    $self->_cached_arguments($field_info);
     return $self->_cached_arguments();
 }
 

Modified: jifty/branches/moose/lib/Jifty/Notification.pm
==============================================================================
--- jifty/branches/moose/lib/Jifty/Notification.pm	(original)
+++ jifty/branches/moose/lib/Jifty/Notification.pm	Fri Jul 14 19:23:30 2006
@@ -43,9 +43,7 @@
     my %args = @_;
 
     # initialize message bits to avoid 'undef' warnings
-    for (qw(body preface footer subject)) {
-        $self->$_('');
-    }
+    #for (qw(body preface footer subject)) { $self->$_(''); }
     $self->_recipients( [] );
 
     while ( my ( $arg, $value ) = each %args ) {
@@ -206,11 +204,12 @@
 
     my $currentuser_object_class = Jifty->config->framework('ApplicationClass')."::CurrentUser";
     for my $to ( grep {defined} ($self->to, $self->to_list) ) {
+        if ($to->can('id')) {
         next if     $currentuser_object_class->can("nobody")
                 and $to->id == $currentuser_object_class->nobody->id;
                 
         next if $to->id == $currentuser_object_class->superuser->id;
-        
+        } 
         $self->to($to);
         $self->recipients($to);
         $self->send_one_message(@_);

Modified: jifty/branches/moose/lib/Jifty/Script/Schema.pm
==============================================================================
--- jifty/branches/moose/lib/Jifty/Script/Schema.pm	(original)
+++ jifty/branches/moose/lib/Jifty/Script/Schema.pm	Fri Jul 14 19:23:30 2006
@@ -267,7 +267,11 @@
     my $appv = version->new( $Jifty::VERSION );
 
     return unless $self->upgrade_tables( "Jifty" => $dbv, $appv, "Jifty::Upgrade::Internal" );
-    Jifty::Model::Metadata->store( jifty_db_version => $appv );
+    if( $self->{print} ) {
+        warn "Need to upgrade jifty_db_version to $appv here!";
+    } else {
+        Jifty::Model::Metadata->store( jifty_db_version => $appv );
+    }
 }
 
 =head2 upgrade_application_tables
@@ -283,7 +287,11 @@
         = version->new( Jifty->config->framework('Database')->{'Version'} );
 
     return unless $self->upgrade_tables( $self->{_application_class} => $dbv, $appv );
-    Jifty::Model::Metadata->store( application_db_version => $appv );
+    if( $self->{print} ) {
+        warn "Need to upgrade application_db_version to $appv here!";
+    } else {
+        Jifty::Model::Metadata->store( application_db_version => $appv );
+    }
 }
 
 =head2 upgrade_tables BASECLASS, FROM, TO, [UPGRADECLASS]

Modified: jifty/branches/moose/lib/Jifty/Web.pm
==============================================================================
--- jifty/branches/moose/lib/Jifty/Web.pm	(original)
+++ jifty/branches/moose/lib/Jifty/Web.pm	Fri Jul 14 19:23:30 2006
@@ -111,28 +111,22 @@
 
 sub url {
     my $self = shift;
-    my %args = @_;
+    my %args = (scheme => undef,
+                @_);
 
     my $url  = Jifty->config->framework("Web")->{BaseURL};
     my $port = Jifty->config->framework("Web")->{Port};
-    
-    my $scheme = 'http';
-    if ($url =~ /^(\w+)/) {
-        $scheme = $1;
+   
+    if ($args{'scheme'}) {
+        $self->log->error("Jifty->web->url no longer accepts a 'scheme' argument");
     }
-    $scheme = $args{scheme} if $args{scheme};
-
+    my $uri = URI->new($url);
+    
     if ($ENV{'HTTP_HOST'}) {
-        return $scheme ."://".$ENV{'HTTP_HOST'};
-    }
-
-    my $append_port = 0;
-    if (   ( $scheme  eq 'http' and $port != 80 )
-        or ( $scheme  eq'https' and $port != 443 ) ) {
-        $append_port = 1;
+        return $uri->scheme ."://".$ENV{'HTTP_HOST'};
     }
-    return( $url . ($append_port ? ":$port" : ""));
 
+    return $uri->canonical;
 }
 
 =head3 serial 

Modified: jifty/branches/moose/lib/Jifty/Web/Form/Clickable.pm
==============================================================================
--- jifty/branches/moose/lib/Jifty/Web/Form/Clickable.pm	(original)
+++ jifty/branches/moose/lib/Jifty/Web/Form/Clickable.pm	Fri Jul 14 19:23:30 2006
@@ -519,7 +519,6 @@
                 } 
                 # Toggle region if the toggle flag is set, and clicking wouldn't change path
                 if ($hook->{toggle} and $hook->{replace_with} eq $currently_shown) {
-                    warn "Toggling region @{[$hook->{region}]} to empty";
                     $self->region_fragment( $hook->{region}, "/__jifty/empty" );
 #                    Jifty->web->request->remove_state_variable('region-'.$region->qualified_name);
                 } else {

Modified: jifty/branches/moose/lib/Jifty/Web/Menu.pm
==============================================================================
--- jifty/branches/moose/lib/Jifty/Web/Menu.pm	(original)
+++ jifty/branches/moose/lib/Jifty/Web/Menu.pm	Fri Jul 14 19:23:30 2006
@@ -105,23 +105,21 @@
                                                         escape_label => 1,
                                                         @_
                                                        });
-    # Activate it
-    if (my $url = $self->{children}{$key}->url) {
-    # XXX TODO cleanup for mod_perl
-    my $base_path = Jifty->web->request->path;
-    chomp($base_path);
+        # Activate it
+        if (my $url = $self->{children}{$key}->url and Jifty->web->request) {
+            # XXX TODO cleanup for mod_perl
+            my $base_path = Jifty->web->request->path;
+            chomp($base_path);
         
-    $base_path =~ s/index\.html$//g;
-    $base_path =~ s/\/+$//g;
-    $url =~ s/\/+$//i;
-    if ($url eq $base_path) {
-        $self->{children}{$key}->active(1); 
+            $base_path =~ s/index\.html$//g;
+            $base_path =~ s/\/+$//g;
+            $url =~ s/\/+$//i;
+    
+            if ($url eq $base_path) {
+                $self->{children}{$key}->active(1); 
+            }
+	    }
     }
-	}
-
-}
-
-
 
     return $self->{children}{$key}
 }

Modified: jifty/branches/moose/share/web/static/js/calendar.js
==============================================================================
--- jifty/branches/moose/share/web/static/js/calendar.js	(original)
+++ jifty/branches/moose/share/web/static/js/calendar.js	Fri Jul 14 19:23:30 2006
@@ -33,6 +33,7 @@
         if ( wrap ) {
             wrap.style.display = "block";
             Jifty.Calendar.openCalendar = wrapId;
+            Jifty.Utils.scrollToShow( wrapId );
             return;
         }
 
@@ -67,6 +68,7 @@
         cal.render();
         
         Jifty.Calendar.openCalendar = wrapId;
+        Jifty.Utils.scrollToShow( wrapId );
         /*Jifty.Calendar.preventStutter = wrapId;*/
     },
 

Modified: jifty/branches/moose/share/web/static/js/context_menu.js
==============================================================================
--- jifty/branches/moose/share/web/static/js/context_menu.js	(original)
+++ jifty/branches/moose/share/web/static/js/context_menu.js	Fri Jul 14 19:23:30 2006
@@ -84,7 +84,7 @@
         
         ul.style.display = "block";
         Jifty.ContextMenu.currently_open = ul.id;
-        Jifty.ContextMenu.scrollToShow( ul.id );
+        Jifty.Utils.scrollToShow( ul.id );
     },
 
     hideOpenMenu: function(event) {
@@ -105,17 +105,6 @@
         if (Jifty.ContextMenu.currently_open) {
             Jifty.ContextMenu.hide(Jifty.ContextMenu.currently_open);
         }
-    },
-
-    scrollToShow: function(id) {
-        var ul        = $(id);
-        var y         = Jifty.Utils.findPosY( ul ) + ul.offsetHeight + 10;
-        var scrollTop = Jifty.Utils.getScrollTop();
-        var screen    = Jifty.Utils.findScreenHeight() + scrollTop;
-        var diff      = y - screen;
-        
-        if ( diff > 0 )
-             Jifty.SmoothScroll.scrollTo( scrollTop + diff );
     }
 };
 

Modified: jifty/branches/moose/share/web/static/js/jifty.js
==============================================================================
--- jifty/branches/moose/share/web/static/js/jifty.js	(original)
+++ jifty/branches/moose/share/web/static/js/jifty.js	Fri Jul 14 19:23:30 2006
@@ -698,7 +698,7 @@
     var onFailure = function(transport, object) {
         hide_wait_message_now();
         
-        alert("Oops!  Looks like the server is down.\n\nTry again in a few minutes.");
+        alert("Unable to connect to server.\n\nTry again in a few minutes.");
 
         var keys = request["actions"].keys();
         for ( var i = 0; i < keys.length; i++ ) {

Modified: jifty/branches/moose/share/web/static/js/jifty_utils.js
==============================================================================
--- jifty/branches/moose/share/web/static/js/jifty_utils.js	(original)
+++ jifty/branches/moose/share/web/static/js/jifty_utils.js	Fri Jul 14 19:23:30 2006
@@ -97,6 +97,17 @@
         if (window.pageYOffset)
             return window.pageYOffset;
         return 0; 
+    },
+
+    scrollToShow: function(id) {
+        var ul        = $(id);
+        var y         = Jifty.Utils.findPosY( ul ) + ul.offsetHeight + 10;
+        var scrollTop = Jifty.Utils.getScrollTop();
+        var screen    = Jifty.Utils.findScreenHeight() + scrollTop;
+        var diff      = y - screen;
+        
+        if ( diff > 0 )
+             Jifty.SmoothScroll.scrollTo( scrollTop + diff );
     }
 };
 

Modified: jifty/branches/moose/share/web/templates/__jifty/webservices/xml
==============================================================================
--- jifty/branches/moose/share/web/templates/__jifty/webservices/xml	(original)
+++ jifty/branches/moose/share/web/templates/__jifty/webservices/xml	Fri Jul 14 19:23:30 2006
@@ -66,8 +66,9 @@
     # Jifty::DBI::Record's yet, which are technically circular data
     # structures at some level (current_user of a
     # current_user->user_object is itself)
+    use Scalar::Util qw(blessed);
     my $content = $results{$_}->content;
-    ref $content->{$_}
+    blessed $content->{$_}
         and ( $content->{$_}->isa("Jifty::DBI::Record")
            or $content->{$_}->isa("Jifty::DBI::Collection") )
         and delete $content->{$_}

Added: jifty/branches/moose/t/TestApp/t/08-notifications.t
==============================================================================
--- (empty file)
+++ jifty/branches/moose/t/TestApp/t/08-notifications.t	Fri Jul 14 19:23:30 2006
@@ -0,0 +1,13 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+use lib 't/lib';
+use Jifty::SubTest;
+
+use Jifty::Test tests => 2;
+use_ok('Jifty::Notification');
+
+TODO: {local $TODO = "Actually write tests"; ok(0, "Test notifications")};
+
+1;


More information about the Jifty-commit mailing list