aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2012-03-15 16:07:50 +0000
committerStruan Donald <struan@exo.org.uk>2012-03-15 16:07:50 +0000
commitf67d9298a0727e44cf2ba12d9d58ee57973ebef0 (patch)
treeea8d5fd9a67b1ebf41ee0de5dd9fc29176d8c343
parent7c6ba5a5dac101bc7ac1629471162123ac204427 (diff)
first pass of using password to loging. needs lots of work still
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm17
-rw-r--r--phonegap/www/js/mobile.js32
-rw-r--r--phonegap/www/report_created.html130
3 files changed, 167 insertions, 12 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 724e84a41..70dee63c6 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -126,6 +126,7 @@ sub report_new_ajax : Path('mobile') : Args(0) {
unless ($c->forward('check_for_errors')) {
$c->stash->{ json_response } = { errors => $c->stash->{field_errors} };
+ $c->stash->{ json_response }->{check_name} = $c->user->name if $c->stash->{check_name};
$c->forward('send_json_response');
return 1;
}
@@ -141,12 +142,16 @@ sub report_new_ajax : Path('mobile') : Args(0) {
id => $report->id
}
} );
- $c->stash->{token_url} = $c->uri_for_email( '/P', $token->token );
- $c->send_email( 'problem-confirm.txt', {
- to => [ [ $report->user->email, $report->name ] ],
- } );
+ if ( $report->confirmed ) {
+ $c->stash->{ json_response } = { success => 1, report => $report->id };
+ } else {
+ $c->stash->{token_url} = $c->uri_for_email( '/P', $token->token );
+ $c->send_email( 'problem-confirm.txt', {
+ to => [ [ $report->user->email, $report->name ] ],
+ } );
+ $c->stash->{ json_response } = { success => 1 };
+ }
- $c->stash->{ json_response } = { success => 1 };
$c->forward('send_json_response');
}
@@ -156,7 +161,6 @@ sub send_json_response : Private {
my $body = JSON->new->utf8(1)->encode(
$c->stash->{json_response},
);
-
$c->res->content_type('application/json; charset=utf-8');
$c->res->body($body);
}
@@ -712,6 +716,7 @@ sub process_user : Private {
my $user = $c->user->obj;
$report->user( $user );
$report->name( $user->name );
+ $c->stash->{check_name} = 1;
$c->stash->{field_errors}->{name} = _('You have successfully signed in; please check and confirm your details are accurate:');
$c->log->info($user->id . ' logged in during problem creation');
return 1;
diff --git a/phonegap/www/js/mobile.js b/phonegap/www/js/mobile.js
index 55fca3d76..309b34073 100644
--- a/phonegap/www/js/mobile.js
+++ b/phonegap/www/js/mobile.js
@@ -195,12 +195,14 @@ function fileUploadFail() {
}
+var submit_clicked = null;
+
function postReport(e) {
e.preventDefault();
// the .stopImmediatePropogation call in invalidHandler should render this
// redundant but it doesn't seem to work so belt and braces :(
- if ( !$('#map_form').valid() ) { return; }
+ if ( !$('#mapForm').valid() ) { return; }
var params = {
service: 'iphone',
@@ -212,9 +214,17 @@ function postReport(e) {
category: $('#form_category').val(),
lat: $('#fixmystreet\\.latitude').val(),
lon: $('#fixmystreet\\.longitude').val(),
+ password_sign_in: $('#password_sign_in').val(),
+ phone: $('#form_phone').val(),
pc: $('#pc').val()
};
+ if ( submit_clicked.attr('id') == 'submit_sign_in' ) {
+ params.submit_sign_in = 1;
+ } else {
+ params.submit_register = 1;
+ }
+
if ( $('#form_photo').val() !== '' ) {
fileURI = $('#form_photo').val();
@@ -227,20 +237,29 @@ function postReport(e) {
var ft = new FileTransfer();
ft.upload(fileURI, CONFIG.FMS_URL + "report/new/mobile", fileUploadSuccess, fileUploadFail, options);
} else {
- jQuery.ajax( {
+ jQuery.ajax( {
url: CONFIG.FMS_URL + "report/new/mobile",
type: 'POST',
data: params,
timeout: 30000,
success: function(data) {
- console.log( data );
if ( data.success ) {
- window.location = 'email_sent.html';
+ localStorage.pc = null;
+ localStorage.lat = null;
+ localStorage.long = null;
+ if ( data.report ) {
+ localStorage.report = data.report;
+ window.location = 'report_created.html';
+ } else {
+ window.location = 'email_sent.html';
+ }
} else {
- alert( 'Could not upload report');
+ if ( data.check_name ) {
+ $('#form_name').val( data.check_name );
+ $('#form_name').focus();
+ }
$('input[type=submit]').prop("disabled", false);
}
- return false;
},
error: function (data, status, errorThrown ) {
alert( 'There was a problem submitting your report, please try again: ' + data, function(){}, 'Submit report' );
@@ -254,5 +273,6 @@ $(function(){
$('#postcodeForm').submit(locate);
$('#mapForm').submit(postReport);
$('#ffo').click(getPosition);
+ $('#mapForm :input[type=submit]').on('click', function() { submit_clicked = $(this); });
});
diff --git a/phonegap/www/report_created.html b/phonegap/www/report_created.html
new file mode 100644
index 000000000..654beef53
--- /dev/null
+++ b/phonegap/www/report_created.html
@@ -0,0 +1,130 @@
+<!doctype html>
+<!--[if lt IE 7]><html class="no-js ie6 oldie" lang="en-gb"><![endif]-->
+<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en-gb"><![endif]-->
+<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en-gb"><![endif]-->
+<!--[if IE 9]> <html class="no-js ie9 oldie" lang="en-gb"><![endif]-->
+<!--[if gt IE 9]><!--><html class="no-js" lang="en-gb"><!--<![endif]-->
+ <head>
+ <meta name="viewport" content="initial-scale=1.0">
+
+ <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
+ <meta name="HandHeldFriendly" content="true">
+ <meta name="mobileoptimized" content="0">
+
+ <link rel="stylesheet" href="css/base.css">
+ <link rel="stylesheet" href="css/layout.css" media="(min-width:48em)">
+ <!--[if (lt IE 9) & (!IEMobile)]>
+ <link rel="stylesheet" href="/cobrands/fixmystreet/layout.css?1331294274">
+ <![endif]-->
+
+ <script type="text/javascript">
+ validation_strings = {
+ update: 'Please enter a message',
+ title: 'Please enter a subject',
+ detail: 'Please enter some details',
+ name: {
+ required: 'Please enter your name',
+ validName: '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'
+ },
+ category: 'Please choose a category',
+ rznvy: {
+ required: 'Please enter your email',
+ email: 'Please enter a valid email'
+ },
+ email: {
+ required: 'Please enter your email',
+ email: 'Please enter a valid email'
+ }
+ };
+
+
+</script>
+
+
+<meta http-equiv="content-type" content="text/html; charset=utf-8">
+<script type="text/javascript" src="js/config.js"></script>
+<script type="text/javascript" charset="utf-8" src="cordova-1.5.0.js"></script>
+<script type="text/javascript" src="js/jquery-1.7.0.min.js"></script>
+<script src="js/jquery.validate.min.js" type="text/javascript" charset="utf-8"></script>
+<script src="js/modernizr.custom.61367.js" type="text/javascript" charset="utf-8"></script>
+<script type="text/javascript" src="js/geo.min.js"></script>
+<script type="text/javascript" src="js/fixmystreet.js"></script>
+<script type="text/javascript" src="js/mobile.js"></script>
+
+
+<script type="text/javascript">
+ $(function() {
+ var uri = CONFIG.FMS_URL + 'report/' + localStorage.report;
+ $('#report_url').html( '<a href="' + uri + '">' + uri + '</a>' );
+ });
+</script>
+
+
+
+ <meta name="robots" content="noindex,nofollow">
+
+
+
+
+<title>
+ Report Created ::
+ FixMyStreet
+</title>
+
+
+
+ </head>
+ <body class="">
+
+ <div class="wrapper">
+ <div class="table-cell">
+ <header id="site-header" role="banner">
+ <div class="container">
+ <a href="/" id="site-logo">FixMyStreet</a>
+ <a href="#main-nav" id="nav-link">Main Navigation</a>
+ </div>
+ </header>
+
+ <div id="user-meta">
+
+ <!-- <a href="/auth">Sign in</a> -->
+
+ </div>
+
+ <div class="container">
+ <div class="content" role="main">
+
+ <!--
+ -->
+
+
+
+
+<h1>Your report has been created</h1>
+
+ <p>You can view it on the site at <span id="report_url"></span></p>
+
+ </div><!-- .content role=main -->
+ </div><!-- .container -->
+ </div><!-- .table-cell -->
+
+ <div class="nav-wrapper">
+ <div class="nav-wrapper-2">
+ <div id="main-nav" role="navigation">
+ <ul id="mysoc-menu">
+ <li><a id="mysoc-logo" href="http://www.mysociety.org/">mySociety</a></li><li><a href="http://mysociety.org/donate/">Donate</a></li><li><a href="http://www.mysociety.org/projects/">Our Sites</a></li>
+ </ul>
+
+ <ul id="main-menu">
+ <li><a href="/" class="report-a-problem-btn">Report a problem</a></li><li><a href="/my">Your reports</a></li><li><a href="/reports">All reports</a></li><li><a href="/alert">Local alerts</a></li><li><a href="/faq">Help</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+
+<!--
+
+ -->
+ </div> <!-- .wrapper -->
+</body>
+</html>