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

Alex M Vandiver alexmv at bestpractical.com
Wed May 20 15:07:07 EDT 2009


The branch, master has been updated
       via  f5ed974a6263ede7e31304e77b70b2912a4c294e (commit)
      from  887ce913ebf9ab5613a9fa1226c8c1772758151a (commit)

Summary of changes:
 lib/App/Changeloggr/Model/Changelog.pm |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit f5ed974a6263ede7e31304e77b70b2912a4c294e
Author: Alex Vandiver <alexmv at mit.edu>
Date:   Wed May 20 15:06:43 2009 -0400

    Add a validator to enforce the "is distinct"

diff --git a/lib/App/Changeloggr/Model/Changelog.pm b/lib/App/Changeloggr/Model/Changelog.pm
index 997313a..cf35eb5 100644
--- a/lib/App/Changeloggr/Model/Changelog.pm
+++ b/lib/App/Changeloggr/Model/Changelog.pm
@@ -9,7 +9,8 @@ use App::Changeloggr::Record schema {
         type is 'text',
         label is 'Project name',
         is distinct,
-        is mandatory;
+        is mandatory,
+        ajax validates;
 
     column done =>
         is boolean,
@@ -39,6 +40,14 @@ use App::Changeloggr::Record schema {
 # has to go below schema
 use JiftyX::ModelHelpers;
 
+sub validate_name {
+    my $self = shift;
+    my $name = shift;
+    my $exist = M(Changelog => name => $name);
+    return (0, "That name already exists -- choose another") if $exist->id;
+    return 1;
+}
+
 sub _generate_admin_token {
     require Data::GUID;
     Data::GUID->new->as_string;

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



More information about the Bps-public-commit mailing list