[Bps-public-commit] App-Changeloggr branch, master, updated. d0256c52fba94dfe27a62fb02438e9c98a644ce4
Alex M Vandiver
alexmv at bestpractical.com
Wed May 20 17:06:54 EDT 2009
The branch, master has been updated
via d0256c52fba94dfe27a62fb02438e9c98a644ce4 (commit)
via 42a1a500089444436d3ac9c3a22bcbd591c592e7 (commit)
from e077aa0f01209faea84eccf77137c3ba1fa18a78 (commit)
Summary of changes:
etc/config.yml | 3 ++-
lib/App/Changeloggr/Model/News.pm | 30 ++++++++++++++++++++++++++++++
lib/App/Changeloggr/Model/User.pm | 11 ++++++++++-
lib/App/Changeloggr/View.pm | 3 +++
4 files changed, 45 insertions(+), 2 deletions(-)
create mode 100644 lib/App/Changeloggr/Model/News.pm
- Log -----------------------------------------------------------------
commit 42a1a500089444436d3ac9c3a22bcbd591c592e7
Author: Alex Vandiver <alexmv at mit.edu>
Date: Wed May 20 16:11:53 2009 -0400
Add SiteNews plugin
diff --git a/etc/config.yml b/etc/config.yml
index fcb39de..3e83ba1 100644
--- a/etc/config.yml
+++ b/etc/config.yml
@@ -14,7 +14,7 @@ framework:
Password: ''
RecordBaseClass: Jifty::DBI::Record::Cachable
User: ''
- Version: 0.0.11
+ Version: 0.0.12
DevelMode: 1
L10N:
PoDir: share/po
@@ -33,6 +33,7 @@ framework:
- Feedback:
to: changelogger at my.hiveminder.com
from: changelogger-user at bestpractical.com
+ - SiteNews: {}
SkipAccessControl: 0
TemplateClass: App::Changeloggr::View
View:
diff --git a/lib/App/Changeloggr/Model/News.pm b/lib/App/Changeloggr/Model/News.pm
new file mode 100644
index 0000000..bae2779
--- /dev/null
+++ b/lib/App/Changeloggr/Model/News.pm
@@ -0,0 +1,19 @@
+use strict;
+use warnings;
+
+package App::Changeloggr::Model::News;
+use Jifty::DBI::Schema;
+
+use App::Changeloggr::Record schema {
+};
+
+use Jifty::Plugin::SiteNews::Mixin::Model::News;
+
+use constant since => '0.0.12';
+
+sub current_user_can {
+ return 1;
+}
+
+1;
+
diff --git a/lib/App/Changeloggr/View.pm b/lib/App/Changeloggr/View.pm
index c2ed5a0..9a75aad 100644
--- a/lib/App/Changeloggr/View.pm
+++ b/lib/App/Changeloggr/View.pm
@@ -10,6 +10,9 @@ alias App::Changeloggr::View::Admin under '/admin';
require App::Changeloggr::View::Account;
alias App::Changeloggr::View::Account under '/account';
+require Jifty::Plugin::SiteNews::View::News;
+alias Jifty::Plugin::SiteNews::View::News under '/news';
+
# No salutation, ever
template '/salutation' => sub {};
commit d0256c52fba94dfe27a62fb02438e9c98a644ce4
Author: Alex Vandiver <alexmv at mit.edu>
Date: Wed May 20 17:03:08 2009 -0400
Add authors on news posts, and user access levels
diff --git a/lib/App/Changeloggr/Model/News.pm b/lib/App/Changeloggr/Model/News.pm
index bae2779..1ac4b4b 100644
--- a/lib/App/Changeloggr/Model/News.pm
+++ b/lib/App/Changeloggr/Model/News.pm
@@ -4,7 +4,14 @@ use warnings;
package App::Changeloggr::Model::News;
use Jifty::DBI::Schema;
+use App::Changeloggr::Model::User;
+
use App::Changeloggr::Record schema {
+ column author =>
+ refers_to App::Changeloggr::Model::User,
+ default is defer { Jifty->web->current_user->id },
+ is protected,
+ since '0.0.12';
};
use Jifty::Plugin::SiteNews::Mixin::Model::News;
@@ -12,7 +19,11 @@ use Jifty::Plugin::SiteNews::Mixin::Model::News;
use constant since => '0.0.12';
sub current_user_can {
- return 1;
+ 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 0;
}
1;
diff --git a/lib/App/Changeloggr/Model/User.pm b/lib/App/Changeloggr/Model/User.pm
index ca29c90..91760df 100644
--- a/lib/App/Changeloggr/Model/User.pm
+++ b/lib/App/Changeloggr/Model/User.pm
@@ -27,6 +27,15 @@ use App::Changeloggr::Record schema {
default is 0,
label is 'Always show full diff',
since '0.0.10';
+
+ column access_level =>
+ is mandatory,
+ default is 'guest',
+ since '0.0.12',
+ label is 'Access level',
+ valid_values are qw(user staff),
+ is protected;
+
};
# has to go below schema
@@ -44,7 +53,7 @@ sub current_user_can {
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';
+ return 1 if $right eq 'read' and ( $args{column} eq 'name' or $args{column} eq 'access_level' );
# anyone can create accounts
return 1 if $right eq 'create';
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list