[Bps-public-commit] App-Changeloggr branch, master, updated. 2654dd104e90c90ce211c105436bc9cc168d4b8a

sartak at bestpractical.com sartak at bestpractical.com
Mon May 11 20:44:24 EDT 2009


The branch, master has been updated
       via  2654dd104e90c90ce211c105436bc9cc168d4b8a (commit)
      from  dbb03de321db966008c365ac170b6cc668ee8871 (commit)

Summary of changes:
 etc/config.yml                                     |    2 +-
 .../Changeloggr/Model/{Vote.pm => Importance.pm}   |   23 ++++++++-----------
 2 files changed, 11 insertions(+), 14 deletions(-)
 copy lib/App/Changeloggr/Model/{Vote.pm => Importance.pm} (72%)

- Log -----------------------------------------------------------------
commit 2654dd104e90c90ce211c105436bc9cc168d4b8a
Author: Shawn M Moore <sartak at gmail.com>
Date:   Mon May 11 20:44:16 2009 -0400

    Add Importance model

diff --git a/etc/config.yml b/etc/config.yml
index 5283f9e..81dea39 100644
--- a/etc/config.yml
+++ b/etc/config.yml
@@ -14,7 +14,7 @@ framework:
     Password: ''
     RecordBaseClass: Jifty::DBI::Record::Cachable
     User: ''
-    Version: 0.0.7
+    Version: 0.0.8
   DevelMode: 1
   L10N: 
     PoDir: share/po
diff --git a/lib/App/Changeloggr/Model/Importance.pm b/lib/App/Changeloggr/Model/Importance.pm
new file mode 100644
index 0000000..88b7d41
--- /dev/null
+++ b/lib/App/Changeloggr/Model/Importance.pm
@@ -0,0 +1,53 @@
+use strict;
+use warnings;
+
+package App::Changeloggr::Model::Importance;
+use Jifty::DBI::Schema;
+use Scalar::Defer 'defer';
+
+use App::Changeloggr::Record schema {
+    column change_id =>
+        refers_to App::Changeloggr::Model::Change,
+        is mandatory,
+        is immutable,
+        render as 'hidden';
+
+    column user_id =>
+        refers_to App::Changeloggr::Model::User,
+        is mandatory,
+        is immutable,
+        is private,
+        default is defer { Jifty->web->current_user->user_object };
+
+    column importance =>
+        type is 'text',
+        valid_values are qw(major normal minor),
+        default is 'normal',
+        is immutable;
+
+    column date =>
+        type is 'timestamp',
+        filters are qw( Jifty::Filter::DateTime Jifty::DBI::Filter::DateTime),
+        label is 'Date',
+        default is defer { DateTime->now };
+};
+
+sub since { '0.0.8' }
+
+sub current_user_can {
+    my $self  = shift;
+    my $right = shift;
+    my %args  = @_;
+
+    # importance-votes are public except for who the voter was
+    return 1 if $right eq 'read' && $args{column} ne 'user_id';
+
+    # anyone can submit importance-votes
+    return 1 if $right eq 'create';
+
+    # but importance-votes are immutable
+    return $self->SUPER::current_user_can($right, %args);
+}
+
+1;
+

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



More information about the Bps-public-commit mailing list