[Bps-public-commit] App-Changeloggr branch, master, updated. 5e6e70ee1db37d3acfbc9b1d9796a35cef82ef52
Alex M Vandiver
alexmv at bestpractical.com
Tue Mar 31 15:28:19 EDT 2009
The branch, master has been updated
via 5e6e70ee1db37d3acfbc9b1d9796a35cef82ef52 (commit)
via 2e259696749c735492742209e67cd6f9420e65dd (commit)
from f31574708db8bc26525b3b1cb1bcc603ae786e94 (commit)
Summary of changes:
lib/App/Changeloggr/Model/Changelog.pm | 24 +++++++++++++++++++++++-
lib/App/Changeloggr/Model/Vote.pm | 3 ++-
lib/App/Changeloggr/View.pm | 11 +++++++----
3 files changed, 32 insertions(+), 6 deletions(-)
- Log -----------------------------------------------------------------
commit 2e259696749c735492742209e67cd6f9420e65dd
Author: Alex Vandiver <alexmv at mit.edu>
Date: Tue Mar 31 15:09:27 2009 -0400
We need to hand it the ID, not the whole object
diff --git a/lib/App/Changeloggr/View.pm b/lib/App/Changeloggr/View.pm
index f9e6241..fca0d52 100644
--- a/lib/App/Changeloggr/View.pm
+++ b/lib/App/Changeloggr/View.pm
@@ -111,7 +111,7 @@ sub show_vote_form {
form {
my $vote = App::Changeloggr::Action::CreateVote->new(
- arguments => { change => $change } );
+ arguments => { change => $change->id } );
render_action $vote ;
form_submit( label => 'Vote' );
}
commit 5e6e70ee1db37d3acfbc9b1d9796a35cef82ef52
Author: Alex Vandiver <alexmv at mit.edu>
Date: Tue Mar 31 15:23:26 2009 -0400
Make selection of changes to vote on a bit more clever
It now at least doesn't offer you changes you haven't voted on already.
diff --git a/lib/App/Changeloggr/Model/Changelog.pm b/lib/App/Changeloggr/Model/Changelog.pm
index 005b8a4..049c202 100644
--- a/lib/App/Changeloggr/Model/Changelog.pm
+++ b/lib/App/Changeloggr/Model/Changelog.pm
@@ -66,7 +66,29 @@ sub choose_change {
# This will become more advanced in the future, picking a change that
# the current user has not voted on yet, ordered by the confidence of the
# top tag. But for now.. an arbitrary change belonging to this changelog.
- return M('Change', changelog => $self);
+ my $changes = M('ChangeCollection', changelog => $self);
+ my $votes = $changes->join(
+ type => 'left',
+ column1 => 'id',
+ table2 => 'votes',
+ column2 => 'change',
+ is_distinct => 1,
+ );
+ $changes->limit(
+ leftjoin => $votes,
+ column => 'user_session_id',
+ value => Jifty->web->session->id,
+ case_sensitive => 1,
+ );
+ $changes->limit(
+ column => 'id',
+ alias => $votes,
+ operator => 'IS',
+ value => 'NULL',
+ );
+ $changes->rows_per_page(1);
+ warn $changes->build_select_query;
+ return $changes->first;
}
1;
diff --git a/lib/App/Changeloggr/Model/Vote.pm b/lib/App/Changeloggr/Model/Vote.pm
index 2eaf0ab..e69ae80 100644
--- a/lib/App/Changeloggr/Model/Vote.pm
+++ b/lib/App/Changeloggr/Model/Vote.pm
@@ -17,7 +17,8 @@ use App::Changeloggr::Record schema {
default is defer { Jifty->web->session->id },
is mandatory,
is immutable,
- is private;
+ is private,
+ is case_sensitive;
column tag =>
type is 'text',
diff --git a/lib/App/Changeloggr/View.pm b/lib/App/Changeloggr/View.pm
index fca0d52..1566db1 100644
--- a/lib/App/Changeloggr/View.pm
+++ b/lib/App/Changeloggr/View.pm
@@ -49,9 +49,12 @@ template '/changelog' => page {
template '/vote-on-change' => sub {
my $changelog = M('Changelog', id => get('changelog'));
my $change = $changelog->choose_change;
-
- show_change($change);
- show_vote_form($change);
+ if ($change) {
+ show_change($change);
+ show_vote_form($change);
+ } else {
+ h2 { "No changes left in this log" };
+ }
};
template '/changelog/admin' => page {
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list