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

sartak at bestpractical.com sartak at bestpractical.com
Thu Apr 30 16:24:09 EDT 2009


The branch, master has been updated
       via  cf6ed549cc0155353ea813793da22bfa8606a693 (commit)
       via  90cd3c8e2eb98c7c7e3921f5e4aa1236bd9184cf (commit)
       via  bc997931995a172f32fb3b4ee398257ec4404f76 (commit)
      from  da8898c2d4d6628206af941de42851ede4223e2c (commit)

Summary of changes:
 lib/App/Changeloggr/Action/CreateTag.pm |   15 ---------------
 lib/App/Changeloggr/Model/Changelog.pm  |   10 ++++++++++
 lib/App/Changeloggr/Model/Tag.pm        |   24 ++++++++++++++++++++++++
 lib/App/Changeloggr/View.pm             |   16 ++++++++++------
 4 files changed, 44 insertions(+), 21 deletions(-)

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

    Changelog->has_tag

diff --git a/lib/App/Changeloggr/Model/Changelog.pm b/lib/App/Changeloggr/Model/Changelog.pm
index a4f9628..02dc270 100644
--- a/lib/App/Changeloggr/Model/Changelog.pm
+++ b/lib/App/Changeloggr/Model/Changelog.pm
@@ -80,6 +80,15 @@ sub tags {
     return M('TagCollection', changelog_id => $self);
 }
 
+sub has_tag {
+    my $self = shift;
+    my $tag  = shift;
+
+    my $tags = $self->tags;
+    $tags->limit(column => 'text', value => $tag);
+    return $tags->count;
+}
+
 sub commit_links {
     my $self = shift;
 

commit 90cd3c8e2eb98c7c7e3921f5e4aa1236bd9184cf
Author: Shawn M Moore <sartak at gmail.com>
Date:   Thu Apr 30 16:14:06 2009 -0400

    UI for incrmenetal tagging

diff --git a/lib/App/Changeloggr/Model/Changelog.pm b/lib/App/Changeloggr/Model/Changelog.pm
index 02dc270..f172dcf 100644
--- a/lib/App/Changeloggr/Model/Changelog.pm
+++ b/lib/App/Changeloggr/Model/Changelog.pm
@@ -31,6 +31,7 @@ use App::Changeloggr::Record schema {
     column incremental_tags =>
         is boolean,
         default is 0,
+        label is 'Incremental tags?',
         since '0.0.6';
 };
 
diff --git a/lib/App/Changeloggr/View.pm b/lib/App/Changeloggr/View.pm
index 50aefac..fb12780 100644
--- a/lib/App/Changeloggr/View.pm
+++ b/lib/App/Changeloggr/View.pm
@@ -155,7 +155,8 @@ template '/change/more' => sub {
 sub show_vote_form {
     my $change = shift;
 
-    my $valid_tags = $change->changelog->tags;
+    my $changelog = $change->changelog;
+    my $valid_tags = $changelog->tags;
 
     form {
         h4 { 'Vote!' };
@@ -164,15 +165,18 @@ sub show_vote_form {
             arguments => { change_id => $change->id }
         );
 
-        if ($valid_tags->count == 0) {
-            render_action $vote, ['change_id', 'tag'];
+        render_param($vote, 'change_id');
+        if ($valid_tags->count == 0 || $changelog->incremental_tags) {
+            render_param($vote, 'tag');
+
+            my $label = $changelog->incremental_tags ? 'Vote and add tag' : 'Vote';
             form_submit(
-                label   => 'Vote',
+                label   => $label,
                 onclick => { submit => $vote, refresh_self => 1 }
             );
         }
-        else {
-            render_action $vote, ['change_id'];
+
+        if ($valid_tags->count) {
             while (my $valid_tag = $valid_tags->next) {
                 $vote->button(
                     class => "vote",

commit cf6ed549cc0155353ea813793da22bfa8606a693
Author: Shawn M Moore <sartak at gmail.com>
Date:   Thu Apr 30 16:23:55 2009 -0400

    Move canonicalization of hotkey from CreateTag to Tag->create

diff --git a/lib/App/Changeloggr/Action/CreateTag.pm b/lib/App/Changeloggr/Action/CreateTag.pm
index 578baef..aac1398 100644
--- a/lib/App/Changeloggr/Action/CreateTag.pm
+++ b/lib/App/Changeloggr/Action/CreateTag.pm
@@ -3,20 +3,6 @@ use strict;
 use warnings;
 use base 'App::Changeloggr::Action::Mixin::RequiresAdminToken', 'Jifty::Action::Record::Create';
 
-sub canonicalize_text {
-    my $self = shift;
-    my $tag = shift;
-
-    if (length $tag and not length($self->argument_value('hotkey')||'')) {
-        my $possible = lc substr($tag, 0, 1);
-        my $existing = App::Changeloggr::Model::TagCollection->new;
-        $existing->limit( column => 'changelog_id', value => $self->argument_value('changelog_id') );
-        $existing->limit( column => 'hotkey',       value => $possible );
-        $self->argument_value( hotkey => $possible ) unless $existing->count;
-    }
-    return $tag;
-}
-
 sub take_action {
     my $self = shift;
     $self->record->current_user(App::Changeloggr::CurrentUser->superuser);
@@ -30,4 +16,3 @@ sub report_success {
 
 1;
 
-
diff --git a/lib/App/Changeloggr/Model/Tag.pm b/lib/App/Changeloggr/Model/Tag.pm
index cd5242d..612492e 100644
--- a/lib/App/Changeloggr/Model/Tag.pm
+++ b/lib/App/Changeloggr/Model/Tag.pm
@@ -38,6 +38,30 @@ sub validate_hotkey {
     return 1;
 }
 
+sub create {
+    my $self = shift;
+    my %args = @_;
+
+    my $text      = $args{text};
+    my $hotkey    = $args{hotkey};
+    my $changelog = $args{changelog_id};
+
+    if (length $text and not length($hotkey)) {
+        my $possible = lc substr($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 );
+        $hotkey = $possible unless $existing->count;
+    }
+
+    return $self->SUPER::create(
+        %args,
+        text         => $text,
+        hotkey       => $hotkey,
+        changelog_id => $changelog,
+    );
+}
+
 sub current_user_can {
     my $self  = shift;
     my $right = shift;

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



More information about the Bps-public-commit mailing list