[Bps-public-commit] App-Changeloggr branch, master, updated. 2e796b21eea8cf76b15b981ba527c8d6bf9a731c
sartak at bestpractical.com
sartak at bestpractical.com
Wed Apr 29 17:48:18 EDT 2009
The branch, master has been updated
via 2e796b21eea8cf76b15b981ba527c8d6bf9a731c (commit)
via 7b4cba91accf3ce69a55f18961e2eab2f40c767d (commit)
via 2781f542f06fe5ea1b1f7f16c077043d59f7a1fe (commit)
from 8d0424da1429f800800d0a48c0de3c17ec2d377d (commit)
Summary of changes:
lib/App/Changeloggr/Model/User.pm | 19 +++++++++++++++++++
lib/App/Changeloggr/Model/Vote.pm | 16 ++++++++++++----
2 files changed, 31 insertions(+), 4 deletions(-)
- Log -----------------------------------------------------------------
commit 2781f542f06fe5ea1b1f7f16c077043d59f7a1fe
Author: Shawn M Moore <sartak at gmail.com>
Date: Wed Apr 29 16:23:20 2009 -0400
current_user_can for users
diff --git a/lib/App/Changeloggr/Model/User.pm b/lib/App/Changeloggr/Model/User.pm
index 264d5eb..19de180 100644
--- a/lib/App/Changeloggr/Model/User.pm
+++ b/lib/App/Changeloggr/Model/User.pm
@@ -17,5 +17,24 @@ use App::Changeloggr::Record schema {
sub since { '0.0.4' }
+sub current_user_can {
+ my $self = shift;
+ my $right = shift;
+ my %args = @_;
+
+ # 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;
+
+ # users are private except name
+ return 1 if $right eq 'read' && $args{column} ne 'name';
+
+ # anyone can create accounts
+ return 1 if $right eq 'create';
+
+ # but otherwise users are locked down
+ return $self->SUPER::current_user_can($right, %args);
+}
+
1;
commit 7b4cba91accf3ce69a55f18961e2eab2f40c767d
Author: Shawn M Moore <sartak at gmail.com>
Date: Wed Apr 29 16:24:23 2009 -0400
user -> user_id
diff --git a/lib/App/Changeloggr/Model/Vote.pm b/lib/App/Changeloggr/Model/Vote.pm
index c912ab1..98fb1ad 100644
--- a/lib/App/Changeloggr/Model/Vote.pm
+++ b/lib/App/Changeloggr/Model/Vote.pm
@@ -12,13 +12,12 @@ use App::Changeloggr::Record schema {
is immutable,
render as 'hidden';
- column user_session_id =>
- type is 'text',
- default is defer { Jifty->web->session->id },
+ column user_id =>
+ refers_to App::Changeloggr::Model::User,
is mandatory,
is immutable,
is private,
- is case_sensitive;
+ default is defer { _default_user() };
column tag =>
type is 'text',
@@ -31,6 +30,12 @@ use App::Changeloggr::Record schema {
since '0.0.3';
};
+sub _default_user {
+ my $user = App::Changeloggr::Model::User->new;
+ $user->load_or_create(session_id => Jifty->web->session->id);
+ return $user;
+}
+
sub current_user_can {
my $self = shift;
my $right = shift;
commit 2e796b21eea8cf76b15b981ba527c8d6bf9a731c
Author: Shawn M Moore <sartak at gmail.com>
Date: Wed Apr 29 17:47:43 2009 -0400
Don't try to grab a default value for a vote's user if there is no
session_id
diff --git a/lib/App/Changeloggr/Model/Vote.pm b/lib/App/Changeloggr/Model/Vote.pm
index 98fb1ad..1e28d9a 100644
--- a/lib/App/Changeloggr/Model/Vote.pm
+++ b/lib/App/Changeloggr/Model/Vote.pm
@@ -31,8 +31,11 @@ use App::Changeloggr::Record schema {
};
sub _default_user {
+ my $session_id = Jifty->web->session->id;
+ return if !defined($session_id);
+
my $user = App::Changeloggr::Model::User->new;
- $user->load_or_create(session_id => Jifty->web->session->id);
+ $user->load_or_create(session_id => $session_id);
return $user;
}
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list