3 SGN::Controller::ITAG - actions related to ITAG things
7 package SGN
::Controller
::ITAG
;
9 use namespace
::autoclean
;
11 use CXGN
::ITAG
::Release
;
13 BEGIN { extends
'Catalyst::Controller' }
19 Public path: /itag/list_releases
21 List ITAG bulk file releases available for download.
25 sub list_releases
:Path
('/itag/list_releases') :Args
(0) {
26 my ( $self, $c ) = @_;
28 my $itag = $c->enabled_feature('ITAG')
29 or $c->throw_404('ITAG site feature not available');
31 $c->stash->{itag_releases
} = [ CXGN
::ITAG
::Release
->find( dir
=> $itag->releases_base ) ];
33 $c->stash->{template
} = '/itag/list_releases.mas';
34 $c->forward('View::Mason');
37 =head2 list_release_files
39 Public path: /itag/release/<releasenum>/list_files
41 List the downloadable files in a specific ITAG release.
45 sub list_release_files
:Chained
('get_release') :PathPart
('list_files') :Args
(0) {
46 my ( $self, $c ) = @_;
48 $c->stash->{template
} = '/itag/list_release_files.mas';
52 =head2 download_release_file
54 Public path: /itag/release/<releasenum>/download/<file_key>
56 Download a specific file from an ITAG release. Requires C<name>,
57 C<email>, and C<organization> GET or POST vars to be provided in the
58 request, and sends an email to the configured C<bugs_email> address
59 reporting the download (including the name, email, and organization).
63 sub download_release_file
:Chained
('get_release') :PathPart
('download') :Args
(1) {
64 my ( $self, $c, $file_tag ) = @_;
66 # get and validate the name, email, and organization from the post data
67 my $name = $c->req->params->{name
};
68 # $name && length($name) > 5
69 # or $c->throw( public_message => 'Must provide both your first and last name, at least 6 letters in total length, to download ITAG bulk files.', is_client_error => 1 );
70 my $email = $c->req->params->{email
};
71 # $email && $email =~ /^[^@]+@[^@]+$/
72 # or $c->throw( public_message => 'Must provide a real email address to download ITAG bulk files.', is_client_error => 1 );
74 my $organization = $c->req->params->{organization
};
76 # stash them for the reported_download action
77 $c->stash->{download_info
} = {
80 organization
=> $organization,
83 $c->stash->{download_filename
} = $c->stash->{itag_release
}->get_file_info( $file_tag )->{file
};
85 $c->forward( '/download/reported_download' );
89 # chaining root for fetching a specific ITAG release. will 404 if the release is not found.
90 # URL format: /itag/release/2/<rest of the chain>
91 sub get_release
:Chained
('/') :PathPart
('itag/release') :CaptureArgs
(1) {
92 my ( $self, $c, $releasenum ) = @_;
94 my $itag = $c->enabled_feature('ITAG')
95 or $c->throw_404('ITAG site feature not available');
97 # get and stash the itag release object, throwing if not found
98 ($c->stash->{itag_release
}) = CXGN
::ITAG
::Release
->find(
99 releasenum
=> $releasenum,
100 dir
=> $itag->releases_base,
102 or $c->throw_404("Release not found");