aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r--perllib/FixMyStreet/App/Controller/Moderate.pm25
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm5
2 files changed, 27 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Moderate.pm b/perllib/FixMyStreet/App/Controller/Moderate.pm
index c47c34f37..d8fc38211 100644
--- a/perllib/FixMyStreet/App/Controller/Moderate.pm
+++ b/perllib/FixMyStreet/App/Controller/Moderate.pm
@@ -69,19 +69,40 @@ sub report : Chained('moderate') : PathPart('report') : CaptureArgs(1) {
sub moderate_report : Chained('report') : PathPart('') : Args(0) {
my ($self, $c) = @_;
+ my $problem = $c->stash->{problem};
+
# Make sure user can moderate this report
- $c->detach unless $c->user->can_moderate($c->stash->{problem});
+ $c->detach unless $c->user->can_moderate($problem);
$c->forward('report_moderate_hide');
my @types = grep $_,
- ($c->user->can_moderate_title($c->stash->{problem}, 1)
+ ($c->user->can_moderate_title($problem, 1)
? $c->forward('moderate_text', [ 'title' ])
: ()),
$c->forward('moderate_text', [ 'detail' ]),
$c->forward('moderate_boolean', [ 'anonymous', 'show_name' ]),
$c->forward('moderate_boolean', [ 'photo' ]);
+ # Deal with possible photo changes. If a moderate form uses a standard
+ # photo upload field (with upload_fileid, label and file upload handlers),
+ # this will allow photos to be changed, not just switched on/off. You will
+ # probably want a hidden field with problem_photo=1 to skip that check.
+ my $photo_edit_form = defined $c->get_param('photo1');
+ if ($photo_edit_form) {
+ $c->forward('/photo/process_photo');
+ if ( my $photo_error = delete $c->stash->{photo_error} ) {
+ $c->flash->{photo_error} = $photo_error;
+ } else {
+ my $fileid = $c->stash->{upload_fileid};
+ if ($fileid ne $problem->photo) {
+ $problem->get_photoset->delete_cached;
+ $problem->update({ photo => $fileid || undef });
+ push @types, 'photo';
+ }
+ }
+ }
+
$c->detach( 'report_moderate_audit', \@types )
}
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index 198edb5f7..d4ff0a2ca 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -194,7 +194,7 @@ sub load_updates : Private {
$c->stash->{updates} = \@combined;
if ($c->sessionid) {
- foreach (qw(alert_to_reporter anonymized)) {
+ foreach (qw(alert_to_reporter anonymized photo_error)) {
$c->stash->{$_} = $c->flash->{$_} if $c->flash->{$_};
}
}
@@ -207,6 +207,9 @@ sub format_problem_for_display : Private {
my $problem = $c->stash->{problem};
+ # upload_fileid is used by the update form on this page
+ $c->stash->{problem_upload_fileid} = $problem->get_photoset->data;
+
( $c->stash->{latitude}, $c->stash->{longitude} ) =
map { Utils::truncate_coordinate($_) }
( $problem->latitude, $problem->longitude );