Commit ee917ef4 by Riku Silvola

Merge branch 'master' of codecrew.fi:bortal

2 parents 7e7d27ae 6599c10a
...@@ -38,14 +38,7 @@ import fi.insomnia.bortal.utilities.I18n; ...@@ -38,14 +38,7 @@ import fi.insomnia.bortal.utilities.I18n;
*/ */
@Stateless @Stateless
@LocalBean @LocalBean
@DeclareRoles({ @DeclareRoles({ BillPermission.S_CREATE_BILL, BillPermission.S_READ_ALL, BillPermission.S_VIEW_OWN, BillPermission.S_WRITE_ALL, SpecialPermission.S_USER, SpecialPermission.S_VERKKOMAKSU_CHECK, })
BillPermission.S_CREATE_BILL,
BillPermission.S_READ_ALL,
BillPermission.S_VIEW_OWN,
BillPermission.S_WRITE_ALL,
SpecialPermission.S_USER,
SpecialPermission.S_VERKKOMAKSU_CHECK,
})
public class BillBean implements BillBeanLocal { public class BillBean implements BillBeanLocal {
private static final Logger logger = LoggerFactory.getLogger(BillBean.class); private static final Logger logger = LoggerFactory.getLogger(BillBean.class);
...@@ -92,7 +85,8 @@ public class BillBean implements BillBeanLocal { ...@@ -92,7 +85,8 @@ public class BillBean implements BillBeanLocal {
EventUser currentuser = permbean.getCurrentUser(); EventUser currentuser = permbean.getCurrentUser();
logger.debug("bill {} user {}", bill, currentuser); logger.debug("bill {} user {}", bill, currentuser);
if (bill != null && !currentuser.equals(bill.getUser()) && !permbean.hasPermission(BillPermission.READ_ALL)) { if (bill != null && !currentuser.equals(bill.getUser())
&& !permbean.hasPermission(BillPermission.READ_ALL)) {
bill = null; bill = null;
} }
return bill; return bill;
...@@ -197,26 +191,29 @@ public class BillBean implements BillBeanLocal { ...@@ -197,26 +191,29 @@ public class BillBean implements BillBeanLocal {
@Override @Override
@RolesAllowed(BillPermission.S_READ_ALL) @RolesAllowed(BillPermission.S_READ_ALL)
public Collection<BillSummary> getBillLineSummary() { public Collection<BillSummary> getBillLineSummary() {
Collection<BillSummary> ret = billLineFacade.getLineSummary(eventbean.getCurrentEvent()); Collection<BillSummary> ret = billLineFacade.getLineSummary(eventbean
.getCurrentEvent());
return ret; return ret;
} }
@Override @Override
@RolesAllowed({ BillPermission.S_WRITE_ALL, SpecialPermission.S_VERKKOMAKSU_CHECK }) @RolesAllowed({ BillPermission.S_WRITE_ALL,
SpecialPermission.S_VERKKOMAKSU_CHECK })
public void markPaid(Bill bill, Calendar when) { public void markPaid(Bill bill, Calendar when) {
if (bill.getAccountEvent() != null || bill.getPaidDate() != null) if (bill.getAccountEvent() != null || bill.getPaidDate() != null) {
{
throw new EJBException("Bill already marked paid!"); throw new EJBException("Bill already marked paid!");
} }
bill = billFacade.reload(bill); bill = billFacade.reload(bill);
Product creditproduct = productBean.findCreditProduct(); Product creditproduct = productBean.findCreditProduct();
EventUser user = bill.getUser(); EventUser user = bill.getUser();
AccountEvent ac = productBean.createAccountEvent(creditproduct, bill.totalPrice(), user); AccountEvent ac = productBean.createAccountEvent(creditproduct,
bill.totalPrice(), user);
logger.info("Created creditentry. {}, userproducts {}", ac, user.getAccountEvents().size()); logger.info("Created creditentry. {}, userproducts {}", ac, user
.getAccountEvents().size());
ac.setDelivered(when); ac.setDelivered(when);
ac.setEventTime(when); ac.setEventTime(when);
...@@ -231,17 +228,24 @@ public class BillBean implements BillBeanLocal { ...@@ -231,17 +228,24 @@ public class BillBean implements BillBeanLocal {
for (BillLine bl : bill.getBillLines()) { for (BillLine bl : bill.getBillLines()) {
Product prod = bl.getLineProduct(); Product prod = bl.getLineProduct();
if (prod != null if (prod != null
&& prod.getProductFlags().contains(ProductFlag.PREPAID_INSTANT_CREATE)) { && prod.getProductFlags().contains(
ProductFlag.PREPAID_INSTANT_CREATE)) {
logger.debug("Creating Bill prepaidInstant product {}, {}", prod.getName(), bl.getQuantity());
if (prod.getProductFlags().contains(ProductFlag.RESERVE_PLACE_WHEN_BOUGHT) logger.debug("Creating Bill prepaidInstant product {}, {}",
|| prod.getProductFlags().contains(ProductFlag.CREATE_NEW_PLACE_WHEN_BOUGHT)) prod.getName(), bl.getQuantity());
{ if (prod.getProductFlags().contains(
placebean.lockPlaceProduct(bill.getUser(), prod, bl.getQuantity()); ProductFlag.RESERVE_PLACE_WHEN_BOUGHT)
|| prod.getProductFlags().contains(
ProductFlag.CREATE_NEW_PLACE_WHEN_BOUGHT)) {
placebean.lockPlaceProduct(bill.getUser(), prod,
bl.getQuantity());
} }
AccountEvent ac2 = productPBean.createAccountEvent(prod, bl.getQuantity(), user, bill.getSentDate()); AccountEvent ac2 = productPBean.createAccountEvent(prod,
logger.info("Created ac from product. {}, userproducts {}", ac2, user.getAccountEvents().size()); bl.getQuantity(), user, bill.getSentDate(), bl.getFoodwave());
logger.info("Created ac from product. {}, userproducts {}",
ac2, user.getAccountEvents().size());
ac2.setSeller(permbean.getCurrentUser()); ac2.setSeller(permbean.getCurrentUser());
} }
...@@ -249,7 +253,9 @@ public class BillBean implements BillBeanLocal { ...@@ -249,7 +253,9 @@ public class BillBean implements BillBeanLocal {
} }
MailMessage msg = new MailMessage(); MailMessage msg = new MailMessage();
msg.setSubject(I18n.get("bill.billMarkedPaidMail.subject")); msg.setSubject(I18n.get("bill.billMarkedPaidMail.subject"));
msg.setMessage(I18n.get("bill.billMarkedPaidMail.message", (bill.getBillNumber() == null) ? "----" : bill.getBillNumber().toString())); msg.setMessage(I18n.get("bill.billMarkedPaidMail.message", (bill
.getBillNumber() == null) ? "----" : bill.getBillNumber()
.toString()));
msg.setTo(bill.getUser().getUser()); msg.setTo(bill.getUser().getUser());
utilbean.sendMail(msg); utilbean.sendMail(msg);
eventUserFacade.flush(); eventUserFacade.flush();
...@@ -259,9 +265,13 @@ public class BillBean implements BillBeanLocal { ...@@ -259,9 +265,13 @@ public class BillBean implements BillBeanLocal {
@Override @Override
@RolesAllowed({ BillPermission.S_CREATE_BILL, BillPermission.S_WRITE_ALL }) @RolesAllowed({ BillPermission.S_CREATE_BILL, BillPermission.S_WRITE_ALL })
public void createBill(Bill bill) { public void createBill(Bill bill) {
if (!permbean.isCurrentUser(bill.getUser()) && !permbean.hasPermission(BillPermission.WRITE_ALL)) { if (!permbean.isCurrentUser(bill.getUser())
loggingBean.logMessage(SecurityLogType.permissionDenied, permbean.getCurrentUser(), "Not enought rights to create bill for user "); && !permbean.hasPermission(BillPermission.WRITE_ALL)) {
throw new EJBAccessException("Could not create bill for another user"); loggingBean.logMessage(SecurityLogType.permissionDenied,
permbean.getCurrentUser(),
"Not enought rights to create bill for user ");
throw new EJBAccessException(
"Could not create bill for another user");
} }
billFacade.create(bill); billFacade.create(bill);
generateBillNumber(bill); generateBillNumber(bill);
...@@ -275,9 +285,13 @@ public class BillBean implements BillBeanLocal { ...@@ -275,9 +285,13 @@ public class BillBean implements BillBeanLocal {
@Override @Override
@RolesAllowed({ BillPermission.S_VIEW_OWN, BillPermission.S_READ_ALL }) @RolesAllowed({ BillPermission.S_VIEW_OWN, BillPermission.S_READ_ALL })
public List<Bill> find(EventUser user) { public List<Bill> find(EventUser user) {
if (!permbean.isCurrentUser(user) && !permbean.hasPermission(BillPermission.READ_ALL)) { if (!permbean.isCurrentUser(user)
loggingBean.logMessage(SecurityLogType.permissionDenied, permbean.getCurrentUser(), "Not enought rights to get bill list for user "); && !permbean.hasPermission(BillPermission.READ_ALL)) {
throw new EJBAccessException("Could not list bills for another user"); loggingBean.logMessage(SecurityLogType.permissionDenied,
permbean.getCurrentUser(),
"Not enought rights to get bill list for user ");
throw new EJBAccessException(
"Could not list bills for another user");
} }
return billFacade.find(user); return billFacade.find(user);
} }
......
...@@ -18,6 +18,7 @@ import fi.insomnia.bortal.model.AccountEvent; ...@@ -18,6 +18,7 @@ import fi.insomnia.bortal.model.AccountEvent;
import fi.insomnia.bortal.model.Discount; import fi.insomnia.bortal.model.Discount;
import fi.insomnia.bortal.model.DiscountInstance; import fi.insomnia.bortal.model.DiscountInstance;
import fi.insomnia.bortal.model.EventUser; import fi.insomnia.bortal.model.EventUser;
import fi.insomnia.bortal.model.FoodWave;
import fi.insomnia.bortal.model.Product; import fi.insomnia.bortal.model.Product;
/** /**
...@@ -31,7 +32,8 @@ public class ProductPBean { ...@@ -31,7 +32,8 @@ public class ProductPBean {
private PermissionBean permbean; private PermissionBean permbean;
@EJB @EJB
private AccountEventFacade accounteventfacade; private AccountEventFacade accounteventfacade;
private static final Logger logger = LoggerFactory.getLogger(ProductPBean.class); private static final Logger logger = LoggerFactory
.getLogger(ProductPBean.class);
/** /**
* Default constructor. * Default constructor.
...@@ -40,6 +42,11 @@ public class ProductPBean { ...@@ -40,6 +42,11 @@ public class ProductPBean {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
public AccountEvent createAccountEvent(Product product,
BigDecimal quantity, EventUser user, Calendar date) {
return this.createAccountEvent(product, quantity, user, date, null);
}
/** /**
* Creates new AccountEvent from provided product to provided user <br> * Creates new AccountEvent from provided product to provided user <br>
* <strong>Notice</strong>, that this function expects the user parameter to * <strong>Notice</strong>, that this function expects the user parameter to
...@@ -56,11 +63,13 @@ public class ProductPBean { ...@@ -56,11 +63,13 @@ public class ProductPBean {
* AccountEvent creation time * AccountEvent creation time
* @return The created AccountEvent entity * @return The created AccountEvent entity
*/ */
public AccountEvent createAccountEvent(Product product, BigDecimal quantity, EventUser user, Calendar date) { public AccountEvent createAccountEvent(Product product,
BigDecimal quantity, EventUser user, Calendar date,
FoodWave foodwave) {
if (!product.getEvent().equals(user.getEvent())) if (!product.getEvent().equals(user.getEvent())) {
{ throw new EJBException(
throw new EJBException("Trying to create accountevent for different event in user and product"); "Trying to create accountevent for different event in user and product");
} }
BigDecimal unitPrice = product.getPrice().negate(); BigDecimal unitPrice = product.getPrice().negate();
...@@ -69,11 +78,16 @@ public class ProductPBean { ...@@ -69,11 +78,16 @@ public class ProductPBean {
unitPrice = unitPrice.multiply(d.getPercentage()); unitPrice = unitPrice.multiply(d.getPercentage());
} }
AccountEvent ret = new AccountEvent(user, product, unitPrice, quantity, Calendar.getInstance()); AccountEvent ret = new AccountEvent(user, product, unitPrice, quantity,
Calendar.getInstance());
ret.setDelivered(Calendar.getInstance()); ret.setDelivered(Calendar.getInstance());
ret.setSeller(permbean.getCurrentUser()); ret.setSeller(permbean.getCurrentUser());
if (foodwave != null) {
ret.setFoodWave(foodwave);
}
List<DiscountInstance> accEventdiscounts = ret.getDiscountInstances(); List<DiscountInstance> accEventdiscounts = ret.getDiscountInstances();
for (Discount d : discounts) { for (Discount d : discounts) {
// discountsArray.add(discInst); // discountsArray.add(discInst);
......
...@@ -14,6 +14,7 @@ import javax.persistence.Lob; ...@@ -14,6 +14,7 @@ import javax.persistence.Lob;
import javax.persistence.ManyToMany; import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table; import javax.persistence.Table;
import org.eclipse.persistence.annotations.OptimisticLocking; import org.eclipse.persistence.annotations.OptimisticLocking;
...@@ -45,6 +46,7 @@ public class FoodWaveTemplate extends GenericEntity { ...@@ -45,6 +46,7 @@ public class FoodWaveTemplate extends GenericEntity {
private List<Product> products; private List<Product> products;
@OneToMany(mappedBy = "template") @OneToMany(mappedBy = "template")
@OrderBy(value = "time")
private List<FoodWave> foodwaves; private List<FoodWave> foodwaves;
public FoodWaveTemplate() { public FoodWaveTemplate() {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "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:f="http://java.sun.com/jsf/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:f="http://java.sun.com/jsf/core"
xmlns:products="http://java.sun.com/jsf/composite/cditools/products" xmlns:users="http://java.sun.com/jsf/composite/cditools/user" xmlns:c="http://java.sun.com/jsp/jstl/core"> xmlns:products="http://java.sun.com/jsf/composite/cditools/products" xmlns:users="http://java.sun.com/jsf/composite/cditools/user" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:p="http://primefaces.org/ui">
<h:body> <h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml"> <ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata> <f:metadata>
...@@ -15,12 +15,47 @@ ...@@ -15,12 +15,47 @@
<ui:define name="content"> <ui:define name="content">
<h:form> <h:form>
<h:panelGrid columns="3"> <p:wizard>
<h:outputLabel for="name" value="#{i18n['foodwavetemplate.name']}" /> <p:tab id="basicinfo" title="#{i18n['foodwavetemplate.basicinfo']}">
<h:inputText id="name" value="#{foodWaveView.template.name}" /> <h:panelGrid columns="3">
<h:message for="name" /> <h:outputLabel for="name" value="#{i18n['foodwavetemplate.name']}" />
</h:panelGrid> <h:inputText id="name" value="#{foodWaveView.template.name}" />
<h:commandButton action="#{foodWaveView.saveTemplate()}" value="#{i18n['foowavetemplate.create']}" /> <h:message for="name" />
<h:outputLabel for="description" value="#{i18n['foodwavetemplate.description']}" />
<h:inputText id="description" value="#{foodWaveView.template.description}" />
<h:message for="description" />
</h:panelGrid>
</p:tab>
<p:tab id="selectproducts" title="#{i18n['foodwavetemplate.selectproducts']}">
<h:messages />
<h:panelGrid columns="4">
<h:outputText value="#{i18n['foodwavetemplate.productname']}" />
<h:outputText value="#{i18n['foodwavetemplate.productdescription']}" />
<h:outputText value="#{i18n['foodwavetemplate.price']}" />
<h:outputText value="&nbsp;" />
<h:inputText id="productname" value="#{foodWaveView.currentProduct.name}" />
<h:inputText id="productdescription" value="#{foodWaveView.currentProduct.name}" />
<h:inputText id="price" value="#{foodWaveView.currentProduct.price}" />
<p:commandButton value="#{i18n['foodwavetemplate.addproduct']}" actionListener="#{foodWaveView.addProductToTemplate}" update="productTable" />
</h:panelGrid>
<p:dataTable name="productTable" id="productTable" value="#{foodWaveView.template.products}" var="product">
<p:column headerText="#{i18n['foodwavetemplate.productname']}">
<h:outputText value="#{product.name}" />
</p:column>
<p:column headerText="#{i18n['foodwavetemplate.productdescription']}">
<h:outputText value="#{product.name}" />
</p:column>
<p:column headerText="#{i18n['foodwavetemplate.price']}">
<h:outputText value="#{product.price}" />
</p:column>
</p:dataTable>
</p:tab>
</p:wizard>
</h:form> </h:form>
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
<ui:define name="title"> <ui:define name="title">
<h1>#{i18n['user.shop.title']}</h1> <h1>#{i18n['user.shop.title']}</h1>
<users:usertabs tabId="foodwave" />
</ui:define> </ui:define>
<ui:define name="content"> <ui:define name="content">
Kiitoksia tilauksesta, muista käydä maksamassa tilaukset tiskillä. Kiitoksia tilauksesta, muista käydä maksamassa tilaukset tiskillä.
......
...@@ -18,8 +18,7 @@ ...@@ -18,8 +18,7 @@
</f:metadata> </f:metadata>
<ui:define name="title"> <ui:define name="title">
<h1>#{i18n['user.shop.title']}</h1> <h1>#{i18n['user.shop.title']}</h1>
<users:usertabs tabId="foodwave" />
</ui:define> </ui:define>
<ui:define name="content"> <ui:define name="content">
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
<ui:define name="title"> <ui:define name="title">
<h1>#{i18n['user.foodwave.products.title']}</h1> <h1>#{i18n['user.foodwave.products.title']}</h1>
<users:usertabs tabId="foodwave" />
</ui:define> </ui:define>
<ui:define name="content"> <ui:define name="content">
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
<ui:define name="title"> <ui:define name="title">
<h1>#{i18n['user.shop.title']}</h1> <h1>#{i18n['user.shop.title']}</h1>
<users:usertabs tabId="foodwave" />
</ui:define> </ui:define>
<ui:define name="content"> <ui:define name="content">
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<f:event type="preRenderView" listener="#{userView.initCreateView}" /> <f:event type="preRenderView" listener="#{userView.initCreateView}" />
</f:metadata> </f:metadata>
<ui:define name="content"> <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:define>
</ui:composition> </ui:composition>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</f:metadata> </f:metadata>
<ui:param name="thispage" value="page.user.create" /> <ui:param name="thispage" value="page.user.create" />
<ui:define name="content"> <ui:define name="content">
<users:create creating="true" commitaction="#{userView.createUser()}" commitvalue="#{i18n['user.create']}" /> <users:create creating="true" commitaction="#{userView.createAdminUser()}" commitvalue="#{i18n['user.create']}" />
</ui:define> </ui:define>
</ui:composition> </ui:composition>
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
<div id="usercart" style="display: #{((userCartView.isEmpty())?'none':'block')};"> <div id="usercart" style="display: #{((userCartView.isEmpty())?'none':'block')};">
<h:outputText value="#{i18n['usercart.cartsize']}" /> <h:outputText value="#{i18n['usercart.cartsize']}" />
<h:outputText value=" #{userCartView.userCartSize}" /> <h:outputText value=" #{userCartView.userCartSize}" />
<h:commandButton action="#{userCartView.clearCart}" value="#{i18n['usercart.clear']}" /> <h:commandButton action="#{userCartView.clearCart()}" value="#{i18n['usercart.clear']}" />
<br /> <br />
<h:commandButton actionListener="#{userSearchView.addToCart}" value="#{i18n['usercart.addSearcherUsers']}" /> <h:commandButton actionListener="#{userSearchView.addToCart}" value="#{i18n['usercart.addSearcherUsers']}" />
<h:commandButton action="#{userCartView.traverse}" value="#{i18n['usercart.traverse']}" /> <h:commandButton action="#{userCartView.traverse}" value="#{i18n['usercart.traverse']}" />
......
...@@ -77,6 +77,8 @@ billine.vat = VAT ...@@ -77,6 +77,8 @@ billine.vat = VAT
bills.noBills = No bills bills.noBills = No bills
card.massprint.title = Print all
cardTemplate.create = Create cardTemplate.create = Create
cardTemplate.edit = Edit cardTemplate.edit = Edit
cardTemplate.id = Id cardTemplate.id = Id
...@@ -104,6 +106,7 @@ checkout.return.successMessage = Payment confirmed. Your products have been paid ...@@ -104,6 +106,7 @@ checkout.return.successMessage = Payment confirmed. Your products have been paid
compo.edit = Edit compo compo.edit = Edit compo
compo.saveVotes = Save votes compo.saveVotes = Save votes
compo.savesort = Save order
compo.votesSaved = Votes saved compo.votesSaved = Votes saved
compofile.download = Download compofile.download = Download
...@@ -270,6 +273,13 @@ mapView.errorWhenReservingPlace = Error when reserving place! ...@@ -270,6 +273,13 @@ mapView.errorWhenReservingPlace = Error when reserving place!
mapView.errorWhileBuyingPlaces = Error when buying places. Please try again. If error reoccurs please contact organizers. mapView.errorWhileBuyingPlaces = Error when buying places. Please try again. If error reoccurs please contact organizers.
mapView.notEnoughCreditsToReserve = You don't have enough credits to reserve this place. mapView.notEnoughCreditsToReserve = You don't have enough credits to reserve this place.
menu.item = Item
menu.name = Name
menu.select = Select
menu.sort = Sort
menuitem.navigation.key = Product flag
nasty.user = Go away! nasty.user = Go away!
org.hibernate.validator.constraints.Email.message = not a well-formed email address org.hibernate.validator.constraints.Email.message = not a well-formed email address
...@@ -464,16 +474,19 @@ productshop.plusOne = +1 ...@@ -464,16 +474,19 @@ productshop.plusOne = +1
productshop.plusTen = +10 productshop.plusTen = +10
productshop.total = Total productshop.total = Total
reader.assocToCard = Associate to card reader.assocToCard = Associate to card
reader.createNewCard = Create new card reader.automaticProduct = Default product
reader.description = Description reader.automaticProductCount = Amount
reader.edit = Edit reader.createNewCard = Create new card
reader.identification = Identification reader.description = Description
reader.name = Reader name reader.edit = Edit
reader.select = Select reader reader.identification = Identification
reader.tag = Tag reader.name = Reader name
reader.type = Type reader.save = Save
reader.user = User reader.select = Select reader
reader.tag = Tag
reader.type = Type
reader.user = User
readerView.searchforuser = Search user readerView.searchforuser = Search user
...@@ -606,12 +619,12 @@ submenu.voting.myEntries = My entries ...@@ -606,12 +619,12 @@ submenu.voting.myEntries = My entries
supernavi.admin = Adminview supernavi.admin = Adminview
supernavi.user = Userview supernavi.user = Userview
svm.failure.errorMessage = Payment error. svm.failure.errorMessage = Payment error.
svm.failure.successMessage = Payment error successfull\u2026 ( Possibly already marked paid ) svm.failure.successMessage = Payment error successfull\u2026 ( Possibly already marked paid )
svm.pending.errorMessage = Unknown error! If payment was successfull email will be sent after verification. svm.pending.errorMessage = Unknown error! If payment was successfull email will be sent after verification.
svm.pending.successMessage = Payment pending. You will receive email after payment verification. svm.pending.successMessage = Payment pending. You will receive email after payment verification.
svm.success.errorMessage = Payment could not be verified! svm.success.errorMessage = Payment could not be verified!
svm.success.successMessage = Payment was successfull. You can now your credits in the system. svm.success.successMessage = Payment was successfull. You can now your credits in the system.
template.loggedInAs = Logged in as: template.loggedInAs = Logged in as:
......
...@@ -75,6 +75,8 @@ billine.vat = ALV ...@@ -75,6 +75,8 @@ billine.vat = ALV
bills.noBills = Ei laskuja bills.noBills = Ei laskuja
card.massprint.title = Tulosta kaikki
cardTemplate.create = Luo cardTemplate.create = Luo
cardTemplate.edit = Muokkaa cardTemplate.edit = Muokkaa
cardTemplate.id = Id cardTemplate.id = Id
...@@ -102,6 +104,7 @@ checkout.return.successMessage = Maksu vahvistettu. Tuotteet on maksettu ja voit ...@@ -102,6 +104,7 @@ checkout.return.successMessage = Maksu vahvistettu. Tuotteet on maksettu ja voit
compo.edit = Muokkaa compoa compo.edit = Muokkaa compoa
compo.saveVotes = Tallenna \u00E4\u00E4net compo.saveVotes = Tallenna \u00E4\u00E4net
compo.savesort = Tallenna j\u00E4rjestys
compo.votesSaved = \u00C4\u00E4net tallennettu compo.votesSaved = \u00C4\u00E4net tallennettu
compofile.download = lataa compofile.download = lataa
...@@ -277,11 +280,14 @@ mapView.errorWhenReservingPlace = Paikkaa varatessa tapahtui virhe. ...@@ -277,11 +280,14 @@ mapView.errorWhenReservingPlace = Paikkaa varatessa tapahtui virhe.
mapView.errorWhileBuyingPlaces = Virhe paikkojen ostossa. Ole hyv\u00E4 ja yrit\u00E4 uudelleen. Jos virhe toistuu ota yhteytt\u00E4 j\u00E4rjest\u00E4jiin. mapView.errorWhileBuyingPlaces = Virhe paikkojen ostossa. Ole hyv\u00E4 ja yrit\u00E4 uudelleen. Jos virhe toistuu ota yhteytt\u00E4 j\u00E4rjest\u00E4jiin.
mapView.notEnoughCreditsToReserve = Sinulla ei ole riitt\u00E4v\u00E4sti suoritettuja konepaikkamaksuja t\u00E4m\u00E4n paikan varaamiseen. mapView.notEnoughCreditsToReserve = Sinulla ei ole riitt\u00E4v\u00E4sti suoritettuja konepaikkamaksuja t\u00E4m\u00E4n paikan varaamiseen.
menu.index = Etusivu menu.index = Etusivu
menu.place.placemap = Paikkakartta menu.name = Nimi
menu.poll.index = Kyselyt menu.place.placemap = Paikkakartta
menu.shop.createBill = Kauppa menu.poll.index = Kyselyt
menu.user.edit = Omat tiedot menu.select = Valitse
menu.shop.createBill = Kauppa
menu.sort = J\u00E4rjest\u00E4
menu.user.edit = Omat tiedot
news.abstract = Lyhennelm\u00E4 news.abstract = Lyhennelm\u00E4
news.expire = Lopeta julkaisu news.expire = Lopeta julkaisu
...@@ -452,16 +458,19 @@ productshop.plusOne = +1 ...@@ -452,16 +458,19 @@ productshop.plusOne = +1
productshop.plusTen = +10 productshop.plusTen = +10
productshop.total = Yhteens\u00E4 productshop.total = Yhteens\u00E4
reader.assocToCard = Yhdist\u00E4 korttiin reader.assocToCard = Yhdist\u00E4 korttiin
reader.createNewCard = Luo uusi kortti reader.automaticProduct = Oletustuote
reader.description = Kuvaus reader.automaticProductCount = M\u00E4\u00E4r\u00E4
reader.edit = Muokkaa reader.createNewCard = Luo uusi kortti
reader.identification = Tunniste reader.description = Kuvaus
reader.name = Lukijan nimi reader.edit = Muokkaa
reader.select = Valitse lukija reader.identification = Tunniste
reader.tag = Tag reader.name = Lukijan nimi
reader.type = Tyyppi reader.save = Tallenna
reader.user = K\u00E4ytt\u00E4j\u00E4 reader.select = Valitse lukija
reader.tag = Tag
reader.type = Tyyppi
reader.user = K\u00E4ytt\u00E4j\u00E4
readerView.searchforuser = Etsi k\u00E4ytt\u00E4j\u00E4\u00E4 readerView.searchforuser = Etsi k\u00E4ytt\u00E4j\u00E4\u00E4
...@@ -593,12 +602,12 @@ submenu.voting.myEntries = Omat entryt ...@@ -593,12 +602,12 @@ submenu.voting.myEntries = Omat entryt
supernavi.admin = Yll\u00E4piton\u00E4kym\u00E4 supernavi.admin = Yll\u00E4piton\u00E4kym\u00E4
supernavi.user = K\u00E4ytt\u00E4j\u00E4n\u00E4kym\u00E4 supernavi.user = K\u00E4ytt\u00E4j\u00E4n\u00E4kym\u00E4
svm.failure.errorMessage = Verkkomaksuvirhe. svm.failure.errorMessage = Verkkomaksuvirhe.
svm.failure.successMessage = Maksuvirhe onnistunut. ( Maksu mahdollisesti merkitty jo maksetuksi ) svm.failure.successMessage = Maksuvirhe onnistunut. ( Maksu mahdollisesti merkitty jo maksetuksi )
svm.pending.errorMessage = Maksukuittausta odotetaan. Kuittauksesta l\u00E4hetet\u00E4\u00E4n ilmoitus s\u00E4hk\u00F6postitse. svm.pending.errorMessage = Maksukuittausta odotetaan. Kuittauksesta l\u00E4hetet\u00E4\u00E4n ilmoitus s\u00E4hk\u00F6postitse.
svm.pending.successMessage = Maksukuittausta odotetaan. Kuittauksesta l\u00E4hetet\u00E4\u00E4n ilmoitus s\u00E4hk\u00F6postitse. svm.pending.successMessage = Maksukuittausta odotetaan. Kuittauksesta l\u00E4hetet\u00E4\u00E4n ilmoitus s\u00E4hk\u00F6postitse.
svm.success.errorMessage = Verkkomaksua ei voitu verifioida! Virheest\u00E4 on raportoitu eteenp\u00E4in. svm.success.errorMessage = Verkkomaksua ei voitu verifioida! Virheest\u00E4 on raportoitu eteenp\u00E4in.
svm.success.successMessage = Verkkomaksu onnistui. svm.success.successMessage = Verkkomaksu onnistui.
template.loggedInAs = Kirjautunut tunnuksella: template.loggedInAs = Kirjautunut tunnuksella:
......
...@@ -26,6 +26,7 @@ public class FoodShopView extends GenericCDIView { ...@@ -26,6 +26,7 @@ public class FoodShopView extends GenericCDIView {
private static final long serialVersionUID = 1288114954999406683L; private static final long serialVersionUID = 1288114954999406683L;
@Inject @Inject
@SelectedUser @SelectedUser
private EventUser user; private EventUser user;
......
package fi.insomnia.bortal.web.cdiview.shop; package fi.insomnia.bortal.web.cdiview.shop;
import java.util.ArrayList;
import java.util.TreeSet;
import java.util.Vector;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped; import javax.enterprise.context.ConversationScoped;
import javax.faces.model.ListDataModel; import javax.faces.model.ListDataModel;
...@@ -11,6 +15,8 @@ import fi.insomnia.bortal.beans.FoodWaveBeanLocal; ...@@ -11,6 +15,8 @@ import fi.insomnia.bortal.beans.FoodWaveBeanLocal;
import fi.insomnia.bortal.enums.apps.ShopPermission; import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.model.FoodWave; import fi.insomnia.bortal.model.FoodWave;
import fi.insomnia.bortal.model.FoodWaveTemplate; import fi.insomnia.bortal.model.FoodWaveTemplate;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.model.ProductFlag;
import fi.insomnia.bortal.web.cdiview.GenericCDIView; import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named @Named
...@@ -33,6 +39,8 @@ public class FoodWaveView extends GenericCDIView { ...@@ -33,6 +39,8 @@ public class FoodWaveView extends GenericCDIView {
private ListDataModel<FoodWave> foodWaves; private ListDataModel<FoodWave> foodWaves;
private FoodWave selectedFoodWave = null; private FoodWave selectedFoodWave = null;
private Product currentProduct;
public void initTemplateList() { public void initTemplateList() {
if (super.requirePermissions(ShopPermission.LIST_USERPRODUCTS)) { if (super.requirePermissions(ShopPermission.LIST_USERPRODUCTS)) {
...@@ -59,10 +67,35 @@ public class FoodWaveView extends GenericCDIView { ...@@ -59,10 +67,35 @@ public class FoodWaveView extends GenericCDIView {
if (super.requirePermissions(ShopPermission.MANAGE_PRODUCTS) && template == null) if (super.requirePermissions(ShopPermission.MANAGE_PRODUCTS) && template == null)
{ {
template = new FoodWaveTemplate(); template = new FoodWaveTemplate();
template.setProducts(new ArrayList<Product>());
template.setEvent(eventbean.getCurrentEvent()); template.setEvent(eventbean.getCurrentEvent());
createNewProductSkeleton();
super.beginConversation(); super.beginConversation();
} }
} }
private void createNewProductSkeleton() {
TreeSet<ProductFlag> ts = new TreeSet<ProductFlag>();
ts.add(ProductFlag.PREPAID_INSTANT_CREATE);
currentProduct = new Product();
currentProduct.setProductFlags(ts);
}
public void addProductToTemplate() {
template.getProducts().add(currentProduct);
createNewProductSkeleton();
}
public Product getCurrentProduct() {
return currentProduct;
}
public void setCurrentProduct(Product currentProduct) {
this.currentProduct = currentProduct;
}
public void initUserFoodWaveList() { public void initUserFoodWaveList() {
this.foodWaves = new ListDataModel<FoodWave>( this.foodWaves = new ListDataModel<FoodWave>(
......
...@@ -69,7 +69,8 @@ public class UserCartView extends GenericCDIView { ...@@ -69,7 +69,8 @@ public class UserCartView extends GenericCDIView {
updateCurrent(); updateCurrent();
return "/useradmin/userCartShow"; return "/useradmin/userCartShow";
} }
else return "/useradmin/list"; else
return "/useradmin/list";
} }
public String saveUser() { public String saveUser() {
...@@ -107,7 +108,7 @@ public class UserCartView extends GenericCDIView { ...@@ -107,7 +108,7 @@ public class UserCartView extends GenericCDIView {
usercart.clear(); usercart.clear();
return null; return null;
} }
public boolean isEmpty() { public boolean isEmpty() {
return usercart == null || usercart.isEmpty(); return usercart == null || usercart.isEmpty();
} }
......
...@@ -14,7 +14,9 @@ import javax.inject.Named; ...@@ -14,7 +14,9 @@ import javax.inject.Named;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.PermissionBeanLocal;
import fi.insomnia.bortal.beans.UserBeanLocal; import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.enums.apps.UserPermission;
import fi.insomnia.bortal.utilities.I18n; import fi.insomnia.bortal.utilities.I18n;
@Named @Named
...@@ -29,12 +31,15 @@ public class UserValidator implements Serializable { ...@@ -29,12 +31,15 @@ public class UserValidator implements Serializable {
private static final Integer PASSWORD_MIN_LENGTH = 8; private static final Integer PASSWORD_MIN_LENGTH = 8;
@EJB @EJB
private transient UserBeanLocal userbean; private transient UserBeanLocal userbean;
@EJB
private transient PermissionBeanLocal permbean;
private static final Logger logger = LoggerFactory.getLogger(UserValidator.class); private static final Logger logger = LoggerFactory.getLogger(UserValidator.class);
public void validateEmail(FacesContext context, UIComponent ui, Object value) { public void validateEmail(FacesContext context, UIComponent ui, Object value) {
String email = (String) value; String email = (String) value;
if (email.indexOf('@') == -1) { if (!permbean.hasPermission(UserPermission.MODIFY) && (email == null || email.indexOf('@') == -1)) {
message(context, ui, "userview.invalidEmail"); message(context, ui, "userview.invalidEmail");
} }
} }
...@@ -53,21 +58,25 @@ public class UserValidator implements Serializable { ...@@ -53,21 +58,25 @@ public class UserValidator implements Serializable {
public void password(FacesContext context, UIComponent ui, Object object) { public void password(FacesContext context, UIComponent ui, Object object) {
logger.info("Executing pwd, firstpwd {}", firstpwd); logger.info("Executing pwd, firstpwd {}", firstpwd);
if (object == null) { if (!permbean.hasPermission(UserPermission.MODIFY))
message(context, ui, "user.passwordlengthMessage"); {
return; if (object == null) {
} message(context, ui, "user.passwordlengthMessage");
if (firstpwd == null) { return;
firstpwd = object.toString(); }
if (PASSWORD_MIN_LENGTH.compareTo(firstpwd.length()) > 0) { if (firstpwd == null) {
message(context, ui, "userview.passwordTooShort", PASSWORD_MIN_LENGTH); firstpwd = object.toString();
if (PASSWORD_MIN_LENGTH.compareTo(firstpwd.length()) > 0) {
message(context, ui, "userview.passwordTooShort", PASSWORD_MIN_LENGTH);
}
logger.info("Setting firstpwd to {} as {}", firstpwd, object.getClass());
return;
}
logger.info("Checking length");
if (!firstpwd.equals(object)) {
message(context, ui, "userview.passwordsDontMatch");
} }
logger.info("Setting firstpwd to {} as {}", firstpwd, object.getClass());
return;
}
logger.info("Checking length");
if (!firstpwd.equals(object)) {
message(context, ui, "userview.passwordsDontMatch");
} }
logger.info("Done pwd"); logger.info("Done pwd");
} }
......
...@@ -85,10 +85,10 @@ public class UserView extends GenericCDIView { ...@@ -85,10 +85,10 @@ public class UserView extends GenericCDIView {
private transient EventBeanLocal eventbean; private transient EventBeanLocal eventbean;
@EJB @EJB
private transient CardPrintBeanLocal cardPrintBean; private transient CardPrintBeanLocal cardPrintBean;
private File file; private File file;
private StreamedContent streamedFile; private StreamedContent streamedFile;
private MassPrintResult mpr = null; private MassPrintResult mpr = null;
private boolean waitForAcceptance = false; private boolean waitForAcceptance = false;
...@@ -142,13 +142,13 @@ public class UserView extends GenericCDIView { ...@@ -142,13 +142,13 @@ public class UserView extends GenericCDIView {
// user = userbean.getEventUser(img.getUser()); // user = userbean.getEventUser(img.getUser());
// croppedImage = null; // croppedImage = null;
if (croppedImage == null)
if(croppedImage == null) return null; return null;
logger.info("Cropped image {}x{}", croppedImage.getLeft(), croppedImage.getTop()); logger.info("Cropped image {}x{}", croppedImage.getLeft(), croppedImage.getTop());
logger.info("Cropped data bytesize {}, type {}", croppedImage.getBytes().length, croppedImage.getOriginalFilename()); logger.info("Cropped data bytesize {}, type {}", croppedImage.getBytes().length, croppedImage.getOriginalFilename());
try { try {
UserImage newImage = UserImage newImage =
userbean.saveCroppedImage(user.getUser().getCurrentImage(), userbean.saveCroppedImage(user.getUser().getCurrentImage(),
croppedImage.getLeft(), croppedImage.getTop(), croppedImage.getLeft(), croppedImage.getTop(),
...@@ -160,29 +160,29 @@ public class UserView extends GenericCDIView { ...@@ -160,29 +160,29 @@ public class UserView extends GenericCDIView {
} }
return null; return null;
} }
public void prepareCardDownload() { public void prepareCardDownload() {
file = null; file = null;
try { try {
mpr = cardPrintBean.getUserCardAsPrintablePdf(this.user.getId()); mpr = cardPrintBean.getUserCardAsPrintablePdf(this.user.getId());
file = File.createTempFile("cardprintout",null); file = File.createTempFile("cardprintout", null);
FileOutputStream fostream = new FileOutputStream(file); FileOutputStream fostream = new FileOutputStream(file);
fostream.write(mpr.getPdf()); fostream.write(mpr.getPdf());
fostream.close(); fostream.close();
setStreamedFile(new DefaultStreamedContent(new FileInputStream(this.file))); setStreamedFile(new DefaultStreamedContent(new FileInputStream(this.file)));
} catch(Exception e) { } catch (Exception e) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(e.getMessage())); FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(e.getMessage()));
} }
} }
public String acceptPrintedCard() { public String acceptPrintedCard() {
if(mpr != null && mpr.getAffectedUsers().size() > 0) { if (mpr != null && mpr.getAffectedUsers().size() > 0) {
cardPrintBean.acceptMassPrintResult(mpr); cardPrintBean.acceptMassPrintResult(mpr);
return "accepted"; return "accepted";
} else { } else {
return "failure"; return "failure";
} }
} }
...@@ -290,6 +290,12 @@ public class UserView extends GenericCDIView { ...@@ -290,6 +290,12 @@ public class UserView extends GenericCDIView {
return "/user/created"; return "/user/created";
} }
public String createAdminUser() {
userbean.createNewUser(user, getPassword());
canSave = permbean.hasPermission(UserPermission.MODIFY);
return "/useradmin/edit";
}
public void setUserid(Integer userid) { public void setUserid(Integer userid) {
this.userid = userid; this.userid = userid;
} }
...@@ -357,7 +363,7 @@ public class UserView extends GenericCDIView { ...@@ -357,7 +363,7 @@ public class UserView extends GenericCDIView {
public void raiseWaitForAcceptance() { public void raiseWaitForAcceptance() {
waitForAcceptance = true; waitForAcceptance = true;
} }
public boolean isWaitForAcceptance() { public boolean isWaitForAcceptance() {
return waitForAcceptance; return waitForAcceptance;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!