diff --git a/Application.hs b/Application.hs index 5356f19..394f76c 100755 --- a/Application.hs +++ b/Application.hs @@ -55,6 +55,7 @@ import Handler.Barcode import Handler.Transfer import Handler.Supplier import Handler.SupplierActions +import Handler.Demand -- This line actually creates our YesodDispatch instance. It is the second half -- of the call to mkYesodData which occurs in Foundation.hs. Please see the diff --git a/Handler/Buy.hs b/Handler/Buy.hs index 3527681..ce08e1d 100755 --- a/Handler/Buy.hs +++ b/Handler/Buy.hs @@ -61,8 +61,12 @@ postBuyR uId bId = do setMessageI MsgPurchaseSuccess redirect HomeR True -> do - setMessageI MsgPurchaseDebtful - redirect HomeR + let level = case userBalance user - price of + balance + | balance <= -5000 -> 3 + | balance <= -1000 -> 2 + | otherwise -> 1 + redirect $ DemandR level _ -> do setMessageI MsgErrorOccured redirect HomeR diff --git a/Handler/Demand.hs b/Handler/Demand.hs new file mode 100644 index 0000000..ef6cae4 --- /dev/null +++ b/Handler/Demand.hs @@ -0,0 +1,26 @@ +-- yammat - Yet Another MateMAT +-- Copyright (C) 2015 Amedeo Molnár, Astro +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU Affero General Public License as published +-- by the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU Affero General Public License for more details. +-- +-- You should have received a copy of the GNU Affero General Public License +-- along with this program. If not, see . +module Handler.Demand where + +import Import + +getDemandR :: Int -> Handler Html +getDemandR level = defaultLayout $ do + let audio = lookup level $ [1..] `zip` map StaticR + [audio_air_alarm_mp3, + audio_nuclear_alarm_mp3, + audio_alarm_loud_pulsating_mp3] + $(widgetFile "demand") diff --git a/config/routes b/config/routes index 9d8872b..05aafda 100755 --- a/config/routes +++ b/config/routes @@ -43,3 +43,4 @@ /supply/#SupplierId/modify ModifySupplierR GET POST /supply/#SupplierId/digest SupplierDigestR GET /supply/#SupplierId/delete DeleteSupplierR GET +/demand/#Int DemandR GET diff --git a/static/audio/air-alarm.mp3 b/static/audio/air-alarm.mp3 new file mode 100644 index 0000000..3fc0fa2 Binary files /dev/null and b/static/audio/air-alarm.mp3 differ diff --git a/static/audio/alarm-loud-pulsating.mp3 b/static/audio/alarm-loud-pulsating.mp3 new file mode 100644 index 0000000..b094048 Binary files /dev/null and b/static/audio/alarm-loud-pulsating.mp3 differ diff --git a/static/audio/nuclear-alarm.mp3 b/static/audio/nuclear-alarm.mp3 new file mode 100644 index 0000000..000569d Binary files /dev/null and b/static/audio/nuclear-alarm.mp3 differ diff --git a/static/css/main.css b/static/css/main.css index 5461044..f5b5302 100755 --- a/static/css/main.css +++ b/static/css/main.css @@ -275,3 +275,9 @@ input[type], button { #barcodeContent { text-align: center; } + +#demand-warning { + color: red; + font-weight: bold; + font-size: 150%; +} diff --git a/templates/demand.hamlet b/templates/demand.hamlet new file mode 100644 index 0000000..1dcee40 --- /dev/null +++ b/templates/demand.hamlet @@ -0,0 +1,7 @@ +$doctype 5 + +

+ _{MsgPurchaseDebtful} + +$maybe src <- audio +