Commit a463db99 by Tuomas Riihimäki

Add user approval stuff, fix property enctype.

1 parent df989629
......@@ -254,6 +254,7 @@ public class BillBean implements BillBeanLocal {
String subject = MessageFormat.format(eventbean.getPropertyString(LanEventPropertyKey.BILL_PAID_MAIL_SUBJECT), user.getEvent().getName());
String content = MessageFormat.format(eventbean.getPropertyString(LanEventPropertyKey.BILL_PAID_MAIL_CONTENT), (bill.getBillNumber() == null) ? "----" : bill.getBillNumber().toString());
logger.info("Bill mail subject: {}, content {}", subject, content);
msg.setSubject(subject);
msg.setMessage(content);
msg.setTo(bill.getUser().getUser());
......
......@@ -30,13 +30,16 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.facade.ApprovalFacade;
import fi.codecrew.moya.facade.EventUserFacade;
import fi.codecrew.moya.facade.FeedbackFacade;
import fi.codecrew.moya.facade.GroupMembershipFacade;
import fi.codecrew.moya.facade.PlaceGroupFacade;
import fi.codecrew.moya.facade.RoleFacade;
import fi.codecrew.moya.facade.UserApprovalFacade;
import fi.codecrew.moya.facade.UserFacade;
import fi.codecrew.moya.facade.UserImageFacade;
import fi.codecrew.moya.model.Approval;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Feedback;
import fi.codecrew.moya.model.GroupMembership;
......@@ -47,6 +50,7 @@ import fi.codecrew.moya.model.PlaceGroup;
import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.model.Role;
import fi.codecrew.moya.model.User;
import fi.codecrew.moya.model.UserApproval;
import fi.codecrew.moya.model.UserImage;
import fi.codecrew.moya.util.MailMessage;
import fi.codecrew.moya.util.UserSearchQuery;
......@@ -116,6 +120,10 @@ public class UserBean implements UserBeanLocal {
private PlaceGroupFacade pgfacade;
@EJB
private FeedbackFacade feedbackFacade;
@EJB
private ApprovalFacade approvalFacade;
@EJB
private UserApprovalFacade userApprovalFacade;
@Override
@RolesAllowed(UserPermission.S_VIEW_ALL)
......@@ -619,4 +627,14 @@ public class UserBean implements UserBeanLocal {
fb.setTimestamp(Calendar.getInstance());
feedbackFacade.create(fb);
}
@Override
public UserApproval setUserApproval(EventUser user, String approvalName, boolean approvalValue, String notes) {
Approval approval = approvalFacade.findOrCreate(approvalName);
UserApproval ret = userApprovalFacade.findOrCreateApproval(user, approval);
ret.setApprovalValue(approvalValue);
ret.setNotes(notes);
return ret;
}
}
\ No newline at end of file
......@@ -5,12 +5,13 @@ import java.util.List;
import javax.ejb.Local;
import fi.codecrew.moya.util.UserSearchQuery;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.GroupMembership;
import fi.codecrew.moya.model.Role;
import fi.codecrew.moya.model.User;
import fi.codecrew.moya.model.UserApproval;
import fi.codecrew.moya.model.UserImage;
import fi.codecrew.moya.util.UserSearchQuery;
import fi.codecrew.moya.utilities.SearchQuery;
import fi.codecrew.moya.utilities.SearchResult;
......@@ -83,4 +84,6 @@ public interface UserBeanLocal {
void submitFeedback(String feedback);
UserApproval setUserApproval(EventUser user, String approvalName, boolean approvalValue, String notes);
}
......@@ -3,7 +3,7 @@ package fi.codecrew.moya.model;
public enum LanEventPropertyKey {
EVENT_LOGO(Type.DATA, null),
INVITEMAIL_SUBJECT(Type.TEXT, "Invitation to Moya Online Youth Accumulator"),
INVITEMAIL_CONTENT(Type.TEXT, "You have been invited to an event by {1}.\n\nYou can register to intranet at: {0}\n\nAfter registering to the intranet you can buy a ticket to Stream demoparty reduced price and invite your friends to join the party with you. More information can be found in the intranet. Remember also to visit our website at http://www.streamparty.org and join us at #streamparty in IRCNet. If you have any questions about this mail, registering to intranet, or anything else regarding Stream demoparty, please send us email to info@streamparty.org\n\n-- \nStream organizing\ninfo@streamparty.org"),
INVITEMAIL_CONTENT(Type.TEXT, "You have been invited to an event by {1}.\n\nYou can register to intranet at: {0}."),
BILL_PAID_MAIL_SUBJECT(Type.TEXT, "[{0}] Lasku merkitty maksetuksi"),
BILL_PAID_MAIL_CONTENT(Type.TEXT, "Laskusi numero {0} on merkitty maksetuksi. Voit nyt siirtyä lippukauppaan varamaan haluamasi paikat. Tervetuloa tapahtumaan!"),
PORTAL_EMAIL_ADDRESS(Type.TEXT, "moya@codecrew.fi"),
......
......@@ -9,19 +9,24 @@ import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
@Entity
@Table(name = "user_approvals")
@Table(name = "user_approvals", uniqueConstraints = @UniqueConstraint(columnNames = { UserApproval.APPROVAL_ID_COL, UserApproval.USER_ID_COL }))
public class UserApproval extends GenericEntity {
private static final long serialVersionUID = -5275823003990286642L;
protected static final String USER_ID_COL = "user_id";
protected static final String APPROVAL_ID_COL = "approval_id";
@ManyToOne()
@JoinColumn(nullable = false, updatable = false)
@JoinColumn(nullable = false, updatable = false, name = APPROVAL_ID_COL)
private Approval approval;
@ManyToOne()
@JoinColumn(nullable = false, updatable = false)
@JoinColumn(nullable = false, updatable = false, name = USER_ID_COL)
private EventUser user;
@Column(nullable = false, updatable = false)
......
......@@ -103,7 +103,7 @@
<h:message for="propval" />
</h:form>
<h:form rendered="#{!empty eventPropertyView.property}" enctype="multipart/form-data">
<h:form rendered="#{!empty eventPropertyView.property}" enctype="#{eventPropertyView.property.key.data?'multipart/form-data':''}">
<h:panelGrid columns="3">
<h:outputLabel for="key" value="#{i18n['lanEventProperty.key']}" />
<h:outputText value="#{eventPropertyView.property.key}" id="key" />
......
......@@ -19,6 +19,7 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.BillBeanLocal;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.enums.apps.ShopPermission;
import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.EventUser;
......@@ -46,6 +47,8 @@ public class ProductShopView extends GenericCDIView {
@EJB
private transient BillBeanLocal billbean;
@EJB
private transient UserBeanLocal userbean;
@EJB
private transient EventBeanLocal eventbean;
......@@ -282,6 +285,10 @@ public class ProductShopView extends GenericCDIView {
}
}
billbean.createBill(bill);
if (isCheckAllowStats())
{
userbean.setUserApproval(bill.getUser(), "bill_allow_stats", allowStatistics, "Automagically created");
}
addFaceMessage("productshop.billCreated");
cash = BigDecimal.ZERO;
shoppingcart = null;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!