[Bps-public-commit] App-Changeloggr branch, master, updated. 980c1b9acfe0a50eafba66636b87a34ac0d05df4

sartak at bestpractical.com sartak at bestpractical.com
Thu Feb 26 22:05:17 EST 2009


The branch, master has been updated
       via  980c1b9acfe0a50eafba66636b87a34ac0d05df4 (commit)
       via  f31a2ff6b0caac0d54419a51b476806c1eae7c13 (commit)
       via  2bbb9c995d86ece591c08ef52fe0387bc73241b2 (commit)
       via  2317baa004be545f38729872b66ee1551415ce3d (commit)
       via  3b9d35960b69a398980d85b0b66366645fbf1113 (commit)
      from  90805eaf68c6ba2231ecc21df4f835617651ad9e (commit)

Summary of changes:
 Makefile.PL                                   |    1 +
 lib/App/Changeloggr/Action/UpdateChangelog.pm |   29 +++++++++++++++++++++++++
 lib/App/Changeloggr/Dispatcher.pm             |    4 +-
 lib/App/Changeloggr/Model/Changelog.pm        |    3 +-
 lib/App/Changeloggr/View.pm                   |    7 +++--
 5 files changed, 38 insertions(+), 6 deletions(-)
 create mode 100644 lib/App/Changeloggr/Action/UpdateChangelog.pm

- Log -----------------------------------------------------------------
commit 3b9d35960b69a398980d85b0b66366645fbf1113
Author: Shawn M Moore <sartak at gmail.com>
Date:   Thu Feb 26 22:03:25 2009 -0500

    We require Data::UUID for generating admin tokens

diff --git a/Makefile.PL b/Makefile.PL
index 3e8c5c2..7a768a0 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -5,5 +5,6 @@ version     '0.01';
 
 requires    'Jifty' => '0.90220';
 requires    'JiftyX::ModelHelpers' => '0.22';
+requires    'Data::UUID';
 
 WriteAll;

commit 2317baa004be545f38729872b66ee1551415ce3d
Author: Shawn M Moore <sartak at gmail.com>
Date:   Thu Feb 26 22:03:41 2009 -0500

    Ignore changelog id and use name instead, making it distinct

diff --git a/lib/App/Changeloggr/Dispatcher.pm b/lib/App/Changeloggr/Dispatcher.pm
index 255b1cb..1480ac3 100644
--- a/lib/App/Changeloggr/Dispatcher.pm
+++ b/lib/App/Changeloggr/Dispatcher.pm
@@ -13,8 +13,8 @@ on '/created-changelog' => run {
     redirect '/changelog/admin/' . Changelog($id)->admin_token;
 };
 
-on '/changelog/#' => run {
-    set id => $1;
+on '/changelog/*' => run {
+    set name => $1;
     show '/changelog';
 };
 
diff --git a/lib/App/Changeloggr/Model/Changelog.pm b/lib/App/Changeloggr/Model/Changelog.pm
index e2958d0..1575162 100644
--- a/lib/App/Changeloggr/Model/Changelog.pm
+++ b/lib/App/Changeloggr/Model/Changelog.pm
@@ -7,7 +7,8 @@ use Jifty::DBI::Schema;
 use App::Changeloggr::Record schema {
     column name =>
         type is 'text',
-        label is 'Project name';
+        label is 'Project name',
+        is distinct;
 
     column done =>
         is boolean,
diff --git a/lib/App/Changeloggr/View.pm b/lib/App/Changeloggr/View.pm
index 8a3067c..d456d41 100644
--- a/lib/App/Changeloggr/View.pm
+++ b/lib/App/Changeloggr/View.pm
@@ -27,7 +27,7 @@ template '/create-changelog' => page {
 };
 
 template '/changelog' => page {
-    my $changelog = Changelog(id => get('id'));
+    my $changelog = Changelog(name => get('name'));
     h1 { $changelog->name }
 };
 

commit 2bbb9c995d86ece591c08ef52fe0387bc73241b2
Author: Shawn M Moore <sartak at gmail.com>
Date:   Thu Feb 26 22:04:12 2009 -0500

    JiftyX::ModelHelpers seems to not give us collection functions, ah well

diff --git a/lib/App/Changeloggr/View.pm b/lib/App/Changeloggr/View.pm
index d456d41..53daa00 100644
--- a/lib/App/Changeloggr/View.pm
+++ b/lib/App/Changeloggr/View.pm
@@ -5,7 +5,7 @@ use strict;
 use warnings;
 
 template '/' => page {
-    my $changelogs = ChangelogCollection(done => 0);
+    my $changelogs = M(ChangelogCollection => done => 0);
 
     if ($changelogs->count) {
         h2 { "These projects need your help!" };

commit f31a2ff6b0caac0d54419a51b476806c1eae7c13
Author: Shawn M Moore <sartak at gmail.com>
Date:   Thu Feb 26 22:04:42 2009 -0500

    Pass admin_token to the update action so it can confirm that the user is
    an admin

diff --git a/lib/App/Changeloggr/View.pm b/lib/App/Changeloggr/View.pm
index 53daa00..30bf458 100644
--- a/lib/App/Changeloggr/View.pm
+++ b/lib/App/Changeloggr/View.pm
@@ -36,7 +36,8 @@ template '/changelog/admin' => page {
 
     my $update = $changelog->as_update_action;
     form {
-        render_action $update, ['name', 'done'];
+        render_action($update => ['name', 'done']);
+        render_param($update => 'admin_token' => render_as => 'hidden');
         form_submit(label => 'Update');
     };
 };

commit 980c1b9acfe0a50eafba66636b87a34ac0d05df4
Author: Shawn M Moore <sartak at gmail.com>
Date:   Thu Feb 26 22:05:01 2009 -0500

    Add an UpdateChangelog action which confirms that you have the admin
    token before letting you update

diff --git a/lib/App/Changeloggr/Action/UpdateChangelog.pm b/lib/App/Changeloggr/Action/UpdateChangelog.pm
new file mode 100644
index 0000000..0eaddcc
--- /dev/null
+++ b/lib/App/Changeloggr/Action/UpdateChangelog.pm
@@ -0,0 +1,29 @@
+package App::Changeloggr::Action::UpdateChangelog;
+use strict;
+use warnings;
+use base 'Jifty::Action::Record::Create';
+
+use JiftyX::ModelHelpers;
+
+sub record_class { 'App::Changeloggr::Model::Changelog' }
+
+sub validate_admin_token {
+    my $self        = shift;
+    my $admin_token = shift;
+
+    if ($self->record->as_superuser->admin_token eq $admin_token) {
+        return $self->validation_ok('admin_token');
+    }
+    else {
+        return $self->validation_error(admin_token => "You do not have permission to update this changelog.");
+    }
+}
+
+sub take_action {
+    my $self = shift;
+    $self->record->current_user(App::Changeloggr::CurrentUser->superuser);
+    $self->SUPER::take_action(@_);
+}
+
+1;
+

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



More information about the Bps-public-commit mailing list