ready to alpha test

This commit is contained in:
Massimiliano Assante 2021-11-10 11:13:03 +01:00
parent 8f16a1daba
commit beb35222ca
3 changed files with 163 additions and 139 deletions

View File

@ -110,9 +110,7 @@ public class CompileForm extends MVCPortlet {
_log.debug("organisationType:" + organisationType); _log.debug("organisationType:" + organisationType);
_log.debug("email:" + emailAddress); _log.debug("email:" + emailAddress);
_log.debug("country:" + country); _log.debug("country:" + country);
_log.debug("participatedInActivities:" + participatedInActivities); _log.info("participatedInActivities:" + participatedInActivities);
_log.debug("textareaMotivation:\n" + textareaMotivation+"\n");
_log.info("itemsAreaOfExpertise (Multi):\n");
Connection conn; Connection conn;
try { try {
@ -124,9 +122,8 @@ public class CompileForm extends MVCPortlet {
String mainMotivation = ""; String mainMotivation = "";
for (int i = 0; i < mainMotivationValues.length; i++) { for (int i = 0; i < mainMotivationValues.length; i++) {
System.out.println(i+"mainMotivationValues[i]="+mainMotivationValues[i]);
boolean valueTrue = Boolean.parseBoolean(mainMotivationValues[i]); boolean valueTrue = Boolean.parseBoolean(mainMotivationValues[i]);
if (valueTrue) if (valueTrue && i > 0)
mainMotivation += main_motivations[i-1]+"; "; //0 is a placeholder always false mainMotivation += main_motivations[i-1]+"; "; //0 is a placeholder always false
} }
@ -139,7 +136,7 @@ public class CompileForm extends MVCPortlet {
for (int i = 0; i < itemsAreaOfExpertiseSelectValues.length; i++) { for (int i = 0; i < itemsAreaOfExpertiseSelectValues.length; i++) {
boolean valueTrue = Boolean.parseBoolean(itemsAreaOfExpertiseSelectValues[i]); boolean valueTrue = Boolean.parseBoolean(itemsAreaOfExpertiseSelectValues[i]);
if (valueTrue) if (valueTrue && i > 0)
areaOfExpertise += areas_of_expertise[i-1]+"; "; areaOfExpertise += areas_of_expertise[i-1]+"; ";
} }
@ -148,91 +145,91 @@ public class CompileForm extends MVCPortlet {
String[] degree_of_participationValues = actionRequest.getParameterValues("commitment"); String[] degree_of_participationValues = actionRequest.getParameterValues("commitment");
list = getDgreesOfParticipation(conn); list = getDgreesOfParticipation(conn);
String[] degrees_of_participation = list.toArray(new String[0]); String[] degrees_of_participation = list.toArray(new String[0]);
String degree_of_participation = ""; String degreeOfParticipation = "";
for (int i = 0; i < degree_of_participationValues.length; i++) { for (int i = 0; i < degree_of_participationValues.length; i++) {
boolean valueTrue = Boolean.parseBoolean(degree_of_participationValues[i]); boolean valueTrue = Boolean.parseBoolean(degree_of_participationValues[i]);
if (valueTrue) if (valueTrue && i > 0)
degree_of_participation += degrees_of_participation[i-1]+"; "; //0 is a placeholder always false degreeOfParticipation += degrees_of_participation[i-1]+"; "; //0 is a placeholder always false
} }
System.out.println("degree_of_participation="+degree_of_participation); System.out.println("degree_of_participation="+degreeOfParticipation);
_log.debug("textareaExperience:\n" + elaborated_expertise+"\n"); _log.debug("textareaExperience:\n" + elaborated_expertise+"\n");
_log.info("Got form compiled, inserting in DB."); _log.info("Got form compiled, inserting in DB.");
// String insertTableSQL = "INSERT INTO forms(name, surname, organisation, organisation_type, email, " String insertTableSQL = "INSERT INTO forms(name, surname, organisation, organisation_type, email, "
// + "country, activities_participation, main_motivation, elaborated_motivation, area_of_expertise, " + "country, activities_participation, main_motivation, elaborated_motivation, area_of_expertise, "
// + "elaborated_expertise, degree_of_participation, data_management, datecreated, processed_form, user_accepted) " + "elaborated_expertise, degree_of_participation, data_management, datecreated, processed_form, user_accepted) "
// + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,current_timestamp,?,?)"; + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,current_timestamp,?,?)";
//
// PreparedStatement preparedStatement = conn.prepareStatement(insertTableSQL); PreparedStatement preparedStatement = conn.prepareStatement(insertTableSQL);
// preparedStatement.setString(1, name); preparedStatement.setString(1, name);
// preparedStatement.setString(2, surname); preparedStatement.setString(2, surname);
// preparedStatement.setString(3, organisation); preparedStatement.setString(3, organisation);
// preparedStatement.setString(4, organisationType); preparedStatement.setString(4, organisationType);
// preparedStatement.setString(5, emailAddress); preparedStatement.setString(5, emailAddress);
// preparedStatement.setString(6, country); preparedStatement.setString(6, country);
// preparedStatement.setBoolean(7, participatedInActivities); preparedStatement.setBoolean(7, participatedInActivities);
// preparedStatement.setString(8, mainMotivation); preparedStatement.setString(8, mainMotivation);
// preparedStatement.setString(9, textareaMotivation); preparedStatement.setString(9, textareaMotivation);
// preparedStatement.setString(10, areaOfExpertise); preparedStatement.setString(10, areaOfExpertise);
// preparedStatement.setString(11, elaborated_expertise); preparedStatement.setString(11, elaborated_expertise);
// preparedStatement.setString(12, degree_of_participation); preparedStatement.setString(12, degreeOfParticipation);
// preparedStatement.setBoolean(13, true); //data_management preparedStatement.setBoolean(13, true); //data_management
// preparedStatement.setBoolean(14, false); //processed_form preparedStatement.setBoolean(14, false); //processed_form
// preparedStatement.setBoolean(15, false); //user_accepted preparedStatement.setBoolean(15, false); //user_accepted
// // execute insert SQL stetement // execute insert SQL stetement
// preparedStatement .executeUpdate(); preparedStatement .executeUpdate();
// _log.info("Inserting in DB done, sending confirmation to user and notification to managers via email"); _log.info("Inserting in DB done, sending confirmation to user and notification to managers via email");
//
// String copySubmitted = new StringBuffer("\n\n\nCOPY OF INFORMATION SUBMITTED\n\n") String copySubmitted = new StringBuffer("\n\n\nCOPY OF INFORMATION SUBMITTED\n\n")
// .append("\n").append("Name: ") .append("\n").append("Name: ")
// .append(name).append(" ").append(surname) .append(name).append(" ").append(surname)
// .append("\n").append("Organisation: ") .append("\n").append("Organisation: ")
// .append(organisation) .append(organisation)
// .append("\n").append("Organisation type: ") .append("\n").append("Organisation type: ")
// .append(organisationType) .append(organisationType)
// .append("\n").append("emailAddress: ") .append("\n").append("emailAddress: ")
// .append("*** hidden on purpose ***") .append("*** hidden on purpose ***")
// .append("\n").append("Country: ") .append("\n").append("Country: ")
// .append(country) .append(country)
// .append("\n\n").append("Have you participated in the activities of any of our MOVING Regional Multi-Actors Platforms? ") .append("\n\n").append("Have you participated in the activities of any of our MOVING Regional Multi-Actors Platforms? ")
// .append(participatedInActivities) .append(participatedInActivities)
// .append("\n\n").append("What is your main motivation for joining the EU MAP of MOVING? ") .append("\n\n").append("What is your main motivation for joining the EU MAP of MOVING? ")
// .append(mainMotivation) .append(mainMotivation)
// .append("\n\n").append("Please elaborate on your motivation expressed above so that we understand better your interest, and form a dynamic and relevant community. Vague explanations of the motivation might not be taken into consideration. ") .append("\n\n").append("Please elaborate on your motivation expressed above so that we understand better your interest, and form a dynamic and relevant community. Vague explanations of the motivation might not be taken into consideration. ")
// .append("\n\n").append(textareaMotivation).append("\n") .append("\n\n").append(textareaMotivation).append("\n")
// .append("\n\n").append("What is your main area of expertise in relation to mountain sustainability and resilience? (Multiple choice): ") .append("\n\n").append("What is your main area of expertise in relation to mountain sustainability and resilience? (Multiple choice): ")
// .append(areaOfExpertise) .append(areaOfExpertise)
// .append("\n\n").append("Please elaborate on the relevant experience you can bring to mountain value chains and the resilience of these areas, so that we have more detailed information to be able to form a dynamic and relevant community: ") .append("\n\n").append("Please elaborate on the relevant experience you can bring to mountain value chains and the resilience of these areas, so that we have more detailed information to be able to form a dynamic and relevant community: ")
// .append("\n\n").append(elaborated_expertise) .append("\n\n").append(elaborated_expertise)
// .append("\n\n").append("As a starting point, the degree of participation you commit to is: ") .append("\n\n").append("As a starting point, the degree of participation you commit to is: ")
// .append(degree_of_participation) .append(degreeOfParticipation)
// .append("\n").append("\n").append("Data Management: ") .append("\n").append("\n").append("Data Management: ")
// .append("Agreed") .append("Agreed")
// .append("\n\nEND COPY OF INFORMATION SUBMITTED\n\n").toString(); .append("\n\nEND COPY OF INFORMATION SUBMITTED\n\n").toString();
//
//
// Properties props = System.getProperties(); Properties props = System.getProperties();
// Session session = null; Session session = null;
// props.put("mail.smtp.host", mailServiceHost); props.put("mail.smtp.host", mailServiceHost);
// props.put("mail.smtp.port", mailServicePort); props.put("mail.smtp.port", mailServicePort);
// //use localhost (probaly postfix instance) //use localhost (probaly postfix instance)
// session = Session.getDefaultInstance(props); session = Session.getDefaultInstance(props);
//
// sendEmailConfirmationToUser(props, session, emailAddress, copySubmitted); sendEmailConfirmationToUser(props, session, emailAddress, copySubmitted);
//
// String groupIdVREforManagers = GetterUtil.getString(actionRequest.getPreferences().getValue("VREGroupId", StringPool.BLANK)); String groupIdVREforManagers = GetterUtil.getString(actionRequest.getPreferences().getValue("VREGroupId", StringPool.BLANK));
// if (groupIdVREforManagers != null && groupIdVREforManagers.compareTo("") != 0) { if (groupIdVREforManagers != null && groupIdVREforManagers.compareTo("") != 0) {
// HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(actionRequest); HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(actionRequest);
// sendEmailNotificationToVREManagers(httpRequest, props, session, groupIdVREforManagers, copySubmitted); sendEmailNotificationToVREManagers(httpRequest, props, session, groupIdVREforManagers, copySubmitted);
// } }
// else { else {
// _log.warn("WARNING, non config found for groupId, no email will be send to VRE Managers"); _log.warn("WARNING, non config found for groupId, no email will be send to VRE Managers");
// } }
} catch (Exception e) { } catch (Exception e) {
_log.error("Some error while trying to insert form"); _log.error("Some error while trying to insert form");

View File

@ -16,7 +16,7 @@
} }
#wrapper label { #wrapper label {
display: inline-block; display: block;
max-width: 100%; max-width: 100%;
margin-bottom: 5px; margin-bottom: 5px;
margin-top: 15px; margin-top: 15px;
@ -27,9 +27,10 @@
font-family: "Open Sans", Arial, sans-serif !important; font-family: "Open Sans", Arial, sans-serif !important;
} }
#wrapper label.checkbox { #wrapper label.checkbox, #wrapper label.radio {
margin-bottom: 0; margin-bottom: 0;
margin-top: 5px; margin-top: 5px;
margin-left: 20px;
display: block; display: block;
} }
.form-display { .form-display {

View File

@ -13,7 +13,7 @@ pageContext.setAttribute("main_motivations", main_motivations);
pageContext.setAttribute("areas_of_expertise", areas_of_expertise); pageContext.setAttribute("areas_of_expertise", areas_of_expertise);
pageContext.setAttribute("degrees_of_participation", degrees_of_participation); pageContext.setAttribute("degrees_of_participation", degrees_of_participation);
pageContext.setAttribute("required", "false"); pageContext.setAttribute("required", "true");
%> %>
<portlet:defineObjects /> <portlet:defineObjects />
<script src="https://www.google.com/recaptcha/api.js" async defer></script> <script src="https://www.google.com/recaptcha/api.js" async defer></script>
@ -32,7 +32,7 @@ pageContext.setAttribute("required", "false");
<aui:input label="Surname" name="surname" type="text" <aui:input label="Surname" name="surname" type="text"
required="${required}" style="width:300px;" /> required="${required}" style="width:300px;" />
<aui:input label="Organisation" name="organisation" type="text" <aui:input label="Organisation" name="organisation" type="text"
required="${required}" style="width:300px;" /> required="false" style="width:300px;" />
<!-- <!--
SELECT SELECT
--> -->
@ -51,19 +51,24 @@ pageContext.setAttribute("required", "false");
required="${required}" style="width:300px;" /> required="${required}" style="width:300px;" />
</aui:fieldset> </aui:fieldset>
<aui:fieldset> <aui:fieldset>
<aui:input id="participatedInActivities " type="checkbox"
name="participatedInActivities"
label=" Have you participated in the activities of any of our MOVING Regional Multi-Actors Platforms?"
required="${required}" />
<aui:field-wrapper name="participatedInActivitiesWrapper"
label=" Have you participated in the activities of any of our MOVING Regional Multi-Actors Platforms? (Required)">
<div class="control-group input-text-wrapper">
<aui:input label="Yes" name="participatedInActivities" type="radio"
value="true" />
<aui:input label="No" name="participatedInActivities" type="radio"
value="false" checked="true" />
</div>
</aui:field-wrapper>
<div class="control-group input-text-wrapper"> <div class="control-group input-text-wrapper">
<aui:field-wrapper name="mainMotivation" <aui:field-wrapper name="mainMotivation"
label="What is your main motivation for joining the EU MAP of MOVING? (Required)"> label="What is your main motivation for joining the EU MAP of MOVING? (Required)">
<!-- the first is needed as placeholder otherwise the validator does not work, make sure you take into account in the server part --> <!-- the first is needed as placeholder otherwise the validator does not work, make sure you take into account in the server part -->
<aui:input id="mainMotivation" type="checkbox" <aui:input id="mainMotivation" type="checkbox" name="mainMotivation"
name="mainMotivation" cssClass="first-checkbox-hidden" label=""/> cssClass="first-checkbox-hidden" label="" />
<c:forEach var="type" items="${main_motivations}"> <c:forEach var="type" items="${main_motivations}">
<aui:input id="mainMotivation" type="checkbox" <aui:input id="mainMotivation" type="checkbox"
name="mainMotivation" label="${type}" /> name="mainMotivation" label="${type}" />
@ -87,10 +92,12 @@ pageContext.setAttribute("required", "false");
mountain sustainability and resilience? (Required)"> mountain sustainability and resilience? (Required)">
<!-- the first is needed as placeholder otherwise the validator does not work, make sure you take into account in the server part --> <!-- the first is needed as placeholder otherwise the validator does not work, make sure you take into account in the server part -->
<aui:input id="areaOfExpertiseSelect" type="checkbox" <aui:input id="areaOfExpertiseSelect" type="checkbox"
name="areaOfExpertiseSelect" cssClass="first-checkbox-hidden" label=""/> name="areaOfExpertiseSelect" cssClass="first-checkbox-hidden"
label="" />
<c:forEach var="type" items="${areas_of_expertise}"> <c:forEach var="type" items="${areas_of_expertise}">
<aui:input id="areaOfExpertiseSelect" type="checkbox" <aui:input id="areaOfExpertiseSelect" type="checkbox"
name="areaOfExpertiseSelect" label="${type}" showRequiredLabel="false"/> name="areaOfExpertiseSelect" label="${type}"
showRequiredLabel="false" />
</c:forEach> </c:forEach>
</aui:field-wrapper> </aui:field-wrapper>
</div> </div>
@ -105,8 +112,8 @@ pageContext.setAttribute("required", "false");
<aui:field-wrapper name="commitment" <aui:field-wrapper name="commitment"
label="As a starting point, the degree of participation you commit to is: (Required)"> label="As a starting point, the degree of participation you commit to is: (Required)">
<!-- the first is needed as placeholder otherwise the validator does not work, make sure you take into account in the server part --> <!-- the first is needed as placeholder otherwise the validator does not work, make sure you take into account in the server part -->
<aui:input id="commitment" type="checkbox" <aui:input id="commitment" type="checkbox" name="commitment"
name="commitment" cssClass="first-checkbox-hidden" label=""/> cssClass="first-checkbox-hidden" label="" />
<c:forEach var="type" items="${degrees_of_participation}"> <c:forEach var="type" items="${degrees_of_participation}">
<aui:input id="commitment" type="checkbox" name="commitment" <aui:input id="commitment" type="checkbox" name="commitment"
label="${type}" /> label="${type}" />
@ -114,7 +121,7 @@ pageContext.setAttribute("required", "false");
</aui:field-wrapper> </aui:field-wrapper>
</div> </div>
<aui:spacer></aui:spacer> <div style="margin-top: 20px;">&nbsp;</div>
<p class="lead">Data Management</p> <p class="lead">Data Management</p>
<p> <p>
MOVING is responsible for the processing of the personal data MOVING is responsible for the processing of the personal data
@ -133,9 +140,9 @@ pageContext.setAttribute("required", "false");
Submit Button Submit Button
--> -->
<div style="width: 100%; text-align: center;"> <div style="width: 100%; text-align: center;">
<!-- <div class="g-recaptcha" --> <div class="g-recaptcha"
<!-- data-sitekey="6Ld0hfYZAAAAAKlIHde1v3QE4NyY4AniN6j-U9SP"></div> --> data-sitekey="6Ld0hfYZAAAAAKlIHde1v3QE4NyY4AniN6j-U9SP"></div>
<!-- <br /> --> <br />
<aui:button-row> <aui:button-row>
<aui:button value="Submit your application" type="submit" <aui:button value="Submit your application" type="submit"
cssClass="btn-large btn-fill" /> cssClass="btn-large btn-fill" />
@ -145,6 +152,25 @@ pageContext.setAttribute("required", "false");
</aui:form> </aui:form>
<!-- Validate the captcha -->
<script type="text/javascript">
AUI().use('aui-tooltip', 'aui-base', 'selector-css3', function(A) {
var form = A.one('#<portlet:namespace />fm');
if (form) {
form.on('submit', function(event) {
if (grecaptcha.getResponse() === '') {
event.halt();
event.stopImmediatePropagation();
alert('Please prove you are not a robot');
}
});
}
});
</script>
<!-- Validate the checkboxes, the number of min oprtions is configurable -->
<aui:script> <aui:script>
AUI().use('aui-form-validator', 'aui-overlay-context-panel', function(A) { AUI().use('aui-form-validator', 'aui-overlay-context-panel', function(A) {