Changeset 41 for server


Ignore:
Timestamp:
11/27/10 20:15:04 (14 years ago)
Author:
nanardon
Message:
  • improve admin part
Location:
server/trunk/web/lib/Sophie
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • server/trunk/web/lib/Sophie/Base/Result/Medias.pm

    r5 r41  
    77__PACKAGE__->table('d_media'); 
    88__PACKAGE__->add_columns( 
    9     qw/d_media_key label comment group_label d_arch dist_label/ 
     9    qw/d_media_key label comment group_label d_arch/ 
    1010); 
    1111__PACKAGE__->set_primary_key('d_media_key'); 
    1212__PACKAGE__->belongs_to(Arch => 'Sophie::Base::Result::Arch', 'd_arch'); 
    1313__PACKAGE__->has_many(MediasPaths => 'Sophie::Base::Result::MediasPaths', 'd_media'); 
     14__PACKAGE__->add_unique_constraint('label' => [ 'label', 'd_arch' ]); 
    1415 
    15161; 
  • server/trunk/web/lib/Sophie/Controller/Admin.pm

    r32 r41  
    6060        ->search_related('Arch', arch => $distribspec->{arch})->next; 
    6161    if ($d) { 
    62         my $new = my $rs = $c->model('Base')->resultset('Medias')->new({ 
     62        my $new = my $rs = $c->model('Base')->resultset('Medias') 
     63            ->update_or_create({ 
    6364                %{ $mediaspec }, 
    6465                Arch => $d, 
    65             }); 
    66         if ($new->insert) { 
     66            }, 
     67            { key => 'label' } 
     68        ); 
     69        if ($new) { 
    6770            $c->stash->{xmlrpc} = 'OK'; 
    6871            $c->model('Base')->storage->dbh->commit; 
     
    132135} 
    133136 
     137sub media_remove_path :XMLRPC { 
     138    my ( $self, $c, $distribution, $version, $arch, $label, $path ) = @_; 
     139 
     140    if (ref $distribution) { 
     141        ($distribution, $version, $arch, $label, $path) =  
     142        ( 
     143            $distribution->{distribution}, 
     144            $distribution->{release}, 
     145            $distribution->{arch}, 
     146            $version, 
     147            $arch, 
     148        ); 
     149    } 
     150 
     151    $path =~ s/\/*$//; 
     152    $path =~ s/\/+/\//g; 
     153 
     154    my $med = $c->model('Base')->resultset('Distribution') 
     155        ->search(name => $distribution) 
     156        ->search_related('Release', version => $version) 
     157        ->search_related('Arch', arch => $arch) 
     158        ->search_related('Medias', label => $label)->next or return; 
     159 
     160    my $rspath = $c->model('Base')->resultset('Paths') 
     161        ->find({ path => $path }) or do { 
     162            return; 
     163    }; 
     164    my $new = $c->model('Base')->resultset('MediasPaths')->new({ 
     165            Medias => $med, 
     166            Paths =>  $rspath, 
     167        }); 
     168    $new->delete; 
     169 
     170    $c->model('Base')->storage->dbh->commit; 
     171} 
     172 
     173sub ls_local : XMLRPC { 
     174    my ($self, $c, $path) = @_; 
     175 
     176    $c->stash->{xmlrpc} = [ <$path*> ]; 
     177} 
    134178 
    135179=head1 AUTHOR 
  • server/trunk/web/lib/Sophie/Controller/Distrib.pm

    r27 r41  
    6969        ->search_related('Release', { version => $release }) 
    7070        ->search_related('Arch', { arch => $arch }) 
    71         ->search_related('Medias'); 
    72     @{$c->stash->{xmlrpc}} = map {  
     71        ->search_related('Medias')->search({}, { order_by => 'label' }); 
     72    $c->stash->{xmlrpc} = [ map {  
    7373        {  
    74             dist_label => $_->dist_label, 
    7574            label => $_->label, 
    7675            group_label => $_->group_label, 
    7776            key => $_->d_media_key, 
    7877        }  
    79     } $rs->all; 
     78    } $rs->all ]; 
    8079} 
    8180 
  • server/trunk/web/lib/Sophie/Controller/Root.pm

    r23 r41  
    8888    } 
    8989    $c->stash->{data} = $c->stash->{xmlrpc}; 
    90     $c->model('Base')->storage->dbh->rollback; 
     90    $c->model('Base')->storage->dbh->commit; 
    9191} 
    9292 
  • server/trunk/web/lib/Sophie/Model/Base.pm

    r35 r41  
    99        dsn => 'toto', 
    1010    },     
    11      
    1211); 
    1312 
Note: See TracChangeset for help on using the changeset viewer.