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

Alex M Vandiver alexmv at bestpractical.com
Wed May 20 19:27:05 EDT 2009


The branch, master has been updated
       via  bf06eb0a1835e70f2d0879ad1052a9583e2c68a9 (commit)
       via  bc515a94bc521773a900f0f8d6cefc28e980c811 (commit)
       via  1bf4545430e6ab18cc38a33f2eb584649be053b7 (commit)
       via  794a92e2041cdfb46680e6afecc79975c9221a1f (commit)
      from  f138cf8272527f101270fbd40821ce90effd8562 (commit)

Summary of changes:
 lib/App/Changeloggr/Dispatcher.pm      |   10 ++++++++++
 lib/App/Changeloggr/Model/Changelog.pm |    2 ++
 lib/App/Changeloggr/Model/News.pm      |    2 +-
 lib/App/Changeloggr/View.pm            |    6 +++++-
 4 files changed, 18 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit 794a92e2041cdfb46680e6afecc79975c9221a1f
Author: Alex Vandiver <alexmv at mit.edu>
Date:   Wed May 20 19:14:02 2009 -0400

    Use new ->is_staff method for news

diff --git a/lib/App/Changeloggr/Model/News.pm b/lib/App/Changeloggr/Model/News.pm
index 1ac4b4b..4fe5930 100644
--- a/lib/App/Changeloggr/Model/News.pm
+++ b/lib/App/Changeloggr/Model/News.pm
@@ -22,7 +22,7 @@ sub current_user_can {
     my $self = shift;
     my $right = shift;
     return 1 if $right eq "read";
-    return 1 if $self->current_user->user_object and $self->current_user->user_object->access_level eq "staff";
+    return 1 if $self->current_user->user_object and $self->current_user->user_object->is_staff;
     return 0;
 }
 

commit 1bf4545430e6ab18cc38a33f2eb584649be053b7
Author: Alex Vandiver <alexmv at mit.edu>
Date:   Wed May 20 19:23:43 2009 -0400

    Admins can read the admin_token

diff --git a/lib/App/Changeloggr/Model/Changelog.pm b/lib/App/Changeloggr/Model/Changelog.pm
index bcd5a13..5e4d040 100644
--- a/lib/App/Changeloggr/Model/Changelog.pm
+++ b/lib/App/Changeloggr/Model/Changelog.pm
@@ -69,6 +69,8 @@ sub current_user_can {
     return 1 if $right eq 'create'
              || ($right eq 'read' && ($args{column}||'') ne 'admin_token');
 
+    return 1 if $right eq 'read' && ($args{column}||'') eq 'admin_token' && $self->current_user_is_admin;
+
     # but not delete or update. those must happen as root
     return $self->SUPER::current_user_can($right, %args);
 }

commit bc515a94bc521773a900f0f8d6cefc28e980c811
Author: Alex Vandiver <alexmv at mit.edu>
Date:   Wed May 20 19:25:04 2009 -0400

    Add administrate menu item if you are one

diff --git a/lib/App/Changeloggr/Dispatcher.pm b/lib/App/Changeloggr/Dispatcher.pm
index d696315..fd81580 100644
--- a/lib/App/Changeloggr/Dispatcher.pm
+++ b/lib/App/Changeloggr/Dispatcher.pm
@@ -23,6 +23,16 @@ on '/admin/created-changelog' => run {
     redirect "/admin/changelog/changes/$admin_token";
 };
 
+before '/changelog/*' => run {
+    warn "Checking before $1";
+    my $cl = Changelog( name => $1 );
+    warn "cl is $cl id ".$cl->id;
+    return unless $cl->id and $cl->current_user_is_admin;
+    Jifty->web->navigation->child(
+        "Administrate" => url => "/admin/changelog/" . $cl->admin_token,
+    );
+};
+
 on '/changelog/*' => run {
     set name => $1;
     show '/changelog';

commit bf06eb0a1835e70f2d0879ad1052a9583e2c68a9
Author: Alex Vandiver <alexmv at mit.edu>
Date:   Wed May 20 19:26:58 2009 -0400

    Rediret to the only changelog if there is but one

diff --git a/lib/App/Changeloggr/View.pm b/lib/App/Changeloggr/View.pm
index f6d4555..fe69a82 100644
--- a/lib/App/Changeloggr/View.pm
+++ b/lib/App/Changeloggr/View.pm
@@ -23,13 +23,17 @@ template '/' => page {
     my $changelogs = M(ChangelogCollection => done => 0);
     $changelogs->with_changes;
 
-    if ($changelogs->count) {
+    my $count = $changelogs->count;
+
+    if ($count > 1) {
         h2 { "These projects need your help!" };
         ul {
             while (my $changelog = $changelogs->next) {
                 li { changelog_summary($changelog) }
             }
         }
+    } elsif ( $count == 1) {
+        redirect '/changelog/' . $changelogs->first->name;
     } else {
         redirect '/admin/create-changelog';
     }

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



More information about the Bps-public-commit mailing list