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

sartak at bestpractical.com sartak at bestpractical.com
Thu Apr 30 16:48:49 EDT 2009


The branch, master has been updated
       via  5b0879f20978197bbb1b2e1bc44155c2f0903319 (commit)
       via  3eb587f695fed2ecbdf61889380f5e044d06aa6f (commit)
       via  aa4cee0630127fc6aad506bf027426a20cb79f2e (commit)
      from  cf6ed549cc0155353ea813793da22bfa8606a693 (commit)

Summary of changes:
 lib/App/Changeloggr/Action/CreateVote.pm |   21 +++++++++++++++++++--
 lib/App/Changeloggr/Model/Changelog.pm   |   11 +++++++++++
 lib/App/Changeloggr/Model/Tag.pm         |   12 ++++--------
 3 files changed, 34 insertions(+), 10 deletions(-)

- Log -----------------------------------------------------------------
commit aa4cee0630127fc6aad506bf027426a20cb79f2e
Author: Shawn M Moore <sartak at gmail.com>
Date:   Thu Apr 30 16:48:07 2009 -0400

    Changelog->add_tag

diff --git a/lib/App/Changeloggr/Model/Changelog.pm b/lib/App/Changeloggr/Model/Changelog.pm
index f172dcf..692a37e 100644
--- a/lib/App/Changeloggr/Model/Changelog.pm
+++ b/lib/App/Changeloggr/Model/Changelog.pm
@@ -90,6 +90,17 @@ sub has_tag {
     return $tags->count;
 }
 
+sub add_tag {
+    my $self = shift;
+    my $text = shift;
+
+    my $tag = M('Tag');
+    $tag->as_superuser->create(
+        text         => $text,
+        changelog_id => $self->id,
+    );
+}
+
 sub commit_links {
     my $self = shift;
 

commit 3eb587f695fed2ecbdf61889380f5e044d06aa6f
Author: Shawn M Moore <sartak at gmail.com>
Date:   Thu Apr 30 16:48:33 2009 -0400

    Fixes for Tag->create

diff --git a/lib/App/Changeloggr/Model/Tag.pm b/lib/App/Changeloggr/Model/Tag.pm
index 612492e..b27bc9d 100644
--- a/lib/App/Changeloggr/Model/Tag.pm
+++ b/lib/App/Changeloggr/Model/Tag.pm
@@ -42,12 +42,10 @@ sub create {
     my $self = shift;
     my %args = @_;
 
-    my $text      = $args{text};
-    my $hotkey    = $args{hotkey};
-    my $changelog = $args{changelog_id};
+    my $hotkey = $args{hotkey};
 
-    if (length $text and not length($hotkey)) {
-        my $possible = lc substr($text, 0, 1);
+    if (length $args{text} and not length($hotkey)) {
+        my $possible = lc substr($args{text}, 0, 1);
         my $existing = App::Changeloggr::Model::TagCollection->new;
         $existing->limit( column => 'changelog_id', value => $args{changelog_id} );
         $existing->limit( column => 'hotkey',       value => $possible );
@@ -56,9 +54,7 @@ sub create {
 
     return $self->SUPER::create(
         %args,
-        text         => $text,
-        hotkey       => $hotkey,
-        changelog_id => $changelog,
+        hotkey => $hotkey,
     );
 }
 

commit 5b0879f20978197bbb1b2e1bc44155c2f0903319
Author: Shawn M Moore <sartak at gmail.com>
Date:   Thu Apr 30 16:48:39 2009 -0400

    CreateVote can create tags

diff --git a/lib/App/Changeloggr/Action/CreateVote.pm b/lib/App/Changeloggr/Action/CreateVote.pm
index 16c9543..abd9b81 100644
--- a/lib/App/Changeloggr/Action/CreateVote.pm
+++ b/lib/App/Changeloggr/Action/CreateVote.pm
@@ -8,12 +8,29 @@ sub validate_tag {
     my $self = shift;
     my $tag  = shift;
 
+    my $changelog = Changelog($self->argument_value('changelog_id'));
+    if (!$changelog->id) {
+        my $change = Change($self->argument_value('change_id'));
+        $changelog = $change->changelog;
+    }
+
+    return $self->validation_error(change_id => "No change provided")
+        if !$changelog->id;
+
+    # if the admin wants incremental tag creation for this project, then
+    # add this tag before voting
+    if (!$changelog->has_tag($tag)) {
+        my ($ok, $msg) = $changelog->add_tag($tag);
+        return $self->validation_ok('tag') if $ok;
+        return $self->validation_error(tag => $msg);
+    }
+
     # 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;
+    my $valid_tags = $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_ok('tag') if $valid_tag->text eq $tag;
         }
 
         return $self->validation_error(tag => "That is not a valid tag for this changelog.");

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



More information about the Bps-public-commit mailing list