diff options
-rwxr-xr-x | bin/fixmystreet.com/fixture | 16 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Borsetshire.pm | 12 | ||||
-rw-r--r-- | templates/web/borsetshire/auth/_general_top.html | 3 | ||||
-rw-r--r-- | web/cobrands/borsetshire/js.js | 19 |
4 files changed, 39 insertions, 11 deletions
diff --git a/bin/fixmystreet.com/fixture b/bin/fixmystreet.com/fixture index 6cf5ad199..2636ec1cc 100755 --- a/bin/fixmystreet.com/fixture +++ b/bin/fixmystreet.com/fixture @@ -78,7 +78,7 @@ $priority->[0]->add_to_contacts($body->contacts->first); # Users say "Created users, all with password 'password':"; -my $user; # Will store the final (normal) user of the loop for later user +my %users; my $perms_inspector = ['report_inspect', 'planned_reports']; my $perms_cs = [ 'contribute_as_body', 'contribute_as_another_user', @@ -95,7 +95,7 @@ foreach ( { name => 'Wizard of Oz', email => 'admin@example.org', is_superuser => 't' }, { name => "Norma User", email => 'user@example.org' }, ) { - $user = FixMyStreet::DB::Factory::User->find_or_create($_); + $users{$_->{email}} = FixMyStreet::DB::Factory::User->find_or_create($_); my $perms = $_->{permissions} ? " (" . join(', ', @{$_->{permissions} || []}) . ")" : ""; my $su = $_->{is_superuser} ? " (superuser)" : ""; say "* $_->{email}$perms$su"; @@ -129,7 +129,8 @@ foreach (FixMyStreet::Cobrand->available_cobrand_classes) { } } -my $num = 10; +my $user = $users{'user@example.org'}; +my $num = 20; say "Created $num problems around '$location' in cobrand '$cobrand'"; my $inaccurate_km = 0.01; my $confirmed = DateTime->today->subtract(days => 1)->add(hours => 8); @@ -143,8 +144,8 @@ for (1..$num) { areas => ',' . $opt->area_id . ',', user => $user, postcode => $location, - latitude => $lat + rand($inaccurate_km) - $inaccurate_km / 2, - longitude => $lon + rand($inaccurate_km) - $inaccurate_km / 2, + latitude => $lat + rand(2 * $inaccurate_km) - $inaccurate_km, + longitude => $lon + rand(3 * $inaccurate_km) - 1.5 * $inaccurate_km, category => $category, cobrand => $cobrand, title => $titles->[int(rand(@$titles))], @@ -153,6 +154,11 @@ for (1..$num) { }); } +for (1..3) { + my $p = $problems->[int(rand(@$problems))]; + $users{'inspector@example.org'}->add_to_planned_reports($p); +} + # Comment my $updates = []; diff --git a/perllib/FixMyStreet/Cobrand/Borsetshire.pm b/perllib/FixMyStreet/Cobrand/Borsetshire.pm index 89869ff1b..7ddcff469 100644 --- a/perllib/FixMyStreet/Cobrand/Borsetshire.pm +++ b/perllib/FixMyStreet/Cobrand/Borsetshire.pm @@ -15,10 +15,14 @@ sub example_places { sub pin_colour { my ( $self, $p, $context ) = @_; - #return 'grey' if $p->state eq 'not responsible'; - #return 'green' if $p->is_fixed || $p->is_closed; - #return 'red' if $p->state eq 'confirmed'; - return 'yellow'; + return 'grey' if $p->is_closed; + return 'green' if $p->is_fixed; + return 'yellow' if $p->state eq 'confirmed'; + return 'orange'; # all the other `open_states` like "in progress" +} + +sub path_to_pin_icons { + return '/cobrands/oxfordshire/images/'; } sub send_questionnaires { diff --git a/templates/web/borsetshire/auth/_general_top.html b/templates/web/borsetshire/auth/_general_top.html index efff99018..6e65bf90b 100644 --- a/templates/web/borsetshire/auth/_general_top.html +++ b/templates/web/borsetshire/auth/_general_top.html @@ -1,4 +1,5 @@ -<p>The following users exist, all with password <kbd>password</kbd>:</p> +<p>The following users exist, all with password <kbd>password</kbd> +(click them to quickly log in):</p> <style> #demo-user-list dt { padding: 0 0.5em; diff --git a/web/cobrands/borsetshire/js.js b/web/cobrands/borsetshire/js.js index b612c3a8b..eee78df43 100644 --- a/web/cobrands/borsetshire/js.js +++ b/web/cobrands/borsetshire/js.js @@ -1,9 +1,26 @@ (function(){ + + function set_redirect(form) { + var e = form.email.value; + if (e == 'inspector@example.org') { + form.r.value = 'my/planned'; + } else if (e == 'cs@example.org') { + form.r.value = 'reports'; + } else if (e == 'super@example.org') { + form.r.value = 'admin'; + } + } + $('#demo-user-list dt').click(function(){ var form = document.forms.general_auth; form.email.value = $(this).text(); form.password_sign_in.value = 'password'; - form.r.value = 'admin'; + set_redirect(form); form.submit(); }); + + $('form[name=general_auth]').on('submit', function() { + set_redirect(this); + }); + })(); |