Skip to content

Commit eb478cf

Browse files
committed
Merge pull request #280 from asobolev/master
bugfix with unique short for confs
2 parents 7f3b33d + 67722bb commit eb478cf

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

app/controllers/Application.scala

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,18 @@ class Application(implicit val env: Environment[Login, CachedCookieAuthenticator
6767
}
6868

6969
def conferences = UserAwareAction { implicit request =>
70+
val is_admin = request.identity match {
71+
case Some(uid) => uid.account.isAdmin
72+
case _ => false
73+
}
74+
7075
val conferences = conferenceService.list()
7176

72-
val list_opened = conferences.filter(conf => conf.isOpen)
7377
val list_published = conferences.filter(conf => conf.isPublished && !conf.isOpen)
78+
var list_opened = conferences.filter(conf => !list_published.contains(conf))
79+
if (!is_admin) {
80+
list_opened = list_opened.filter(conf => conf.isOpen)
81+
}
7482

7583
Ok(views.html.conferencelist(request.identity.map{ _.account }, list_opened, list_published))
7684
}
@@ -112,7 +120,6 @@ class Application(implicit val env: Environment[Login, CachedCookieAuthenticator
112120
}
113121
}
114122

115-
116123
def adminAbstracts(confId: String) = SecuredAction { implicit request =>
117124
val conference = conferenceService.get(confId)
118125

app/models/Conference.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class Conference extends Model with Owned {
3333
def dateFormatter = DateTimeFormat.forPattern("d MMMM, yyyy")
3434

3535
var name: String = _
36+
@Column(unique = true)
3637
var short: String = _
3738
var cite: String = _
3839
var link: String = _

test/controller/ConferenceCtrlTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ConferenceCtrlTest extends BaseCtrlTest {
2626

2727
@Test
2828
def testCreate(): Unit = {
29-
val body = formatter.writes(assets.conferences(0)).as[JsObject] - "uuid" - "abstracts"
29+
val body = formatter.writes(assets.conferences(0)).as[JsObject] - "uuid" - "abstracts" - "short"
3030

3131
val createUnauth = FakeRequest(POST, "/api/conferences").withHeaders(
3232
("Content-Type", "application/json")

0 commit comments

Comments
 (0)