[Bps-public-commit] App-Changeloggr branch, master, updated. 16a3869d831d77fc847553bc7f4179f33fc6a3e1

sartak at bestpractical.com sartak at bestpractical.com
Wed Apr 29 13:43:48 EDT 2009


The branch, master has been updated
       via  16a3869d831d77fc847553bc7f4179f33fc6a3e1 (commit)
       via  b108bd1d11ef99afe323238ecf12993ed38049d7 (commit)
       via  b6002d3f20bb32e0a40ef5525cc8f2c2afc06700 (commit)
       via  dab4894f2cc05c8ed48ffb27cd06e69508906ae6 (commit)
      from  7472dfa91e2d3e65cc3dc917f987e54fbeb700eb (commit)

Summary of changes:
 lib/App/Changeloggr/Dispatcher.pm             |    3 +
 lib/App/Changeloggr/Model/ChangeCollection.pm |   21 ++++++++++
 lib/App/Changeloggr/Model/VoteCollection.pm   |   10 +++++
 lib/App/Changeloggr/View.pm                   |    6 +--
 lib/App/Changeloggr/View/Admin.pm             |   50 +++++++++++++++++++++++++
 5 files changed, 85 insertions(+), 5 deletions(-)

- Log -----------------------------------------------------------------
commit dab4894f2cc05c8ed48ffb27cd06e69508906ae6
Author: Shawn M Moore <sartak at gmail.com>
Date:   Wed Apr 29 13:20:30 2009 -0400

    limit_to_commented method

diff --git a/lib/App/Changeloggr/Model/VoteCollection.pm b/lib/App/Changeloggr/Model/VoteCollection.pm
index 310212d..745cf2e 100644
--- a/lib/App/Changeloggr/Model/VoteCollection.pm
+++ b/lib/App/Changeloggr/Model/VoteCollection.pm
@@ -5,5 +5,15 @@ use base 'App::Changeloggr::Collection';
 
 use constant results_are_readable => 1;
 
+sub limit_to_commented {
+    my $self = shift;
+    $self->limit(
+        column   => 'comment',
+        operator => '!=',
+        value    => '',
+    );
+    return $self;
+}
+
 1;
 
diff --git a/lib/App/Changeloggr/View.pm b/lib/App/Changeloggr/View.pm
index 2c051f6..cb6a3c7 100644
--- a/lib/App/Changeloggr/View.pm
+++ b/lib/App/Changeloggr/View.pm
@@ -183,11 +183,7 @@ sub show_vote_comments {
     my $change = shift;
     my $votes = $change->votes;
 
-    $votes->limit(
-        column   => 'comment',
-        operator => '!=',
-        value    => '',
-    );
+    $votes->limit_to_commented;
 
     return if $votes->count == 0;
 

commit b6002d3f20bb32e0a40ef5525cc8f2c2afc06700
Author: Shawn M Moore <sartak at gmail.com>
Date:   Wed Apr 29 13:21:33 2009 -0400

    changes->limit_to_voted

diff --git a/lib/App/Changeloggr/Model/ChangeCollection.pm b/lib/App/Changeloggr/Model/ChangeCollection.pm
index b28d936..65ff81c 100644
--- a/lib/App/Changeloggr/Model/ChangeCollection.pm
+++ b/lib/App/Changeloggr/Model/ChangeCollection.pm
@@ -43,5 +43,26 @@ sub create_from_parser {
     }
 }
 
+sub limit_to_voted {
+    my $self = shift;
+
+    my $votes = $self->join(
+        type        => 'left',
+        column1     => 'id',
+        table2      => 'votes',
+        column2     => 'change_id',
+        is_distinct => 1,
+    );
+
+    $self->limit(
+        column   => 'id',
+        alias    => $votes,
+        operator => 'IS NOT',
+        value    => 'NULL',
+    );
+
+    return $self;
+}
+
 1;
 

commit b108bd1d11ef99afe323238ecf12993ed38049d7
Author: Shawn M Moore <sartak at gmail.com>
Date:   Wed Apr 29 13:42:54 2009 -0400

    An admin page for displaying changes

diff --git a/lib/App/Changeloggr/View/Admin.pm b/lib/App/Changeloggr/View/Admin.pm
index 450f00c..5b97307 100644
--- a/lib/App/Changeloggr/View/Admin.pm
+++ b/lib/App/Changeloggr/View/Admin.pm
@@ -45,6 +45,56 @@ template '/changelog/links' => page {
     edit_links($changelog);
 };
 
+template '/changelog/votes' => page {
+    my $changelog = Changelog(id => get('id'));
+    my $changes = $changelog->changes;
+
+    $changes->limit_to_voted;
+
+    ul {
+        for my $change (@$changes) {
+            li {
+                my $message = $change->message;
+                substr($message, 40) = '...' if length($message) >= 40;
+
+                span { $message };
+
+                my @sections = change_sections($change);
+                if (@sections) {
+                    dl {
+                        for (@sections) {
+                            my ($name, $code) = @$_;
+                            dt { $name }
+                            dd { $code->() }
+                        }
+                    }
+                }
+            }
+        }
+    }
+};
+
+
+sub change_sections {
+    my $change = shift;
+    my @sections;
+
+    my $votes = $change->votes;
+    $votes->limit_to_commented;
+
+    if ($votes->count) {
+        push @sections, [Comments => sub {
+            ul {
+                while (my $vote = <$votes>) {
+                    li { $vote->comment }
+                }
+            }
+        }];
+    }
+
+    return @sections;
+}
+
 sub add_changes_to {
     my $changelog = shift;
 

commit 16a3869d831d77fc847553bc7f4179f33fc6a3e1
Author: Shawn M Moore <sartak at gmail.com>
Date:   Wed Apr 29 13:43:30 2009 -0400

    Link to the new page in nav

diff --git a/lib/App/Changeloggr/Dispatcher.pm b/lib/App/Changeloggr/Dispatcher.pm
index eb691bb..d85fcf7 100644
--- a/lib/App/Changeloggr/Dispatcher.pm
+++ b/lib/App/Changeloggr/Dispatcher.pm
@@ -57,6 +57,9 @@ on qr{^/admin/changelog/([^/]+)(?:/([^/]+))?$} => run {
     $admin->child(
         Links => url => "/admin/changelog/links/$uuid",
     );
+    $admin->child(
+        Votes => url => "/admin/changelog/votes/$uuid",
+    );
 
     set id => $cl->id;
     show "/admin/changelog" . ($subpage ? "/$subpage" : "");

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



More information about the Bps-public-commit mailing list