Commit 72b07451 by Tuomas Riihimäki

Merge branch 'master' into restfix

2 parents 21932402 8a2b16a8
......@@ -105,12 +105,15 @@ public class MenuBean implements MenuBeanLocal {
userkauppa.addPage(menuitemfacade.findOrCreate("/shop/createBill"), BillPermission.CREATE_BILL);
userkauppa.addPage(menuitemfacade.findOrCreate("/foodwave/list"), ShopPermission.SHOP_FOODWAVE);
userkauppa.addPage(menuitemfacade.findOrCreate("/bill/list"), BillPermission.VIEW_OWN);
userkauppa.addPage(menuitemfacade.findOrCreate("/bill/edit"), BillPermission.VIEW_OWN).setVisible(false);
userkauppa.addPage(menuitemfacade.findOrCreate("/bill/showBill"), BillPermission.VIEW_OWN).setVisible(false);
userkauppa.addPage(menuitemfacade.findOrCreate("/user/accountEvents"), UserPermission.VIEW_ACCOUNTEVENTS);
MenuNavigation userPlaces = usermenu.addPage(null, null);
userPlaces.setKey("topnavi.userplaces");
userPlaces.addPage(menuitemfacade.findOrCreate("/place/placemap"), MapPermission.VIEW);
userPlaces.addPage(menuitemfacade.findOrCreate("/place/myGroups"), MapPermission.BUY_PLACES);
userPlaces.addPage(menuitemfacade.findOrCreate("/place/edit"), MapPermission.MANAGE_OTHERS).setVisible(false);
MenuNavigation usercompetitions = usermenu.addPage(null, null);
usercompetitions.setKey("topnavi.competitions");
......
......@@ -200,24 +200,33 @@ public class PlaceBean implements PlaceBeanLocal {
place = placeFacade.find(place.getId());
user = eventUserFacade.find(user.getId());
boolean ret = false;
if (place.isBuyable() && !place.isTaken()) {
place.setCurrentUser(user);
place.setReleaseTime(Calendar.getInstance());
place.getReleaseTime().add(Calendar.MINUTE, RESERVE_MINUTES);
// Create timeout service to timeout the reserved place in
// RESERVE_MINUTES
boolean foundTimeout = false;
for (Timer t : ts.getTimers()) {
if (t.getInfo().equals(PLACE_RESERVE_TIMEOUTER)) {
foundTimeout = true;
// when admin click's place, he reserves it -> just ignore it
if (!place.isTaken() || (permbean.hasPermission(MapPermission.MANAGE_OTHERS) && permbean.getCurrentUser().equals(place.getCurrentUser()) )) {
if (place.isBuyable() || permbean.hasPermission(MapPermission.MANAGE_OTHERS)) {
if(!place.isBuyable()) {
place.setBuyable(true);
}
place.setCurrentUser(user);
place.setReleaseTime(Calendar.getInstance());
place.getReleaseTime().add(Calendar.MINUTE, RESERVE_MINUTES);
// Create timeout service to timeout the reserved place in
// RESERVE_MINUTES
boolean foundTimeout = false;
for (Timer t : ts.getTimers()) {
if (t.getInfo().equals(PLACE_RESERVE_TIMEOUTER)) {
foundTimeout = true;
}
}
if (!foundTimeout) {
logger.info("Place timeout calculator not started. Starting new.");
ts.createTimer(new Date(), 1000 * 60, PLACE_RESERVE_TIMEOUTER);
}
ret = true;
}
if (!foundTimeout) {
logger.info("Place timeout calculator not started. Starting new.");
ts.createTimer(new Date(), 1000 * 60, PLACE_RESERVE_TIMEOUTER);
}
ret = true;
}
return ret;
}
......
package fi.codecrew.moya.model;
import java.math.BigDecimal;
import java.sql.Time;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
......@@ -25,9 +27,13 @@ import javax.validation.constraints.NotNull;
import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;
import org.eclipse.persistence.annotations.PrivateOwned;
import org.eclipse.persistence.annotations.TimeOfDay;
import org.eclipse.persistence.jpa.jpql.parser.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.sun.xml.ws.commons.xmlutil.Converter;
import fi.codecrew.moya.enums.Gender;
import fi.codecrew.moya.utilities.PasswordFunctions;
......@@ -366,5 +372,41 @@ public class User extends GenericEntity implements IUser {
public void setLicenseCodes(List<LicenseCode> codes) {
this.licenseCodes = codes;
}
public BigDecimal getAge() {
BigDecimal age = new BigDecimal(0);
if(birthday != null) {
Calendar calBirthday = Calendar.getInstance();
calBirthday.setTime(birthday);
Calendar calNow = Calendar.getInstance();
int yearB = calBirthday.get(Calendar.YEAR);
int yearNow = calNow.get(Calendar.YEAR);
int years = yearNow - yearB -1;
int dayOfYearBirthDay = calBirthday.get(Calendar.DAY_OF_YEAR);
int dayOfYear = calNow.get(Calendar.DAY_OF_YEAR);
int days = 0;
if(dayOfYearBirthDay > dayOfYear) {
calBirthday.set(Calendar.YEAR, yearNow - 1);
days = 365 - calBirthday.get(Calendar.DAY_OF_YEAR) + dayOfYear;
} else {
days = dayOfYear - dayOfYearBirthDay;
}
BigDecimal decimalYears = new BigDecimal(years);
float fraction = (float)((float)days/(float)365);
BigDecimal decimalDays = new BigDecimal(fraction);
age = age.add(decimalYears);
age = age.add(decimalDays);
System.out.print("Years: " + years + "\n");
System.out.print("Days: " + days + "\n");
System.out.print("Fraction of days: " + fraction + "\n");
}
return age;
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:map="http://java.sun.com/jsf/composite/cditools/map" xmlns:tools="http://java.sun.com/jsf/composite/cditools"
xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:map="http://java.sun.com/jsf/composite/cditools/map"
xmlns:tools="http://java.sun.com/jsf/composite/cditools"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
......
......@@ -100,6 +100,12 @@
<h:outputText value="#{user.firstnames}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['user.lastName']}" />
</f:facet>
<h:outputText value="#{user.lastname}"/>
</h:column>
<h:column>
<h:commandButton action="#{placeView.reserveForUser()}" value="#{i18n['place.reserveForUser']}" />
</h:column>
</h:dataTable>
......
......@@ -29,7 +29,7 @@
<p:overlayPanel id="chartPanel" for="webcamButton" hideEffect="fade">
<p:photoCam widgetVar="pc" listener="#{userView.oncapture}" update="@all" />
<p:photoCam widgetVar="pc" listener="#{userView.oncapture}" update="@all" />
<p:commandButton type="button" value="Capture" onclick="PF('pc').capture()" onerror="location.reload(true);" />
</p:overlayPanel>
......@@ -112,8 +112,21 @@
<br />
<p:commandButton ajax="false" rendered="#{cc.attrs.creating or userView.canSave}" id="commitbtn" action="#{cc.attrs.commitaction}" value="#{cc.attrs.commitvalue}" onerror="location.reload(true);"/>
<p:commandButton ajax="false" rendered="#{cc.attrs.creating or userView.canSave}" id="commitbtn" action="#{cc.attrs.commitaction}" value="#{cc.attrs.commitvalue}" onerror="location.reload(true);" />
<br />
<br />
<p:lightBox iframe="true">
<h:outputLink value="http://codecrew.fi/rekisteriseloste.html" title="#{i18n['registerleaflet.title']}">
<h:outputText value="Rekisteriseloste" />
</h:outputLink>
</p:lightBox>
<br />
</h:panelGroup>
</h:panelGrid>
......
......@@ -86,59 +86,90 @@
<table>
<ui:fragment rendered="#{!cc.attrs.creating}">
<tr>
<td colspan="2"><h:outputLabel for="login" value="#{i18n['user.login']}" /><br /> <h:outputText value="#{userView.selectedUser.login}" id="login" /></td>
<td colspan="2"><b><h:outputLabel for="login" value="#{i18n['user.login']}" /></b><br />
<h:outputText value="#{userView.selectedUser.login}" id="login" />
</td>
</tr>
</ui:fragment>
<tr>
<td colspan="2"><h:outputLabel value="#{i18n['user.nick']}" for="nick" /> <br /> <p:inplace emptyLabel="#{i18n['user.insert']}">
<p:inputText size="45" id="nick" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.nick}" />
</p:inplace></td>
<td colspan="2"><b><h:outputLabel value="#{i18n['user.nick']}" for="nick" /> </b><br />
<p:inplace emptyLabel="#{i18n['user.insert']}">
<p:inputText size="45" id="nick" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.nick}" />
</p:inplace>
</td>
</tr>
<tr>
<td><h:outputLabel value="#{i18n['user.firstNames']}" for="firstnames" /><br /> <p:inplace emptyLabel="#{i18n['user.insert']}">
<td><b><h:outputLabel value="#{i18n['user.firstNames']}" for="firstnames" /></b><br />
<p:inplace emptyLabel="#{i18n['user.insert']}">
<p:inputText size="22" id="firstnames" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.firstnames}" />
</p:inplace></td>
<td><h:outputLabel value="#{i18n['user.lastName']}" for="lastname" /><br /> <p:inplace emptyLabel="#{i18n['user.insert']}">
</p:inplace>
</td>
<td><b><h:outputLabel value="#{i18n['user.lastName']}" for="lastname" /></b><br />
<p:inplace emptyLabel="#{i18n['user.insert']}">
<p:inputText size="30" id="lastname" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.lastname}" />
</p:inplace></td>
</p:inplace>
</td>
</tr>
<tr>
<td><h:outputLabel for="birthday" value="#{i18n['user.birthday']}" /><br /> <p:inplace emptyLabel="#{i18n['user.insert']}">
<p:calendar id="birthday" navigator="true" yearRange="c-80:c-0" value="#{userView.selectedUser.birthday}">
<f:convertDateTime pattern="#{sessionHandler.dateFormat}" timeZone="#{sessionHandler.timezone}" />
</p:calendar>
</p:inplace> <h:message for="birthday" /></td>
<td><h:outputLabel value="#{i18n['user.sex']}" for="sex" /> <br /> <p:selectOneMenu disabled="#{!cc.attrs.creating and !userView.canSave}" id="sex" value="#{userView.selectedUser.gender}">
<td colspan="2"><b><h:outputLabel value="#{i18n['user.sex']}" for="sex" /></b> <br />
<p:selectOneMenu disabled="#{!cc.attrs.creating and !userView.canSave}" id="sex" value="#{userView.selectedUser.gender}">
<f:selectItem id="undefined" itemLabel="#{i18n['user.sex.UNDEFINED']}" itemValue="UNDEFINED" />
<f:selectItem id="male" itemLabel="#{i18n['user.sex.MALE']}" itemValue="MALE" />
<f:selectItem id="female" itemLabel="#{i18n['user.sex.FEMALE']}" itemValue="FEMALE" />
</p:selectOneMenu></td>
</p:selectOneMenu>
</td>
</tr>
<tr>
<td><b><h:outputLabel for="birthday" value="#{i18n['user.birthday']}" /></b><br />
<p:inplace emptyLabel="#{i18n['user.insert']}">
<p:calendar id="birthday" navigator="true" yearRange="c-80:c-0" value="#{userView.selectedUser.birthday}">
<f:convertDateTime pattern="#{sessionHandler.dateFormat}" timeZone="#{sessionHandler.timezone}" />
</p:calendar>
</p:inplace> <h:message for="birthday" />
</td>
<td><b><h:outputLabel for="age" value="#{i18n['user.age']}" /></b><br />
<h:outputText value="#{userView.selectedUser.user.age}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2"/>
</h:outputText>
</td>
</tr>
</table>
<table>
<tr>
<td colspan="2"><p:outputLabel value="#{i18n['user.address']}" for="address" /><br /> <p:inplace emptyLabel="#{i18n['user.insert']}">
<td colspan="2"><b><p:outputLabel value="#{i18n['user.address']}" for="address" /></b><br />
<p:inplace emptyLabel="#{i18n['user.insert']}">
<p:inputText size="45" id="address" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.address}" />
</p:inplace></td>
</p:inplace>
</td>
</tr>
<tr>
<td><p:outputLabel value="#{i18n['user.zipCode']}" for="zip" /><br /> <p:inplace emptyLabel="#{i18n['user.insert']}">
<td><b><p:outputLabel value="#{i18n['user.zipCode']}" for="zip" /></b><br />
<p:inplace emptyLabel="#{i18n['user.insert']}">
<p:inputText styleClass="ui-input" size="7" id="zip" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.zip}" />
</p:inplace> <p:message for="zip" /></td>
<td><p:outputLabel value="#{i18n['user.town']}" for="town" /><br /> <p:inplace emptyLabel="#{i18n['user.insert']}">
</p:inplace> <p:message for="zip" />
</td>
<td><b><p:outputLabel value="#{i18n['user.town']}" for="town" /></b><br />
<p:inplace emptyLabel="#{i18n['user.insert']}">
<p:inputText styleClass="ui-input" size="25" id="town" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.town}" />
</p:inplace> <p:message for="town" /></td>
</p:inplace> <p:message for="town" />
</td>
</tr>
<tr>
<td colspan="2"><h:outputLabel value="#{i18n['user.email']}" for="email" /> <br /> <p:inplace emptyLabel="#{i18n['user.insert']}">
<td colspan="2"><b><h:outputLabel value="#{i18n['user.email']}" for="email" /></b> <br />
<p:inplace emptyLabel="#{i18n['user.insert']}">
<p:inputText validator="#{userValidator.validateEmail}" size="45" id="email" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.email}" />
</p:inplace></td>
</p:inplace>
</td>
</tr>
<tr>
<td><p:outputLabel value="#{i18n['user.phone']}" for="phone" /><br /> <p:inplace emptyLabel="#{i18n['user.insert']}">
<td><b><p:outputLabel value="#{i18n['user.phone']}" for="phone" /></b><br />
<p:inplace emptyLabel="#{i18n['user.insert']}">
<p:inputText styleClass="ui-input" size="7" id="phone" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.phone}" />
</p:inplace> <p:message for="phone" /></td>
</p:inplace> <p:message for="phone" />
</td>
</tr>
</table>
......
......@@ -103,7 +103,7 @@
<nav>
<div id="menu">
<p:panelMenu model="#{primeMenuView.menuModel}" />
<p:panelMenu model="#{primeMenuView.menuModel}" />
<h:link style="font-size: 10px;" rendered="#{readerView.shopToOthers}" outcome="/shop/showReaderEvents" value="Readers" />
</div>
</nav>
......
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:users="http://java.sun.com/jsf/composite/cditools/user"
xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:users="http://java.sun.com/jsf/composite/cditools/user" xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:p="http://primefaces.org/ui">
<h:body>
<ui:composition template="#{sessionHandler.template}">
<f:metadata>
<f:event type="preRenderView" listener="#{userView.initCreateView}" />
</f:metadata>
<ui:define name="content">
<users:create creating="true" commitaction="#{userView.createUser()}" commitvalue="#{i18n['user.create']}" />
<users:create creating="true" commitaction="#{userView.createUser()}" commitvalue="#{i18n['user.create']}" />
</ui:define>
</ui:composition>
......
......@@ -156,7 +156,8 @@ global.notauthorized = You don't have enough rights to enter this site.
global.save = Save
httpsession.creationTime = Created
incomingflow.giveplace = Merkitse annetuksi
incomingflow.giveplace = Merkitse annetuksi
lanEventPrivateProperty.defaultValue = Default value
lanEventPrivateProperty.editProperty = Edit property
......@@ -220,6 +221,8 @@ productshop.minusTen = -10
productshop.plusOne = +1
productshop.plusTen = +10
registerleaflet.title = Rekisteriseloste
resetMail.header = Reset lost password
resetMail.username = Username
......
......@@ -799,6 +799,8 @@ readerevent.tagname = Tag
readerview.cards = Card ( printcount )
registerleaflet.title = Register leaflet
resetMail.body = You can change a forgotten password by inserting your username or email address to the field below. A link where you can change the password will be sent to the email address associated to that.
resetMail.email = Email address
resetMail.header = Reset lost password
......@@ -1151,6 +1153,7 @@ user.accountBalance = Account balance
user.accountEventHeader = Account events
user.accountevents = Account events
user.address = Address
user.age = Age
user.bank = Bank
user.bankaccount = Bank number
user.birthday = Birthday
......
......@@ -785,6 +785,8 @@ readerevent.tagname = Tagi
readerview.cards = Kortit ( tulostuslkm )
registerleaflet.title = Rekisteriseloste
resetMail.body = Voit vaihtaa unohtuneen salasanan sy\u00F6tt\u00E4m\u00E4ll\u00E4 k\u00E4ytt\u00E4j\u00E4tunnuksesi tai tunnukseen liitetyn s\u00E4hk\u00F6postiosoitteen allaolevaan kentt\u00E4\u00E4n. Tunnukseen liitettyyn s\u00E4hk\u00F6postiosoitteeseen l\u00E4hetet\u00E4\u00E4n kertak\u00E4ytt\u00F6inen osoite jossa voit vaihtaa sy\u00F6tt\u00E4m\u00E4si k\u00E4ytt\u00E4j\u00E4tunnuksen salasanan.
resetMail.email = S\u00E4hk\u00F6postiosoite
resetMail.header = Salasana unohtunut?
......@@ -1136,9 +1138,10 @@ user.accountBalance = Tilin saldo
user.accountEventHeader = Tilitapahtumat
user.accountevents = Tilitapahtumat
user.address = Osoite
user.age = Ik
user.bank = Pankki
user.bankaccount = Pankkitili
user.birthday = Syntym\u00E4p\u00E4iv\u00E4
user.birthday = Syntym\u00E4aika
user.cardPower = K\u00E4ytt\u00E4j\u00E4tyyppi
user.changePassword = Vaihda salasana
user.changepassword.forUser = K\u00E4ytt\u00E4j\u00E4lle
......
......@@ -91,12 +91,18 @@ public class PrimeMenuView extends GenericCDIView {
{
menuModel = new DefaultMenuModel();
MenuNavigation selectedTop = layoutview.getSelectedTopmenu();
if (selectedTop == null)
if (selectedTop == null) {
return null;
}
int testid = 3;
for (MenuNavigation m : selectedTop.getChildren()) {
if (m.getItem() != null && m.getChildren().isEmpty()) {
DefaultMenuItem menuitem = mkMenuitem(m);
if (menuitem != null) {
menuModel.addElement(menuitem);
}
......
......@@ -44,14 +44,19 @@ public class UserCartView extends GenericCDIView {
public StreamedContent getDownloadCsv() {
StringBuilder sb = new StringBuilder();
sb.append("firstname").append(CSV_SEPARATOR);
sb.append("lastname").append(CSV_SEPARATOR);
sb.append("nick").append(CSV_SEPARATOR);
sb.append("login").append(CSV_SEPARATOR);
sb.append("birthday").append(CSV_SEPARATOR);
sb.append("phone").append(CSV_SEPARATOR);
sb.append("email").append(CSV_SEPARATOR);
sb.append("places").append(CSV_SEPARATOR);
sb.append("Firstname").append(CSV_SEPARATOR);
sb.append("Lastname").append(CSV_SEPARATOR);
sb.append("Nick").append(CSV_SEPARATOR);
sb.append("Login").append(CSV_SEPARATOR);
sb.append("Birthday").append(CSV_SEPARATOR);
sb.append("Age").append(CSV_SEPARATOR);
sb.append("Phone").append(CSV_SEPARATOR);
sb.append("Email").append(CSV_SEPARATOR);
sb.append("Street").append(CSV_SEPARATOR);
sb.append("Zip").append(CSV_SEPARATOR);
sb.append("City").append(CSV_SEPARATOR);
sb.append("Places").append(CSV_SEPARATOR);
sb.append("\n");
for (EventUser uc : usercart)
{
......@@ -60,8 +65,12 @@ public class UserCartView extends GenericCDIView {
sb.append(uc.getNick()).append(CSV_SEPARATOR);
sb.append(uc.getLogin()).append(CSV_SEPARATOR);
sb.append(uc.getBirthday() != null ? dateformat.format(uc.getBirthday()) : "").append(CSV_SEPARATOR);
sb.append(uc.getUser().getAge()).append(CSV_SEPARATOR);
sb.append(uc.getPhone()).append(CSV_SEPARATOR);
sb.append(uc.getEmail()).append(CSV_SEPARATOR);
sb.append(uc.getAddress()).append(CSV_SEPARATOR);
sb.append(uc.getZip()).append(CSV_SEPARATOR);
sb.append(uc.getUser().getTown()).append(CSV_SEPARATOR);
for (GroupMembership gm : uc.getGroupMemberships())
{
if (gm.getPlaceReservation() != null)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!