Changeset 53 for server/trunk
- Timestamp:
- 11/30/10 02:02:14 (14 years ago)
- Location:
- server/trunk/web
- Files:
-
- 5 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
server/trunk/web/lib/Sophie/Controller/Distrib.pm
r50 r53 78 78 } 79 79 80 sub distrib_rs : Private { 81 my ( $self, $c, $distrib ) = @_; 82 return $c->model('Base')->resultset('Distribution') 83 ->search( 84 { 85 $distrib->{distribution} 86 ? (name => $distrib->{distribution}) 87 : () 88 } 89 )->search_related('Release', 90 { 91 $distrib->{release} 92 ? (version => $distrib->{release}) 93 : () 94 } 95 )->search_related('Arch', 96 { 97 $distrib->{arch} 98 ? (arch => $distrib->{arch}) 99 : () 100 } 101 )->search_related('Medias', 102 { 103 ($distrib->{media} ? (label => $distrib->{media}) : ()), 104 ($distrib->{media_group} 105 ? (group_label => $distrib->{media_group}) 106 : ()), 107 } 108 ); 109 } 110 111 sub exists : XMLRPC { 112 my ( $self, $c, $d ) = @_; 113 114 my $rs = $c->forward('distrib_rs', [ $d ]); 115 116 if ($rs->search({}, { rows => 1 })->next) { 117 $c->stash->{xmlrpc} = 1; 118 } else { 119 $c->stash->{xmlrpc} = 0; 120 } 121 } 80 122 81 123 =head2 index … … 96 138 my ( $self, $c, $distribution ) = @_; 97 139 $c->stash->{dist}{distribution} = $distribution; 140 if (!$c->forward('exists', [ $c->stash->{dist} ])) { 141 $c->go('/404/index'); 142 } 98 143 $c->forward('list', [ $c->stash->{dist} ] ); 99 144 } … … 127 172 } 128 173 129 sub rpms :XMLRPC {130 my ( $self, $c, $distribution, $release, $arch ) = @_; 131 132 if ( ref $distribution) {133 ($distribution, $release, $arch) = (134 $distribution->{distribution},135 $distribution->{release},136 $distribution->{arch},137 );138 } 139 174 sub anyrpms :XMLRPC { 175 my ( $self, $c, $distribution, $release, $arch ) = @_; 176 177 if (!ref $distribution) { 178 $distribution = { 179 distribution => $distribution, 180 release => $release, 181 arch => $arch, 182 } 183 } 184 140 185 @{$c->stash->{rpm}} = map { 141 186 { … … 144 189 } 145 190 } 146 $c->model('Base') 147 ->resultset('Distribution')->search({ name => $distribution }) 148 ->search_related('Release', { version => $release }) 149 ->search_related('Arch', { arch => $arch }) 150 ->search_related('Medias') 191 $c->forward('distrib_rs', [ $distribution ]) 192 ->search_related('MediasPaths') 193 ->search_related('Paths') 194 ->search_related('Rpmfiles') 195 ->all; 196 197 $c->stash->{xmlrpc} = $c->stash->{rpm}; 198 } 199 200 sub rpms :XMLRPC { 201 my ( $self, $c, $distribution, $release, $arch ) = @_; 202 203 if (!ref $distribution) { 204 $distribution = { 205 distribution => $distribution, 206 release => $release, 207 arch => $arch, 208 } 209 } 210 211 $c->stash->{rpm} = [ map { 212 { 213 pkgid => $_->pkgid, 214 filename => $_->filename, 215 } 216 } 217 $c->forward('distrib_rs', [ $distribution ]) 151 218 ->search_related('MediasPaths') 152 219 ->search_related('Paths') … … 155 222 IN => $c->model('Base')->resultset('Rpms') 156 223 ->search({ issrc => 'false' })->get_column('pkgid') ->as_query } 157 } )->all ;224 } )->all ]; 158 225 159 226 $c->stash->{xmlrpc} = $c->stash->{rpm}; … … 163 230 my ( $self, $c, $distribution, $release, $arch ) = @_; 164 231 165 if ( ref $distribution) {166 ($distribution, $release, $arch) = (167 $distribution->{distribution},168 $distribution->{release},169 $distribution->{arch},170 );232 if (!ref $distribution) { 233 $distribution = { 234 distribution => $distribution, 235 release => $release, 236 arch => $arch, 237 } 171 238 } 172 239 … … 177 244 } 178 245 } 179 $c->model('Base') 180 ->resultset('Distribution')->search({ name => $distribution }) 181 ->search_related('Release', { version => $release }) 182 ->search_related('Arch', { arch => $arch }) 183 ->search_related('Medias') 246 $c->forward('distrib_rs', [ $distribution ]) 184 247 ->search_related('MediasPaths') 185 248 ->search_related('Paths') … … 193 256 } 194 257 258 sub rpms_name :XMLRPC { 259 my ( $self, $c, $distribution, $release, $arch ) = @_; 260 261 if (!ref $distribution) { 262 $distribution = { 263 distribution => $distribution, 264 release => $release, 265 arch => $arch, 266 } 267 } 268 269 $c->stash->{xmlrpc} = [ 270 $c->model('Base')->resultset('Rpms')->search( 271 { pkgid => { 272 IN => 273 $c->forward('distrib_rs', [ $distribution ]) 274 ->search_related('MediasPaths') 275 ->search_related('Paths') 276 ->search_related('Rpmfiles')->get_column('pkgid')->as_query 277 } }, 278 { group_by => [ qw(name) ], order_by => [ qw(name) ] } 279 )->get_column('name')->all ]; 280 } 281 195 282 sub list_rpms :Chained('distrib_view') PathPart('rpms') { 196 283 my ( $self, $c ) = @_; … … 224 311 } 225 312 226 sub media_rpms : XMLRPC {227 my ( $self, $c, $distribution, $release, $arch, $media ) = @_;228 229 if (ref $distribution) {230 ($distribution, $release, $arch, $media) = (231 $distribution->{distribution},232 $distribution->{release},233 $distribution->{arch},234 $release,235 );236 }237 238 @{$c->stash->{rpm}} = map {239 {240 pkgid => $_->pkgid,241 filename => $_->filename,242 }243 }244 $c->model('Base')245 ->resultset('Distribution')->search({ name => $distribution })246 ->search_related('Release', { version => $release })247 ->search_related('Arch', { arch => $arch })248 ->search_related('Medias', { label => $media })249 ->search_related('MediasPaths')250 ->search_related('Paths')251 ->search_related('Rpmfiles')->all;252 253 $c->stash->{xmlrpc} = $c->stash->{rpm};254 }255 256 313 sub _media_list_rpms :Chained('distrib_view') PathPart('media') CaptureArgs(1) { 257 314 my ( $self, $c, $media ) = @_; 258 $c->stash->{ media} = $media;315 $c->stash->{dist}{media} = $media; 259 316 } 260 317 261 318 sub media_list_rpms :Chained('_media_list_rpms') PathPart('') { 262 319 my ( $self, $c ) = @_; 263 $c->forward(' media_rpms', [ $c->stash->{dist}, $c->stash->{media} ]);320 $c->forward('anyrpms', [ $c->stash->{dist} ]); 264 321 } 265 322 -
server/trunk/web/lib/Sophie/Controller/Search.pm
r51 r53 66 66 my ( $self, $c, $searchspec ) = @_; 67 67 68 return $c->model('Base')->resultset('Distribution') 69 ->search( 70 { 71 $searchspec->{distribution} 72 ? (name => $searchspec->{distribution}) 73 : () 74 } 75 )->search_related('Release', 76 { 77 $searchspec->{release} 78 ? (version => $searchspec->{release}) 79 : () 80 } 81 )->search_related('Arch', 82 { 83 $searchspec->{arch} 84 ? (arch => $searchspec->{arch}) 85 : () 86 } 87 )->search_related('Medias', 88 { 89 ($searchspec->{media} ? (label => $searchspec->{media}) : ()), 90 ($searchspec->{media_group} 91 ? (group_label => $searchspec->{media_group}) 92 : ()), 93 } 94 )->search_related('MediasPaths') 68 return $c->forward('/distrib/distrib_rs', [ $searchspec ]) 69 ->search_related('MediasPaths') 95 70 ->search_related('Paths') 96 71 ->search_related('Rpmfiles'); -
server/trunk/web/root/templates/html/distrib/distrib.html
r21 r53 1 <ol> 2 [% FOREACH media = xmlrpc %] 3 <li><a href="[% c.uri_for('/', c.req.path, 'media', media) %]">[% media %]</a></li> 4 [% END %] 5 </ol> 1 <!-- $Id$ --> 2 3 [% INCLUDE 'distrib/distrib.tt' %] -
server/trunk/web/t/controller_Distrib.t
r21 r53 9 9 my $release = 'cooker'; 10 10 my $arch = 'i586'; 11 my $media = 'main-release'; 11 12 12 13 BEGIN { use_ok 'Catalyst::Test', 'Sophie' } … … 30 31 ok( request("/distrib/$distribution/$release")->is_success, 'Request should succeed' ); 31 32 ok( request("/distrib/$distribution/$release/$arch")->is_success, 'Request should succeed' ); 33 ok( request("/distrib/$distribution/$release/$arch/media")->is_success, 'Request should succeed' ); 32 34 done_testing();
Note: See TracChangeset
for help on using the changeset viewer.