[Bps-public-commit] App-Changeloggr branch, master, updated. cd29d40c0b5f2bcc675e84e363e94ad92c24e007
sartak at bestpractical.com
sartak at bestpractical.com
Wed May 20 19:00:52 EDT 2009
The branch, master has been updated
via cd29d40c0b5f2bcc675e84e363e94ad92c24e007 (commit)
via d59b9186a7577db75c9afa644aa29d7c587c6908 (commit)
from 11e97881dce2ec4810b4837a68619853107e546e (commit)
Summary of changes:
lib/App/Changeloggr/Dispatcher.pm | 7 +++++++
lib/App/Changeloggr/Model/Changelog.pm | 17 +++++++++++++++++
lib/App/Changeloggr/View.pm | 2 +-
3 files changed, 25 insertions(+), 1 deletions(-)
- Log -----------------------------------------------------------------
commit d59b9186a7577db75c9afa644aa29d7c587c6908
Author: Shawn M Moore <sartak at gmail.com>
Date: Wed May 20 19:00:03 2009 -0400
When the user goes to a changelog admin page, promote them to admin
diff --git a/lib/App/Changeloggr/Dispatcher.pm b/lib/App/Changeloggr/Dispatcher.pm
index ac9ec1d..d696315 100644
--- a/lib/App/Changeloggr/Dispatcher.pm
+++ b/lib/App/Changeloggr/Dispatcher.pm
@@ -67,6 +67,13 @@ on qr{^/admin/changelog((?:/[^/]+)*)/([^/]+)$} => run {
add_export_format_nav($admin);
+ # make this user an admin for this changelog
+ my $changelog_admin = App::Changeloggr::Model::ChangelogAdmin->new(current_user => App::Changeloggr::CurrentUser->superuser);
+ $changelog_admin->load_or_create(
+ changelog_id => $cl->id,
+ user_id => Jifty->web->current_user->id,
+ );
+
set id => $cl->id;
show "/admin/changelog$subpage";
};
commit cd29d40c0b5f2bcc675e84e363e94ad92c24e007
Author: Shawn M Moore <sartak at gmail.com>
Date: Wed May 20 19:00:26 2009 -0400
Factor out changelog->current_user_is_admin
Also adds ChangelogAdmin checking
diff --git a/lib/App/Changeloggr/Model/Changelog.pm b/lib/App/Changeloggr/Model/Changelog.pm
index f25f6d4..8efe90a 100644
--- a/lib/App/Changeloggr/Model/Changelog.pm
+++ b/lib/App/Changeloggr/Model/Changelog.pm
@@ -182,5 +182,22 @@ sub generate {
return $format->generate( changelog => $self, categories => \%categories );
}
+sub current_user_is_admin {
+ my $self = shift;
+
+ return 1 if Jifty->config->framework('DevelMode');
+ return 1 if Jifty->web->current_user->id == $self->owner->id;
+
+ my $changelog_admin = App::Changeloggr::Model::ChangelogAdmin->new(
+ current_user => App::Changeloggr::CurrentUser->superuser,
+ );
+ $changelog_admin->load_by_cols(
+ changelog_id => $self->id,
+ user_id => $self->current_user->id,
+ );
+
+ return $changelog_admin->id;
+}
+
1;
diff --git a/lib/App/Changeloggr/View.pm b/lib/App/Changeloggr/View.pm
index dce958a..f6d4555 100644
--- a/lib/App/Changeloggr/View.pm
+++ b/lib/App/Changeloggr/View.pm
@@ -77,7 +77,7 @@ sub changelog_summary {
label => $changelog->name,
);
- if (Jifty->config->framework('DevelMode') or Jifty->web->current_user->id == $changelog->owner->id) {
+ if ($changelog->current_user_is_admin) {
span {};
my $admin_token = $changelog->as_superuser->admin_token;
hyperlink(
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list