[Jifty-commit] r5917 - in JiftyX-ExpenseApp/trunk: lib/Jifty/Plugin/ExpenseApp/Model

Jifty commits jifty-commit at lists.jifty.org
Fri Oct 10 12:48:49 EDT 2008


Author: gugod
Date: Fri Oct 10 12:48:48 2008
New Revision: 5917

Modified:
   JiftyX-ExpenseApp/trunk/   (props changed)
   JiftyX-ExpenseApp/trunk/lib/Jifty/Plugin/ExpenseApp/Model/Expense.pm

Log:
 r24488 at yra:  gugod | 2008-10-10 12:22:25 +0800
 Send a default list of categories if nothing matches.
 


Modified: JiftyX-ExpenseApp/trunk/lib/Jifty/Plugin/ExpenseApp/Model/Expense.pm
==============================================================================
--- JiftyX-ExpenseApp/trunk/lib/Jifty/Plugin/ExpenseApp/Model/Expense.pm	(original)
+++ JiftyX-ExpenseApp/trunk/lib/Jifty/Plugin/ExpenseApp/Model/Expense.pm	Fri Oct 10 12:48:48 2008
@@ -9,7 +9,7 @@
 use Jifty::Plugin::ExpenseApp::Record schema {
     column created_at =>
         type is 'timestamp',
-        render_as "Hidden",
+        render as "Hidden",
         default is defer { Jifty::DateTime->now },
         filters are ('Jifty::Filter::DateTime', 'Jifty::DBI::Filter::DateTime');
 
@@ -27,22 +27,24 @@
 
     column amount =>
         type is 'int',
+        label is _("Amount of money"),
         is mandatory;
 
     column currency =>
         type is 'varchar(255)',
         label is _("Currency"),
-        render_as "Radio",
+        render as "Radio",
         is mandatory,
         valid_values are qw(JPY NTD);
 
     column category =>
+        type is 'varchar(255)',
         label is _("Category"),
-        type is 'varchar(255)';
+        hints is _("Any text is OK. You define your own categories.");
 
     column note =>
         type is 'text',
-        render_as 'Textarea';
+        render as 'Textarea';
 };
 
 sub current_user_can {
@@ -63,8 +65,15 @@
         operator => "MATCHES",
         value => $value
     );
+    return map { $_->category } @{ $c->items_array_ref } unless $c->count == 0;
 
-    return map { $_->category } @{ $c->items_array_ref }
+    # Default list
+    return (
+        _("Food"),
+        _("Fuel"),
+        _("Books"),
+        _("Groceries")
+    );
 }
 
 1;


More information about the Jifty-commit mailing list