aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2020-09-29 14:23:52 +0200
committerMarius Halden <marius.h@lden.org>2020-09-29 14:23:52 +0200
commita27ce1524d801d2742a2bdb6ec1da45126d64353 (patch)
tree64123c4e17dc1776aa0a7cd65ee01d49d3e7d978 /perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm
parent377bd96aab7cad3434185c30eb908c9da447fe40 (diff)
parent2773c60226b9370fe8ee00f7b205b571bb87c3b5 (diff)
Merge tag 'v3.0.1' into fiksgatami-dev
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm81
1 files changed, 0 insertions, 81 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm b/perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm
deleted file mode 100644
index 0026acb9c..000000000
--- a/perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm
+++ /dev/null
@@ -1,81 +0,0 @@
-package FixMyStreet::App::Controller::Admin::ExorDefects;
-use Moose;
-use namespace::autoclean;
-
-use DateTime;
-use Try::Tiny;
-use FixMyStreet::Integrations::ExorRDI;
-use FixMyStreet::DateRange;
-
-BEGIN { extends 'Catalyst::Controller'; }
-
-
-sub index : Path : Args(0) {
- my ( $self, $c ) = @_;
-
- foreach (qw(error_message start_date end_date user_id)) {
- if ( defined $c->flash->{$_} ) {
- $c->stash->{$_} = $c->flash->{$_};
- }
- }
-
- my @inspectors = $c->cobrand->users->search({
- 'user_body_permissions.permission_type' => 'report_inspect'
- }, {
- join => 'user_body_permissions',
- distinct => 1,
- }
- )->all;
- $c->stash->{inspectors} = \@inspectors;
-
- # Default start/end date is today
- my $now = DateTime->now( time_zone =>
- FixMyStreet->time_zone || FixMyStreet->local_time_zone );
- $c->stash->{start_date} ||= $now;
- $c->stash->{end_date} ||= $now;
-
-}
-
-sub download : Path('download') : Args(0) {
- my ( $self, $c ) = @_;
-
- if ( !$c->cobrand->can('exor_rdi_link_id') ) {
- # This only works on the Oxfordshire cobrand currently.
- $c->detach( '/page_error_404_not_found', [] );
- }
-
- my $range = FixMyStreet::DateRange->new(
- start_date => $c->get_param('start_date'),
- end_date => $c->get_param('end_date'),
- parser => DateTime::Format::Strptime->new( pattern => '%Y-%m-%d' ),
- );
-
- my $params = {
- start_date => $range->start,
- inspection_date => $range->start,
- end_date => $range->end,
- user => $c->get_param('user_id'),
- mark_as_processed => 0,
- };
- my $rdi = FixMyStreet::Integrations::ExorRDI->new($params);
-
- try {
- my $out = $rdi->construct;
- $c->res->content_type('text/csv; charset=utf-8');
- $c->res->header('content-disposition' => "attachment; filename=" . $rdi->filename);
- $c->res->body( $out );
- } catch {
- die $_ unless $_ =~ /FixMyStreet::Integrations::ExorRDI::Error/;
- if ($params->{user}) {
- $c->flash->{error_message} = _("No inspections by that inspector in the selected date range.");
- } else {
- $c->flash->{error_message} = _("No inspections in the selected date range.");
- }
- $c->flash->{start_date} = $params->{start_date};
- $c->flash->{end_date} = $params->{end_date};
- $c->flash->{user_id} = $params->{user};
- $c->res->redirect( $c->uri_for( '' ) );
- };
-}
-
-1;