aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm10
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm23
2 files changed, 25 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 67fe12697..c2488424d 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -1032,9 +1032,6 @@ Save the user and the report.
Be smart about the user - only set the name and phone if user did not exist
before or they are currently logged in. Otherwise discard any changes.
-Save the problem as unconfirmed. FIXME - change this behaviour with respect to
-the user's logged in status.
-
=cut
sub save_user_and_report : Private {
@@ -1044,14 +1041,11 @@ sub save_user_and_report : Private {
# Save or update the user if appropriate
if ( !$report_user->in_storage ) {
- $report_user->insert(); # FIXME - set user state to 'unconfirmed'
+ $report_user->insert();
}
elsif ( $c->user && $report_user->id == $c->user->id ) {
$report_user->update();
-
- # we can also confirm the report straight away
- $report->state('confirmed');
- $report->confirmed( \'ms_current_timestamp()' ); # FIXME - move to model
+ $report->confirm;
}
else {
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 5873a9b7f..bafad4ec0 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -164,4 +164,27 @@ sub is_from_abuser {
|| undef;
}
+=head2 confirm
+
+ $bool = $problem->confirm( );
+ $problem->update;
+
+
+Set the state to 'confirmed' and put current time into 'confirmed' field. This
+is a no-op if the report is already confirmed.
+
+NOTE - does not update storage - call update or insert to do that.
+
+=cut
+
+sub confirm {
+ my $self = shift;
+
+ return if $self->state eq 'confirmed';
+
+ $self->state('confirmed');
+ $self->confirmed( \'ms_current_timestamp()' );
+ return 1;
+}
+
1;