fix registration form post request callback, refactor api/register route
This commit is contained in:
parent
cae6e7572e
commit
0f2c6bb3cc
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,5 +2,5 @@
|
|||||||
/logs/*
|
/logs/*
|
||||||
!/logs/README.md
|
!/logs/README.md
|
||||||
/templates/.cache
|
/templates/.cache
|
||||||
/db/ggdworkshop.db
|
/db/surfaces2018.db
|
||||||
/db/.schema.lock
|
/db/.schema.lock
|
||||||
|
@ -10,8 +10,8 @@ $().ready(function(){
|
|||||||
$("#txtbda,#txteda").datepicker({
|
$("#txtbda,#txteda").datepicker({
|
||||||
|
|
||||||
dateFormat: "dd/mm/yy",
|
dateFormat: "dd/mm/yy",
|
||||||
minDate:new Date(2018,6,16),
|
minDate:new Date(2018,11,17),
|
||||||
maxDate:new Date(2018,7,3)
|
maxDate:new Date(2018,11,19)
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#pais").select2({
|
$("#pais").select2({
|
||||||
@ -67,7 +67,7 @@ function select2Focus() {
|
|||||||
if(grecaptcha.getResponse() == "") return true;
|
if(grecaptcha.getResponse() == "") return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -94,12 +94,24 @@ function select2Focus() {
|
|||||||
formdata.find(item => item.name === "pais").value = $("#pais").select2("data")[0].text;
|
formdata.find(item => item.name === "pais").value = $("#pais").select2("data")[0].text;
|
||||||
formdata.find(item => item.name === "roomtype").value = $("#roomtype").select2("data")[0].text;
|
formdata.find(item => item.name === "roomtype").value = $("#roomtype").select2("data")[0].text;
|
||||||
var parameters = $.param(formdata);
|
var parameters = $.param(formdata);
|
||||||
$.post('api/register', parameters)
|
/*$.ajax({
|
||||||
.done(function(data){
|
url: 'api/register',
|
||||||
alert("post done");
|
type: "POST",
|
||||||
|
data: parameters,
|
||||||
|
success:function(result){
|
||||||
|
console.log(result);
|
||||||
|
},
|
||||||
|
error: function(jqxhr, status, exception){
|
||||||
|
console.log(exception);
|
||||||
|
console.log(jqxhr);
|
||||||
|
}
|
||||||
|
});*/
|
||||||
|
|
||||||
|
var req = $.post('api/register', parameters)
|
||||||
|
req.done(function(data){
|
||||||
|
|
||||||
if(data.success){
|
if(data.success){
|
||||||
alert("peter");
|
|
||||||
validator.resetForm();
|
validator.resetForm();
|
||||||
reset($("#registerform"));
|
reset($("#registerform"));
|
||||||
showMsg(false,data.msg);
|
showMsg(false,data.msg);
|
||||||
|
@ -97,21 +97,18 @@ $app->group('/api', function($app){
|
|||||||
$app->post('/register', function (Request $request, Response $response, array $args) {
|
$app->post('/register', function (Request $request, Response $response, array $args) {
|
||||||
$messages = $this->flash;
|
$messages = $this->flash;
|
||||||
$data = $request->getParsedBody();
|
$data = $request->getParsedBody();
|
||||||
|
$db = $this->db;
|
||||||
if($this->settings['close_registration']){
|
if($this->settings['close_registration']){
|
||||||
$messages->addMessageNow("submit-register-err", "Registration has benn closed");
|
$messages->addMessageNow("submit-register-err", "Registration has benn closed");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$db = $this->db;
|
|
||||||
if(!isset($data['nombre'])||empty($data['nombre']))
|
if(!isset($data['nombre'])||empty($data['nombre']))
|
||||||
$messages->addMessageNow("submit-register-err", "First name could not be empty");
|
$messages->addMessageNow("submit-register-err", "First name could not be empty");
|
||||||
if(!isset($data['apellido'])||empty($data['apellido']))
|
if(!isset($data['apellido'])||empty($data['apellido']))
|
||||||
$messages->addMessageNow("submit-register-err", "Last name could not be empty");
|
$messages->addMessageNow("submit-register-err", "Last name could not be empty");
|
||||||
if(!isset($data['email'])||empty($data['email']))
|
if(!isset($data['email'])||empty($data['email']))
|
||||||
$messages->addMessageNow("submit-register-err", "E-mail could not be empty");
|
$messages->addMessageNow("submit-register-err", "E-mail could not be empty");
|
||||||
/*if(!isset($data['financiacion'])||!is_numeric($data['financiacion']))
|
|
||||||
$messages->addMessageNow("submit-register-err", "Question about financial support must have a selected answer");*/
|
|
||||||
/*if(!isset($data['invited'])||!is_numeric($data['invited']))
|
|
||||||
$messages->addMessageNow("submit-register-err", "Question about 'invited to participate in this conference' must have a selected answer");*/
|
|
||||||
if(!isset($data['letterinvited'])||!is_numeric($data['letterinvited']))
|
if(!isset($data['letterinvited'])||!is_numeric($data['letterinvited']))
|
||||||
$messages->addMessageNow("submit-register-err", "Question about needing a letter of invitation must have a selected answer");
|
$messages->addMessageNow("submit-register-err", "Question about needing a letter of invitation must have a selected answer");
|
||||||
|
|
||||||
@ -124,7 +121,7 @@ $app->group('/api', function($app){
|
|||||||
if($this->settings['testing']){
|
if($this->settings['testing']){
|
||||||
$recapsecret = $this->settings['recaptcha']['secrettest'];
|
$recapsecret = $this->settings['recaptcha']['secrettest'];
|
||||||
}
|
}
|
||||||
var_dump($recapsecret);
|
|
||||||
$recaptcha = new ReCaptcha\ReCaptcha($recapsecret);
|
$recaptcha = new ReCaptcha\ReCaptcha($recapsecret);
|
||||||
//get remote ip from request header TODO
|
//get remote ip from request header TODO
|
||||||
$resp = $recaptcha->verify($data['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
|
$resp = $recaptcha->verify($data['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
|
||||||
@ -140,14 +137,12 @@ $app->group('/api', function($app){
|
|||||||
if($db->findByMail($data['email']))
|
if($db->findByMail($data['email']))
|
||||||
$messages->addMessageNow("submit-register-err", $data['email']." is already registered<br/>"
|
$messages->addMessageNow("submit-register-err", $data['email']." is already registered<br/>"
|
||||||
."Please contact: <b>surfacedynamics2018@cmat.edu.uy</b>");
|
."Please contact: <b>surfacedynamics2018@cmat.edu.uy</b>");
|
||||||
else
|
}catch (Exception $e){
|
||||||
$db->insert($data);
|
|
||||||
}
|
|
||||||
catch (Exception $e){
|
|
||||||
$this->logger->debug("Submit register DB error: ".$e->getMessage());
|
$this->logger->debug("Submit register DB error: ".$e->getMessage());
|
||||||
$messages->addMessageNow("submit-register-err", "DB error: ".$e->getMessage());
|
$messages->addMessageNow("submit-register-err", "DB error: ".$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($messages->hasMessage("submit-register-err")){
|
if($messages->hasMessage("submit-register-err")){
|
||||||
$arrayresponse = array("success" => false,
|
$arrayresponse = array("success" => false,
|
||||||
"msg"=>"You registration could not be completed:\n",
|
"msg"=>"You registration could not be completed:\n",
|
||||||
@ -155,21 +150,25 @@ $app->group('/api', function($app){
|
|||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
try{
|
||||||
|
$db->insert($data);
|
||||||
|
}catch (Exception $e){
|
||||||
|
$this->logger->debug("Submit register DB error: ".$e->getMessage());
|
||||||
|
$messages->addMessageNow("submit-register-err", "DB error: ".$e->getMessage());
|
||||||
|
}
|
||||||
$arrayresponse = array("success" => true,
|
$arrayresponse = array("success" => true,
|
||||||
"msg"=>"You have been successfully registered to the GGDWorkshop",
|
"msg"=>"You have been successfully registered to the GGDWorkshop",
|
||||||
"data"=>$data);
|
"data"=>$data);
|
||||||
$msg = "Hello ".$data["nombre"]." ".$data["apellido"].",\n\n".
|
$mailbody = "Hello ".$data["nombre"]." ".$data["apellido"].",\n\n".
|
||||||
"You have been successfully registered to the Surface Dynamics 2018 Workshop!\n\n".
|
"You have been successfully registered to the Workshop on Surface Dynamics 2018!\n\n".
|
||||||
"For any questions please contact surfacedynamics2018@cmat.edu.uy\n\n".
|
"If you need to change the information you have provided on the registration and for any".
|
||||||
|
"questions please contact surfacedynamics2018@cmat.edu.uy\n\n".
|
||||||
"Best!\n\n";
|
"Best!\n\n";
|
||||||
$headers = 'From: ' . "surfacedynamics2018@cmat.edu.uy" . "\r\n" .
|
$headers = 'From: ' . "surfacedynamics2018@cmat.edu.uy" . "\r\n" .
|
||||||
'Reply-To: ' . "surfacedynamics2018@edu.uy" . "\r\n" .
|
'Reply-To: ' . "surfacedynamics2018@edu.uy" . "\r\n" .
|
||||||
'Content-Type: ' . "text/plain; charset=UTF-8". "\r\n" .
|
'Content-Type: ' . "text/plain; charset=UTF-8". "\r\n" .
|
||||||
'X-Mailer: PHP/' . phpversion();
|
'X-Mailer: PHP/' . phpversion();
|
||||||
mail($data['email'], 'Successfully registered to the Surface Dynamics 2018 Workshop', $msg, $headers);
|
mail($data['email'], 'Successfully registered to the Surface Dynamics 2018 Workshop', $mailbody, $headers);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
$newres = $response->withJson($arrayresponse);
|
$newres = $response->withJson($arrayresponse);
|
||||||
return $newres;
|
return $newres;
|
||||||
|
@ -3,18 +3,15 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<h1 id="welcome"><strong>Welcome!</strong></h1>
|
<h1 id="welcome"><strong>Welcome!</strong></h1>
|
||||||
<p>
|
<p>
|
||||||
The Dynamical Systems Group at the Universidad de la República has
|
The Dynamical Systems Group at the Universidad de la República is very honored to host a workshop
|
||||||
been organizing several international Conferences and
|
on the occasion of Patrice Le Calvez's 60th anniversary.
|
||||||
Workshops in the last 20 years, focusing on different aspects of
|
|
||||||
dynamics and related topics.
|
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
As our group expanded, both in number of participants and areas
|
The aim is to bring together top scientists working on surface topological dynamics to share their
|
||||||
of research, we are holding a Workshop on Groups, Geometry and Dynamics
|
knowledge and ideas.
|
||||||
on 2018 at Montevideo as a satellite conference of ICM 2018 (Rio de
|
</p>
|
||||||
Janeiro). The goal of the Workshop is to bring together top scientists
|
<p>
|
||||||
working on these areas to discuss new trends on these topics. The
|
The event will take place on december 17th–20th, 2018.
|
||||||
idea is to have few talks and lots of discussion time.
|
|
||||||
</p>
|
</p>
|
||||||
<hr class="separador">
|
<hr class="separador">
|
||||||
<!--<p>
|
<!--<p>
|
||||||
|
@ -197,19 +197,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<!--<fieldset disabled="disabled">-->
|
<!--<fieldset disabled="disabled">-->
|
||||||
</form>
|
</form>
|
||||||
<div id="statusmsg" class="alert alert-error">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<!--{% if flash("submit-register-err") %}
|
|
||||||
<div id="statusmsg" class="alert alert-error">
|
|
||||||
<strong>Error!</strong>
|
|
||||||
{% for msg in flash("submit-register-err") %}
|
|
||||||
<kbd>{{ msg }}.</kdb>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
{% endif %}-->
|
|
||||||
<div id="msgModal" class="modal fade" role="dialog">
|
<div id="msgModal" class="modal fade" role="dialog">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user