[Bps-public-commit] App-Changeloggr branch, master, updated. a44c820ce850487963bd4a76e8e8629391a1f673
sartak at bestpractical.com
sartak at bestpractical.com
Wed Apr 29 18:48:17 EDT 2009
The branch, master has been updated
via a44c820ce850487963bd4a76e8e8629391a1f673 (commit)
via 1689152be602ffeaab4f57c8cb35bbcdaa2903fc (commit)
via 59c6b8c19852d9a3dbd5d828d433be1eef46af60 (commit)
from a05e0d2975f31a52683061e247674174ee9c60ae (commit)
Summary of changes:
lib/App/Changeloggr/CurrentUser.pm | 15 +++++++++++++++
lib/App/Changeloggr/Dispatcher.pm | 7 +++++++
lib/App/Changeloggr/Model/Changelog.pm | 5 +----
lib/App/Changeloggr/Model/Vote.pm | 11 +----------
lib/App/Changeloggr/View/Account.pm | 3 +++
5 files changed, 27 insertions(+), 14 deletions(-)
create mode 100644 lib/App/Changeloggr/CurrentUser.pm
- Log -----------------------------------------------------------------
commit 59c6b8c19852d9a3dbd5d828d433be1eef46af60
Author: Shawn M Moore <sartak at gmail.com>
Date: Wed Apr 29 18:28:23 2009 -0400
Add /votes to the account subnav
diff --git a/lib/App/Changeloggr/Dispatcher.pm b/lib/App/Changeloggr/Dispatcher.pm
index 8bf8c9a..4d1e06f 100644
--- a/lib/App/Changeloggr/Dispatcher.pm
+++ b/lib/App/Changeloggr/Dispatcher.pm
@@ -63,5 +63,12 @@ on qr{^/admin/changelog((?:/[^/]+)*)/([^/]+)$} => run {
show "/admin/changelog$subpage";
};
+before '/account' => sub {
+ my $account = Jifty->web->navigation->child('Account');
+ $account->child(
+ Votes => url => "/account/votes",
+ );
+};
+
1;
diff --git a/lib/App/Changeloggr/View/Account.pm b/lib/App/Changeloggr/View/Account.pm
index dc34b10..6bae928 100644
--- a/lib/App/Changeloggr/View/Account.pm
+++ b/lib/App/Changeloggr/View/Account.pm
@@ -7,5 +7,8 @@ use warnings;
template '/index.html' => page {
};
+template '/votes' => page {
+};
+
1;
commit 1689152be602ffeaab4f57c8cb35bbcdaa2903fc
Author: Shawn M Moore <sartak at gmail.com>
Date: Wed Apr 29 18:34:03 2009 -0400
Add App::Changeloggr::CurrentUser->user_object
diff --git a/lib/App/Changeloggr/CurrentUser.pm b/lib/App/Changeloggr/CurrentUser.pm
new file mode 100644
index 0000000..d9e8952
--- /dev/null
+++ b/lib/App/Changeloggr/CurrentUser.pm
@@ -0,0 +1,15 @@
+package App::Changeloggr::CurrentUser;
+use strict;
+use warnings;
+use base 'Jifty::CurrentUser';
+
+sub user_object {
+ my $session = Jifty->web->session
+ or return;
+ my $user = App::Changeloggr::Model::User->new;
+ $user->load_or_create(session_id => $session);
+ return $user;
+}
+
+1;
+
commit a44c820ce850487963bd4a76e8e8629391a1f673
Author: Shawn M Moore <sartak at gmail.com>
Date: Wed Apr 29 18:46:15 2009 -0400
Use current_user->user_object as DRY for load or create
diff --git a/lib/App/Changeloggr/CurrentUser.pm b/lib/App/Changeloggr/CurrentUser.pm
index d9e8952..6e0601a 100644
--- a/lib/App/Changeloggr/CurrentUser.pm
+++ b/lib/App/Changeloggr/CurrentUser.pm
@@ -4,7 +4,7 @@ use warnings;
use base 'Jifty::CurrentUser';
sub user_object {
- my $session = Jifty->web->session
+ my $session = Jifty->web->session->id
or return;
my $user = App::Changeloggr::Model::User->new;
$user->load_or_create(session_id => $session);
diff --git a/lib/App/Changeloggr/Model/Changelog.pm b/lib/App/Changeloggr/Model/Changelog.pm
index eb1e185..b33f346 100644
--- a/lib/App/Changeloggr/Model/Changelog.pm
+++ b/lib/App/Changeloggr/Model/Changelog.pm
@@ -84,9 +84,6 @@ sub commit_links {
sub choose_change {
my $self = shift;
- my $user = App::Changeloggr::Model::User->new;
- $user->load_or_create(session_id => Jifty->web->session->id);
-
# 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
# top tag. But for now.. an arbitrary change belonging to this changelog.
@@ -101,7 +98,7 @@ sub choose_change {
$changes->limit(
leftjoin => $votes,
column => 'user_id',
- value => $user->id,
+ value => $self->current_user->user_object->id,
case_sensitive => 1,
);
$changes->limit(
diff --git a/lib/App/Changeloggr/Model/Vote.pm b/lib/App/Changeloggr/Model/Vote.pm
index 61934b7..8d5349d 100644
--- a/lib/App/Changeloggr/Model/Vote.pm
+++ b/lib/App/Changeloggr/Model/Vote.pm
@@ -17,7 +17,7 @@ use App::Changeloggr::Record schema {
is mandatory,
is immutable,
is private,
- default is defer { _default_user() };
+ default is defer { Jifty->web->current_user->user_object };
column tag =>
type is 'text',
@@ -30,15 +30,6 @@ use App::Changeloggr::Record schema {
since '0.0.3';
};
-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 => $session_id);
- return $user;
-}
-
sub current_user_can {
my $self = shift;
my $right = shift;
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list