aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-06-23 14:38:07 +0100
committerStruan Donald <struan@exo.org.uk>2011-06-23 14:38:07 +0100
commit11c91b87abe2e89e8dc63a4d541fba7ed1d096b3 (patch)
tree5a315646cda9691ca63fd52f4cb3f9d3aafb1b4b
parent41c7d068f954e062b4da0675b5782211b8ad10c3 (diff)
parent09ce7aeb489e5a43054c3b2b7bfa47fd6aba7c43 (diff)
Merge branch 'master' of ssh://git.mysociety.org/data/git/public/fixmystreet into new_statuses
Conflicts: templates/web/default/report/display.html
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm25
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm44
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm57
-rw-r--r--perllib/FixMyStreet/DB/Result/User.pm18
-rw-r--r--t/app/controller/admin.t2
-rw-r--r--t/app/controller/report_updates.t4
-rw-r--r--templates/email/default/questionnaire.txt2
-rwxr-xr-xtemplates/web/default/faq/faq-en-gb.html19
-rw-r--r--templates/web/default/report/display.html52
-rw-r--r--templates/web/default/report/new/fill_in_details.html10
-rw-r--r--web/css/main-scambs.css46
11 files changed, 105 insertions, 174 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index f732b94f1..a15ee993f 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -60,9 +60,9 @@ sub load_problem_or_display_error : Private {
my ( $self, $c, $id ) = @_;
# try to load a report if the id is a number
- my $problem #
- = $id =~ m{\D} # is id non-numeric?
- ? undef # ...don't even search
+ my $problem
+ = ( !$id || $id =~ m{\D} ) # is id non-numeric?
+ ? undef # ...don't even search
: $c->cobrand->problems->find( { id => $id } );
# check that the problem is suitable to show.
@@ -110,23 +110,8 @@ sub format_problem_for_display : Private {
$c->stash->{report_name} = $c->req->param('name');
- if ( $c->req->param('submit_update') ) {
- # we may have munged these previously in /report/update
- # so only set if they're not already in the stash
- $c->stash->{form_name} ||= $c->req->param('name');
- $c->stash->{update_text} ||= $c->req->param('update');
- $c->stash->{email} ||= $c->req->param('rznvy');
- $c->stash->{fixed} ||= $c->req->param('fixed') ? ' checked' : '';
- $c->stash->{add_alert_checked} ||=
- ( $c->req->param('add_alert') ? ' checked' : '' );
- }
- else {
- if ( $c->user ) {
- $c->stash->{form_name} = $c->user->name;
- $c->stash->{email} = $c->user->email;
- $c->stash->{may_show_name} = ' checked' if $c->user->name;
- }
- $c->stash->{add_alert_checked} = ' checked';
+ unless ( $c->req->param('submit_update') ) {
+ $c->stash->{add_alert} = 1;
}
$c->forward('generate_map_tags');
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index dfa45df55..130eee858 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -93,10 +93,10 @@ sub report_new : Path : Args(0) {
# deal with the user and report and check both are happy
return
- unless $c->forward('process_user')
+ unless $c->forward('check_form_submitted')
+ && $c->forward('process_user')
&& $c->forward('process_report')
&& $c->forward('process_photo')
- && $c->forward('check_form_submitted')
&& $c->forward('check_for_errors')
&& $c->forward('save_user_and_report')
&& $c->forward('redirect_or_confirm_creation');
@@ -325,6 +325,9 @@ sub initialize_report : Private {
}
+ # Capture whether the map was used
+ $report->used_map( $c->req->param('skipped') ? 0 : 1 );
+
$c->stash->{report} = $report;
return 1;
@@ -547,8 +550,6 @@ Load user from the database or prepare a new one.
sub process_user : Private {
my ( $self, $c ) = @_;
- # FIXME - If user already logged in use them regardless
-
# Extract all the params to a hash to make them easier to work with
my %params = #
map { $_ => scalar $c->req->param($_) } #
@@ -559,15 +560,12 @@ sub process_user : Private {
$email =~ s{\s+}{}g;
my $report = $c->stash->{report};
- my $report_user #
- = ( $report ? $report->user : undef )
- || $c->model('DB::User')->find_or_new( { email => $email } );
+ $report->user( $c->model('DB::User')->find_or_new( { email => $email } ) )
+ unless $report->user;
# set the user's name and phone (if given)
- $report_user->name( Utils::trim_text( $params{name} ) );
- $report_user->phone( Utils::trim_text( $params{phone} ) ) if $params{phone};
-
- $c->stash->{report_user} = $report_user;
+ $report->user->name( Utils::trim_text( $params{name} ) );
+ $report->user->phone( Utils::trim_text( $params{phone} ) );
return 1;
}
@@ -590,7 +588,7 @@ sub process_report : Private {
'title', 'detail', 'pc', #
'name', 'may_show_name', #
'category', #
- 'partial', 'skipped', 'submit_problem' #
+ 'partial', #
);
# load the report
@@ -601,12 +599,6 @@ sub process_report : Private {
$report->latitude( $c->stash->{latitude} );
$report->longitude( $c->stash->{longitude} );
- # Capture whether the map was used
- $report->used_map( $params{skipped} ? 0 : 1 );
-
- # Short circuit unless the form has been submitted
- return 1 unless $params{submit_problem};
-
# set some simple bool values (note they get inverted)
$report->anonymous( $params{may_show_name} ? 0 : 1 );
@@ -794,7 +786,7 @@ sub check_for_errors : Private {
# let the model check for errors
my %field_errors = (
- %{ $c->stash->{report_user}->check_for_errors },
+ %{ $c->stash->{report}->user->check_for_errors },
%{ $c->stash->{report}->check_for_errors },
);
@@ -822,27 +814,23 @@ before or they are currently logged in. Otherwise discard any changes.
sub save_user_and_report : Private {
my ( $self, $c ) = @_;
- my $report_user = $c->stash->{report_user};
my $report = $c->stash->{report};
# Save or update the user if appropriate
- if ( !$report_user->in_storage ) {
- $report_user->insert();
+ if ( !$report->user->in_storage ) {
+ $report->user->insert();
}
- elsif ( $c->user && $report_user->id == $c->user->id ) {
- $report_user->update();
+ elsif ( $c->user && $report->user->id == $c->user->id ) {
+ $report->user->update();
$report->confirm;
}
else {
# user exists and we are not logged in as them. Throw away changes to
# the name and phone. TODO - propagate changes using tokens.
- $report_user->discard_changes();
+ $report->user->discard_changes();
}
- # add the user to the report
- $report->user($report_user);
-
# If there was a photo add that too
if ( my $fileid = $c->stash->{upload_fileid} ) {
my $file = file( $c->config->{UPLOAD_CACHE}, "$fileid.jpg" );
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index 02d111d9f..354690949 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -20,10 +20,6 @@ Creates an update to a report
sub report_update : Path : Args(0) {
my ( $self, $c ) = @_;
- # if there's no id then we should just stop now
- $c->detach( '/page_error_404_not_found', [ _('Unknown problem ID') ] )
- unless $c->req->param('id');
-
$c->forward( '/report/load_problem_or_display_error', [ $c->req->param('id') ] )
&& $c->forward('process_user')
&& $c->forward('process_update')
@@ -81,14 +77,6 @@ sub update_problem : Private {
return 1;
}
-sub display_confirmation : Private {
- my ( $self, $c ) = @_;
-
- $c->stash->{template} = 'tokens/confirm_update.html';
-
- return 1;
-}
-
=head2 process_user
Load user from the database or prepare a new one.
@@ -98,25 +86,28 @@ Load user from the database or prepare a new one.
sub process_user : Private {
my ( $self, $c ) = @_;
- # FIXME - If user already logged in use them regardless
+ my $update_user;
+ if ( $c->user ) {
+
+ $update_user = $c->user->obj;
+
+ } else {
- # Extract all the params to a hash to make them easier to work with
- my %params = #
- map { $_ => scalar $c->req->param($_) } #
- ( 'rznvy', 'name' );
+ # Extract all the params to a hash to make them easier to work with
+ my %params = #
+ map { $_ => scalar $c->req->param($_) } #
+ ( 'rznvy', 'name' );
- # cleanup the email address
- my $email = $params{rznvy} ? lc $params{rznvy} : '';
- $email =~ s{\s+}{}g;
+ # cleanup the email address
+ my $email = $params{rznvy} ? lc $params{rznvy} : '';
+ $email =~ s{\s+}{}g;
- my $update_user = $c->model('DB::User')->find_or_new( { email => $email } );
+ $update_user = $c->model('DB::User')->find_or_new( { email => $email } );
+ $update_user->name( Utils::trim_text( $params{name} ) );
- # set the user's name if they don't have one
- $update_user->name( Utils::trim_text( $params{name} ) )
- unless $update_user->name;
+ }
$c->stash->{update_user} = $update_user;
- $c->stash->{email} = $update_user->email;
return 1;
}
@@ -162,9 +153,7 @@ sub process_update : Private {
);
$c->stash->{update} = $update;
- $c->stash->{update_text} = $update->text;
$c->stash->{add_alert} = $c->req->param('add_alert');
- $c->stash->{may_show_name} = ' checked' if $c->req->param('may_show_name');
return 1;
}
@@ -191,7 +180,7 @@ sub check_for_errors : Private {
# let the model check for errors
my %field_errors = (
- %{ $c->stash->{update_user}->check_for_errors },
+ %{ $c->stash->{update}->user->check_for_errors },
%{ $c->stash->{update}->check_for_errors },
);
@@ -222,14 +211,14 @@ Save the update and the user as appropriate.
sub save_update : Private {
my ( $self, $c ) = @_;
- my $user = $c->stash->{update_user};
my $update = $c->stash->{update};
- if ( !$user->in_storage ) {
- $user->insert;
+ if ( !$update->user->in_storage ) {
+ $update->user->insert;
}
- elsif ( $c->user && $c->user->id == $user->id ) {
- $user->update;
+ elsif ( $c->user && $c->user->id == $update->user->id ) {
+ # Logged in and same user, so can confirm update straight away
+ $update->user->update;
$update->confirm;
}
@@ -264,8 +253,8 @@ sub redirect_or_confirm_creation : Private {
# If confirmed send the user straight there.
if ( $update->confirmed ) {
- $c->forward( 'signup_for_alerts' );
$c->forward( 'update_problem' );
+ $c->forward( 'signup_for_alerts' );
my $report_uri = $c->uri_for( '/report', $update->problem_id );
$c->res->redirect($report_uri);
$c->detach;
diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm
index cdac54280..dfcb18c5b 100644
--- a/perllib/FixMyStreet/DB/Result/User.pm
+++ b/perllib/FixMyStreet/DB/Result/User.pm
@@ -74,7 +74,7 @@ sub check_for_errors {
my %errors = ();
- if ( $self->name !~ m/\S/ ) {
+ if ( !$self->name || $self->name !~ m/\S/ ) {
$errors{name} = _('Please enter your name');
}
elsif (length( $self->name ) < 5
@@ -117,4 +117,20 @@ sub answered_ever_reported {
return $has_answered->count > 0;
}
+=head2 alert_for_problem
+
+Returns whether the user is already subscribed to an
+alert for the problem ID provided.
+
+=cut
+
+sub alert_for_problem {
+ my ( $self, $id ) = @_;
+
+ return $self->alerts->find( {
+ alert_type => 'new_updates',
+ parameter => $id,
+ } );
+}
+
1;
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t
index b92041830..ba5095cea 100644
--- a/t/app/controller/admin.t
+++ b/t/app/controller/admin.t
@@ -133,7 +133,7 @@ subtest 'check summary counts' => sub {
ok $mech->host('fixmystreet.com');
};
-my $host = FixMyStreet->config('OPTION_BASE_URL');
+my $host = FixMyStreet->config('BASE_URL');
$mech->get_ok('/admin/council_contacts/2650');
$mech->content_contains('Aberdeen City Council');
$mech->content_contains('AB15 8RN');
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index bec81fb83..5d14a893f 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -276,7 +276,7 @@ for my $test (
initial_values => {
name => '',
rznvy => '',
- may_show_name => undef,
+ may_show_name => 1,
add_alert => 1,
photo => '',
update => '',
@@ -295,7 +295,7 @@ for my $test (
initial_values => {
name => '',
rznvy => '',
- may_show_name => undef,
+ may_show_name => 1,
add_alert => 1,
photo => '',
update => '',
diff --git a/templates/email/default/questionnaire.txt b/templates/email/default/questionnaire.txt
index 4be8eeaa4..7ff184c41 100644
--- a/templates/email/default/questionnaire.txt
+++ b/templates/email/default/questionnaire.txt
@@ -1,4 +1,4 @@
-Subject: Questionnaire about your problem on FixMyStreet
+Subject: FixMyStreet questionnaire about '<?=$values['title']?>'
Hi <?=$values['name']?>,
diff --git a/templates/web/default/faq/faq-en-gb.html b/templates/web/default/faq/faq-en-gb.html
index 2da32fc19..0907d6275 100755
--- a/templates/web/default/faq/faq-en-gb.html
+++ b/templates/web/default/faq/faq-en-gb.html
@@ -169,18 +169,23 @@ non-technical. Please see our <a
href="http://www.mysociety.org/helpus/">Get Involved page</a>.</dd>
<dt>I&rsquo;d like a site like this for my own location/ where&rsquo;s the "source code" to this site?</dt>
<dd>
-<p>The software behind this site is open source, and available
+The software behind this site is open source, and available
to you mainly under the GNU Affero GPL software license. You can <a
href="http://github.com/mysociety/fixmystreet">download the
source code</a> and help us develop it.
You&rsquo;re welcome to use it in your own projects, although you must also
-make available the source code to any such projects.</p>
-<p>Some Canadians at VisibleGovernment.ca wrote their own code for <a
-href="http://www.fixmystreet.ca/">http://www.fixmystreet.ca/</a> which is
+make available the source code to any such projects.
+<a href="http://www.fiksgatami.no/">Fiksgatami</a> is an example of our code
+being used in a Norwegian version of this site.
+</dd>
+<dt>I&rsquo;d prefer code in a different language?</dt>
+<dd>
+VisibleGovernment.ca wrote their own code for
+<a href="http://www.fixmystreet.ca/">http://www.fixmystreet.ca/</a>, which is
written in GeoDjango and available under an MIT licence at <a
-href="http://github.com/visiblegovernment/django-fixmystreet/tree/master">github</a>
-&ndash; it might well be more suitable for adapting than our code, and
-definitely has better installation instructions at present.
+href="http://github.com/visiblegovernment/django-fixmystreet/tree/master">github</a>.
+Or <a href="http://www.fixmystreet.org.nz/">FixMyStreet.org.nz</a> is written in
+Drupal.
</p>
</dd>
<dt>People build things, not organisations. Who <em>actually</em> built it?</dt>
diff --git a/templates/web/default/report/display.html b/templates/web/default/report/display.html
index a05d721d3..38c3014fa 100644
--- a/templates/web/default/report/display.html
+++ b/templates/web/default/report/display.html
@@ -77,31 +77,12 @@
<input type="hidden" name="submit_update" value="1">
<input type="hidden" name="id" value="[% problem.id | html %]">
- <div>
- <label for="form_name">[% loc( 'Name:') %]</label>
- <input type="text" name="name" id="form_name" value="[% form_name | html %]" size="20"> [% loc( '(optional)' ) %]
- </div>
-
- <div class="checkbox">
- <input type="checkbox" name="may_show_name" id="form_may_show_name" value="1"[% may_show_name %]>
- <label for="form_may_show_name">[% loc('Can we show your name publicly?') %]</label>
- <small>[% loc('(we never show your email address or phone number)') %]</small>
- </div>
-
- [% IF field_errors.email %]
- <div class='form-error'>[% field_errors.email %]</div>
- [% END %]
- <div class="form-field">
- <label for="form_rznvy">[% loc('Email' ) %]</label>
- <input type="text" name="rznvy" id="form_rznvy" value="[% email | html %]" size="20">
- </div>
-
[% IF field_errors.update %]
<div class='form-error'>[% field_errors.update %]</div>
[% END %]
<div class="form-field">
<label for="form_update">[% loc( 'Update:' ) %]</label>
- <textarea name="update" id="form_update" rows="7" cols="30">[% update_text | html %]</textarea>
+ <textarea name="update" id="form_update" rows="7" cols="30">[% update.text | html %]</textarea>
</div>
[% IF c.user && c.user.from_authority %]
@@ -114,7 +95,6 @@
<option [% 'selected ' IF state.0 == problem.state %] value="[% state.0 %]">[% state.1 %]</option>
[% END %]
</select>
- </div>
[% ELSE %]
[% IF !problem.is_fixed %]
<div class="checkbox">
@@ -124,7 +104,6 @@
[% END %]
[% END %]
-
[% IF c.cobrand.allow_photo_upload %]
[% IF photo_error %]
<div class='form-error'>[% photo_error %]</div>
@@ -135,25 +114,44 @@
<input type="hidden" name="upload_fileid" value="[% upload_fileid %]">
[% END %]
<label for="form_photo">[% loc('Photo:') %]</label>
- <input type="file" name="photo" id="form_photo">
+ <input type="file" name="photo" id="form_photo" style="width:20em">
</div>
[% END %]
+ <div>
+ <label for="form_name">[% loc( 'Name:') %]</label>
+ <input type="text" name="name" id="form_name" value="[% update.name || c.user.name | html %]" size="20">
+ </div>
<div class="checkbox">
- <input type="checkbox" name="add_alert" id="form_add_alert" value="1"[% add_alert_checked %]>
- <label for="form_add_alert">[% loc( 'Alert me to future updates' ) %]</label>
+ <input type="checkbox" name="may_show_name" id="form_may_show_name" value="1"[% ' checked' UNLESS update.anonymous %]>
+ <label for="form_may_show_name">[% loc('Show my name publicly') %]</label>
+ <small>[% loc('(we never show your email)') %]</small>
</div>
+[% IF NOT c.user %]
+
+ [% IF field_errors.email %]
+ <div class='form-error'>[% field_errors.email %]</div>
+ [% END %]
+ <div class="form-field">
+ <label for="form_rznvy">[% loc('Email' ) %]</label>
+ <input type="text" name="rznvy" id="form_rznvy" value="[% update.user.email || c.user.email | html %]" size="20">
+ </div>
+
+[% END %]
<div class="checkbox">
- <input type="submit" id="update_post" value="[% loc('Post') %]">
+ <input type="checkbox" name="add_alert" id="form_add_alert" value="1"[% ' checked' IF add_alert %]>
+ <label for="form_add_alert">[% loc( 'Alert me to future updates' ) %]</label>
</div>
+ <div class="checkbox">
+ <input type="submit" id="update_post" value="[% loc('Post') %]">
+ </div>
[% cobrand_update_fields %]
-
</form>
</div>
diff --git a/templates/web/default/report/new/fill_in_details.html b/templates/web/default/report/new/fill_in_details.html
index 26f092c8e..48407bb45 100644
--- a/templates/web/default/report/new/fill_in_details.html
+++ b/templates/web/default/report/new/fill_in_details.html
@@ -137,11 +137,7 @@
[%# if there is nothing in the name field then set check box as default on form %]
<input type="checkbox" name="may_show_name" id="form_may_show_name" value="1"[% ' checked' IF !report.anonymous || !report.name %]>
- [% IF c.cobrand.moniker == 'emptyhomes' %]
- <label for="form_may_show_name">[% loc('Can we show your name on the site?') %]</label>
- [% ELSE %]
- <label for="form_may_show_name">[% loc('Can we show your name publicly?') %]</label>
- [% END %]
+ <label for="form_may_show_name">[% loc('Show my name publicly') %]</label>
<small>[% loc('(we never show your email address or phone number)') %]</small>
</div>
@@ -151,12 +147,12 @@
<div class="form-field">
<label for="form_email">[% loc('Email:') %]</label>
- <input type="text" value="[% report_user.email | html %]" name="email" id="form_email" size="25">
+ <input type="text" value="[% report.user.email | html %]" name="email" id="form_email" size="25">
</div>
<div>
<label for="form_phone">[% loc('Phone:') %]</label>
- <input type="text" value="[% report_user.phone | html %]" name="phone" id="form_phone" size="15">
+ <input type="text" value="[% report.user.phone | html %]" name="phone" id="form_phone" size="15">
<small>[% loc('(optional)') %]</small>
</div>
diff --git a/web/css/main-scambs.css b/web/css/main-scambs.css
deleted file mode 100644
index 52f01ffcf..000000000
--- a/web/css/main-scambs.css
+++ /dev/null
@@ -1,46 +0,0 @@
-ul#error {
- padding-top: 4px;
- padding-bottom: 4px;
-}
-
-blockquote {
- border-left: solid 4px #013B63;
-}
-
-.a {
- color: #000000;
- background-color: #427499;
-}
-
-#postcodeForm, #front_stats div {
- background-color: #427499;
- color: #ffffff;
-}
-
-#front_stats div {
- padding: 0.5em 0;
- width: 7em;
-}
-
-/* Smaller map */
-#map_box {
- width: 380px;
-}
-#map, #drag {
- width: 378px;
- height: 378px;
-}
-#watermark {
- display: none;
- background: url("/i/mojwatermark-378.png");
- height: 84px;
- width: 171px;
- position: absolute;
- bottom: 0;
- right: 0;
-}
-
-#fixed, #unknown {
- margin-right: 400px;
-}
-