Changeset 20b3fcc6b52236b404b7d7aaf1517f57be3f84a2

Show
Ignore:
Timestamp:
11/06/09 22:20:07 (10 months ago)
Author:
Stephen Bennett <spb@…>
Parents:
2090df0c85d347d43405ce36c1fd4a76ac8fab4d
Children:
a75ca74156bfac8b92c3b87b2c120d446dcf5345
git-committer:
Stephen Bennett <spb@exherbo.org> / 2009-11-06T22:20:07Z+0000
Message:

Use the database validation of uniqueness in group names

Location:
lib/GMS
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lib/GMS/Schema/Result/Group.pm

    r4b12c94 r20b3fcc  
    7474} 
    7575 
     76sub insert { 
     77    my $self=shift; 
     78    try { 
     79        return $self->next::method(@_); 
     80    } 
     81    catch (DBIx::Class::Exception $e) { 
     82        if ("$e" =~ /unique_group_name/) { 
     83            die GMS::Exception->new("A group with that name already exists."); 
     84        } else { 
     85            die $e; 
     86        } 
     87    } 
     88} 
     89 
    7690sub use_automatic_verification { 
    7791    my ($name, $url) = @_; 
  • lib/GMS/Web/Controller/Group.pm

    r78afb7b r20b3fcc  
    5454 
    5555    my $group_rs = $c->model('DB::Group'); 
    56  
    57     if ($group_rs->find({ groupname => $p->{group_name} })) 
    58     { 
    59         $c->flash->{errors} = [ "A group with that name already exists." ]; 
    60         # Merge params into the flash so that they get back into the form for the second try. 
    61         %{$c->flash} = ( %{$c->flash}, %$p ); 
    62         $c->response->redirect($c->uri_for('/group/new')); 
    63         return; 
    64     } 
    6556 
    6657    my $group;