aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-06-28 18:02:52 +0100
committerStruan Donald <struan@exo.org.uk>2011-06-28 18:02:52 +0100
commit3773cf3459d023ed3515afbd4ff7b3e1253dc4d0 (patch)
treeab4d4f6e1b99b93f9b916b64a99aa198e2ece20b
parente2414d30dd673ecea38e2a40d187b835bd076ac3 (diff)
parent70cbebec7bb2fd412c6a9fbfb694357401916372 (diff)
Merge branch 'master' of ssh://git.mysociety.org/data/git/public/fixmystreet into new_statuses
Conflicts: perllib/FixMyStreet/App/Controller/Report/Update.pm templates/web/default/report/display.html
-rw-r--r--perllib/FixMyStreet/App/Controller/Alert.pm75
-rw-r--r--perllib/FixMyStreet/App/Controller/My.pm41
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm74
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm67
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm3
-rw-r--r--perllib/FixMyStreet/DB/Result/Comment.pm3
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm12
-rw-r--r--perllib/FixMyStreet/DB/Result/User.pm8
-rw-r--r--perllib/FixMyStreet/Map/FMS.pm2
-rw-r--r--perllib/Utils.pm23
-rw-r--r--t/app/controller/alert_new.t73
-rw-r--r--t/app/controller/auth.t5
-rw-r--r--t/app/controller/report_new.t167
-rw-r--r--t/app/controller/report_updates.t132
-rw-r--r--templates/web/default/alert/list.html4
-rw-r--r--templates/web/default/alert/updates.html2
-rw-r--r--templates/web/default/auth/general.html2
-rw-r--r--templates/web/default/footer.html6
-rw-r--r--templates/web/default/header.html9
-rw-r--r--templates/web/default/my/my.html85
-rw-r--r--templates/web/default/report/display.html117
-rw-r--r--templates/web/default/report/new/fill_in_details.html116
-rw-r--r--web/css/_main.scss35
-rw-r--r--web/css/core.css6
-rw-r--r--web/css/core.scss6
-rw-r--r--web/css/main.css35
-rw-r--r--web/js/fixmystreet.js2
-rw-r--r--web/js/map-bing-ol.js6
28 files changed, 837 insertions, 279 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Alert.pm b/perllib/FixMyStreet/App/Controller/Alert.pm
index d1759a330..ff92a7d2d 100644
--- a/perllib/FixMyStreet/App/Controller/Alert.pm
+++ b/perllib/FixMyStreet/App/Controller/Alert.pm
@@ -55,17 +55,14 @@ Target for subscribe form
sub subscribe : Path('subscribe') : Args(0) {
my ( $self, $c ) = @_;
- if ( $c->req->param('rss') ) {
- $c->detach('rss');
- }
+ $c->detach('rss') if $c->req->param('rss');
+
# if it exists then it's been submitted so we should
# go to subscribe email and let it work out the next step
- elsif ( exists $c->req->params->{'rznvy'} ) {
- $c->detach('subscribe_email');
- }
- elsif ( $c->req->params->{'id'} ) {
- $c->go('updates');
- }
+ $c->detach('subscribe_email')
+ if exists $c->req->params->{'rznvy'} || $c->req->params->{'alert'};
+
+ $c->go('updates') if $c->req->params->{'id'};
# shouldn't get to here but if we have then do something sensible
$c->go('index');
@@ -116,25 +113,18 @@ Sign up to email alerts
sub subscribe_email : Private {
my ( $self, $c ) = @_;
- my $type = $c->req->param('type');
- $c->stash->{email_type} = 'alert';
+ $c->stash->{errors} = [];
+ $c->forward('process_user');
- my @errors;
- push @errors, _('Please enter a valid email address')
- unless is_valid_email( $c->req->param('rznvy') );
- push @errors, _('Please select the type of alert you want')
+ my $type = $c->req->param('type');
+ push @{ $c->stash->{errors} }, _('Please select the type of alert you want')
if $type && $type eq 'local' && !$c->req->param('feed');
- if (@errors) {
- $c->stash->{errors} = \@errors;
+ if (@{ $c->stash->{errors} }) {
$c->go('updates') if $type && $type eq 'updates';
$c->go('list') if $type && $type eq 'local';
$c->go('index');
}
- my $email = $c->req->param('rznvy');
- $c->stash->{email} = $email;
- $c->forward('process_user');
-
if ( $type eq 'updates' ) {
$c->forward('set_update_alert_options');
}
@@ -200,14 +190,12 @@ sub create_alert : Private {
$options->{cobrand_data} = $c->cobrand->extra_update_data();
$options->{lang} = $c->stash->{lang_code};
- if ( $c->user && $c->stash->{alert_user}->in_storage && $c->user->id == $c->stash->{alert_user}->id ) {
- $options->{confirmed} = 1;
- }
-
$alert = $c->model('DB::Alert')->new($options);
$alert->insert();
}
+ $alert->confirm() if $c->user && $c->user->id == $alert->user->id;
+
$c->stash->{alert} = $alert;
}
@@ -303,6 +291,7 @@ sub send_confirmation_email : Private {
$c->send_email( 'alert-confirm.txt', { to => $c->stash->{alert}->user->email } );
+ $c->stash->{email_type} = 'alert';
$c->stash->{template} = 'email_sent.html';
}
@@ -331,12 +320,46 @@ sub prettify_pc : Private {
return 1;
}
+=head2 process_user
+
+Fetch/check email address
+
+=cut
+
sub process_user : Private {
my ( $self, $c ) = @_;
- my $email = $c->stash->{email};
+ if ( $c->user_exists ) {
+ $c->stash->{alert_user} = $c->user->obj;
+ return;
+ }
+
+ # Extract all the params to a hash to make them easier to work with
+ my %params = map { $_ => scalar $c->req->param($_) }
+ ( 'rznvy' ); # , 'password_register' );
+
+ # cleanup the email address
+ my $email = $params{rznvy} ? lc $params{rznvy} : '';
+ $email =~ s{\s+}{}g;
+
+ push @{ $c->stash->{errors} }, _('Please enter a valid email address')
+ unless is_valid_email( $email );
+
my $alert_user = $c->model('DB::User')->find_or_new( { email => $email } );
$c->stash->{alert_user} = $alert_user;
+
+# # The user is trying to sign in. We only care about email from the params.
+# if ( $c->req->param('submit_sign_in') ) {
+# unless ( $c->forward( '/auth/sign_in', [ $email ] ) ) {
+# $c->stash->{field_errors}->{password} = _('There was a problem with your email/password combination. Please try again.');
+# return 1;
+# }
+# my $user = $c->user->obj;
+# $c->stash->{alert_user} = $user;
+# return 1;
+# }
+#
+# $alert_user->password( Utils::trim_text( $params{password_register} ) );
}
=head2 setup_coordinate_rss_feeds
diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm
index 79d5c5681..b1359ae03 100644
--- a/perllib/FixMyStreet/App/Controller/My.pm
+++ b/perllib/FixMyStreet/App/Controller/My.pm
@@ -22,7 +22,48 @@ Catalyst Controller.
sub my : Path : Args(0) {
my ( $self, $c ) = @_;
+
$c->detach( '/auth/redirect' ) unless $c->user;
+
+ # Even though front end doesn't yet have it, have it on this page, it's better!
+ FixMyStreet::Map::set_map_class( 'FMS' );
+
+ my $p_page = $c->req->params->{p} || 1;
+ my $u_page = $c->req->params->{u} || 1;
+
+ my $pins = [];
+ my $problems = {};
+ my $rs = $c->user->problems->search( undef,
+ { rows => 50 } )->page( $p_page );
+
+ while ( my $problem = $rs->next ) {
+ push @$pins, {
+ latitude => $problem->latitude,
+ longitude => $problem->longitude,
+ colour => $problem->state eq 'fixed' ? 'green' : 'red',
+ id => $problem->id,
+ title => $problem->title,
+ };
+ push @{ $problems->{$problem->state} }, $problem;
+ }
+ $c->stash->{problems_pager} = $rs->pager;
+ $c->stash->{problems} = $problems;
+
+ $rs = $c->user->comments->search(
+ { state => 'confirmed' },
+ { rows => 50 } )->page( $u_page );
+ my @updates = $rs->all;
+ $c->stash->{updates} = \@updates;
+ $c->stash->{updates_pager} = $rs->pager;
+
+ FixMyStreet::Map::display_map(
+ $c,
+ latitude => $pins->[0]{latitude},
+ longitude => $pins->[0]{longitude},
+ pins => $pins,
+ any_zoom => 1,
+ )
+ if @$pins;
}
__PACKAGE__->meta->make_immutable;
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index a6be6c90c..4488ce8cd 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -28,7 +28,10 @@ Create a new report, or complete a partial one .
=head2 flow control
-submit_problem: true if a problem has been submitted
+submit_problem: true if a problem has been submitted, at all.
+submit_sign_in: true if the sign in button has been clicked by logged out user.
+submit_register: true if the register/confirm by email button has been clicked
+by logged out user.
=head2 location (required)
@@ -90,14 +93,13 @@ sub report_new : Path : Args(0) {
$c->forward('generate_map');
# deal with the user and report and check both are happy
- return
- unless $c->forward('check_form_submitted')
- && $c->forward('process_user')
- && $c->forward('process_report')
- && $c->forward('process_photo')
- && $c->forward('check_for_errors')
- && $c->forward('save_user_and_report')
- && $c->forward('redirect_or_confirm_creation');
+ return unless $c->forward('check_form_submitted');
+ $c->forward('process_user');
+ $c->forward('process_report');
+ $c->forward('process_photo');
+ return unless $c->forward('check_for_errors');
+ $c->forward('save_user_and_report');
+ $c->forward('redirect_or_confirm_creation');
}
=head2 report_import
@@ -548,22 +550,48 @@ Load user from the database or prepare a new one.
sub process_user : Private {
my ( $self, $c ) = @_;
+ my $report = $c->stash->{report};
+
+ # The user is already signed in
+ if ( $c->user_exists ) {
+ my $user = $c->user->obj;
+ my %params = map { $_ => scalar $c->req->param($_) } ( 'name', 'phone' );
+ $user->name( Utils::trim_text( $params{name} ) ) if $params{name};
+ $user->phone( Utils::trim_text( $params{phone} ) );
+ $report->user( $user );
+ $report->name( $user->name );
+ return 1;
+ }
+
# Extract all the params to a hash to make them easier to work with
- my %params = #
- map { $_ => scalar $c->req->param($_) } #
- ( 'email', 'name', 'phone', );
+ my %params = map { $_ => scalar $c->req->param($_) }
+ ( 'email', 'name', 'phone', 'password_register' );
# cleanup the email address
my $email = $params{email} ? lc $params{email} : '';
$email =~ s{\s+}{}g;
- my $report = $c->stash->{report};
$report->user( $c->model('DB::User')->find_or_new( { email => $email } ) )
unless $report->user;
- # set the user's name and phone (if given)
+ # The user is trying to sign in. We only care about email from the params.
+ if ( $c->req->param('submit_sign_in') ) {
+ unless ( $c->forward( '/auth/sign_in' ) ) {
+ $c->stash->{field_errors}->{password} = _('There was a problem with your email/password combination. Please try again.');
+ return 1;
+ }
+ my $user = $c->user->obj;
+ $report->user( $user );
+ $report->name( $user->name );
+ $c->stash->{field_errors}->{name} = _('You have successfully signed in; please check and confirm your details are accurate:');
+ return 1;
+ }
+
+ # set the user's name, phone, and password
$report->user->name( Utils::trim_text( $params{name} ) ) if $params{name};
$report->user->phone( Utils::trim_text( $params{phone} ) );
+ $report->user->password( Utils::trim_text( $params{password_register} ) );
+ $report->name( Utils::trim_text( $params{name} ) );
return 1;
}
@@ -584,7 +612,7 @@ sub process_report : Private {
map { $_ => scalar $c->req->param($_) } #
(
'title', 'detail', 'pc', #
- 'name', 'may_show_name', #
+ 'may_show_name', #
'category', #
'partial', #
);
@@ -606,7 +634,6 @@ sub process_report : Private {
Utils::cleanup_text( $params{detail}, { allow_multiline => 1 } ) );
# set these straight from the params
- $report->name( Utils::trim_text( $params{name} ) );
$report->category( _ $params{category} );
my $areas = $c->stash->{all_areas};
@@ -624,10 +651,7 @@ sub process_report : Private {
} elsif ( $first_council->{type} eq 'LBO') {
unless ( Utils::london_categories()->{ $report->category } ) {
- # TODO Perfect world, this wouldn't short-circuit, other errors would
- # be included as well.
- $c->stash->{field_errors} = { category => _('Please choose a category') };
- return;
+ $c->stash->{field_errors}->{category} = _('Please choose a category');
}
$report->council( $first_council->{id} );
@@ -646,8 +670,9 @@ sub process_report : Private {
)->all;
unless ( @contacts ) {
- $c->stash->{field_errors} = { category => _('Please choose a category') };
- return;
+ $c->stash->{field_errors}->{category} = _('Please choose a category');
+ $report->council( -1 );
+ return 1;
}
# construct the council string:
@@ -662,8 +687,7 @@ sub process_report : Private {
} elsif ( @{ $c->stash->{area_ids_to_list} } ) {
# There was an area with categories, but we've not been given one. Bail.
- $c->stash->{field_errors} = { category => _('Please choose a category') };
- return;
+ $c->stash->{field_errors}->{category} = _('Please choose a category');
} else {
@@ -783,7 +807,9 @@ sub check_for_errors : Private {
my ( $self, $c ) = @_;
# let the model check for errors
+ $c->stash->{field_errors} ||= {};
my %field_errors = (
+ %{ $c->stash->{field_errors} },
%{ $c->stash->{report}->user->check_for_errors },
%{ $c->stash->{report}->check_for_errors },
);
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index 76bd89174..2916e1ee1 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -20,15 +20,15 @@ Creates an update to a report
sub report_update : Path : Args(0) {
my ( $self, $c ) = @_;
- $c->forward( '/report/load_problem_or_display_error', [ $c->req->param('id') ] )
- && $c->forward('process_update')
- && $c->forward('process_user')
- && $c->forward('/report/new/process_photo')
- && $c->forward('check_for_errors')
+ $c->forward( '/report/load_problem_or_display_error', [ $c->req->param('id') ] );
+ $c->forward('process_update');
+ $c->forward('process_user');
+ $c->forward('/report/new/process_photo');
+ $c->forward('check_for_errors')
or $c->go( '/report/display', [ $c->req->param('id') ] );
- return $c->forward('save_update')
- && $c->forward('redirect_or_confirm_creation');
+ $c->forward('save_update');
+ $c->forward('redirect_or_confirm_creation');
}
sub confirm : Private {
@@ -72,6 +72,10 @@ sub update_problem : Private {
$problem->state( $update->problem_state );
}
+ if ( $update->mark_open && $update->user->id == $problem->user->id ) {
+ $problem->state('confirmed');
+ }
+
$problem->lastupdate( \'ms_current_timestamp()' );
$problem->update;
@@ -96,12 +100,17 @@ sub process_user : Private {
my $update = $c->stash->{update};
- $update->user( $c->user->obj ) if $c->user;
+ if ( $c->user_exists ) {
+ my $user = $c->user->obj;
+ my $name = scalar $c->req->param('name');
+ $user->name( Utils::trim_text( $name ) ) if $name;
+ $update->user( $user );
+ return 1;
+ }
# Extract all the params to a hash to make them easier to work with
- my %params = #
- map { $_ => scalar $c->req->param($_) } #
- ( 'rznvy', 'name' );
+ my %params = map { $_ => scalar $c->req->param($_) }
+ ( 'rznvy', 'name', 'password_register' );
# cleanup the email address
my $email = $params{rznvy} ? lc $params{rznvy} : '';
@@ -110,8 +119,22 @@ sub process_user : Private {
$update->user( $c->model('DB::User')->find_or_new( { email => $email } ) )
unless $update->user;
+ # The user is trying to sign in. We only care about email from the params.
+ if ( $c->req->param('submit_sign_in') ) {
+ unless ( $c->forward( '/auth/sign_in', [ $email ] ) ) {
+ $c->stash->{field_errors}->{password} = _('There was a problem with your email/password combination. Please try again.');
+ return 1;
+ }
+ my $user = $c->user->obj;
+ $update->user( $user );
+ $update->name( $user->name );
+ $c->stash->{field_errors}->{name} = _('You have successfully signed in; please check and confirm your details are accurate:');
+ return 1;
+ }
+
$update->user->name( Utils::trim_text( $params{name} ) )
if $params{name};
+ $update->user->password( Utils::trim_text( $params{password_register} ) );
return 1;
}
@@ -130,16 +153,15 @@ sub process_update : Private {
my ( $self, $c ) = @_;
my %params =
- map { $_ => scalar $c->req->param($_) } ( 'update', 'name', 'fixed', 'state' );
+ map { $_ => scalar $c->req->param($_) } ( 'update', 'name', 'fixed', 'state', 'reopen' );
$params{update} =
Utils::cleanup_text( $params{update}, { allow_multiline => 1 } );
my $name = Utils::trim_text( $params{name} );
+ my $anonymous = $c->req->param('may_show_name') ? 0 : 1;
- my $anonymous = 1;
-
- $anonymous = 0 if ( $name && $c->req->param('may_show_name') );
+ $params{reopen} = 0 unless $c->user && $c->user->id == $c->stash->{problem}->user->id;
my $update = $c->model('DB::Comment')->new(
{
@@ -148,6 +170,7 @@ sub process_update : Private {
problem => $c->stash->{problem},
state => 'unconfirmed',
mark_fixed => $params{fixed} ? 1 : 0,
+ mark_open => $params{reopen} ? 1 : 0,
cobrand => $c->cobrand->moniker,
cobrand_data => $c->cobrand->extra_update_data,
lang => $c->stash->{lang_code},
@@ -196,25 +219,27 @@ sub check_for_errors : Private {
}
# let the model check for errors
+ $c->stash->{field_errors} ||= {};
my %field_errors = (
+ %{ $c->stash->{field_errors} },
%{ $c->stash->{update}->user->check_for_errors },
%{ $c->stash->{update}->check_for_errors },
);
- # we don't care if there are errors with this...
- delete $field_errors{name};
+ if ( my $photo_error = delete $c->stash->{photo_error} ) {
+ $field_errors{photo} = $photo_error;
+ }
# all good if no errors
return 1
unless ( scalar keys %field_errors
- || ( $c->stash->{errors} && scalar @{ $c->stash->{errors} } )
- || $c->stash->{photo_error} );
+ || ( $c->stash->{errors} && scalar @{ $c->stash->{errors} } ) );
$c->stash->{field_errors} = \%field_errors;
$c->stash->{errors} ||= [];
- push @{ $c->stash->{errors} },
- _('There were problems with your update. Please see below.');
+ #push @{ $c->stash->{errors} },
+ # _('There were problems with your update. Please see below.');
return;
}
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 878e98c10..d8cd426ba 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -405,7 +405,8 @@ sub uri {
$uri = URI->new( $uri );
$uri->query_param( zoom => 3 )
if $uri->query_param('lat') && !$uri->query_param('zoom');
- $uri->query_param( map => $map_class ); # FIXME Only on /around, /report?
+
+ # $uri->query_param( map => $map_class ); # FIXME Only on /around, /report?
return $uri;
}
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm
index 00f88e136..958194eb8 100644
--- a/perllib/FixMyStreet/DB/Result/Comment.pm
+++ b/perllib/FixMyStreet/DB/Result/Comment.pm
@@ -107,6 +107,9 @@ sub check_for_errors {
my %errors = ();
+ $errors{name} = _('Please enter your name')
+ if !$self->name || $self->name !~ m/\S/;
+
$errors{update} = _('Please enter a message')
unless $self->text =~ m/\S/;
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 1c8487ae7..d5d4b8102 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -274,7 +274,7 @@ sub check_for_errors {
unless $self->council
&& $self->council =~ m/^(?:-1|[\d,]+(?:\|[\d,]+)?)$/;
- if ( $self->name !~ m/\S/ ) {
+ if ( !$self->name || $self->name !~ m/\S/ ) {
$errors{name} = _('Please enter your name');
}
elsif (length( $self->name ) < 5
@@ -499,8 +499,7 @@ sub meta_line {
return $meta;
}
-# TODO Some/much of this could be moved to the template
-sub duration_string {
+sub body {
my ( $problem, $c ) = @_;
my $body;
if ($problem->external_body) {
@@ -522,6 +521,13 @@ sub duration_string {
} @councils
);
}
+ return $body;
+}
+
+# TODO Some/much of this could be moved to the template
+sub duration_string {
+ my ( $problem, $c ) = @_;
+ my $body = $problem->body( $c );
return sprintf(_('Sent to %s %s later'), $body,
Utils::prettify_duration($problem->whensent_local->epoch - $problem->confirmed_local->epoch, 'minute')
);
diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm
index 577d91c31..ada19a406 100644
--- a/perllib/FixMyStreet/DB/Result/User.pm
+++ b/perllib/FixMyStreet/DB/Result/User.pm
@@ -86,14 +86,6 @@ sub check_for_errors {
if ( !$self->name || $self->name !~ m/\S/ ) {
$errors{name} = _('Please enter your name');
}
- elsif (length( $self->name ) < 5
- || $self->name !~ m/\s/
- || $self->name =~ m/\ba\s*n+on+((y|o)mo?u?s)?(ly)?\b/i )
- {
- $errors{name} = _(
-'Please enter your full name, councils need this information - if you do not wish your name to be shown on the site, untick the box'
- );
- }
if ( $self->email !~ /\S/ ) {
$errors{email} = _('Please enter your email');
diff --git a/perllib/FixMyStreet/Map/FMS.pm b/perllib/FixMyStreet/Map/FMS.pm
index a5a2dd9f0..c54ee8f3b 100644
--- a/perllib/FixMyStreet/Map/FMS.pm
+++ b/perllib/FixMyStreet/Map/FMS.pm
@@ -21,7 +21,7 @@ sub map_template {
}
sub copyright {
- return _('Map contains Ordnance Survey data &copy; Crown copyright and database right 2010. Microsoft');
+ return _('Map contains Ordnance Survey data &copy; Crown copyright and database right 2010.<br>&copy; 2011 <a href="http://www.bing.com/maps/">Microsoft</a>. &copy; AND, Navteq, Ordnance Survey.');
}
sub get_quadkey {
diff --git a/perllib/Utils.pm b/perllib/Utils.pm
index 44234607f..39c251876 100644
--- a/perllib/Utils.pm
+++ b/perllib/Utils.pm
@@ -210,20 +210,25 @@ sub cleanup_text {
}
sub prettify_epoch {
- my ($s, $short) = @_;
+ my ( $s, $type ) = @_;
+ $type = 'short' if $type eq '1';
+
my @s = localtime($s);
- my $tt = strftime('%H:%M', @s);
+ my $tt = '';
+ $tt = strftime('%H:%M', @s) unless $type eq 'date';
my @t = localtime();
if (strftime('%Y%m%d', @s) eq strftime('%Y%m%d', @t)) {
- $tt = "$tt " . _('today');
- } elsif (strftime('%Y %U', @s) eq strftime('%Y %U', @t)) {
- $tt = "$tt, " . decode_utf8(strftime('%A', @s));
- } elsif ($short) {
- $tt = "$tt, " . decode_utf8(strftime('%e %b %Y', @s));
+ return "$tt " . _('today');
+ }
+ $tt .= ', ' unless $type eq 'date';
+ if (strftime('%Y %U', @s) eq strftime('%Y %U', @t)) {
+ $tt .= decode_utf8(strftime('%A', @s));
+ } elsif ($type eq 'short') {
+ $tt .= decode_utf8(strftime('%e %b %Y', @s));
} elsif (strftime('%Y', @s) eq strftime('%Y', @t)) {
- $tt = "$tt, " . decode_utf8(strftime('%A %e %B %Y', @s));
+ $tt .= decode_utf8(strftime('%A %e %B %Y', @s));
} else {
- $tt = "$tt, " . decode_utf8(strftime('%a %e %B %Y', @s));
+ $tt .= decode_utf8(strftime('%a %e %B %Y', @s));
}
return $tt;
}
diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t
index d0976b4bb..cb3b4b656 100644
--- a/t/app/controller/alert_new.t
+++ b/t/app/controller/alert_new.t
@@ -193,22 +193,11 @@ foreach my $test (
foreach my $test (
{
desc => 'logged in user signing up',
- user => 'test-sign-in@example.com',
email => 'test-sign-in@example.com',
type => 'council',
param1 => 2651,
param2 => 2651,
confirmed => 1,
- },
- {
- desc => 'logged in user signing up with different email',
- user => 'loggedin@example.com',
- email => 'test-sign-in@example.com',
- type => 'council',
- param1 => 2651,
- param2 => 2651,
- confirmed => 0,
- delete => 1,
}
)
{
@@ -217,42 +206,18 @@ foreach my $test (
my $user =
FixMyStreet::App->model('DB::User')
- ->find_or_create( { email => $test->{user} } );
-
- my $alert_user =
- FixMyStreet::App->model('DB::User')
- ->find( { email => $test->{email} } );
-
- $mech->log_in_ok( $test->{user} );
+ ->find_or_create( { email => $test->{email} } );
+ $mech->log_in_ok( $test->{email} );
$mech->clear_emails_ok;
- my $alert;
- if ($alert_user) {
- $alert = FixMyStreet::App->model('DB::Alert')->find(
- {
- user => $alert_user,
- alert_type => $type
- }
- );
-
- # clear existing data so we can be sure we're creating it
- $alert->delete() if $alert;
- }
-
$mech->get_ok('/alert/list?pc=EH991SP');
-
- my $form_values = $mech->visible_form_values();
- ok $form_values->{rznvy} eq $test->{user},
- 'auto filled in correct email';
-
- $mech->set_visible( [ radio => 'council:2651:City_of_Edinburgh' ],
- [ text => $test->{email} ] );
+ $mech->set_visible( [ radio => 'council:2651:City_of_Edinburgh' ] );
$mech->click('alert');
- $alert = FixMyStreet::App->model('DB::Alert')->find(
+ my $alert = FixMyStreet::App->model('DB::Alert')->find(
{
- user => $alert_user,
+ user => $user,
alert_type => $type,
parameter => $test->{param1},
parameter2 => $test->{param2},
@@ -261,13 +226,8 @@ foreach my $test (
);
ok $alert, 'New alert created with logged in user';
-
- $mech->email_count_is( $test->{confirmed} ? 0 : 1 );
-
- if ( $test->{delete} ) {
- $mech->delete_user($user);
- $mech->delete_user($alert_user);
- }
+ $mech->email_count_is( 0 );
+ $mech->delete_user($user);
};
}
@@ -391,17 +351,24 @@ subtest "Test normal alert signups and that alerts are sent" => sub {
$user2->alerts->delete;
for my $alert (
- { feed => 'local:55.951963:-3.189944', email_confirm => 1 },
- { feed => 'council:2651:City_of_Edinburgh', },
+ {
+ fields => {
+ feed => 'local:55.951963:-3.189944',
+ rznvy => $user2->email,
+ },
+ email_confirm => 1
+ },
+ {
+ fields => {
+ feed => 'council:2651:City_of_Edinburgh',
+ }
+ },
) {
$mech->get_ok( '/alert' );
$mech->submit_form_ok( { with_fields => { pc => 'EH11BB' } } );
$mech->submit_form_ok( {
button => 'alert',
- with_fields => {
- rznvy => $user2->email,
- feed => $alert->{feed},
- }
+ with_fields => $alert->{fields},
} );
if ( $alert->{email_confirm} ) {
my $email = $mech->get_email;
diff --git a/t/app/controller/auth.t b/t/app/controller/auth.t
index 8fbc413ec..1a16457f9 100644
--- a/t/app/controller/auth.t
+++ b/t/app/controller/auth.t
@@ -128,8 +128,7 @@ $mech->not_logged_in_ok;
$mech->get_ok($link);
is $mech->uri->path, '/faq', "redirected to the Help page";
- $mech->get_ok('/my');
- $mech->follow_link_ok( { url => '/auth/change_password' } );
+ $mech->get_ok('/auth/change_password');
ok my $form = $mech->form_name('change_password'),
"found change password form";
@@ -224,7 +223,7 @@ $mech->submit_form_ok(
"sign in with '$test_email' & '$test_password"
);
is $mech->uri->path, '/auth', "redirected to correct page";
-$mech->content_contains( 'Email or password wrong', 'found error message' );
+$mech->content_contains( 'problem with your email/password combination', 'found error message' );
# more test:
# TODO: test that email are always lowercased
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index 3e486d22c..537786ebc 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -65,13 +65,16 @@ foreach my $test (
email => '',
phone => '',
category => 'Street lighting',
+ password_sign_in => '',
+ password_register => '',
+ remember_me => undef,
},
changes => {},
errors => [
'Please enter a subject',
'Please enter some details',
- 'Please enter your name',
'Please enter your email',
+ 'Please enter your name',
],
},
{
@@ -86,13 +89,16 @@ foreach my $test (
email => '',
phone => '',
category => 'Street lighting',
+ password_sign_in => '',
+ password_register => '',
+ remember_me => undef,
},
changes => { may_show_name => '1' },
errors => [
'Please enter a subject',
'Please enter some details',
- 'Please enter your name',
'Please enter your email',
+ 'Please enter your name',
],
},
{
@@ -107,6 +113,9 @@ foreach my $test (
email => '',
phone => '',
category => 'Street lighting',
+ password_sign_in => '',
+ password_register => '',
+ remember_me => undef,
},
changes => {},
errors => [
@@ -127,6 +136,9 @@ foreach my $test (
email => '',
phone => '',
category => 'Street lighting',
+ password_sign_in => '',
+ password_register => '',
+ remember_me => undef,
},
changes => {},
errors => [
@@ -147,6 +159,9 @@ foreach my $test (
email => '',
phone => '',
category => 'Street lighting',
+ password_sign_in => '',
+ password_register => '',
+ remember_me => undef,
},
changes => {
title => 'Dog poo on walls',
@@ -167,11 +182,14 @@ foreach my $test (
email => '',
phone => '',
category => 'Street lighting',
+ password_sign_in => '',
+ password_register => '',
+ remember_me => undef,
},
changes => {},
errors => [
-'Please enter your full name, councils need this information - if you do not wish your name to be shown on the site, untick the box',
'Please enter your email',
+'Please enter your full name, councils need this information - if you do not wish your name to be shown on the site, untick the box',
],
},
{
@@ -186,11 +204,14 @@ foreach my $test (
email => '',
phone => '',
category => 'Street lighting',
+ password_sign_in => '',
+ password_register => '',
+ remember_me => undef,
},
changes => {},
errors => [
-'Please enter your full name, councils need this information - if you do not wish your name to be shown on the site, untick the box',
'Please enter your email',
+'Please enter your full name, councils need this information - if you do not wish your name to be shown on the site, untick the box',
],
},
{
@@ -205,6 +226,9 @@ foreach my $test (
email => 'not an email',
phone => '',
category => 'Street lighting',
+ password_sign_in => '',
+ password_register => '',
+ remember_me => undef,
},
changes => { email => 'notanemail', },
errors => [ 'Please enter a valid email', ],
@@ -221,12 +245,18 @@ foreach my $test (
email => '',
phone => '',
category => 'Street lighting',
+ password_sign_in => '',
+ password_register => '',
+ remember_me => undef,
},
changes => {
title => 'Test title',
detail => "First line\n\nSecond line",
},
- errors => [ 'Please enter your name', 'Please enter your email', ],
+ errors => [
+ 'Please enter your email',
+ 'Please enter your name',
+ ],
},
{
msg => 'clean up name and email',
@@ -240,6 +270,9 @@ foreach my $test (
email => ' BOB @ExAmplE.COM ',
phone => '',
category => 'Street lighting',
+ password_sign_in => '',
+ password_register => '',
+ remember_me => undef,
},
changes => {
name => 'Bob Jones',
@@ -278,14 +311,30 @@ foreach my $test (
};
}
-subtest "test report creation for a user who does not have an account" => sub {
+foreach my $test (
+ {
+ desc => 'does not have an account',
+ user => 0,
+ },
+ {
+ desc => 'does have an account and is not signed in; does not sign in',
+ user => 1,
+ }
+) {
+ subtest "test report creation for a user who " . $test->{desc} => sub {
$mech->log_out_ok;
$mech->clear_emails_ok;
# check that the user does not exist
my $test_email = 'test-1@example.com';
- ok !FixMyStreet::App->model('DB::User')->find( { email => $test_email } ),
- "test user does not exist";
+ if ($test->{user}) {
+ my $user = FixMyStreet::App->model('DB::User')->find( { email => $test_email } );
+ ok $user, "test user does exist";
+ $user->problems->delete;
+ } else {
+ ok !FixMyStreet::App->model('DB::User')->find( { email => $test_email } ),
+ "test user does not exist";
+ }
# submit initial pc form
$mech->get_ok('/around');
@@ -298,6 +347,7 @@ subtest "test report creation for a user who does not have an account" => sub {
$mech->submit_form_ok(
{
+ button => 'submit_register',
with_fields => {
title => 'Test Report',
detail => 'Test report details.',
@@ -307,6 +357,7 @@ subtest "test report creation for a user who does not have an account" => sub {
email => 'test-1@example.com',
phone => '07903 123 456',
category => 'Street lighting',
+ password_register => 'secret',
}
},
"submit good details"
@@ -319,6 +370,7 @@ subtest "test report creation for a user who does not have an account" => sub {
my $user =
FixMyStreet::App->model('DB::User')->find( { email => $test_email } );
ok $user, "created new user";
+ ok $user->check_password('secret'), 'password set correctly';
# find the report
my $report = $user->problems->first;
@@ -358,15 +410,98 @@ subtest "test report creation for a user who does not have an account" => sub {
$mech->logged_in_ok;
# cleanup
- $mech->delete_user($user);
-};
+ $mech->delete_user($user)
+ if $test->{user};
+ };
+}
+
+subtest "test report creation for a user who is signing in as they report" => sub {
+ $mech->log_out_ok;
+ $mech->clear_emails_ok;
+
+ # check that the user does not exist
+ my $test_email = 'test-2@example.com';
+
+ my $user = FixMyStreet::App->model('DB::User')->find_or_create( { email => $test_email } );
+ ok $user, "test user does exist";
+
+ # setup the user.
+ ok $user->update( {
+ name => 'Joe Bloggs',
+ phone => '01234 567 890',
+ password => 'secret2',
+ } ), "set user details";
+
+ # submit initial pc form
+ $mech->get_ok('/around');
+ $mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB', } },
+ "submit location" );
+
+ # click through to the report page
+ $mech->follow_link_ok( { text => 'skip this step', },
+ "follow 'skip this step' link" );
+
+ $mech->submit_form_ok(
+ {
+ button => 'submit_sign_in',
+ with_fields => {
+ title => 'Test Report',
+ detail => 'Test report details.',
+ photo => '',
+ email => 'test-2@example.com',
+ password_sign_in => 'secret2',
+ category => 'Street lighting',
+ }
+ },
+ "submit good details"
+ );
+
+ # check that we got the errors expected
+ is_deeply $mech->form_errors, [
+ 'You have successfully signed in; please check and confirm your details are accurate:',
+ ], "check there were errors";
+
+ # Now submit with a name
+ $mech->submit_form_ok(
+ {
+ with_fields => {
+ name => 'Joe Bloggs',
+ }
+ },
+ "submit good details"
+ );
+
+ # find the report
+ my $report = $user->problems->first;
+ ok $report, "Found the report";
-#### test report creation for a user who has account but is not logged in
-# come to site
-# fill in report
-# receive token
-# confirm token
-# report is confirmed
+ # check that we got redirected to /report/
+ is $mech->uri->path, "/report/" . $report->id, "redirected to report page";
+
+ # Check the report has been assigned appropriately
+ is $report->council, 2651;
+
+ # check that no emails have been sent
+ $mech->email_count_is(0);
+
+ # check report is confirmed and available
+ is $report->state, 'confirmed', "report is now confirmed";
+ $mech->get_ok( '/report/' . $report->id );
+
+ # check that the reporter has an alert
+ my $alert = FixMyStreet::App->model('DB::Alert')->find( {
+ user => $report->user,
+ alert_type => 'new_updates',
+ parameter => $report->id,
+ } );
+ ok $alert, "created new alert";
+
+ # user is created and logged in
+ $mech->logged_in_ok;
+
+ # cleanup
+ $mech->delete_user($user)
+};
#### test report creation for user with account and logged in
foreach my $test (
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index 49bfc0d1b..e8acbfd14 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -201,9 +201,12 @@ for my $test (
fixed => undef,
add_alert => 1,
may_show_name => undef,
+ remember_me => undef,
+ password_register => '',
+ password_sign_in => '',
},
changes => {},
- field_errors => [ 'Please enter a message', 'Please enter your email' ]
+ field_errors => [ 'Please enter a message', 'Please enter your email', 'Please enter your name' ]
},
{
desc => 'Invalid email, no message',
@@ -215,9 +218,12 @@ for my $test (
fixed => undef,
add_alert => 1,
may_show_name => undef,
+ remember_me => undef,
+ password_sign_in => '',
+ password_register => '',
},
changes => {},
- field_errors => [ 'Please enter a message', 'Please enter a valid email' ]
+ field_errors => [ 'Please enter a message', 'Please enter a valid email', 'Please enter your name' ]
},
{
desc => 'email with spaces, no message',
@@ -229,11 +235,14 @@ for my $test (
fixed => undef,
add_alert => 1,
may_show_name => undef,
+ remember_me => undef,
+ password_register => '',
+ password_sign_in => '',
},
changes => {
rznvy => 'test@example.com',
},
- field_errors => [ 'Please enter a message' ]
+ field_errors => [ 'Please enter a message', 'Please enter your name' ]
},
{
desc => 'email with uppercase, no message',
@@ -245,11 +254,14 @@ for my $test (
fixed => undef,
add_alert => 1,
may_show_name => undef,
+ remember_me => undef,
+ password_register => '',
+ password_sign_in => '',
},
changes => {
rznvy => 'test@example.com',
},
- field_errors => [ 'Please enter a message' ]
+ field_errors => [ 'Please enter a message', 'Please enter your name' ]
},
)
{
@@ -281,12 +293,17 @@ for my $test (
photo => '',
update => '',
fixed => undef,
+ remember_me => undef,
+ password_register => '',
+ password_sign_in => '',
},
form_values => {
submit_update => 1,
rznvy => 'unregistered@example.com',
update => 'Update from an unregistered user',
add_alert => undef,
+ name => 'Unreg User',
+ may_show_name => undef,
},
changes => {},
},
@@ -300,12 +317,17 @@ for my $test (
photo => '',
update => '',
fixed => undef,
+ remember_me => undef,
+ password_register => '',
+ password_sign_in => '',
},
form_values => {
submit_update => 1,
rznvy => 'unregistered@example.com',
update => 'update from an unregistered user',
add_alert => 1,
+ name => 'Unreg User',
+ may_show_name => undef,
},
changes => {
update => 'Update from an unregistered user',
@@ -562,32 +584,82 @@ $report->update;
for my $test (
{
- desc => 'submit update for registered user',
- initial_values => {
- name => 'Test User',
- may_show_name => 1,
- add_alert => 1,
- photo => '',
- update => '',
- fixed => undef,
- },
- email => 'test@example.com',
- fields => {
+ desc => 'submit an update for a non registered user, signing in with wrong password',
+ form_values => {
submit_update => 1,
- update => 'update from a registered user',
- add_alert => undef,
- fixed => undef,
- },
- changed => {
- update => 'Update from a registered user'
+ rznvy => 'registered@example.com',
+ update => 'Update from a user',
+ add_alert => undef,
+ password_sign_in => 'secret',
},
- initial_banner => '',
- endstate_banner => '',
- alert => 0,
- anonymous => 0,
+ field_errors => [
+ 'There was a problem with your email/password combination. Please try again.',
+ 'Please enter your name', # FIXME Not really necessary error
+ ],
},
{
- desc => 'submit update for registered user anonymously by unchecking',
+ desc => 'submit an update for a non registered user and sign in',
+ form_values => {
+ submit_update => 1,
+ rznvy => 'registered@example.com',
+ update => 'Update from a user',
+ add_alert => undef,
+ password_sign_in => 'secret2',
+ },
+ field_errors => [
+ 'You have successfully signed in; please check and confirm your details are accurate:',
+ ],
+ }
+) {
+ subtest $test->{desc} => sub {
+ # Set things up
+ my $user = $mech->create_user_ok( $test->{form_values}->{rznvy} );
+ my $pw = 'secret2';
+ $user->update( { name => 'Mr Reg', password => $pw } );
+ $report->comments->delete;
+
+ $mech->log_out_ok();
+ $mech->clear_emails_ok();
+ $mech->get_ok("/report/$report_id");
+ $mech->submit_form_ok(
+ {
+ button => 'submit_sign_in',
+ with_fields => $test->{form_values}
+ },
+ 'submit update'
+ );
+
+ is_deeply $mech->form_errors, $test->{field_errors}, 'check there were errors';
+
+ SKIP: {
+ skip( "Incorrect password", 5 ) unless $test->{form_values}{password_sign_in} eq $pw;
+
+ # Now submit with a name
+ $mech->submit_form_ok(
+ {
+ with_fields => {
+ name => 'Joe Bloggs',
+ }
+ },
+ "submit good details"
+ );
+
+ is $mech->uri->path, "/report/" . $report_id, "redirected to report page";
+ $mech->email_count_is(0);
+
+ my $update = $report->comments->first;
+ ok $update, 'found update';
+ is $update->text, $test->{form_values}->{update}, 'update text';
+ is $update->user->email, $test->{form_values}->{rznvy}, 'update user';
+ is $update->state, 'confirmed', 'update confirmed';
+ $mech->delete_user( $update->user );
+ }
+ };
+}
+
+for my $test (
+ {
+ desc => 'submit update for registered user',
initial_values => {
name => 'Test User',
may_show_name => 1,
@@ -600,7 +672,6 @@ for my $test (
fields => {
submit_update => 1,
update => 'update from a registered user',
- may_show_name => undef,
add_alert => undef,
fixed => undef,
},
@@ -610,10 +681,10 @@ for my $test (
initial_banner => '',
endstate_banner => '',
alert => 0,
- anonymous => 1,
+ anonymous => 0,
},
{
- desc => 'submit update for registered user anonymously by deleting name',
+ desc => 'submit update for registered user anonymously by unchecking',
initial_values => {
name => 'Test User',
may_show_name => 1,
@@ -625,9 +696,8 @@ for my $test (
email => 'test@example.com',
fields => {
submit_update => 1,
- name => '',
update => 'update from a registered user',
- may_show_name => 1,
+ may_show_name => undef,
add_alert => undef,
fixed => undef,
},
diff --git a/templates/web/default/alert/list.html b/templates/web/default/alert/list.html
index 38007ea62..36bfaffd9 100644
--- a/templates/web/default/alert/list.html
+++ b/templates/web/default/alert/list.html
@@ -116,10 +116,14 @@ for the county council.' ) %]
[% loc('or') %]
</p>
+[% UNLESS c.user_exists %]
+
<p>
[% loc('Your email:') %] <input type="text" id="rznvy" name="rznvy" value="[% rznvy | html %]" size="30">
</p>
+[% END %]
+
<p>
<input type="submit" name="alert" value="[% loc('Subscribe me to an email alert') %]">
</p>
diff --git a/templates/web/default/alert/updates.html b/templates/web/default/alert/updates.html
index 88b014ff6..76b5ef23e 100644
--- a/templates/web/default/alert/updates.html
+++ b/templates/web/default/alert/updates.html
@@ -11,7 +11,7 @@
<form action="/alert/subscribe" method="post">
<label class="n" for="alert_rznvy">[% loc('Email:') %]</label>
-<input type="text" name="rznvy" id="alert_rznvy" value="[% email | html %]" size="30">
+<input type="email" name="rznvy" id="alert_rznvy" value="[% email | html %]" size="30">
<input type="hidden" name="id" value="[% problem_id | html %]">
<input type="hidden" name="type" value="updates">
<input type="submit" value="[% loc('Subscribe') %]">
diff --git a/templates/web/default/auth/general.html b/templates/web/default/auth/general.html
index d30fefcee..ffc85b3dc 100644
--- a/templates/web/default/auth/general.html
+++ b/templates/web/default/auth/general.html
@@ -20,7 +20,7 @@
[% IF loc_email_error %]
<div class="form-error">[% loc_email_error %]</div>
[% ELSIF sign_in_error %]
- <div class="form-error">[% loc('Email or password wrong - please try again.') %]</div>
+ <div class="form-error">[% loc('There was a problem with your email/password combination. Please try again.') %]</div>
[% END %]
<div class="form-field">
diff --git a/templates/web/default/footer.html b/templates/web/default/footer.html
index 9222436e2..657d9d826 100644
--- a/templates/web/default/footer.html
+++ b/templates/web/default/footer.html
@@ -4,16 +4,18 @@
<h2 class="v">[% loc('Navigation') %]</h2>
<ul id="navigation">
<li><a href="/">[% loc("Report a problem") %]</a></li>
+<li id="nav_new"><a href="/my">[% loc("Your reports") %]</a></li>
<li><a href="/reports">[% loc("All reports") %]</a></li>
<li><a href="/alert[% pc ? '/list?pc=' : '' %][% pc | uri %]">[% loc("Local alerts") %]</a></li>
<li><a href="/faq">[% loc("Help") %]</a></li>
-<li><a href="/contact">[% loc("Contact") %]</a></li>
</ul>
[% loc('<a href="http://www.mysociety.org/"><img id="logo" width="133" height="26" src="/i/mysociety-dark.png" alt="View mySociety.org"><span id="logoie"></span></a>') %]
<p id="footer">
- [% loc('Built by <a href="http://www.mysociety.org/">mySociety</a>, using some <a href="http://github.com/mysociety/fixmystreet">clever</a>&nbsp;<a href="https://secure.mysociety.org/cvstrac/dir?d=mysociety/services/TilMa">code</a>.') %]
+ [% loc('Built by <a href="http://www.mysociety.org/">mySociety</a>') %]
+ | <a href="http://github.com/mysociety/fixmystreet">[% loc('Source code') %]</a>
+ | <a href="/contact">[% loc("Contact FixMyStreet") %]</a>
</p>
[% INCLUDE 'tracking_code.html' %]
diff --git a/templates/web/default/header.html b/templates/web/default/header.html
index 52f066663..67a5fe631 100644
--- a/templates/web/default/header.html
+++ b/templates/web/default/header.html
@@ -16,6 +16,15 @@
[%- loc('Fix<span id="my">My</span>Street') %]
[%- IF NOT title AND NOT c.req.path %]</h1>[% ELSE %]</a></div>[% END %]
+ <ul id="meta">
+ [% IF c.user_exists %]
+ <li>[% tprintf(loc('Signed in as %s'), c.user.name || c.user.email) %]
+ <li><a href="/auth/logout">[% loc('Sign out') %]</a></li>
+ [% ELSE %]
+ <li>&nbsp;</li>
+ [% END %]
+ </ul>
+
<div id="wrapper"><div id="mysociety">
[% INCLUDE 'debug_header.html' %]
diff --git a/templates/web/default/my/my.html b/templates/web/default/my/my.html
index 03b180a3a..e7f4ca72d 100644
--- a/templates/web/default/my/my.html
+++ b/templates/web/default/my/my.html
@@ -1,18 +1,89 @@
-[% INCLUDE 'header.html', title => loc('My Reports') %]
+[%
+ PROCESS "maps/${map.type}.html" IF problems.size;
+ INCLUDE 'header.html', title = loc('Your Reports')
+%]
+
+[% IF problems.size %]
+ [% map_html %]
+ </div>
+ <div id="side">
+[% ELSE %]
+ <div id="skipped-map">
+[% END %]
<h1>[% loc('Your Reports') %]</h1>
-[% FOREACH p = c.user.problems %]
- [% "<ul>" IF loop.first %]
+[% INCLUDE pagination, pager = problems_pager %]
+
+[% FOREACH p = problems.confirmed %]
+ [% IF loop.first %]<h2>[% loc('Open reports') %]</h2>[% END %]
+ [% INCLUDE problem %]
+[% END %]
+
+[% FOREACH p = problems.fixed %]
+ [% IF loop.first %]<h2>[% loc('Fixed reports') %]</h2>[% END %]
+ [% INCLUDE problem %]
+[% END %]
- <li><a href="[% c.uri_for( '/report', p.id ) %]">[% p.title | html %]</a> ([% loc(p.state) %])</li>
+[%# FOREACH p = problems.unconfirmed;
+ IF loop.first;
+ '<h2>' _ loc('Unconfirmed reports') _ '</h2>';
+ END;
+ INCLUDE problem;
+END %]
+[% FOREACH u IN updates %]
+ [% IF loop.first %]
+ <h2>[% loc('Your updates') %]</h2>
+ [% INCLUDE pagination, pager = updates_pager %]
+ <ul>
+ [% END %]
+
+ <li>&ldquo;[% u.text | html %]&rdquo;
+ &ndash; <a href="[% c.uri_for( '/report', u.problem_id ) %]#update_[% u.id %]">[% u.problem.title | html %]</a>.
+ <em class="council_sent_info">
+ [% tprintf( loc("Added %s"), prettify_epoch( u.confirmed_local.epoch, 'date' ) ) %]
+ </em>
+ </li>
[% "</ul>" IF loop.last %]
[% END %]
+</div>
+
+[% INCLUDE 'footer.html' %]
-[%# FIXME - put in blurb here %]
+[% BLOCK problem %]
+ [% "<ul>" IF loop.first %]
-<a href="/auth/change_password">change password</a>
+ <li><a href="[% c.uri_for( '/report', p.id ) %]">[% p.title | html %]</a>
+ <em class="council_sent_info"> &ndash;
+ [% IF p.whensent %]
+ [% tprintf( loc("Reported %s, to %s"), prettify_epoch( p.confirmed_local.epoch, 'date' ), p.body(c) ) %]
+ [% ELSE %]
+ [% tprintf( loc("Reported %s"), prettify_epoch( p.confirmed_local.epoch, 'date' ) ) %]
+ [% END %]
+ </em>
+ </li>
-[% INCLUDE 'footer.html' %] \ No newline at end of file
+ [% "</ul>" IF loop.last %]
+[% END %]
+
+[% BLOCK pagination %]
+ [% IF pager.last_page > 1 %]
+ <p>
+ [% IF pager.previous_page %]
+ <a href="[% c.req.uri_with({'p_page' => pager.previous_page}) %]">&larr; Previous</a>
+ [% ELSE %]
+ &larr; Previous
+ [% END %]
+ |
+ [% pager.first %] to [% pager.last %] of [% pager.total_entries %]
+ |
+ [% IF pager.next_page %]
+ <a href="[% c.req.uri_with({'p_page' => pager.next_page}) %]">Next &rarr;</a>
+ [% ELSE %]
+ Next &rarr;
+ [% END %]
+ </p>
+ [% END %]
+[% END %]
diff --git a/templates/web/default/report/display.html b/templates/web/default/report/display.html
index a8a58ffce..0c0c5e22d 100644
--- a/templates/web/default/report/display.html
+++ b/templates/web/default/report/display.html
@@ -44,7 +44,7 @@
<form action="[% c.uri_for( '/alert/subscribe' ) %]" method="post" id="email_alert_box">
<p>[% loc('Receive email when updates are left on this problem.' ) %]</p>
<label class="n" for="alert_rznvy">[% loc('Email:') %]</label>
- <input type="text" name="rznvy" id="alert_rznvy" value="[% email | html %]" size="30">
+ <input type="email" name="rznvy" id="alert_rznvy" value="[% email | html %]" size="30">
<input type="hidden" name="id" value="[% problem.id %]">
<input type="hidden" name="type" value="updates">
<input type="submit" value="[% loc('Subscribe') %]">
@@ -96,7 +96,12 @@
[% END %]
</select>
[% ELSE %]
- [% IF !problem.is_fixed %]
+ [% IF problem.state == 'fixed' AND c.user_exists AND c.user.id == problem.user_id %]
+ <div class="checkbox">
+ <input type="checkbox" name="reopen" id="form_reopen" value="1"[% ' checked' IF update.mark_open %]>
+ <label for="form_reopen">[% loc('This problem has not been fixed') %]</label>
+ </div>
+ [% ELSIF problem.state != 'fixed' %]
<div class="checkbox">
<input type="checkbox" name="fixed" id="form_fixed" value="1"[% fixed %]>
<label for="form_fixed">[% loc('This problem has been fixed') %]</label>
@@ -105,12 +110,12 @@
[% END %]
[% IF c.cobrand.allow_photo_upload %]
- [% IF photo_error %]
- <div class='form-error'>[% photo_error %]</div>
+ [% IF field_errors.photo %]
+ <div class='form-error'>[% field_errors.photo %]</div>
[% END %]
<div id="fileupload_normalUI">
[% IF upload_fileid %]
- <p>[% loc('You have already attached a photo to this report, attaching another one will replace it.') %]</p>
+ <p>[% loc('You have already attached a photo to this update, attaching another one will replace it.') %]</p>
<input type="hidden" name="upload_fileid" value="[% upload_fileid %]">
[% END %]
<label for="form_photo">[% loc('Photo:') %]</label>
@@ -118,38 +123,76 @@
</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>
+[% IF c.user_exists %]
+
+ [% INCLUDE name %]
<div class="checkbox">
- <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>
+ <input type="submit" id="update_post" value="[% loc('Post') %]">
</div>
-[% IF NOT c.user_exists %]
+[% ELSE %]
+
+ [% IF field_errors.email %]
+ <div class='form-error'>[% field_errors.email %]</div>
+ [% END %]
+ <div class="form-field">
+ <label for="form_rznvy">[% loc('Your email:' ) %]</label>
+ <input type="email" name="rznvy" id="form_rznvy" value="[% update.user.email | html %]" size="30">
+ </div>
+
+<div id="form_sign_in">
+ <h3>[% loc("Now to submit your update&hellip; do you have a FixMyStreet password?") %]</h3>
- [% IF field_errors.email %]
- <div class='form-error'>[% field_errors.email %]</div>
+ <div id="form_sign_in_yes">
+
+ [% IF field_errors.password %]
+ <div class='form-error'>[% field_errors.password %]</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 %]
+ <p>
+ <label class="n" for="password_sign_in">[% loc('<strong>Yes</strong>, I have a password:') %]</label>
+ <input type="password" name="password_sign_in" id="password_sign_in" value="" size="25">
+ </p>
- <div class="checkbox">
- <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>
+ <p>
+ <input type="checkbox" name="remember_me" value='1'[% ' checked' IF remember_me %]>
+ <label class="n" for="remember_me">
+ [% loc('Keep me signed in on this computer') %]
+ </label>
+ </p>
- <div class="checkbox">
- <input type="submit" id="update_post" value="[% loc('Post') %]">
+ <p>
+ <input type="submit" name="submit_sign_in" value="[% loc('Post') %]">
+ </p>
+
+ </div>
+ <div id="form_sign_in_no">
+
+ <p>[% loc('<strong>No</strong>, let me confirm my update by email:') %]</p>
+
+ <div id="fieldset">
+
+ [% INCLUDE name %]
+
+ <div class="form-field">
+ <label for="password_register">[% loc('Enter a new password:') %]</label>
+ <input type="password" name="password_register" id="password_register" value="" size="25">
+ </div>
</div>
+ <p style="clear:both"><small>[% loc('Providing a password is optional, but doing so will allow you to more easily report problems, leave updates and manage your reports.') %]</small></p>
+
+ <p>
+ <input type="submit" name="submit_register" value="[% loc('Post') %]">
+ </p>
+
+ </div>
+
+</div>
+
+[% END %]
+
[% cobrand_update_fields %]
</form>
@@ -158,3 +201,25 @@
</div>
[% INCLUDE 'footer.html' %]
+
+[% BLOCK name %]
+ [% IF field_errors.name %]
+ <div class='form-error'>[% field_errors.name %]</div>
+ [% END %]
+
+ <div>
+ <label for="form_name">[% loc('Your name:') %]</label>
+ <input type="text" name="name" id="form_name" value="[% update.name || c.user.name | html %]" size="25">
+ </div>
+
+ <div class="checkbox">
+ <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>
+
+ <div class="checkbox">
+ <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>
+[% END %]
diff --git a/templates/web/default/report/new/fill_in_details.html b/templates/web/default/report/new/fill_in_details.html
index 4a40dd707..68443770d 100644
--- a/templates/web/default/report/new/fill_in_details.html
+++ b/templates/web/default/report/new/fill_in_details.html
@@ -5,7 +5,6 @@
[% IF report.used_map %]
<form action="[% c.uri_for('/report/new') %]" method="post" name="mapForm" id="mapForm"[% IF c.cobrand.allow_photo_upload %] enctype="multipart/form-data"[% END %]>
-<input type="hidden" name="submit_map" value="1">
<input type="hidden" name="map" value="[% c.req.params.map | html %]">
<input type="hidden" name="pc" value="[% pc | html %]">
[% c.cobrand.form_elements('mapForm') %]
@@ -118,58 +117,90 @@
[% 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 %]
-[% IF field_errors.name %]
- <div class='form-error'>[% field_errors.name %]</div>
-[% END %]
-
-<div class='form-field'>
- <label for="form_name">[% loc('Name:') %]</label>
- <input type="text" value="[% report.name | html %]" name="name" id="form_name" size="25">
-</div>
+[% IF c.user_exists %]
+ [% INCLUDE name_phone %]
-<div class="checkbox">
+ [% INCLUDE 'report/new/notes.html' %]
- [%# 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 %]>
-
- <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>
+ <p id="problem_submit">
+ <input type="submit" value="[% loc('Submit') %]">
+ </p>
-[% IF NOT c.user_exists %]
+[% ELSE %]
[% IF field_errors.email %]
<div class='form-error'>[% field_errors.email %]</div>
[% END %]
<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">
+ <label for="form_email">[% loc('Your email:') %]</label>
+ <input type="email" value="[% report.user.email | html %]" name="email" id="form_email" size="25">
</div>
-[% END %]
+[% INCLUDE 'report/new/notes.html' %]
+
+<div id="form_sign_in">
+ <h3>[% loc("Now to submit your report&hellip; do you have a FixMyStreet password?") %]</h3>
+
+ <div id="form_sign_in_yes">
+
+ [% IF field_errors.password %]
+ <div class='form-error'>[% field_errors.password %]</div>
+ [% END %]
+
+ <p>
+ <label class="n" for="password_sign_in">[% loc('<strong>Yes</strong>, I have a password:') %]</label>
+ <input type="password" name="password_sign_in" id="password_sign_in" value="" size="25">
+ </p>
+
+ <p>
+ <input type="checkbox" name="remember_me" value='1'[% ' checked' IF remember_me %]>
+ <label class="n" for="remember_me">
+ [% loc('Keep me signed in on this computer') %]
+ </label>
+ </p>
+
+ <p>
+ <input type="submit" name="submit_sign_in" value="[% loc('Submit') %]">
+ </p>
+
+ </div>
+ <div id="form_sign_in_no">
+
+ <p>[% loc('<strong>No</strong>, let me confirm my report by email:') %]</p>
+
+ <div id="fieldset">
+
+ [% INCLUDE name_phone %]
+
+ <div class="form-field">
+ <label for="password_register">[% loc('Enter a new password:') %]</label>
+ <input type="password" name="password_register" id="password_register" value="" size="25">
+ </div>
+ </div>
+
+ <p style="clear:both"><small>[% loc('Providing a password is optional, but doing so will allow you to more easily report problems, leave updates and manage your reports.') %]</small></p>
+
+ <p>
+ <input type="submit" name="submit_register" value="[% loc('Submit') %]">
+ </p>
+
+ </div>
-<div>
- <label for="form_phone">[% loc('Phone:') %]</label>
- <input type="text" value="[% report.user.phone | html %]" name="phone" id="form_phone" size="15">
- <small>[% loc('(optional)') %]</small>
</div>
-[% INCLUDE 'report/new/notes.html' %]
+[% END %]
[% IF partial_token %]
<input type="hidden" name="partial" value="[% partial_token.token %]">
[% END %]
-<p id="problem_submit">
- <input type="hidden" name="submit_problem" value="1">
- <input type="submit" value="[% loc('Submit') %]">
-</p>
+<input type="hidden" name="submit_problem" value="1">
</div>
</div>
@@ -178,3 +209,28 @@
</form>
[% INCLUDE 'footer.html' %]
+
+[% BLOCK name_phone %]
+ [% IF field_errors.name %]
+ <div class='form-error'>[% field_errors.name %]</div>
+ [% END %]
+
+ <div class="form-field">
+ <label for="form_name">[% loc('Your name:') %]</label>
+ <input type="text" value="[% report.name | html %]" name="name" id="form_name" size="25">
+ </div>
+
+ <div class="checkbox">
+ [%# 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 %]>
+ <label for="form_may_show_name">[% loc('Show my name publicly') %]</label>
+ <br><small>[% loc('(we never show your email address or phone number)') %]</small>
+ </div>
+
+ <div>
+ <label for="form_phone">[% loc('Phone:') %]</label>
+ <input type="text" value="[% report.user.phone | html %]" name="phone" id="form_phone" size="15">
+ <small>[% loc('(optional)') %]</small>
+ </div>
+[% END %]
+
diff --git a/web/css/_main.scss b/web/css/_main.scss
index 44fd82b3b..0b9cf33ab 100644
--- a/web/css/_main.scss
+++ b/web/css/_main.scss
@@ -79,7 +79,23 @@ select, input, textarea {
/* Can't put the margin in #mysociety because of above IE craziness */
#wrapper {
- margin: 2em;
+ margin: 1em 2em 2em;
+}
+
+#meta {
+ list-style-type: none;
+ margin: 0.25em 0 0 1em;
+ padding: 0;
+ font-size: 0.875em;
+ li {
+ display: inline;
+ margin: 0;
+ padding: 0 0 0 0.25em;
+ border-left: solid 1px $header_colour;
+ }
+ li:first-child {
+ border-left: none;
+ }
}
.v {
@@ -111,6 +127,12 @@ select, input, textarea {
a:hover, a:active {
background-color: $header_colour;
color: $header_back;
+ -moz-border-radius-topleft: 0.5em;
+ -webkit-border-top-left-radius: 0.5em;
+ border-radius-top-left: 0.5em;
+ -moz-border-radius-topright: 0.5em;
+ -webkit-border-top-right-radius: 0.5em;
+ border-radius-top-right: 0.5em;
}
}
@@ -129,11 +151,10 @@ select, input, textarea {
#footer {
clear: both;
- text-align: right;
- font-size: 83%;
- border-top: solid 1px $header_colour;
- display: table;
- margin: 2em 0 1em auto;
- padding: 2px 4px;
+ text-align: center;
+ border-top: solid 2px $header_back;
+ width: 50%;
+ margin: 2em auto 0;
+ padding: 1em;
}
diff --git a/web/css/core.css b/web/css/core.css
index 937bf533d..cb35000cd 100644
--- a/web/css/core.css
+++ b/web/css/core.css
@@ -144,6 +144,7 @@
background-color: #ffffff; }
#mysociety p#copyright {
float: right;
+ text-align: right;
margin: 0 0 1em 0;
font-size: 78%; }
#mysociety #map {
@@ -315,6 +316,11 @@
font-size: 80%;
margin-top: 2em; }
+.olControlAttribution {
+ bottom: 3px !important;
+ left: 3px;
+}
+
@media print {
#mysociety #map_box {
float: none;
diff --git a/web/css/core.scss b/web/css/core.scss
index cbf15f16b..d845d6de4 100644
--- a/web/css/core.scss
+++ b/web/css/core.scss
@@ -226,6 +226,7 @@ $map_width: 500px;
p#copyright {
float: right;
+ text-align: right;
margin: 0 0 1em 0;
font-size: 78%;
}
@@ -519,6 +520,11 @@ $map_width: 500px;
}
+.olControlAttribution {
+ bottom: 3px !important;
+ left: 3px;
+}
+
// Printing, SCSS doesn't handle @media nesting
@media print {
diff --git a/web/css/main.css b/web/css/main.css
index ddea37970..686b74d40 100644
--- a/web/css/main.css
+++ b/web/css/main.css
@@ -77,7 +77,23 @@ select, input, textarea {
/* Can't put the margin in #mysociety because of above IE craziness */
#wrapper {
- margin: 2em;
+ margin: 1em 2em 2em;
+}
+
+#meta {
+ list-style-type: none;
+ margin: 0.25em 0 0 1em;
+ padding: 0;
+ font-size: 0.875em;
+}
+#meta li {
+ display: inline;
+ margin: 0;
+ padding: 0 0 0 0.25em;
+ border-left: solid 1px #5e552b;
+}
+#meta li:first-child {
+ border-left: none;
}
.v {
@@ -108,6 +124,12 @@ select, input, textarea {
#navigation a:hover, #navigation a:active {
background-color: #5e552b;
color: #e3d595;
+ -moz-border-radius-topleft: 0.5em;
+ -webkit-border-top-left-radius: 0.5em;
+ border-radius-top-left: 0.5em;
+ -moz-border-radius-topright: 0.5em;
+ -webkit-border-top-right-radius: 0.5em;
+ border-radius-top-right: 0.5em;
}
#nav_new a {
@@ -125,10 +147,9 @@ select, input, textarea {
#footer {
clear: both;
- text-align: right;
- font-size: 83%;
- border-top: solid 1px #5e552b;
- display: table;
- margin: 2em 0 1em auto;
- padding: 2px 4px;
+ text-align: center;
+ border-top: solid 2px #e3d595;
+ width: 50%;
+ margin: 2em auto 0;
+ padding: 1em;
}
diff --git a/web/js/fixmystreet.js b/web/js/fixmystreet.js
index 7f6014c6c..50ccb2ac3 100644
--- a/web/js/fixmystreet.js
+++ b/web/js/fixmystreet.js
@@ -12,7 +12,7 @@ YAHOO.util.Event.onContentReady('pc', function() {
YAHOO.util.Event.onContentReady('mapForm', function() {
this.onsubmit = function() {
- if (this.submit_problem) {
+ if (this.submit_problem) {
this.onsubmit = function() { return false; };
}
diff --git a/web/js/map-bing-ol.js b/web/js/map-bing-ol.js
index c3c3b994e..75bce80d3 100644
--- a/web/js/map-bing-ol.js
+++ b/web/js/map-bing-ol.js
@@ -1,5 +1,6 @@
function set_map_config(perm) {
fixmystreet.controls = [
+ new OpenLayers.Control.Attribution(),
new OpenLayers.Control.ArgParser(),
new OpenLayers.Control.Navigation(),
perm,
@@ -9,6 +10,9 @@ function set_map_config(perm) {
}
OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {
+ attribution: '<a href="http://www.bing.com/maps/">' +
+ '<img border=0 src="http://dev.virtualearth.net/Branding/logo_powered_by.png"></a>',
+
initialize: function(name, options) {
var url = [];
options = OpenLayers.Util.extend({
@@ -18,7 +22,7 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {
transitionEffect: "resize",
sphericalMercator: true,
buffer: 0,
- attribution: "© Microsoft / OS 2010"
+ //attribution: "© Microsoft / OS 2010"
}, options);
var newArguments = [name, url, options];
OpenLayers.Layer.XYZ.prototype.initialize.apply(this, newArguments);