[Jifty-commit] r4479 - in apps/spensive: . lib/Spensive lib/Spensive/Model lib/Spensive/View

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Tue Nov 20 12:10:15 EST 2007


Author: jesse
Date: Tue Nov 20 12:10:14 2007
New Revision: 4479

Added:
   apps/spensive/lib/Spensive/View/Prefs.pm
Modified:
   apps/spensive/   (props changed)
   apps/spensive/etc/config.yml
   apps/spensive/lib/Spensive/Dispatcher.pm
   apps/spensive/lib/Spensive/Model/ExpenseReport.pm
   apps/spensive/lib/Spensive/Model/User.pm
   apps/spensive/lib/Spensive/View.pm
   apps/spensive/lib/Spensive/View/Expenses.pm
   apps/spensive/lib/Spensive/View/Reports.pm

Log:
 r67127 at pinglin (orig r7301):  jesse | 2007-09-12 12:20:53 -0400
 


Modified: apps/spensive/etc/config.yml
==============================================================================
--- apps/spensive/etc/config.yml	(original)
+++ apps/spensive/etc/config.yml	Tue Nov 20 12:10:14 2007
@@ -1,7 +1,7 @@
 --- 
 framework: 
   ConfigFileVersion: 2
-  AdminMode: 1
+  AdminMode: 0
   ApplicationClass: Spensive
   ApplicationName: Spensive
   ApplicationUUID: 3FFE1BB2-C132-11DB-893E-FFCA17A9EF72
@@ -27,8 +27,9 @@
         - REST: {}
         - LetMe: {}
         - User: {}
+        - Feedback: {}
         - CompressedCSSandJS:
-            css: 1
+            css: 0
             js: 1
         - Authentication::Password: {}
         - OpenID: {}
@@ -49,3 +50,5 @@
     ServeStaticFiles: 1
     StaticRoot: share/web/static
     TemplateRoot: share/web/templates
+application:
+  EmailDomain: spensive.fsck.com

Modified: apps/spensive/lib/Spensive/Dispatcher.pm
==============================================================================
--- apps/spensive/lib/Spensive/Dispatcher.pm	(original)
+++ apps/spensive/lib/Spensive/Dispatcher.pm	Tue Nov 20 12:10:14 2007
@@ -6,12 +6,22 @@
 use warnings;
 
 
-before qr'^/(?!(?:login|signup|__jifty))' => run {
+before qr'^/(?!(?:login|static|signup|__jifty))' => run {
     unless ( Jifty->web->current_user->id ) {
         Jifty->web->tangent( url => '/login' );
     }
 };
 
+
+on '*' => run {
+    
+    if ( Jifty->web->current_user->id ) {
+    Jifty->web->navigation->child( 'Expense Reports',  url =>  '/reports');
+    Jifty->web->navigation->child( 'Open expenses', url =>'/expenses');
+    Jifty->web->navigation->child( Prefs => label=> 'Preferences' => url => '/prefs');
+}
+};
+
 on qr'/report/(\d+)/build' => run {
     my $report = Spensive::Model::ExpenseReport->new();
     $report->load($1);
@@ -19,4 +29,13 @@
     show 'report/build';
     };
 
+# Change a password
+on '/prefs' => run {
+    redirect('/login') unless ( Jifty->web->current_user->id );
+    set 'action' => Jifty->web->new_action( class => 'UpdateUser', record => Jifty->web->current_user->user_object);
+    set 'next' => Jifty->web->request->continuation
+        || Jifty::Continuation->new(
+        request => Jifty::Request->new( path => "/" ) );
+
+};
 1;

Modified: apps/spensive/lib/Spensive/Model/ExpenseReport.pm
==============================================================================
--- apps/spensive/lib/Spensive/Model/ExpenseReport.pm	(original)
+++ apps/spensive/lib/Spensive/Model/ExpenseReport.pm	Tue Nov 20 12:10:14 2007
@@ -6,7 +6,7 @@
 
 use Spensive::Record schema {
     column title => type is 'text';
-    column description => type is 'text';
+    column description => type is 'text', render as 'textarea';
     column submitted_by => references Spensive::Model::User;
     column submitted => type is 'datetime';
     column approved => type is 'datetime';

Modified: apps/spensive/lib/Spensive/Model/User.pm
==============================================================================
--- apps/spensive/lib/Spensive/Model/User.pm	(original)
+++ apps/spensive/lib/Spensive/Model/User.pm	Tue Nov 20 12:10:14 2007
@@ -3,7 +3,7 @@
 
 package Spensive::Model::User;
 use Jifty::DBI::Schema;
-
+use Text::Password::Pronounceable;
 use Spensive::Record schema {
 
 
@@ -13,6 +13,18 @@
 
 };
 
+
+our $PWGEN =   Text::Password::Pronounceable->new(4=>6);
+
+
+sub published_address { return shift->_value('published_address')."@".Jifty->config->app('EmailDomain') };
+
+sub before_create {
+    my $self = shift;
+    my $args = shift;
+    $args->{'published_address'} = $PWGEN->generate;
+}
+
 use Jifty::Plugin::User::Mixin::Model::User;
 use Jifty::Plugin::Authentication::Password::Mixin::Model::User;
 use Jifty::Plugin::OpenID::Mixin::Model::User;

Modified: apps/spensive/lib/Spensive/View.pm
==============================================================================
--- apps/spensive/lib/Spensive/View.pm	(original)
+++ apps/spensive/lib/Spensive/View.pm	Tue Nov 20 12:10:14 2007
@@ -10,7 +10,6 @@
     h2 { _('(It also helps you get reimbursed for them)') };
 
     h3 { _('Unsubmitted expenses') };
-    span { {class is 'hint'}; hyperlink(label => 'All my expenses...', path => '/expenses/all') };
     form {
         my $search = Spensive::Model::ExpenseCollection->new();
         $search->limit( column => 'expense_report', value => 'null', operator => 'is',  quote_value => 0);
@@ -24,9 +23,13 @@
 
         );
     };
+    span { {class is 'hint'}; hyperlink(label => 'All my expenses...', path => '/expenses/all') };
+};
+
+
+    sub show_open_expense_reports { 
 
     h3 { _('Open expense reports')};
-    span { {class is 'hint'}; hyperlink(label => 'All my expense reports...', path => '/reports/all') };
     form {
         my $search = Spensive::Model::ExpenseReportCollection->new();
         $search->limit(
@@ -42,7 +45,8 @@
 
         );
     };
-};
+    span { {class is 'hint'}; hyperlink(label => 'All my expense reports...', path => '/reports/all') };
+}
 
 
 require Spensive::View::Expenses;
@@ -51,6 +55,10 @@
 require Spensive::View::Reports;
 alias Spensive::View::Reports under 'reports/';
 
+require Spensive::View::Prefs;
+alias Spensive::View::Prefs under './prefs';
+
+
 use Jifty::Plugin::TabView::View;
 
 template 'report/build' => page {
@@ -125,7 +133,7 @@
     h3 { $item->title, ' - ', $item->cost, " - ", };
     form {
         render_param($action => 'expense_report', render_as=>'Hidden', default_value => $report);
-    outs_raw($action->button( onclick=> [{submit => $action, }, { delete => Jifty->web->current_region}] ));
+    outs_raw($action->button( label => 'Add', onclick=> [{submit => $action, }, { delete => Jifty->web->current_region}] ));
     }
 };
 
@@ -137,7 +145,7 @@
     h3 { $item->title, ' - ', $item->cost, " - ", };
     form {
         render_param($action => 'expense_report', render_as=>'Hidden', default_value => undef);
-    outs_raw($action->button( onclick=> [{submit => $action, }, { delete => Jifty->web->current_region}] ));
+    outs_raw($action->button( label => 'Remove', onclick=> [{submit => $action, }, { delete => Jifty->web->current_region}] ));
 }
 };
 1;

Modified: apps/spensive/lib/Spensive/View/Expenses.pm
==============================================================================
--- apps/spensive/lib/Spensive/View/Expenses.pm	(original)
+++ apps/spensive/lib/Spensive/View/Expenses.pm	Tue Nov 20 12:10:14 2007
@@ -8,7 +8,10 @@
 sub fragment_base_path {'/expenses'}
 
 sub object_type { 'Expense' }
+ 
+sub display_columns { return (qw(title cost date_incurred description)); };
+
+private template search_region => sub {};
 
-sub display_columns { return (qw(title cost date_incurred  payment_method description)); };
 
 1;

Added: apps/spensive/lib/Spensive/View/Prefs.pm
==============================================================================
--- (empty file)
+++ apps/spensive/lib/Spensive/View/Prefs.pm	Tue Nov 20 12:10:14 2007
@@ -0,0 +1,57 @@
+use warnings;
+use strict;
+
+package Spensive::View::Prefs;
+
+use Jifty::View::Declare -base;
+
+template 'index.html'  =>  page {
+    title is 'Preferences';
+
+    my ( $action, $next ) = get(qw(action next));
+
+    Jifty->web->form->start( call => $next );
+    h3 { _("A little bit about you") };
+    my $user = Jifty->web->current_user->user_object;
+    div {
+        attr { class => 'form' };
+    render_param( $action => $_ ) for ( 'name', 'time_zone' );
+
+    render_param( $action => 'email', render_mode => 'read' )
+        if $user->email;
+
+    render_param( $action => 'openid', render_mode => 'read' )
+        if $user->openid;
+    form_submit( label => _('Save'), submit => $action );
+    };
+
+        h3 { _('Published address') }; 
+        div {
+            attr { class => 'form' };
+        render_param($action , 'published_address', render_mode => 'read');
+    };
+
+
+
+        h3 { _("Password") };
+
+        div {
+            attr { class => 'form' };
+        render_param( $action => 'password' );
+        render_param(
+            $action => 'password_confirm',
+            label   => 'Type that again?'
+        );
+        form_submit( label => _('Save'), submit => $action );
+        };
+
+    Jifty->web->form->end();
+
+   
+
+    
+
+};
+
+
+1;

Modified: apps/spensive/lib/Spensive/View/Reports.pm
==============================================================================
--- apps/spensive/lib/Spensive/View/Reports.pm	(original)
+++ apps/spensive/lib/Spensive/View/Reports.pm	Tue Nov 20 12:10:14 2007
@@ -7,11 +7,12 @@
 sub fragment_base_path {'/reports'}
 sub object_type { 'ExpenseReport' }
 
+private template search_region => sub {};
 
 private template view_item_controls => sub {
     my $self =shift;
     my $item=shift;
-    tangent(url => '/report/'.$item->id."/build", label => 'Manage expenses');
+    tangent(url => '/report/'.$item->id."/build", label => 'Details');
 };
 
 sub display_columns {


More information about the Jifty-commit mailing list