aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2015-02-08 11:10:16 +0100
committerPacien TRAN-GIRARD2015-02-08 11:10:16 +0100
commitfd5ae4b50e326097194280ad05f19445531338b4 (patch)
tree741596116da777d4fe78f59424e4c9b1019a35b2 /app
parent9079a273501a916262bc50e52f722a9311f12825 (diff)
downloadminibay-fd5ae4b50e326097194280ad05f19445531338b4.tar.gz
Implement money cheat codes
Diffstat (limited to 'app')
-rw-r--r--app/controllers/Console.scala54
1 files changed, 52 insertions, 2 deletions
diff --git a/app/controllers/Console.scala b/app/controllers/Console.scala
index 93bc5d5..58a2478 100644
--- a/app/controllers/Console.scala
+++ b/app/controllers/Console.scala
@@ -1,12 +1,62 @@
1package controllers 1package controllers
2 2
3import java.sql.Timestamp
4
3import play.api._ 5import play.api._
6import play.api.data._
7import play.api.data.Forms._
4import play.api.mvc._ 8import play.api.mvc._
5 9
10import play.api.db.slick._
11import play.api.db.slick.Config.driver.simple._
12import play.api.Play.current
13
14import scala.concurrent.Future
15
16import models._
17
18
19case class CommandData(command: String)
20
6object Console extends Controller { 21object Console extends Controller {
7 22
8 def console = Action { 23 val commandForm = Form(
9 Redirect("/") 24 mapping(
25 "command" -> nonEmptyText
26 )(CommandData.apply)(CommandData.unapply)
27 )
28
29 def console = Auth { implicit request =>
30 if (request.account.isEmpty) {
31 Redirect(routes.Application.index())
32 } else {
33
34 DB.withSession { implicit session =>
35 val commandData = commandForm.bindFromRequest.get
36
37 val grant = commandData.command match {
38 case "kaching" => 1000
39 case "motherlode" => 5000
40 case _ => 0
41 }
42
43 if (grant > 0) {
44 Tables.Transactions += Tables.Transaction(
45 uuid = java.util.UUID.randomUUID.toString,
46 userUuid = request.account.get.userUuid.get,
47 transactionDate = new Timestamp(new java.util.Date().getTime),
48 amount = grant,
49 label = commandData.command
50 )
51
52 Redirect(routes.Application.index()).flashing("success" -> commandData.command)
53 } else {
54 Redirect(routes.Application.index())
55 }
56
57 }
58 }
59
10 } 60 }
11 61
12} 62}