@@ -24,18 +24,20 @@ module Database.CourseQueries
24
24
25
25
import Config (runDb )
26
26
import Control.Monad.IO.Class (MonadIO , liftIO )
27
- import Data.Aeson (object , toJSON , Value )
28
- import Data.Char (isAlphaNum , isPunctuation , isAlpha , isDigit )
27
+ import Data.Aeson (Value , object , toJSON )
28
+ import Data.Char (isAlpha , isAlphaNum , isDigit , isPunctuation )
29
29
import Data.List (partition )
30
30
import Data.Maybe (fromJust , fromMaybe )
31
- import qualified Data.Text as T (Text , append , tail , isPrefixOf , toUpper , filter , snoc , take , unpack )
32
- import Database.DataType ( ShapeType ( Node ) , ShapeType ( Hybrid ), ShapeType ( BoolNode ))
33
- import Database.Persist.Sqlite (Entity , PersistEntity , SqlPersistM , PersistValue ( PersistInt64 ), selectList ,
34
- entityKey , entityVal , selectFirst , (==.) , (<-.) , get , keyToValues , PersistValue ( PersistText ),
35
- rawSql )
31
+ import qualified Data.Text as T (Text , append , filter , isPrefixOf , snoc , tail , take , toUpper ,
32
+ unpack )
33
+ import Database.DataType (ShapeType (BoolNode , Hybrid , Node ))
34
+ import Database.Persist.Sqlite (Entity , PersistEntity , PersistValue (PersistInt64 , PersistText ),
35
+ SqlPersistM , entityKey , entityVal , get , keyToValues , rawSql ,
36
+ selectFirst , selectList , (<-.) , (==.) )
36
37
import Database.Tables as Tables
37
- import Happstack.Server.SimpleHTTP (ServerPart , Response , Request , askRq , lookText' , ifModifiedSince )
38
- import Svg.Builder (intersectsWithShape , buildPath , buildEllipses , buildRect )
38
+ import Happstack.Server.SimpleHTTP (Request , Response , ServerPart , askRq , ifModifiedSince ,
39
+ lookText' )
40
+ import Svg.Builder (buildEllipses , buildPath , buildRect , intersectsWithShape )
39
41
import Util.Happstack (createJSONResponse )
40
42
41
43
-- | Queries the database for all matching lectures, tutorials,
@@ -103,8 +105,8 @@ reqsForPost post = do
103
105
where
104
106
-- | TODO: change function to use a regex
105
107
isCourseCode :: String -> Bool
106
- isCourseCode codeStr =
107
- length codeStr == 8 &&
108
+ isCourseCode codeStr =
109
+ length codeStr == 8 &&
108
110
all isAlphaNum codeStr &&
109
111
all isAlpha (take 3 codeStr) &&
110
112
all isDigit (take 3 (drop 3 codeStr)) &&
0 commit comments