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

sartak at bestpractical.com sartak at bestpractical.com
Fri May 22 14:44:15 EDT 2009


The branch, master has been updated
       via  73cbf82385c474693acc3e3960139c3cb9deabee (commit)
       via  673797321156191b0e9056661bf351ea2dec5701 (commit)
       via  a17d94d6d5e89161aea8c81bd2b64b9a31d10d9a (commit)
       via  4e7e77988b0fef2fade142187e933ee4975d4bb5 (commit)
       via  15503ee2e3fd66512697248d5243f848053eb774 (commit)
      from  bd0af4668476248b98e1bdef75e3eceb2e9038ad (commit)

Summary of changes:
 lib/App/Changeloggr/Dispatcher.pm      |    2 --
 lib/App/Changeloggr/Model/Changelog.pm |    7 +++++++
 lib/App/Changeloggr/Model/Tag.pm       |   23 +++++++++++++++++++++++
 lib/App/Changeloggr/Model/User.pm      |    3 ++-
 lib/App/Changeloggr/View.pm            |    2 +-
 5 files changed, 33 insertions(+), 4 deletions(-)

- Log -----------------------------------------------------------------
commit 15503ee2e3fd66512697248d5243f848053eb774
Author: Shawn M Moore <sartak at gmail.com>
Date:   Fri May 22 13:56:26 2009 -0400

    If the account has no session id, then don't automatically grant
    permission

diff --git a/lib/App/Changeloggr/Model/User.pm b/lib/App/Changeloggr/Model/User.pm
index 91760df..a5c29b8 100644
--- a/lib/App/Changeloggr/Model/User.pm
+++ b/lib/App/Changeloggr/Model/User.pm
@@ -50,7 +50,8 @@ sub current_user_can {
 
     # the current user can do anything to his account
     my $session_id = $self->__value('session_id');
-    return 1 if $session_id eq (Jifty->web->session->id||'');
+    return 1 if $session_id
+             && $session_id eq (Jifty->web->session->id||'');
 
     # users are private except name
     return 1 if $right eq 'read' and ( $args{column} eq 'name' or $args{column} eq 'access_level' );

commit 4e7e77988b0fef2fade142187e933ee4975d4bb5
Author: Shawn M Moore <sartak at gmail.com>
Date:   Fri May 22 14:16:07 2009 -0400

    Remove debug warning

diff --git a/lib/App/Changeloggr/Dispatcher.pm b/lib/App/Changeloggr/Dispatcher.pm
index af6adcb..1817e8a 100644
--- a/lib/App/Changeloggr/Dispatcher.pm
+++ b/lib/App/Changeloggr/Dispatcher.pm
@@ -26,7 +26,6 @@ on '/admin/created-changelog' => run {
 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,

commit a17d94d6d5e89161aea8c81bd2b64b9a31d10d9a
Author: Shawn M Moore <sartak at gmail.com>
Date:   Fri May 22 14:17:27 2009 -0400

    Remove another debug warning

diff --git a/lib/App/Changeloggr/Dispatcher.pm b/lib/App/Changeloggr/Dispatcher.pm
index 1817e8a..585399f 100644
--- a/lib/App/Changeloggr/Dispatcher.pm
+++ b/lib/App/Changeloggr/Dispatcher.pm
@@ -24,7 +24,6 @@ on '/admin/created-changelog' => run {
 };
 
 before '/changelog/*' => run {
-    warn "Checking before $1";
     my $cl = Changelog( name => $1 );
     return unless $cl->id and $cl->current_user_is_admin;
     Jifty->web->navigation->child(

commit 673797321156191b0e9056661bf351ea2dec5701
Author: Shawn M Moore <sartak at gmail.com>
Date:   Fri May 22 14:19:01 2009 -0400

    Add a visible_tags

diff --git a/lib/App/Changeloggr/Model/Changelog.pm b/lib/App/Changeloggr/Model/Changelog.pm
index c494bfe..a8f1d30 100644
--- a/lib/App/Changeloggr/Model/Changelog.pm
+++ b/lib/App/Changeloggr/Model/Changelog.pm
@@ -100,6 +100,19 @@ sub tags {
     return M('TagCollection', changelog_id => $self);
 }
 
+sub visible_tags {
+    my $self = shift;
+    my $tags = $self->tags(@_);
+
+    $tags->limit(
+        column   => 'text',
+        operator => 'NOT LIKE',
+        value    => '_%',
+    );
+
+    return $tags;
+}
+
 sub has_tag {
     my $self = shift;
     my $tag  = shift;
diff --git a/lib/App/Changeloggr/View.pm b/lib/App/Changeloggr/View.pm
index 942a7ba..eb515db 100644
--- a/lib/App/Changeloggr/View.pm
+++ b/lib/App/Changeloggr/View.pm
@@ -215,7 +215,7 @@ sub show_vote_form {
     my $change = shift;
 
     my $changelog = $change->changelog;
-    my $valid_tags = $changelog->tags;
+    my $valid_tags = $changelog->visible_tags;
 
     form {
         h4 { 'Vote!' };

commit 73cbf82385c474693acc3e3960139c3cb9deabee
Author: Shawn M Moore <sartak at gmail.com>
Date:   Fri May 22 14:44:01 2009 -0400

    Tag->limit_to_visible, fix SQLite implementation

diff --git a/lib/App/Changeloggr/Model/Changelog.pm b/lib/App/Changeloggr/Model/Changelog.pm
index a8f1d30..1e9aaa2 100644
--- a/lib/App/Changeloggr/Model/Changelog.pm
+++ b/lib/App/Changeloggr/Model/Changelog.pm
@@ -103,13 +103,7 @@ sub tags {
 sub visible_tags {
     my $self = shift;
     my $tags = $self->tags(@_);
-
-    $tags->limit(
-        column   => 'text',
-        operator => 'NOT LIKE',
-        value    => '_%',
-    );
-
+    $tags->limit_to_visible;
     return $tags;
 }
 
diff --git a/lib/App/Changeloggr/Model/Tag.pm b/lib/App/Changeloggr/Model/Tag.pm
index b27bc9d..01eddc8 100644
--- a/lib/App/Changeloggr/Model/Tag.pm
+++ b/lib/App/Changeloggr/Model/Tag.pm
@@ -68,6 +68,29 @@ sub current_user_can {
     return $self->SUPER::current_user_can($right, @_);
 }
 
+sub limit_to_visible {
+    my $self = shift;
+
+    if ($self->_handle->isa('Jifty::DBI::Handle::SQLite')) {
+        $self->limit(
+            column   => 'text',
+            escape   => '\\',
+            operator => 'NOT LIKE',
+            value    => '\_%',
+        );
+    }
+    elsif ($self->_handle->isa('Jifty::DBI::Handle::Pg')) {
+        $self->limit(
+            column => 'text',
+            # ...
+        );
+    }
+    else {
+        Carp::confess "You must use SQLite or Postgres, or fix Tags->limit_to_visible for your RDBMS. Sorry. :(";
+    }
+
+    return $self;
+}
 
 1;
 

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



More information about the Bps-public-commit mailing list