[Jifty-commit] r3235 - in jifty/trunk: . lib/Jifty/Plugin/SiteNews/Mixin/Model lib/Jifty/View/Declare

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sat May 12 04:01:02 EDT 2007


Author: jesse
Date: Sat May 12 04:00:58 2007
New Revision: 3235

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Plugin/SiteNews/Mixin/Model/News.pm
   jifty/trunk/lib/Jifty/Plugin/SiteNews/View/News.pm
   jifty/trunk/lib/Jifty/View/Declare/CRUD.pm

Log:
 r56809 at pinglin:  jesse | 2007-05-12 04:00:42 -0400
 * site news plugin very close to working. Big known problem is that 'T::D package variables don't propagate quite right.


Modified: jifty/trunk/lib/Jifty/Plugin/SiteNews/Mixin/Model/News.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/SiteNews/Mixin/Model/News.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/SiteNews/Mixin/Model/News.pm	Sat May 12 04:00:58 2007
@@ -5,15 +5,13 @@
 use Jifty::DBI::Schema;
 use base 'Jifty::DBI::Record::Plugin';
 
-our @EXPORT = qw();
+our @EXPORT = qw(current_user_can);
 
 use Jifty::Plugin::SiteNews::Record schema {
 
     my $user_class = Jifty->app_class('Model', 'User');
 
-column author_id =>
-  refers_to $user_class;
-  label is 'Author';
+#column author_id => refers_to $user_class; label is 'Author';
 column created   =>
   type is 'timestamp',
   filters are qw( Jifty::Filter::DateTime Jifty::DBI::Filter::DateTime),
@@ -52,6 +50,7 @@
     my $self = shift;
     my $right = shift;
 
+    return 1;
     # Anyone can read
     return 1 if ($right eq "read");
     

Modified: jifty/trunk/lib/Jifty/Plugin/SiteNews/View/News.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/SiteNews/View/News.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/SiteNews/View/News.pm	Sat May 12 04:00:58 2007
@@ -10,23 +10,44 @@
 
     h1 { 'This is your site news'};
     form {
-        show('list');
+        show('/news/list');
     }
 
 };
 
 
+template 'view' => sub {
+    my $self = 'Jifty::View::Declare::CRUD';
+    my ( $object_type, $id ) = ( $self->object_type, get('id') );
+    my $update = new_action(
+        class => 'Update' . $object_type,
+        moniker => "update-" . Jifty->web->serial,
+        record  => $self->get_record( $id )
+    );
+
+    my $record = $self->get_record($id);
+
+    h1 { $record->title };
+    blockquote {$record->content};
+        hyperlink(
+                label   => "Edit",
+                class   => "editlink",
+                onclick => {
+                    replace_with => $self->fragment_for('update'),
+                    args         => { object_type => $object_type, id => $id }
+                },
+        );
 
 
-template '/edit' => page {
-    h1 {'foo'};
-    
 };
 
 
-alias Jifty::View::Declare::CRUD under '.', { object_type => 'News', base_path => '/news', 
-    fragment_for_list => '/news/list',
-    fragment_for_view => '/news/view'
+
+
+
+alias Jifty::View::Declare::CRUD under '/', { object_type => 'News', base_path => '/news', 
+    fragment_for_view => '/news/view',
+    fragment_for_new_item => '/news/new_item'
 
 };
 

Modified: jifty/trunk/lib/Jifty/View/Declare/CRUD.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Declare/CRUD.pm	(original)
+++ jifty/trunk/lib/Jifty/View/Declare/CRUD.pm	Sat May 12 04:00:58 2007
@@ -12,7 +12,7 @@
 sub fragment_for {
     my $self = shift;
     my $fragment = shift;
-    return ($self->package_variable('fragment_for_'.$fragment)||$self->package_variable('base_path')|| '/crud')."/". $fragment;
+    return $self->package_variable('fragment_for_'.$fragment)||($self->package_variable('base_path')|| '/crud')."/". $fragment;
 }
 
 sub get_record {
@@ -124,8 +124,9 @@
     my $self = shift;
     my ( $object_type) = ($self->object_type);
     
-    my( $page, $new_slot_path, $item_path, $search_collection )= get(qw(page new_slot_path item_path search_collection));
+    my( $page, $fragment_for_new_item, $item_path, $search_collection )= get(qw(page fragment_for_new_item item_path search_collection));
 
+    $fragment_for_new_item ||= $self->package_variable('fragment_for_new_item');
     $item_path ||= $self->fragment_for("view");
 
     my $collection_class
@@ -207,10 +208,10 @@
         }
     };
 
-    if ($new_slot_path) {
+    if ($fragment_for_new_item) {
         render_region(
                 name     => 'new_item',
-                path     => $new_slot_path,
+                path     => $fragment_for_new_item,
                 defaults => { object_type => $object_type },
         );
     }
@@ -218,6 +219,7 @@
 
 
 template 'new_item' => sub {
+    my $self = shift;
     my ( $object_type, $id ) = ($self->object_type, get('id'));
 
     my $record_class = Jifty->app_class("Model", $object_type);


More information about the Jifty-commit mailing list