Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 2cf56407
authored
Oct 13, 2013
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Participate role checking.
1 parent
1eeae2e4
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
113 additions
and
48 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/MenuBean.java
code/MoyaEar/.project
code/MoyaEar/EarContent/META-INF/application.xml
code/MoyaWeb/WebContent/WEB-INF/web.xml
code/MoyaWeb/WebContent/tournaments/admin/delete.xhtml
code/MoyaWeb/WebContent/tournaments/admin/edit.xhtml
code/MoyaWeb/WebContent/tournaments/admin/index.xhtml
code/MoyaWeb/WebContent/tournaments/index.xhtml
code/MoyaWeb/WebContent/tournaments/participate_multi.xhtml
code/MoyaWeb/WebContent/tournaments/participate_single.xhtml
code/MoyaWeb/pom.xml
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentAdminView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentCreateView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentDeleteView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentEditView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentListView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentParticipateView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentRulesView.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/MenuBean.java
View file @
2cf5640
...
...
@@ -118,7 +118,7 @@ public class MenuBean implements MenuBeanLocal {
userprofile
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/edit"
),
UserPermission
.
VIEW_SELF
);
userprofile
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/changePassword"
),
UserPermission
.
VIEW_SELF
);
userprofile
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/gameids"
),
TournamentPermission
.
VIEW
);
userprofile
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/gameids"
),
TournamentPermission
.
PARTICIPATE
);
userprofile
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/auth/logout"
),
UserPermission
.
LOGOUT
);
MenuNavigation
tournaments
=
usermenu
.
addPage
(
null
,
null
);
...
...
code/MoyaEar/.project
View file @
2cf5640
...
...
@@ -6,6 +6,7 @@
<project>
lib-AuthModule-depends
</project>
<project>
MoyaAuthModule
</project>
<project>
MoyaCardPrinter
</project>
<project>
MoyaEventMgmtWeb
</project>
</projects>
<buildSpec>
<buildCommand>
...
...
code/MoyaEar/EarContent/META-INF/application.xml
View file @
2cf5640
<?xml version="1.0" encoding="UTF-8"?>
<application
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation=
"http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd"
version=
"7"
>
<application
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation=
"http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd"
version=
"7"
>
<display-name>
moya-ear
</display-name>
<module>
<ejb>
moya-beans-0.2.0.jar
</ejb>
...
...
@@ -10,5 +13,7 @@
<context-root>
/MoyaWeb
</context-root>
</web>
</module>
<!-- <module> <web> <web-uri>MoyaEventMgmtWeb.war</web-uri> <context-root>EventMgmt</context-root>
</web> </module> -->
<library-directory>
lib
</library-directory>
</application>
\ No newline at end of file
code/MoyaWeb/WebContent/WEB-INF/web.xml
View file @
2cf5640
...
...
@@ -17,6 +17,8 @@
<param-name>
javax.faces.PROJECT_STAGE
</param-name>
<param-value>
Development
</param-value>
</context-param>
<filter>
<display-name>
PrimefacesFileupload
</display-name>
<filter-name>
PrimefacesFileupload
</filter-name>
...
...
code/MoyaWeb/WebContent/tournaments/admin/delete.xhtml
View file @
2cf5640
...
...
@@ -5,6 +5,8 @@
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{tournamentDeleteView.initView()}"
/>
</f:metadata>
<ui:define
name=
"content"
>
...
...
code/MoyaWeb/WebContent/tournaments/admin/edit.xhtml
View file @
2cf5640
...
...
@@ -5,6 +5,7 @@
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{tournamentEditView.initView()}"
/>
</f:metadata>
<ui:define
name=
"content"
>
...
...
code/MoyaWeb/WebContent/tournaments/admin/index.xhtml
View file @
2cf5640
...
...
@@ -5,6 +5,7 @@
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{tournamentAdminView.initView()}"
/>
</f:metadata>
<ui:define
name=
"content"
>
...
...
code/MoyaWeb/WebContent/tournaments/index.xhtml
View file @
2cf5640
<!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:tools=
"http://java.sun.com/jsf/composite/cditools"
xmlns:p=
"http://primefaces.org/ui"
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:users=
"http://java.sun.com/jsf/composite/cditools/user"
xmlns:tools=
"http://java.sun.com/jsf/composite/cditools"
xmlns:p=
"http://primefaces.org/ui"
xmlns:f=
"http://java.sun.com/jsf/core"
>
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{tournamentListView.initView()}"
/>
</f:metadata>
<ui:define
name=
"content"
>
...
...
@@ -67,13 +70,14 @@
<f:param
name=
"tournament_id"
value=
"#{tournament.id}"
/>
</h:link>
</p:column>
<p:column>
<p:column
rendered=
"#{tournamentListView.canParticipate()}"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"#{i18n['tournament.control']}"
/>
</f:facet>
<h:panelGroup>
<p:commandButton
value=
"#{i18n['tournament.participate']}"
action=
"#{tournamentParticipateView.participate(tournament.id)}"
rendered=
"#{tournament.participants.size() lt tournament.maxParticipants}"
ajax=
"false"
/>
<h:outputText
value=
"#{i18n['tournament.full']}"
rendered=
"#{tournament.participants.size() ge tournament.maxParticipants}"
/>
<p:commandButton
value=
"#{i18n['tournament.participate']}"
action=
"#{tournamentParticipateView.participate(tournament.id)}"
rendered=
"#{tournament.participants.size() lt tournament.maxParticipants}"
ajax=
"false"
/>
<h:outputText
value=
"#{i18n['tournament.full']}"
rendered=
"#{tournament.participants.size() ge tournament.maxParticipants}"
/>
</h:panelGroup>
</p:column>
<p:rowExpansion>
...
...
@@ -82,10 +86,8 @@
<h:panelGroup>
<ul>
<ui:repeat
var=
"participant"
value=
"#{tournament.participants}"
>
<li>
<h:outputText
value=
"#{participant.teamName}"
rendered=
"#{not empty participant.teamName}"
/>
<h:outputText
value=
"#{participant.participator.user.nick}"
rendered=
"#{empty participant.teamName}"
/>
</li>
<li><h:outputText
value=
"#{participant.teamName}"
rendered=
"#{not empty participant.teamName}"
/>
<h:outputText
value=
"#{participant.participator.user.nick}"
rendered=
"#{empty participant.teamName}"
/></li>
</ui:repeat>
</ul>
</h:panelGroup>
...
...
code/MoyaWeb/WebContent/tournaments/participate_multi.xhtml
View file @
2cf5640
...
...
@@ -5,6 +5,7 @@
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{tournamentParticipateView.initView()}"
/>
</f:metadata>
<ui:define
name=
"content"
>
...
...
code/MoyaWeb/WebContent/tournaments/participate_single.xhtml
View file @
2cf5640
...
...
@@ -5,6 +5,7 @@
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{tournamentParticipateView.initView()}"
/>
</f:metadata>
<ui:define
name=
"content"
>
...
...
code/MoyaWeb/pom.xml
View file @
2cf5640
...
...
@@ -81,7 +81,7 @@
<dependency>
<groupId>
org.primefaces
</groupId>
<artifactId>
primefaces
</artifactId>
<version>
4.0
-SNAPSHOT
</version>
<version>
4.0
.RC1
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentAdminView.java
View file @
2cf5640
...
...
@@ -7,12 +7,24 @@ import javax.enterprise.context.RequestScoped;
import
javax.inject.Named
;
import
fi.codecrew.moya.beans.TournamentBeanLocal
;
import
fi.codecrew.moya.enums.apps.TournamentPermission
;
import
fi.codecrew.moya.model.Tournament
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
@RequestScoped
@Named
public
class
TournamentAdminView
{
@EJB
private
TournamentBeanLocal
tournamentBean
;
public
class
TournamentAdminView
extends
GenericCDIView
{
/**
*
*/
private
static
final
long
serialVersionUID
=
-
9079431236226432769L
;
@EJB
private
TournamentBeanLocal
tournamentBean
;
public
void
initView
()
{
super
.
requirePermissions
(
TournamentPermission
.
MANAGE_ALL
);
}
public
List
<
Tournament
>
getActiveTournaments
()
{
List
<
Tournament
>
tl
=
tournamentBean
.
getActiveTournaments
();
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentCreateView.java
View file @
2cf5640
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
tournaments
;
import
java.io.Serializable
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.inject.Named
;
import
org.primefaces.event.FlowEvent
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.TournamentBeanLocal
;
import
fi.codecrew.moya.enums.TournamentStatus
;
import
fi.codecrew.moya.enums.TournamentType
;
import
fi.codecrew.moya.
model.Role
;
import
fi.codecrew.moya.
enums.apps.TournamentPermission
;
import
fi.codecrew.moya.model.Tournament
;
import
fi.codecrew.moya.model.TournamentGame
;
import
fi.codecrew.moya.model.TournamentRule
;
import
fi.codecrew.moya.utilities.jsf.MessageHelper
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
import
javax.ejb.EJB
;
import
javax.ejb.Remove
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.faces.event.ActionEvent
;
import
javax.inject.Named
;
import
org.primefaces.event.FlowEvent
;
@Named
@ConversationScoped
public
class
TournamentCreateView
extends
GenericCDIView
{
...
...
@@ -43,11 +40,13 @@ public class TournamentCreateView extends GenericCDIView {
private
Integer
backupPlayers
;
@EJB
TournamentBeanLocal
tournamentBean
;
@EJB
EventBeanLocal
eventBean
;
@EJB
TournamentBeanLocal
tournamentBean
;
@EJB
EventBeanLocal
eventBean
;
public
void
initView
()
{
if
(
tournament
==
null
)
{
if
(
super
.
requirePermissions
(
TournamentPermission
.
MANAGE_ALL
)
&&
tournament
==
null
)
{
this
.
beginConversation
();
tournament
=
new
Tournament
();
tournament
.
setPlayersPerMatch
(
0
);
...
...
@@ -57,7 +56,6 @@ public class TournamentCreateView extends GenericCDIView {
}
}
public
String
save
()
{
tournament
.
setPlayersPerTeam
(
tournament
.
getPlayersPerMatch
()
+
backupPlayers
);
tournament
.
setLanEvent
(
eventBean
.
getCurrentEvent
());
...
...
@@ -69,7 +67,7 @@ public class TournamentCreateView extends GenericCDIView {
tournamentBean
.
createTournament
(
tournament
);
this
.
endConversation
();
return
"success"
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
MessageHelper
.
err
(
e
.
getMessage
());
return
""
;
}
...
...
@@ -93,9 +91,9 @@ public class TournamentCreateView extends GenericCDIView {
}
public
String
onFlowProcess
(
FlowEvent
event
)
{
switch
(
event
.
getOldStep
())
{
switch
(
event
.
getOldStep
())
{
case
"selectGame"
:
if
(
tournamentGameName
.
length
()
>
0
)
{
if
(
tournamentGameName
.
length
()
>
0
)
{
// oh lurd, we want to create a new gamy now
TournamentGame
tg
=
new
TournamentGame
();
tg
.
setName
(
tournamentGameName
);
...
...
@@ -109,7 +107,7 @@ public class TournamentCreateView extends GenericCDIView {
System
.
out
.
println
(
tournamentRules
);
break
;
case
"selectRuleset"
:
if
(
rulesetName
!=
null
&&
rulesetName
.
length
()
>
0
)
{
if
(
rulesetName
!=
null
&&
rulesetName
.
length
()
>
0
)
{
TournamentRule
tr
=
new
TournamentRule
();
tr
.
setName
(
rulesetName
);
tr
.
setDescription
(
rulesetDescription
);
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentDeleteView.java
View file @
2cf5640
...
...
@@ -2,11 +2,10 @@ package fi.codecrew.moya.web.cdiview.tournaments;
import
javax.ejb.EJB
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.enterprise.context.RequestScoped
;
import
javax.faces.bean.ManagedProperty
;
import
javax.inject.Named
;
import
fi.codecrew.moya.beans.TournamentBeanLocal
;
import
fi.codecrew.moya.enums.apps.TournamentPermission
;
import
fi.codecrew.moya.utilities.I18n
;
import
fi.codecrew.moya.utilities.jsf.MessageHelper
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
...
...
@@ -17,7 +16,13 @@ public class TournamentDeleteView extends GenericCDIView {
private
static
final
long
serialVersionUID
=
7283815262506163537L
;
private
Integer
id
=
null
;
@EJB
private
TournamentBeanLocal
tournamentBean
;
@EJB
private
TournamentBeanLocal
tournamentBean
;
public
void
initView
()
{
super
.
requirePermissions
(
TournamentPermission
.
MANAGE_ALL
);
}
public
String
showConfirm
(
Integer
id
)
{
this
.
beginConversation
();
...
...
@@ -26,11 +31,11 @@ public class TournamentDeleteView extends GenericCDIView {
}
public
String
delete
()
{
if
(
this
.
id
!=
null
)
{
if
(
this
.
id
!=
null
)
{
try
{
tournamentBean
.
deleteTournament
(
tournamentBean
.
getTournamentById
(
this
.
id
));
MessageHelper
.
info
(
I18n
.
get
(
"tournament.admin.tournament_deleted_successfully"
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
MessageHelper
.
err
(
I18n
.
get
(
"tournament.admin.tournament_delete_failed"
));
}
}
else
{
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentEditView.java
View file @
2cf5640
...
...
@@ -2,10 +2,10 @@ package fi.codecrew.moya.web.cdiview.tournaments;
import
javax.ejb.EJB
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.enterprise.context.RequestScoped
;
import
javax.inject.Named
;
import
fi.codecrew.moya.beans.TournamentBeanLocal
;
import
fi.codecrew.moya.enums.apps.TournamentPermission
;
import
fi.codecrew.moya.model.Tournament
;
import
fi.codecrew.moya.utilities.I18n
;
import
fi.codecrew.moya.utilities.jsf.MessageHelper
;
...
...
@@ -15,9 +15,19 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView;
@ConversationScoped
public
class
TournamentEditView
extends
GenericCDIView
{
@EJB
private
TournamentBeanLocal
tournamentBean
;
/**
*
*/
private
static
final
long
serialVersionUID
=
-
2655058086651272660L
;
@EJB
private
TournamentBeanLocal
tournamentBean
;
private
Tournament
tournament
=
null
;
public
void
initView
()
{
super
.
requirePermissions
(
TournamentPermission
.
MANAGE_ALL
);
}
public
String
showEdit
(
Integer
tournamentId
)
{
this
.
beginConversation
();
this
.
setTournament
(
tournamentBean
.
getTournamentById
(
tournamentId
));
...
...
@@ -25,11 +35,11 @@ public class TournamentEditView extends GenericCDIView {
}
public
String
commit
()
{
if
(
this
.
tournament
!=
null
)
{
if
(
this
.
tournament
!=
null
)
{
try
{
this
.
tournamentBean
.
editTournament
(
tournament
);
MessageHelper
.
info
(
I18n
.
get
(
"tournament.admin.tournament_edited_successfully"
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
MessageHelper
.
err
(
I18n
.
get
(
"tournament.admin.tournament_edit_failed"
));
}
}
else
{
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentListView.java
View file @
2cf5640
...
...
@@ -16,6 +16,10 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView;
@RequestScoped
public
class
TournamentListView
extends
GenericCDIView
{
/**
*
*/
private
static
final
long
serialVersionUID
=
5401481953726472887L
;
@EJB
private
TournamentBeanLocal
tournamentBean
;
...
...
@@ -23,6 +27,10 @@ public class TournamentListView extends GenericCDIView {
super
.
requirePermissions
(
TournamentPermission
.
VIEW
);
}
public
boolean
canParticipate
()
{
return
super
.
hasPermission
(
TournamentPermission
.
PARTICIPATE
);
}
public
List
<
Tournament
>
getSetupPhaseTournaments
()
{
return
tournamentBean
.
getTournamentsInStatus
(
TournamentStatus
.
SETUP
,
true
);
}
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentParticipateView.java
View file @
2cf5640
...
...
@@ -29,6 +29,10 @@ public class TournamentParticipateView extends GenericCDIView {
@EJB
private
PermissionBeanLocal
permissionBean
;
public
void
initView
()
{
super
.
requirePermissions
(
TournamentPermission
.
PARTICIPATE
);
}
private
String
selectedPlayerLogin
;
private
String
selectedBackupPlayerLogin
;
...
...
@@ -66,6 +70,11 @@ public class TournamentParticipateView extends GenericCDIView {
}
public
String
participate
(
Integer
tournamentId
)
{
if
(!
super
.
hasPermission
(
TournamentPermission
.
PARTICIPATE
))
{
super
.
addFaceMessage
(
"tournament.notRightsToParticipate"
);
return
null
;
}
tournament
=
tournamentBean
.
getTournamentById
(
tournamentId
);
if
(
tournamentBean
.
hasParticipations
(
permissionBean
.
getCurrentUser
(),
tournament
))
{
MessageHelper
.
err
(
"tournament.already_participated_into_tournament"
);
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentRulesView.java
View file @
2cf5640
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
tournaments
;
import
java.util.List
;
import
javax.annotation.PostConstruct
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.faces.bean.ManagedProperty
;
import
javax.inject.Named
;
import
fi.codecrew.moya.beans.TournamentBeanLocal
;
import
fi.codecrew.moya.enums.
TournamentStatus
;
import
fi.codecrew.moya.enums.
apps.TournamentPermission
;
import
fi.codecrew.moya.model.Tournament
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
@Named
@RequestScoped
public
class
TournamentRulesView
{
@EJB
private
TournamentBeanLocal
tournamentBean
;
public
class
TournamentRulesView
extends
GenericCDIView
{
/**
*
*/
private
static
final
long
serialVersionUID
=
590702851593367871L
;
@EJB
private
TournamentBeanLocal
tournamentBean
;
private
Tournament
tournament
;
private
Integer
tournamentId
;
public
void
init
()
{
if
(
super
.
requirePermissions
(
TournamentPermission
.
VIEW
))
{
tournament
=
tournamentBean
.
getTournamentById
(
tournamentId
);
}
}
public
Integer
getTournamentId
()
{
return
tournamentId
;
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment