Skip to content
This repository has been archived by the owner on May 5, 2022. It is now read-only.

Commit

Permalink
Merge pull request #324 from echo-webkom/develop
Browse files Browse the repository at this point in the history
Release 7.2.1
  • Loading branch information
bakseter authored May 5, 2022
2 parents 3238150 + eada92c commit 8be1c8b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 49 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Cypress](https://github.com/echo-webkom/echo-web-backend/actions/workflows/cypress_test.yaml/badge.svg)](https://github.com/echo-webkom/echo-web-backend/actions/workflows/cypress_test.yaml)


Backend til nettsiden til **echo – Fagutvalget for informatikk** ved Universitetet i Bergen.
Backend til nettsiden til **echo – Linjeforeningen for informatikk** ved Universitetet i Bergen.

Utviklet av frivillige informatikkstudenter fra undergruppen **echo Webkom**.

Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/no/uib/echo/Response.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ enum class Response {
InvalidTerms,
DegreeMismatchBachelor,
DegreeMismatchMaster,
DegreeMismatchKogni,
DegreeMismatchArmninf,
AlreadySubmitted,
AlreadySubmittedWaitList,
Expand Down Expand Up @@ -47,7 +46,7 @@ fun resToJson(
defaultDesc,
regDate
)
Response.DegreeMismatchBachelor, Response.DegreeMismatchMaster, Response.DegreeMismatchKogni, Response.DegreeMismatchArmninf ->
Response.DegreeMismatchBachelor, Response.DegreeMismatchMaster, Response.DegreeMismatchArmninf ->
return ResponseJson(res, "Studieretning og årstrinn stemmer ikke overens.", defaultDesc, regDate)
Response.AlreadySubmitted ->
return ResponseJson(res, "Du er allerede påmeldt.", "Du har allerede fått plass.", regDate)
Expand Down
21 changes: 4 additions & 17 deletions src/main/kotlin/no/uib/echo/plugins/Routing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ import no.uib.echo.schema.SpotRange
import no.uib.echo.schema.SpotRangeWithCountJson
import no.uib.echo.schema.User
import no.uib.echo.schema.UserJson
import no.uib.echo.schema.bachelors
import no.uib.echo.schema.countRegistrationsDegreeYear
import no.uib.echo.schema.insertOrUpdateHappening
import no.uib.echo.schema.masters
import no.uib.echo.schema.selectSpotRanges
import no.uib.echo.schema.toCsv
import no.uib.echo.schema.validateLink
Expand Down Expand Up @@ -371,25 +373,15 @@ object Routing {
return@post
}

if ((
registration.degree == Degree.DTEK ||
registration.degree == Degree.DSIK ||
registration.degree == Degree.DVIT ||
registration.degree == Degree.BINF ||
registration.degree == Degree.IMO ||
registration.degree == Degree.IKT ||
registration.degree == Degree.KOGNI ||
registration.degree == Degree.ARMNINF
) && registration.degreeYear !in 1..3
) {
if (registration.degree in bachelors && registration.degreeYear !in 1..3) {
call.respond(
HttpStatusCode.BadRequest,
resToJson(Response.DegreeMismatchBachelor, registration.type)
)
return@post
}

if ((registration.degree == Degree.INF || registration.degree == Degree.PROG) && (registration.degreeYear !in 4..5)) {
if (registration.degree in masters && registration.degreeYear !in 4..5) {
call.respond(HttpStatusCode.BadRequest, resToJson(Response.DegreeMismatchMaster, registration.type))
return@post
}
Expand All @@ -402,11 +394,6 @@ object Routing {
return@post
}

if (registration.degree == Degree.KOGNI && registration.degreeYear != 3) {
call.respond(HttpStatusCode.BadRequest, resToJson(Response.DegreeMismatchKogni, registration.type))
return@post
}

if (!registration.terms) {
call.respond(HttpStatusCode.BadRequest, resToJson(Response.InvalidTerms, registration.type))
return@post
Expand Down
10 changes: 6 additions & 4 deletions src/main/kotlin/no/uib/echo/schema/Degree.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ enum class Degree {
DVIT,
BINF,
IMO,
IKT,
KOGNI,
INF,
PROG,
ARMNINF,
POST,
MISC
MISC,
// IKT and KOGNI should not be used,
// they are only here for backwards compatibility.
IKT,
KOGNI
}

val bachelors: List<Degree> = listOf(Degree.DTEK, Degree.DSIK, Degree.DVIT, Degree.BINF, Degree.IMO, Degree.IKT)
val bachelors: List<Degree> = listOf(Degree.DTEK, Degree.DSIK, Degree.DVIT, Degree.BINF, Degree.IMO)
val masters: List<Degree> = listOf(Degree.INF, Degree.PROG)
25 changes: 0 additions & 25 deletions src/test/kotlin/no/uib/echo/HappeningRegistrationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,6 @@ class HappeningRegistrationTest : StringSpec({
submitReg(m, y, t)
}
}

submitReg(Degree.KOGNI, 3, t)
submitReg(Degree.ARMNINF, 1, t)
}
}
}
Expand Down Expand Up @@ -578,7 +575,6 @@ class HappeningRegistrationTest : StringSpec({
Degree.DVIT,
Degree.BINF,
Degree.IMO,
Degree.IKT,
).map { deg ->
for (t in be) {
for (year in 4..5) {
Expand Down Expand Up @@ -624,27 +620,6 @@ class HappeningRegistrationTest : StringSpec({
}
}

"If degree is KOGNI, degree year should be equal to three." {
withTestApplication({
configureRouting(adminKey, null, true, featureToggles)
}) {
for (t in be) {
val testCall: TestApplicationCall =
handleRequest(method = HttpMethod.Post, uri = "/${Routing.registrationRoute}") {
addHeader(HttpHeaders.ContentType, "application/json")
val invalidDegreeYear = exampleHappeningReg(t).copy(degreeYear = 2, degree = Degree.KOGNI)
setBody(Json.encodeToString(invalidDegreeYear))
}

testCall.response.status() shouldBe HttpStatusCode.BadRequest
val res = Json.decodeFromString<ResponseJson>(testCall.response.content!!)
res.code shouldBe Response.DegreeMismatchKogni
res.title shouldBe "Studieretning og årstrinn stemmer ikke overens."
res.desc shouldBe "Vennligst prøv igjen."
}
}
}

"If degree is ARMNINF, degree year should be equal to one." {
withTestApplication({
configureRouting(adminKey, null, true, featureToggles)
Expand Down

0 comments on commit 8be1c8b

Please sign in to comment.