[Jifty-commit] r4493 - in apps/spensive: . etc lib/Spensive
lib/Spensive/Action lib/Spensive/Model lib/Spensive/View
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Tue Nov 20 12:12:38 EST 2007
Author: jesse
Date: Tue Nov 20 12:12:35 2007
New Revision: 4493
Modified:
apps/spensive/ (props changed)
apps/spensive/etc/config.yml
apps/spensive/lib/Spensive/Action/EmailDispatch.pm
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
apps/spensive/share/web/static/css/expensereport.css
Log:
r67474 at pinglin (orig r7382): jesse | 2007-09-21 15:09:35 -0400
* added email for expense reports
Modified: apps/spensive/etc/config.yml
==============================================================================
--- apps/spensive/etc/config.yml (original)
+++ apps/spensive/etc/config.yml Tue Nov 20 12:12:35 2007
@@ -13,7 +13,7 @@
Password: ''
RecordBaseClass: Jifty::DBI::Record::Cachable
User: ''
- Version: 0.0.9
+ Version: 0.0.11
DevelMode: 0
L10N:
PoDir: share/po
Modified: apps/spensive/lib/Spensive/Action/EmailDispatch.pm
==============================================================================
--- apps/spensive/lib/Spensive/Action/EmailDispatch.pm (original)
+++ apps/spensive/lib/Spensive/Action/EmailDispatch.pm Tue Nov 20 12:12:35 2007
@@ -87,18 +87,51 @@
}
}
- elsif ($address =~ /^(.*?)(\d+)/) {
+ elsif ( $address =~ /^report-(.*?)(\d+)/ ) {
my $key = $1;
- my $id = $2;
- my $pa = Jifty->app_class('Model', 'User')->new( current_user => Jifty->app_class('CurrentUser')->superuser );
- $pa->load_by_cols( published_address => $key );
-
- # if we have a user's expense creating address
- if ( $pa->id && $pa->id == $id) {
- my $expense = Spensive::Model::Expense->new();
- $expense->create( title => $summary, description => $body, email_content => $self->argument_Value('email'), _force_incurred_by => $pa->id);
+ my $id = $2;
+ my $pa = Jifty->app_class( 'Model', 'ExpenseReport' )
+ ->new(
+ current_user => Jifty->app_class('CurrentUser')->superuser );
+ $pa->load_by_cols( published_address => $key );
+
+ # if we have a user's expense creating address
+ if ( $pa->id && $pa->id == $id ) {
+ my $expense = Spensive::Model::Expense->new();
+ $expense->create(
+ title => $summary,
+ description => $body,
+ expense_report => $pa->id,
+ email_content => $self->argument_value('email'),
+ _force_incurred_by => $pa->submitted_by->id
+ );
}
}
+
+
+ elsif ( $address =~ /^(.*?)(\d+)/ ) {
+ my $key = $1;
+ my $id = $2;
+ my $pa = Jifty->app_class( 'Model', 'User' )
+ ->new(
+ current_user => Jifty->app_class('CurrentUser')->superuser );
+ $pa->load_by_cols( published_address => $key );
+
+ # if we have a user's expense creating address
+ if ( $pa->id && $pa->id == $id ) {
+ my $expense = Spensive::Model::Expense->new();
+ $expense->create(
+ title => $summary,
+ description => $body,
+ email_content => $self->argument_value('email'),
+ _force_incurred_by => $pa->id
+ );
+ }
+ }
+
+
+
+
if($action) {
$action->run;
if($action->result->failure) {
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:12:35 2007
@@ -37,10 +37,7 @@
sub published_address {
my $self = shift;
return unless $self->_value('published_address');
-
- return $self->_value('published_address')
- . $self->id . "@"
- . Jifty->config->app('EmailDomain');
+ return 'expense-'.$self->_value('published_address') . $self->id . "@" . Jifty->config->app('EmailDomain');
}
sub after_create {
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:12:35 2007
@@ -10,6 +10,7 @@
column submitted_by => references Spensive::Model::User;
column submitted => type is 'datetime';
column approved => type is 'datetime';
+ column published_address => type is 'varchar(32)', is immutable, since is '0.0.11';
column approved_by => references Spensive::Model::User;
column status => type is 'text', valid are qw(unsubmitted approved denied);
};
@@ -17,12 +18,19 @@
# Your model-specific methods go here.
+sub published_address {
+ my $self = shift;
+ return unless $self->_value('published_address');
+ return 'report-'.$self->_value('published_address') . $self->id . "@" . Jifty->config->app('EmailDomain');
+}
sub categories { @{Spensive::Model::Expense->new()->column('category')->valid_values()} }
+our $PWGEN = Text::Password::Pronounceable->new(6=>8);
sub before_create {
my $self = shift;
my $args = shift;
+ $args->{'published_address'} = $PWGEN->generate;
$args->{'submitted_by'} = $self->current_user->id;
return 1;
}
Modified: apps/spensive/lib/Spensive/View.pm
==============================================================================
--- apps/spensive/lib/Spensive/View.pm (original)
+++ apps/spensive/lib/Spensive/View.pm Tue Nov 20 12:12:35 2007
@@ -85,7 +85,6 @@
my $expenses = $report->expenses();
my ( $earliest, $latest );
my $appendix_counter='A';
- warn $expenses->count;
map {
$earliest = $_->date_incurred
@@ -173,9 +172,10 @@
h1{ _('Attachments')};
for('A'..$appendix_counter) {
- h2{_("Appendix %1",$_)};
my $expense = $appendices{$_};
+ next unless $expense;
+ h2{_("Appendix %1",$_)};
my $attaches= $expense->attachments;
while (my $attach = $attaches->next) {
@@ -189,6 +189,9 @@
template 'report/build' => page {
my $self = shift;
h1 { get('report')->title };
+ div { { class is 'hint'};
+ outs_raw(_('You can add new expenses to this expense report by emailing %1'. a{ {href is 'mailto:'.get('report')->published_address;} get('report')->published_address}));
+ };
render_region(
name => 'reports',
path => 'report_tabs',
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:12:35 2007
@@ -33,6 +33,7 @@
outs_raw(_('You can email new receipts to this expense by sending to %1'. a{ {href is 'mailto:'.$expense->published_address;} $expense->published_address}));
};
+ form {
render_action($action);
form_submit($action);
h2 { 'Attachments'};
@@ -46,7 +47,7 @@
);
-
+ }
}
};
@@ -54,12 +55,18 @@
my $id = get('id');
my $item = Spensive::Model::EmailAttachment->new();
$item->load($id);
- if ($item->content_type =~ /^image/i) {
+ if ($item->content_type && $item->content_type =~ /^image/i) {
a { {href is '/attachment/view/'.$item->id; target is '_new'};
img { { class is 'inline-image'; src is '/attachment/view/'.$item->id} };
};
- } elsif ($item->content_type eq 'text/plain' || $item->content eq 'message/rfc822' ) {
+ } elsif (!$item->content_type || $item->content_type eq 'text/plain' || $item->content eq 'message/rfc822' ) {
div { $item->content };
+ } else {
+ a { {href is '/attachment/view/'.$item->id; target is '_new'};
+ span {_('Download attachment') } ;
+ };
+
+
}
my $del = Jifty->web->new_action(class => 'DeleteEmailAttachment', record => $item);
Modified: apps/spensive/share/web/static/css/expensereport.css
==============================================================================
--- apps/spensive/share/web/static/css/expensereport.css (original)
+++ apps/spensive/share/web/static/css/expensereport.css Tue Nov 20 12:12:35 2007
@@ -10,9 +10,9 @@
width: 100%;
}
.expense-entry .expense-cost {
- border: 1px solid red;
+ text-align: right;
+ with: 20%;
font-weight: bold;
- right:0;
}
@@ -20,4 +20,4 @@
text-align: right;
font-weight: bold;
-
+}
More information about the Jifty-commit
mailing list