Skip to content

Commit

Permalink
Merge branch 'issues/#805-name-check-cobrand'
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Jul 31, 2015
2 parents 0d65707 + 392052b commit f929b3f
Show file tree
Hide file tree
Showing 85 changed files with 123 additions and 237 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ notifications:
- "irc.mysociety.org#fixmystreet"
use_notice: true
skip_join: true
webhooks:
urls:
- https://webhooks.gitter.im/e/863c1892a6a51e5a3b3c

language: perl
perl:
Expand Down
33 changes: 33 additions & 0 deletions perllib/FixMyStreet/Cobrand/UK.pm
Original file line number Diff line number Diff line change
Expand Up @@ -302,5 +302,38 @@ sub council_rss_alert_options {
return ( \@options, @reported_to_options ? \@reported_to_options : undef );
}

sub report_check_for_errors {
my $self = shift;
my $c = shift;

my %errors = $self->next::method($c);

my $report = $c->stash->{report};

if (!$errors{name} && (length($report->name) < 5
|| $report->name !~ m/\s/
|| $report->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 below'
);
}

# XXX Hardcoded body ID matching mapit area ID
if ( $report->bodies_str && $report->detail ) {
# Custom character limit:
# Bromley Council
if ( $report->bodies_str eq '2482' && length($report->detail) > 1750 ) {
$errors{detail} = sprintf( _('Reports are limited to %s characters in length. Please shorten your report'), 1750 );
}
# Oxfordshire
if ( $report->bodies_str eq '2237' && length($report->detail) > 1700 ) {
$errors{detail} = sprintf( _('Reports are limited to %s characters in length. Please shorten your report'), 1700 );
}
}

return %errors;
}

1;

20 changes: 0 additions & 20 deletions perllib/FixMyStreet/DB/Result/Problem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -405,14 +405,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 below'
) unless $self->cobrand eq 'emptyhomes';
}

if ( $self->category
&& $self->category eq _('-- Pick a category --') )
Expand All @@ -427,18 +419,6 @@ sub check_for_errors {
$self->category(undef);
}

if ( $self->bodies_str && $self->detail ) {
# Custom character limit:
# Bromley Council
if ( $self->bodies_str eq '2482' && length($self->detail) > 1750 ) {
$errors{detail} = sprintf( _('Reports are limited to %s characters in length. Please shorten your report'), 1750 );
}
# Oxfordshire
if ( $self->bodies_str eq '2237' && length($self->detail) > 1700 ) {
$errors{detail} = sprintf( _('Reports are limited to %s characters in length. Please shorten your report'), 1700 );
}
}

return \%errors;
}

Expand Down
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/DB/Result/User.pm
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ use mySociety::EmailUtil;

=head2 check_for_errors
$error_hashref = $problem->check_for_errors();
$error_hashref = $user->check_for_errors();
Look at all the fields and return a hashref with all errors found, keyed on the
field name. This is intended to be passed back to the form to display the
Expand Down
24 changes: 0 additions & 24 deletions t/app/model/problem.t
Original file line number Diff line number Diff line change
Expand Up @@ -66,30 +66,6 @@ for my $test (
name => 'Please enter your name',
}
},
{
desc => 'name too short',
changed => {
name => 'xx',
},
errors => {
title => 'Please enter a subject',
detail => 'Please enter some details',
bodies => 'No council selected',
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 below',
}
},
{
desc => 'name is anonymous',
changed => {
name => 'anonymous',
},
errors => {
title => 'Please enter a subject',
detail => 'Please enter some details',
bodies => 'No council selected',
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 below',
}
},
{
desc => 'correct name',
changed => {
Expand Down
2 changes: 2 additions & 0 deletions templates/web/barnet/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
[% INCLUDE 'common_header_tags.html', js_override = '/cobrands/fixmystreet/fixmystreet.js' %]
<script src="[% version('/js/fancybox/jquery.fancybox-1.3.4.pack.js') %]" charset="utf-8"></script>

[% PROCESS 'header_extra.html' %]

</head>
<body class="[% bodyclass | html IF bodyclass %]">
<div id="barnet-wrapper">
Expand Down
2 changes: 2 additions & 0 deletions templates/web/bromley/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

<link rel="Shortcut Icon" type="image/x-icon" href="/cobrands/bromley/favicon.ico">

[% PROCESS 'header_extra.html' %]

</head>
<body class="[% bodyclass | html IF bodyclass %]">
[%# ie_wrapper is to prevent a horizontal scrollbar in IE7, it appears (from Bromley site) %]
Expand Down
1 change: 1 addition & 0 deletions templates/web/fixmystreet-uk-councils/header_extra.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script src="[% start %][% version('/cobrands/fixmystreet-uk-councils/js.js') %]"></script>
48 changes: 0 additions & 48 deletions templates/web/fixmystreet.com/around/postcode_form.html

This file was deleted.

23 changes: 2 additions & 21 deletions templates/web/fixmystreet.com/header_extra.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
<link rel="Shortcut Icon" type="image/x-icon" href="/cobrands/fixmystreet.com/favicon.ico">

<script src="[% start %][% version('/js/jquery.cookie.min.js') %]" type="text/javascript" charset="utf-8"></script>

[%# We are conducting an A/B experiment on the homepage %]
[% IF c.req.uri.path == '/' %]
<script src="//www.google-analytics.com/cx/api.js?experiment=cX9Tbz_VRl-cZDM5WVRgTQ"></script>
<script>
var variation = cxApi.chooseVariation(),
docElement = document.documentElement,
className = docElement.className;
docElement.className = className + ' ' + 'variant' + variation;
</script>
<style>
html.variant1 #homepage-ab-test {
display: block;
}
html.variant1 #postcodeForm,
html.variant1 #front-main a#geolocate_link {
display: none;
}
</style>
[% END %]
<script src="[% start %][% version('/js/jquery.cookie.min.js') %]"></script>
<script src="[% start %][% version('/cobrands/fixmystreet.com/js.js') %]"></script>

[% INCLUDE 'tracking_code.html' %]
12 changes: 6 additions & 6 deletions templates/web/fixmystreet.com/next_steps.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ <h2>[% loc('Have you tried our mobile app?') %]</h2>
[% END %]
<p>[% loc('Download it now, and it’ll be ready to use when you next pick up your phone.') %]</p>
<p class="next-steps__step__cta">
<a href="https://itunes.apple.com/gb/app/fixmystreet/id297456545"><img src="/cobrands/fixmystreet/images/next-step-apple.png" alt="Download on the App Store" width="120" height="37"></a>
<a href="https://play.google.com/store/apps/details?id=org.mysociety.FixMyStreet"><img src="/cobrands/fixmystreet/images/next-step-google.png" alt="Android app on Google Play" width="120" height="37"></a>
<a href="https://itunes.apple.com/gb/app/fixmystreet/id297456545"><img src="/cobrands/fixmystreet.com/images/next-step-apple.png" alt="Download on the App Store" width="120" height="37"></a>
<a href="https://play.google.com/store/apps/details?id=org.mysociety.FixMyStreet"><img src="/cobrands/fixmystreet.com/images/next-step-google.png" alt="Android app on Google Play" width="120" height="37"></a>
</p>
</div>
<div class="next-steps__step next-steps__step--social">
Expand All @@ -25,18 +25,18 @@ <h2>[% loc('Spread the word about FixMyStreet!') %]</h2>
<p>[% loc('You know how to get things fixed - now make sure your friends do too.') %]</p>
[% END %]
<p class="next-steps__step__cta">
<a href="https://twitter.com/intent/tweet?text=[% twitter_comment | uri %]&amp;url=[% share_url | uri %]&amp;related=fixmystreet,mysociety"><img src="/cobrands/fixmystreet/images/next-step-twitter.png" alt="Tweet it" width="120" height="37"></a>
<a href="https://www.facebook.com/sharer/sharer.php?u=[% share_url | uri %]"><img src="/cobrands/fixmystreet/images/next-step-facebook.png" alt="Share on Facebook" width="120" height="37"></a>
<a href="https://twitter.com/intent/tweet?text=[% twitter_comment | uri %]&amp;url=[% share_url | uri %]&amp;related=fixmystreet,mysociety"><img src="/cobrands/fixmystreet.com/images/next-step-twitter.png" alt="Tweet it" width="120" height="37"></a>
<a href="https://www.facebook.com/sharer/sharer.php?u=[% share_url | uri %]"><img src="/cobrands/fixmystreet.com/images/next-step-facebook.png" alt="Share on Facebook" width="120" height="37"></a>
</p>
</div>
<div class="next-steps__step next-steps__step--goodies">
<h2>[% loc('Free FixMyStreet goodies for you!') %]</h2>
<a href="/posters">
<img src="/cobrands/fixmystreet/images/next-step-goodies.png" alt="" width="105" height="125" class="goodies-preview">
<img src="/cobrands/fixmystreet.com/images/next-step-goodies.png" alt="" width="105" height="125" class="goodies-preview">
</a>
<p>[% loc('Perfect for civic groups, clubs, and schools.') %]</p>
<p class="next-steps__step__cta">
<a href="/posters"><img src="/cobrands/fixmystreet/images/next-step-download.png" alt="Download" width="120" height="37"></a>
<a href="/posters"><img src="/cobrands/fixmystreet.com/images/next-step-download.png" alt="Download" width="120" height="37"></a>
</p>
</div>
</div>
46 changes: 23 additions & 23 deletions templates/web/fixmystreet.com/static/posters.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[% extra_css = BLOCK %]
<link rel="stylesheet" href="[% version('/cobrands/fixmystreet/posters.css') %]">
<link rel="stylesheet" href="[% version('/cobrands/fixmystreet.com/posters.css') %]">
[% END %]

[% INCLUDE header.html
Expand Down Expand Up @@ -54,7 +54,7 @@ <h1 id="goodies">FixMyStreet Goodies</h1>

<h2 id="activist-pack">The FMS Activist Pack</h2>

<img src="/cobrands/fixmystreet/images/pack-general.jpg" class="pack-preview" alt="">
<img src="/cobrands/fixmystreet.com/images/pack-general.jpg" class="pack-preview" alt="">

<p>Everything you need to help spread the word about FixMyStreet. Includes:</p>

Expand All @@ -66,11 +66,11 @@ <h2 id="activist-pack">The FMS Activist Pack</h2>
<li>Ideas for letting more people know about FixMyStreet</li>
</ul>

<a href="/cobrands/fixmystreet/posters/activist-pack.zip" data-goodielink="activist-pack" class="download-button">Download ZIP file</a>
<a href="/cobrands/fixmystreet.com/posters/activist-pack.zip" data-goodielink="activist-pack" class="download-button">Download ZIP file</a>

<h2 id="school-pack">Activity Pack for Schools, Brownies, and Scouts</h2>

<img src="/cobrands/fixmystreet/images/pack-schools.jpg" class="pack-preview" alt="">
<img src="/cobrands/fixmystreet.com/images/pack-schools.jpg" class="pack-preview" alt="">

<p>A special pack with activities suitable for groups of children. Includes:</p>

Expand All @@ -80,11 +80,11 @@ <h2 id="school-pack">Activity Pack for Schools, Brownies, and Scouts</h2>
<li>Ideas for activities</li>
</ul>

<a href="/cobrands/fixmystreet/posters/schools-clubs-pack.zip" data-goodielink="schools-clubs-pack" class="download-button">Download ZIP file</a>
<a href="/cobrands/fixmystreet.com/posters/schools-clubs-pack.zip" data-goodielink="schools-clubs-pack" class="download-button">Download ZIP file</a>

<h2 id="community-pack">Community Group Pack</h2>

<img src="/cobrands/fixmystreet/images/pack-community.jpg" class="pack-preview" alt="">
<img src="/cobrands/fixmystreet.com/images/pack-community.jpg" class="pack-preview" alt="">

<p>Materials for groups of adults who have a particular interest in their local community. Includes:</p>

Expand All @@ -96,7 +96,7 @@ <h2 id="community-pack">Community Group Pack</h2>
<li>Instructions for including a feed of local FixMyStreet reports on your site or blog</li>
</ul>

<a href="/cobrands/fixmystreet/posters/community-group-pack.zip" data-goodielink="community-group-pack" class="download-button">Download ZIP file</a>
<a href="/cobrands/fixmystreet.com/posters/community-group-pack.zip" data-goodielink="community-group-pack" class="download-button">Download ZIP file</a>

<h2 id="web">Website Badge</h2>

Expand All @@ -109,24 +109,24 @@ <h2 id="web">Website Badge</h2>
<h2 id="print">Printed Materials</h2>

<ul class="downloads">
<li><a href="/cobrands/fixmystreet/posters/fixmystreet-poster-a4.pdf" data-goodielink="fixmystreet-poster-a4">
<img src="/cobrands/fixmystreet/images/a4-poster.png" alt="">
<li><a href="/cobrands/fixmystreet.com/posters/fixmystreet-poster-a4.pdf" data-goodielink="fixmystreet-poster-a4">
<img src="/cobrands/fixmystreet.com/images/a4-poster.png" alt="">
<strong>A4 poster</strong> Ideal for a noticeboard at work, in the library, corner shop… wherever your community will see it.
</a></li>
<li><a href="/cobrands/fixmystreet/posters/fixmystreet-flyers-a5.pdf" data-goodielink="fixmystreet-flyers-a5">
<img src="/cobrands/fixmystreet/images/a5-flyers.png" alt="">
<li><a href="/cobrands/fixmystreet.com/posters/fixmystreet-flyers-a5.pdf" data-goodielink="fixmystreet-flyers-a5">
<img src="/cobrands/fixmystreet.com/images/a5-flyers.png" alt="">
<strong>A5 flyers (2 to a sheet)</strong> Perfect for handing out to friends or posting to subscribers.
</a></li>
<li><a href="/cobrands/fixmystreet/posters/fixmystreet-flyers-a6.pdf" data-goodielink="fixmystreet-flyers-a6">
<img src="/cobrands/fixmystreet/images/a6-flyers.png" alt="">
<li><a href="/cobrands/fixmystreet.com/posters/fixmystreet-flyers-a6.pdf" data-goodielink="fixmystreet-flyers-a6">
<img src="/cobrands/fixmystreet.com/images/a6-flyers.png" alt="">
<strong>A6 flyers (4 to a sheet)</strong> Great for cafés, pubs, or meetings.
</a></li>
<li><a href="/cobrands/fixmystreet/posters/fixmystreet-poop-flags.pdf" data-goodielink="fixmystreet-poop-flags">
<img src="/cobrands/fixmystreet/images/dog-poop-flags.png" alt="">
<li><a href="/cobrands/fixmystreet.com/posters/fixmystreet-poop-flags.pdf" data-goodielink="fixmystreet-poop-flags">
<img src="/cobrands/fixmystreet.com/images/dog-poop-flags.png" alt="">
<strong>Doggy poop flags (4 to a sheet)</strong> Take a stand against dog-fouling with our home-made flags. Some assembly required!
</a></li>
<li><a href="/cobrands/fixmystreet/posters/fixmystreet-poop-poster.pdf" data-goodielink="fixmystreet-poop-poster">
<img src="/cobrands/fixmystreet/images/dog-poop-poster.png" alt="">
<li><a href="/cobrands/fixmystreet.com/posters/fixmystreet-poop-poster.pdf" data-goodielink="fixmystreet-poop-poster">
<img src="/cobrands/fixmystreet.com/images/dog-poop-poster.png" alt="">
<strong>A4 &ldquo;We love our street&rsquo; dog poop poster</strong>
</a></li>
</ul>
Expand All @@ -136,16 +136,16 @@ <h2 id="adverts">Pre-made Adverts</h2>
<p>Ideal for promoting FixMyStreet in your community newsletter or local magazine. Specially designed to stand out, and get your message across!</p>

<ul class="downloads">
<li><a href="/cobrands/fixmystreet/posters/fixmystreet-promote-90x130.pdf" data-goodielink="fixmystreet-advert-90x130">
<img src="/cobrands/fixmystreet/images/promote-90x130.png" alt="">
<li><a href="/cobrands/fixmystreet.com/posters/fixmystreet-promote-90x130.pdf" data-goodielink="fixmystreet-advert-90x130">
<img src="/cobrands/fixmystreet.com/images/promote-90x130.png" alt="">
<strong>Quarter page advert</strong> (9cm wide, 13cm high)
</a></li>
<li><a href="/cobrands/fixmystreet/posters/fixmystreet-promote-90x60.pdf" data-goodielink="fixmystreet-advert-90x60">
<img src="/cobrands/fixmystreet/images/promote-90x60.png" alt="">
<li><a href="/cobrands/fixmystreet.com/posters/fixmystreet-promote-90x60.pdf" data-goodielink="fixmystreet-advert-90x60">
<img src="/cobrands/fixmystreet.com/images/promote-90x60.png" alt="">
<strong>One-eighth page advert</strong> (9cm wide, 6cm high)
</a></li>
<li><a href="/cobrands/fixmystreet/posters/fixmystreet-promote-40x60.pdf" data-goodielink="fixmystreet-advert-40x60">
<img src="/cobrands/fixmystreet/images/promote-40x60.png" alt="">
<li><a href="/cobrands/fixmystreet.com/posters/fixmystreet-promote-40x60.pdf" data-goodielink="fixmystreet-advert-40x60">
<img src="/cobrands/fixmystreet.com/images/promote-40x60.png" alt="">
<strong>One-sixteenth page advert</strong> (4cm wide, 6cm high)
</a></li>
</ul>
Expand Down
16 changes: 11 additions & 5 deletions templates/web/fixmystreet/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@
<meta name="mobileoptimized" content="0">

[% INCLUDE 'header_opengraph.html' %]
[% SET start = c.config.ADMIN_BASE_URL IF admin;

[% SET start = c.config.ADMIN_BASE_URL IF admin %]

<link rel="stylesheet" href="[% start %][% version('/cobrands/' _ c.cobrand.moniker _ '/base.css') %]">
<link rel="stylesheet" href="[% start %][% version('/cobrands/' _ c.cobrand.moniker _ '/layout.css') %]" media="(min-width:48em)">
# For clarity, the 'fixmystreet' moniker (for fixmystreet.com) puts
# it stylesheets under fixmystreet.com
IF c.cobrand.moniker == 'fixmystreet';
SET css_dir = 'fixmystreet.com';
ELSE;
SET css_dir = c.cobrand.moniker;
END %]
<link rel="stylesheet" href="[% start %][% version('/cobrands/' _ css_dir _ '/base.css') %]">
<link rel="stylesheet" href="[% start %][% version('/cobrands/' _ css_dir _ '/layout.css') %]" media="(min-width:48em)">
[% extra_css %]
<!--[if (lt IE 9) & (!IEMobile)]>
<link rel="stylesheet" href="[% start %][% version('/cobrands/' _ c.cobrand.moniker _ '/layout.css') %]">
<link rel="stylesheet" href="[% start %][% version('/cobrands/' _ css_dir _ '/layout.css') %]">
<![endif]-->

<script src="[% start %][% version('/js/modernizr.custom.js') %]" charset="utf-8"></script>
Expand Down
2 changes: 1 addition & 1 deletion templates/web/harrogate/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<link rel="canonical" href="https://www.fixmystreet.com[% c.req.uri.path_query %]">
[% END %]

[% TRY %][% PROCESS 'header_extra.html' %][% CATCH file %][% END %]
[% PROCESS 'header_extra.html' %]

</head>
[% TRY %][% PROCESS 'set_body_class.html' %][% CATCH file %][% END %]
Expand Down
Loading

0 comments on commit f929b3f

Please sign in to comment.