diff options
Diffstat (limited to 'lib/MGA/Mirrors/Controller')
-rw-r--r-- | lib/MGA/Mirrors/Controller/Mirrors.pm | 14 | ||||
-rw-r--r-- | lib/MGA/Mirrors/Controller/Validate.pm | 54 |
2 files changed, 66 insertions, 2 deletions
diff --git a/lib/MGA/Mirrors/Controller/Mirrors.pm b/lib/MGA/Mirrors/Controller/Mirrors.pm index 73fa5ae..aa22848 100644 --- a/lib/MGA/Mirrors/Controller/Mirrors.pm +++ b/lib/MGA/Mirrors/Controller/Mirrors.pm @@ -31,12 +31,12 @@ sub mirror :Path :Args(1) { my ( $self, $c, $host ) = @_; $c->stash->{hostname} = $host; - if ($c->req->param('hostinfo')) { + if ($c->req->param('hostinfo') && $c->req->param('mail')) { my $hinfo = $c->model('Mirrors')->find_mirrors({ hostname => $host, })->[0]; if (! $hinfo->{readonly}) { - $c->model('Mirrors')->add_or_update_host($host, + my $reqid = $c->model('Mirrors')->add_host_change_request($host, bandwidth => $c->req->param('bandwidth'), city => $c->req->param('city'), country => $c->req->param('country'), @@ -44,6 +44,16 @@ sub mirror :Path :Args(1) { latitude => $c->req->param('latitude'), longitude => $c->req->param('longitude'), ); + $c->forward( + q'MGA::Mirrors::View::Mail', 'render', + [ 'host_up_request.tt', { + To => $c->req->param('mail'), + Subject => 'Update Mageia mirror request', + mail => { + reqid => $reqid, + } + } ] + ); } } diff --git a/lib/MGA/Mirrors/Controller/Validate.pm b/lib/MGA/Mirrors/Controller/Validate.pm new file mode 100644 index 0000000..61d18f5 --- /dev/null +++ b/lib/MGA/Mirrors/Controller/Validate.pm @@ -0,0 +1,54 @@ +package MGA::Mirrors::Controller::Validate; +use Moose; +use namespace::autoclean; + +BEGIN {extends 'Catalyst::Controller'; } + +=head1 NAME + +MGA::Mirrors::Controller::Validate - Catalyst Controller + +=head1 DESCRIPTION + +Catalyst Controller. + +=head1 METHODS + +=cut + + +=head2 index + +=cut + +sub index :Path :Args(0) { + my ( $self, $c ) = @_; + + $c->response->body('Matched MGA::Mirrors::Controller::Validate in Validate.'); +} + + +sub validate :Path :Args(1) { + my ( $self, $c, $reqid ) = @_; + + if (my $hostname = $c->model('Mirrors')->apply_change_request($reqid)) { + $c->stash->{hostname} = $hostname; + } else { + $c->stash->{template} = 'validate/error.tt'; + } +} + +=head1 AUTHOR + +Olivier Thauvin + +=head1 LICENSE + +This library is free software. You can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut + +__PACKAGE__->meta->make_immutable; + +1; |