[Bps-public-commit] App-Changeloggr branch, master, updated. 8751705f9e573ecead7b87d7586c30c1a30e828b

sartak at bestpractical.com sartak at bestpractical.com
Thu Aug 13 21:45:39 EDT 2009


The branch, master has been updated
       via  8751705f9e573ecead7b87d7586c30c1a30e828b (commit)
      from  a65a8f7ced1819e753c8e4729d9e01b8b482465f (commit)

Summary of changes:
 lib/App/Changeloggr/Model/Changelog.pm |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit 8751705f9e573ecead7b87d7586c30c1a30e828b
Author: Shawn M Moore <sartak at gmail.com>
Date:   Thu Aug 13 21:45:21 2009 -0400

    First stab at Changelog->choose_next_change

diff --git a/lib/App/Changeloggr/Model/Changelog.pm b/lib/App/Changeloggr/Model/Changelog.pm
index 5eaa227..c5b561a 100644
--- a/lib/App/Changeloggr/Model/Changelog.pm
+++ b/lib/App/Changeloggr/Model/Changelog.pm
@@ -201,7 +201,8 @@ sub get_starting_position {
 }
 
 sub choose_change {
-    my $self = shift;
+    my $self     = shift;
+    my $readonly = shift;
 
     # 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
@@ -219,6 +220,7 @@ sub choose_change {
     }
 
     if ($changes->count == 0 && $start > 0) {
+        return if $readonly;
         $self->current_user->set_position_for($self, 0);
         return $self->choose_change(@_);
     }
@@ -228,6 +230,23 @@ sub choose_change {
     return $changes->first;
 }
 
+sub choose_next_change {
+    my $self = shift;
+
+    Jifty->handle->begin_transaction;
+
+    my $change = $self->choose_change(1)
+        or return;
+
+    $change->vote($self->tags->first->text);
+
+    my $next_change = $self->choose_change(1);
+
+    Jifty->handle->rollback_transaction;
+
+    return $next_change;
+}
+
 sub generate {
     my $self = shift;
     my $format = Jifty->app_class( OutputFormat => shift || "Jifty" );

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list