[Jifty-commit] r4475 - in apps/spensive: . bin doc etc lib/Spensive
lib/Spensive/Model lib/Spensive/View share share/po share/web
share/web/templates t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Tue Nov 20 12:09:44 EST 2007
Author: jesse
Date: Tue Nov 20 12:09:43 2007
New Revision: 4475
Added:
apps/spensive/bin/
apps/spensive/bin/jifty (contents, props changed)
apps/spensive/doc/
apps/spensive/etc/
apps/spensive/etc/config.yml
apps/spensive/share/
apps/spensive/share/po/
apps/spensive/share/web/
apps/spensive/share/web/static/
apps/spensive/share/web/templates/
apps/spensive/t/
apps/spensive/t/00-model-Attachment.t
apps/spensive/t/00-model-Expense.t
apps/spensive/t/00-model-ExpenseReport.t
apps/spensive/t/00-model-Organization.t
apps/spensive/t/00-model-OrganizationMember.t
apps/spensive/t/00-model-SubmissionAddress.t
apps/spensive/t/00-model-Team.t
apps/spensive/t/00-model-TeamMember.t
apps/spensive/t/00-model-User.t
Modified:
apps/spensive/ (props changed)
apps/spensive/lib/Spensive/Model/Expense.pm
apps/spensive/lib/Spensive/Model/ExpenseReport.pm
apps/spensive/lib/Spensive/View.pm
apps/spensive/lib/Spensive/View/Expenses.pm
Log:
r58205 at pinglin (orig r6552): jesse | 2007-06-09 23:15:38 -0400
r58202 at pinglin: jesse | 2007-06-09 23:13:35 -0400
* checkpoint
Added: apps/spensive/bin/jifty
==============================================================================
--- (empty file)
+++ apps/spensive/bin/jifty Tue Nov 20 12:09:43 2007
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+use File::Basename qw(dirname);
+use UNIVERSAL::require;
+
+BEGIN {
+ Jifty::Util->require or die $UNIVERSAL::require::ERROR;
+ my $root = Jifty::Util->app_root;
+ unshift @INC, "$root/lib" if ($root);
+}
+
+use Jifty::Script;
+local $SIG{INT} = sub { warn "Stopped\n"; exit; };
+Jifty::Script->dispatch();
Added: apps/spensive/etc/config.yml
==============================================================================
--- (empty file)
+++ apps/spensive/etc/config.yml Tue Nov 20 12:09:43 2007
@@ -0,0 +1,45 @@
+---
+framework:
+ AdminMode: 1
+ ApplicationClass: Spensive
+ ApplicationName: Spensive
+ ApplicationUUID: 3FFE1BB2-C132-11DB-893E-FFCA17A9EF72
+ Database:
+ CheckSchema: 1
+ Database: spensive
+ Driver: SQLite
+ Host: localhost
+ Password: ''
+ RecordBaseClass: Jifty::DBI::Record::Cachable
+ User: ''
+ Version: 0.0.3
+ DevelMode: 1
+ L10N:
+ PoDir: share/po
+ LogLevel: DEBUG
+ Mailer: IO
+ MailerArgs: []
+
+ Plugins:
+ - LetMe: {}
+ - User: {}
+ - Authentication::Password: {}
+ - OpenID: {}
+
+ PubSub:
+ Backend: Memcached
+ Enable: ~
+ Web:
+ BaseURL: http://localhost
+ DataDir: var/mason
+ Globals: []
+
+ MasonConfig:
+ autoflush: 0
+ default_escape_flags: h
+ error_format: text
+ error_mode: fatal
+ Port: 8888
+ ServeStaticFiles: 1
+ StaticRoot: share/web/static
+ TemplateRoot: share/web/templates
Modified: apps/spensive/lib/Spensive/Model/Expense.pm
==============================================================================
--- apps/spensive/lib/Spensive/Model/Expense.pm (original)
+++ apps/spensive/lib/Spensive/Model/Expense.pm Tue Nov 20 12:09:43 2007
@@ -7,19 +7,54 @@
use Spensive::Record schema {
column title => type is 'text';
- column description => type is 'text';
- column date_incurred => type is 'datetime';
- column date_claimed => type is 'datetime';
+ column description => type is 'text', render as 'Textarea';
+ column date_incurred => type is 'datetime', default is defer { Jifty::DateTime->now }, render_as 'Date';;
+ column incurred_by => references Spensive::Model::User;
column tags => type is 'text';
- column expense_report=> references Spensive::Model::ExpenseReport;
column local_cost => type is 'float';
column cost => type is 'float';
column payment_currency => type is 'text', valid_values are qw(USD CAD UKP EUR TWD NZD HKD);
column payment_method => type is 'text', valid_values are qw(personal_credit corporate_credit cash);
-
+ column expense_report=> references Spensive::Model::ExpenseReport;
};
# Your model-specific methods go here.
+sub before_create {
+ my $self = shift;
+ my $args = shift;
+
+ $args->{'incurred_by'} = $self->current_user->id;
+ $args->{'date_incurred'} ||= Jifty::DateTime->now;
+ return 1;
+}
+
+
+sub autocomplete_title {
+ my $self = shift;
+ my $value = shift;
+ my $expenses = Spensive::Model::ExpenseCollection->new();
+ $expenses->limit( column => 'incurred_by', value => $self->current_user->id);
+ $expenses->limit(
+ column => 'title',
+ operator => 'like',
+ value => $value . "%",
+ case_insensitive => 1
+ );
+
+ my %items;
+ while (my $item = $expenses->next) {
+ $items{$item->title}++;
+ }
+
+ my @results;
+
+ for (sort { $items{$a} <=> $items{$b} } keys %items) {
+ push @results, $_;
+ }
+ return @results;
+}
+
+
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:09:43 2007
@@ -5,16 +5,14 @@
use Jifty::DBI::Schema;
use Spensive::Record schema {
-
column title => type is 'text';
column description => type is 'text';
- column expenses_by => references Spensive::Model::User;
- column submitted => type is 'datetime';
- column approved => type is 'datetime';
+ column submitter => references Spensive::Model::User;
+ # column submitted => type is 'datetime';
+ #column approved => type is 'datetime';
column status => type is 'text', valid are qw(unsubmitted approved denied);
- column approver => type is 'text';
- column submit_to => type is 'text';
-
+ #column approver => type is 'text';
+ #column submit_to => type is 'text';
};
# Your model-specific methods go here.
Modified: apps/spensive/lib/Spensive/View.pm
==============================================================================
--- apps/spensive/lib/Spensive/View.pm (original)
+++ apps/spensive/lib/Spensive/View.pm Tue Nov 20 12:09:43 2007
@@ -10,10 +10,19 @@
h2 { _('(It also helps you get reimbursed for them)') };
form {
- my $search = Spensive::Model::ExpenseCollection->new();
- $search->unlimit();
- with( page => 1, search_collection => $search, id => 'xxx'),
- render_region ( name=> 'myregion', path => '/expenses/list');
+ my $search = Spensive::Model::ExpenseCollection->new();
+ $search->limit(
+ column => 'incurred_by',
+ value => Jifty->web->current_user->id
+ );
+ set (search_collection => $search);
+ render_region(
+ name => 'myregion',
+ path => '/expenses/list',
+ defaults =>
+ { page => 1, id => 'xxx' }
+
+ );
};
};
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:09:43 2007
@@ -23,4 +23,16 @@
};
+private template 'edit_item' => sub {
+ my $self = shift;
+ my $action = shift;
+ outs_raw( $action->form_field( 'title', focus => 1) );
+ foreach my $argument ( grep { $_ !~ /(?:incurred_by|local_cost|title)/ }
+ $action->argument_names )
+ {
+ outs_raw( $action->form_field( $argument ) );
+ }
+
+};
+
1;
Added: apps/spensive/t/00-model-Attachment.t
==============================================================================
--- (empty file)
+++ apps/spensive/t/00-model-Attachment.t Tue Nov 20 12:09:43 2007
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A basic test harness for the Attachment model.
+
+=cut
+
+use Jifty::Test tests => 11;
+
+# Make sure we can load the model
+use_ok('Spensive::Model::Attachment');
+
+# Grab a system user
+my $system_user = Spensive::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Try testing a create
+my $o = Spensive::Model::Attachment->new(current_user => $system_user);
+my ($id) = $o->create();
+ok($id, "Attachment create returned success");
+ok($o->id, "New Attachment has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+# And another
+$o->create();
+ok($o->id, "Attachment create returned another value");
+isnt($o->id, $id, "And it is different from the previous one");
+
+# Searches in general
+my $collection = Spensive::Model::AttachmentCollection->new(current_user => $system_user);
+$collection->unlimit;
+is($collection->count, 2, "Finds two records");
+
+# Searches in specific
+$collection->limit(column => 'id', value => $o->id);
+is($collection->count, 1, "Finds one record with specific id");
+
+# Delete one of them
+$o->delete;
+$collection->redo_search;
+is($collection->count, 0, "Deleted row is gone");
+
+# And the other one is still there
+$collection->unlimit;
+is($collection->count, 1, "Still one left");
+
Added: apps/spensive/t/00-model-Expense.t
==============================================================================
--- (empty file)
+++ apps/spensive/t/00-model-Expense.t Tue Nov 20 12:09:43 2007
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A basic test harness for the Expense model.
+
+=cut
+
+use Jifty::Test tests => 11;
+
+# Make sure we can load the model
+use_ok('Spensive::Model::Expense');
+
+# Grab a system user
+my $system_user = Spensive::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Try testing a create
+my $o = Spensive::Model::Expense->new(current_user => $system_user);
+my ($id) = $o->create();
+ok($id, "Expense create returned success");
+ok($o->id, "New Expense has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+# And another
+$o->create();
+ok($o->id, "Expense create returned another value");
+isnt($o->id, $id, "And it is different from the previous one");
+
+# Searches in general
+my $collection = Spensive::Model::ExpenseCollection->new(current_user => $system_user);
+$collection->unlimit;
+is($collection->count, 2, "Finds two records");
+
+# Searches in specific
+$collection->limit(column => 'id', value => $o->id);
+is($collection->count, 1, "Finds one record with specific id");
+
+# Delete one of them
+$o->delete;
+$collection->redo_search;
+is($collection->count, 0, "Deleted row is gone");
+
+# And the other one is still there
+$collection->unlimit;
+is($collection->count, 1, "Still one left");
+
Added: apps/spensive/t/00-model-ExpenseReport.t
==============================================================================
--- (empty file)
+++ apps/spensive/t/00-model-ExpenseReport.t Tue Nov 20 12:09:43 2007
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A basic test harness for the ExpenseReport model.
+
+=cut
+
+use Jifty::Test tests => 11;
+
+# Make sure we can load the model
+use_ok('Spensive::Model::ExpenseReport');
+
+# Grab a system user
+my $system_user = Spensive::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Try testing a create
+my $o = Spensive::Model::ExpenseReport->new(current_user => $system_user);
+my ($id) = $o->create();
+ok($id, "ExpenseReport create returned success");
+ok($o->id, "New ExpenseReport has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+# And another
+$o->create();
+ok($o->id, "ExpenseReport create returned another value");
+isnt($o->id, $id, "And it is different from the previous one");
+
+# Searches in general
+my $collection = Spensive::Model::ExpenseReportCollection->new(current_user => $system_user);
+$collection->unlimit;
+is($collection->count, 2, "Finds two records");
+
+# Searches in specific
+$collection->limit(column => 'id', value => $o->id);
+is($collection->count, 1, "Finds one record with specific id");
+
+# Delete one of them
+$o->delete;
+$collection->redo_search;
+is($collection->count, 0, "Deleted row is gone");
+
+# And the other one is still there
+$collection->unlimit;
+is($collection->count, 1, "Still one left");
+
Added: apps/spensive/t/00-model-Organization.t
==============================================================================
--- (empty file)
+++ apps/spensive/t/00-model-Organization.t Tue Nov 20 12:09:43 2007
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A basic test harness for the Organization model.
+
+=cut
+
+use Jifty::Test tests => 11;
+
+# Make sure we can load the model
+use_ok('Spensive::Model::Organization');
+
+# Grab a system user
+my $system_user = Spensive::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Try testing a create
+my $o = Spensive::Model::Organization->new(current_user => $system_user);
+my ($id) = $o->create();
+ok($id, "Organization create returned success");
+ok($o->id, "New Organization has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+# And another
+$o->create();
+ok($o->id, "Organization create returned another value");
+isnt($o->id, $id, "And it is different from the previous one");
+
+# Searches in general
+my $collection = Spensive::Model::OrganizationCollection->new(current_user => $system_user);
+$collection->unlimit;
+is($collection->count, 2, "Finds two records");
+
+# Searches in specific
+$collection->limit(column => 'id', value => $o->id);
+is($collection->count, 1, "Finds one record with specific id");
+
+# Delete one of them
+$o->delete;
+$collection->redo_search;
+is($collection->count, 0, "Deleted row is gone");
+
+# And the other one is still there
+$collection->unlimit;
+is($collection->count, 1, "Still one left");
+
Added: apps/spensive/t/00-model-OrganizationMember.t
==============================================================================
--- (empty file)
+++ apps/spensive/t/00-model-OrganizationMember.t Tue Nov 20 12:09:43 2007
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A basic test harness for the OrganizationMember model.
+
+=cut
+
+use Jifty::Test tests => 11;
+
+# Make sure we can load the model
+use_ok('Spensive::Model::OrganizationMember');
+
+# Grab a system user
+my $system_user = Spensive::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Try testing a create
+my $o = Spensive::Model::OrganizationMember->new(current_user => $system_user);
+my ($id) = $o->create();
+ok($id, "OrganizationMember create returned success");
+ok($o->id, "New OrganizationMember has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+# And another
+$o->create();
+ok($o->id, "OrganizationMember create returned another value");
+isnt($o->id, $id, "And it is different from the previous one");
+
+# Searches in general
+my $collection = Spensive::Model::OrganizationMemberCollection->new(current_user => $system_user);
+$collection->unlimit;
+is($collection->count, 2, "Finds two records");
+
+# Searches in specific
+$collection->limit(column => 'id', value => $o->id);
+is($collection->count, 1, "Finds one record with specific id");
+
+# Delete one of them
+$o->delete;
+$collection->redo_search;
+is($collection->count, 0, "Deleted row is gone");
+
+# And the other one is still there
+$collection->unlimit;
+is($collection->count, 1, "Still one left");
+
Added: apps/spensive/t/00-model-SubmissionAddress.t
==============================================================================
--- (empty file)
+++ apps/spensive/t/00-model-SubmissionAddress.t Tue Nov 20 12:09:43 2007
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A basic test harness for the SubmissionAddress model.
+
+=cut
+
+use Jifty::Test tests => 11;
+
+# Make sure we can load the model
+use_ok('Spensive::Model::SubmissionAddress');
+
+# Grab a system user
+my $system_user = Spensive::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Try testing a create
+my $o = Spensive::Model::SubmissionAddress->new(current_user => $system_user);
+my ($id) = $o->create();
+ok($id, "SubmissionAddress create returned success");
+ok($o->id, "New SubmissionAddress has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+# And another
+$o->create();
+ok($o->id, "SubmissionAddress create returned another value");
+isnt($o->id, $id, "And it is different from the previous one");
+
+# Searches in general
+my $collection = Spensive::Model::SubmissionAddressCollection->new(current_user => $system_user);
+$collection->unlimit;
+is($collection->count, 2, "Finds two records");
+
+# Searches in specific
+$collection->limit(column => 'id', value => $o->id);
+is($collection->count, 1, "Finds one record with specific id");
+
+# Delete one of them
+$o->delete;
+$collection->redo_search;
+is($collection->count, 0, "Deleted row is gone");
+
+# And the other one is still there
+$collection->unlimit;
+is($collection->count, 1, "Still one left");
+
Added: apps/spensive/t/00-model-Team.t
==============================================================================
--- (empty file)
+++ apps/spensive/t/00-model-Team.t Tue Nov 20 12:09:43 2007
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A basic test harness for the Team model.
+
+=cut
+
+use Jifty::Test tests => 11;
+
+# Make sure we can load the model
+use_ok('Spensive::Model::Team');
+
+# Grab a system user
+my $system_user = Spensive::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Try testing a create
+my $o = Spensive::Model::Team->new(current_user => $system_user);
+my ($id) = $o->create();
+ok($id, "Team create returned success");
+ok($o->id, "New Team has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+# And another
+$o->create();
+ok($o->id, "Team create returned another value");
+isnt($o->id, $id, "And it is different from the previous one");
+
+# Searches in general
+my $collection = Spensive::Model::TeamCollection->new(current_user => $system_user);
+$collection->unlimit;
+is($collection->count, 2, "Finds two records");
+
+# Searches in specific
+$collection->limit(column => 'id', value => $o->id);
+is($collection->count, 1, "Finds one record with specific id");
+
+# Delete one of them
+$o->delete;
+$collection->redo_search;
+is($collection->count, 0, "Deleted row is gone");
+
+# And the other one is still there
+$collection->unlimit;
+is($collection->count, 1, "Still one left");
+
Added: apps/spensive/t/00-model-TeamMember.t
==============================================================================
--- (empty file)
+++ apps/spensive/t/00-model-TeamMember.t Tue Nov 20 12:09:43 2007
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A basic test harness for the TeamMember model.
+
+=cut
+
+use Jifty::Test tests => 11;
+
+# Make sure we can load the model
+use_ok('Spensive::Model::TeamMember');
+
+# Grab a system user
+my $system_user = Spensive::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Try testing a create
+my $o = Spensive::Model::TeamMember->new(current_user => $system_user);
+my ($id) = $o->create();
+ok($id, "TeamMember create returned success");
+ok($o->id, "New TeamMember has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+# And another
+$o->create();
+ok($o->id, "TeamMember create returned another value");
+isnt($o->id, $id, "And it is different from the previous one");
+
+# Searches in general
+my $collection = Spensive::Model::TeamMemberCollection->new(current_user => $system_user);
+$collection->unlimit;
+is($collection->count, 2, "Finds two records");
+
+# Searches in specific
+$collection->limit(column => 'id', value => $o->id);
+is($collection->count, 1, "Finds one record with specific id");
+
+# Delete one of them
+$o->delete;
+$collection->redo_search;
+is($collection->count, 0, "Deleted row is gone");
+
+# And the other one is still there
+$collection->unlimit;
+is($collection->count, 1, "Still one left");
+
Added: apps/spensive/t/00-model-User.t
==============================================================================
--- (empty file)
+++ apps/spensive/t/00-model-User.t Tue Nov 20 12:09:43 2007
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A basic test harness for the User model.
+
+=cut
+
+use Jifty::Test tests => 11;
+
+# Make sure we can load the model
+use_ok('Spensive::Model::User');
+
+# Grab a system user
+my $system_user = Spensive::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Try testing a create
+my $o = Spensive::Model::User->new(current_user => $system_user);
+my ($id) = $o->create();
+ok($id, "User create returned success");
+ok($o->id, "New User has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+# And another
+$o->create();
+ok($o->id, "User create returned another value");
+isnt($o->id, $id, "And it is different from the previous one");
+
+# Searches in general
+my $collection = Spensive::Model::UserCollection->new(current_user => $system_user);
+$collection->unlimit;
+is($collection->count, 2, "Finds two records");
+
+# Searches in specific
+$collection->limit(column => 'id', value => $o->id);
+is($collection->count, 1, "Finds one record with specific id");
+
+# Delete one of them
+$o->delete;
+$collection->redo_search;
+is($collection->count, 0, "Deleted row is gone");
+
+# And the other one is still there
+$collection->unlimit;
+is($collection->count, 1, "Still one left");
+
More information about the Jifty-commit
mailing list