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

sartak at bestpractical.com sartak at bestpractical.com
Wed Apr 1 14:27:56 EDT 2009


The branch, master has been updated
       via  aa47fb86d6a6b8aa3b302b4b7739df5e48dadac1 (commit)
      from  23009d23f66fe0e6803800b25f5308a8d70591dd (commit)

Summary of changes:
 lib/App/Changeloggr/Action/CreateVote.pm |   20 ++++++++++++++++++++
 lib/App/Changeloggr/Model/Changelog.pm   |    6 ++++++
 2 files changed, 26 insertions(+), 0 deletions(-)

- Log -----------------------------------------------------------------
commit aa47fb86d6a6b8aa3b302b4b7739df5e48dadac1
Author: Shawn M Moore <sartak at gmail.com>
Date:   Wed Apr 1 14:26:19 2009 -0400

    Validate tags against what the administrator has decided

diff --git a/lib/App/Changeloggr/Action/CreateVote.pm b/lib/App/Changeloggr/Action/CreateVote.pm
index 4c8ea68..16c9543 100644
--- a/lib/App/Changeloggr/Action/CreateVote.pm
+++ b/lib/App/Changeloggr/Action/CreateVote.pm
@@ -2,6 +2,26 @@ package App::Changeloggr::Action::CreateVote;
 use strict;
 use warnings;
 use base 'Jifty::Action::Record::Create';
+use JiftyX::ModelHelpers;
+
+sub validate_tag {
+    my $self = shift;
+    my $tag  = shift;
+
+    # if the admin has set up a set of tags for this project, then validate
+    # against that list
+    my $valid_tags = Changelog($self->argument_value('changelog'))->tags;
+    if ($valid_tags->count) {
+        while (my $valid_tag = $valid_tags->next) {
+            return $self->validation_ok('tag') if $valid_tag eq $tag;
+        }
+
+        return $self->validation_error(tag => "That is not a valid tag for this changelog.");
+    }
+
+    # otherwise, every tag is valid
+    return $self->validation_ok('tag');
+}
 
 sub report_success { shift->result->message(_("Thanks for voting!")) }
 
diff --git a/lib/App/Changeloggr/Model/Changelog.pm b/lib/App/Changeloggr/Model/Changelog.pm
index 54d5771..62081ac 100644
--- a/lib/App/Changeloggr/Model/Changelog.pm
+++ b/lib/App/Changeloggr/Model/Changelog.pm
@@ -70,6 +70,12 @@ sub changes {
     return M('ChangeCollection', changelog => $self);
 }
 
+sub tags {
+    my $self = shift;
+
+    return M('TagCollection', changelog => $self);
+}
+
 sub choose_change {
     my $self = shift;
 

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



More information about the Bps-public-commit mailing list