Changeset 112


Ignore:
Timestamp:
12/11/10 10:56:15 (13 years ago)
Author:
nanardon
Message:
  • add rpm/location subpage
Location:
server/trunk/web
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • server/trunk/web/lib/Sophie/Controller/Rpms.pm

    r99 r112  
    131131} 
    132132 
    133 =head2 rpms.location (PKGID) 
    134  
    135 Return all distribution where the package having C<PKGID> can be found. 
    136  
    137 =cut 
    138  
    139 sub location : XMLRPCLocal { 
    140     my ($self, $c, $pkgid) = @_; 
    141  
    142     $c->stash->{xmlrpc} = [ 
    143         map { 
    144         { 
    145             distribution => $_->get_column('name'), 
    146             release => $_->get_column('version'), 
    147             arch => $_->get_column('arch'),  
    148             media => $_->get_column('label'), 
    149             media_group => $_->get_column('group_label'), 
    150         } 
    151         } 
    152         $c->forward('/distrib/distrib_rs', [ {} ]) 
    153          ->search_related('MediasPaths') 
    154                  ->search_related('Paths') 
    155         ->search_related('Rpmfiles', 
    156             { pkgid => $pkgid }, 
    157             { 
    158                 select => [ qw(name version arch label group_label) ], 
    159             } 
    160         )->all ] 
    161  
    162  
    163 } 
    164  
    165133sub rpms_ :PathPrefix :Chained :CaptureArgs(1) { 
    166134    my ( $self, $c, $pkgid ) = @_; 
     
    178146sub rpms : Private { 
    179147    my ( $self, $c, $pkgid, $subpart, @args) = @_; 
    180     $c->stash->{rpmurl} = $c->req->path; 
    181148    # Because $c->forward don't take into account Chained sub 
    182149    $c->forward('rpms_', [ $pkgid ]); 
     
    185152        /^files$/     and $c->go('files',     [ $pkgid, @args ]); 
    186153        /^changelog$/ and $c->go('changelog', [ $pkgid, @args ]); 
    187     } 
     154        /^location$/  and $c->go('location',  [ $pkgid, @args ]); 
     155    } 
     156    $c->stash->{rpmurl} = $c->req->path; 
    188157 
    189158    return $c->stash->{xmlrpc} = $c->stash->{rpms}; 
     
    281250} 
    282251 
    283 sub changelog :Chained('rpms_') :PathPart('changelog') :Args(0) { 
     252sub changelog :Chained('rpms_') :PathPart('changelog') :Args(0) :XMLRPCLocal { 
    284253    my ( $self, $c, $pkgid ) = @_; 
    285254    $pkgid ||= $c->stash->{pkgid}; 
     
    310279} 
    311280 
     281=head2 rpms.location (PKGID) 
     282 
     283Return all distribution where the package having C<PKGID> can be found. 
     284 
     285=cut 
     286 
     287sub location :Chained('rpms_') :PathPart('location') :Args(0) { 
     288    my ( $self, $c, $pkgid ) = @_; 
     289    $pkgid ||= $c->stash->{pkgid}; 
     290    $c->stash->{rpmurl} = ($c->req->path =~ m:(.*)/[^/]+:)[0]; 
     291 
     292    $c->stash->{xmlrpc} = [ 
     293        map { 
     294        { 
     295            distribution => $_->get_column('name'), 
     296            dist => $_->get_column('shortname'), 
     297            release => $_->get_column('version'), 
     298            arch => $_->get_column('arch'),  
     299            media => $_->get_column('label'), 
     300            media_group => $_->get_column('group_label'), 
     301        } 
     302        } 
     303        $c->forward('/distrib/distrib_rs', [ {} ]) 
     304         ->search_related('MediasPaths') 
     305                 ->search_related('Paths') 
     306        ->search_related('Rpmfiles', 
     307            { pkgid => $pkgid }, 
     308            { 
     309                select => [ qw(shortname name version arch label group_label) ], 
     310                order_by => [ qw(name version arch label) ], 
     311            } 
     312        )->all ] 
     313} 
     314 
    312315=head1 AUTHOR 
    313316 
  • server/trunk/web/root/templates/html/rpms/menu.tt

    r76 r112  
    33<a href="[% c.uri_for('/', rpmurl, 'files') %]">Files</a> 
    44<a href="[% c.uri_for('/', rpmurl, 'changelog') %]">ChangeLog</a> 
     5<a href="[% c.uri_for('/', rpmurl, 'location') %]">Location</a> 
  • server/trunk/web/t/controller_Rpms.t

    r57 r112  
    1313ok( request("/rpms/$pkgid/files")->is_success, 'Request a pkgid/files should succeed' ); 
    1414ok( request("/rpms/$pkgid/changelog")->is_success, 'Request a pkgid/changelog should succeed' ); 
     15ok( request("/rpms/$pkgid/location")->is_success, 'Request a pkgid/location should succeed' ); 
    1516done_testing(); 
Note: See TracChangeset for help on using the changeset viewer.