Ord TermIdentifier changed
This commit is contained in:
parent
a71c7326a8
commit
1bca71b720
@ -267,6 +267,7 @@ isAuthenticated = do
|
|||||||
Nothing -> Unauthorized "You must login to access this page"
|
Nothing -> Unauthorized "You must login to access this page"
|
||||||
Just _ -> Authorized
|
Just _ -> Authorized
|
||||||
|
|
||||||
|
|
||||||
instance YesodAuthPersist UniWorX
|
instance YesodAuthPersist UniWorX
|
||||||
|
|
||||||
-- This instance is required to use forms. You can modify renderMessage to
|
-- This instance is required to use forms. You can modify renderMessage to
|
||||||
|
|||||||
@ -22,6 +22,7 @@ getShowTermsR = do
|
|||||||
setTitle "Freigeschaltete Semester"
|
setTitle "Freigeschaltete Semester"
|
||||||
-- TODO: provide common utility function for formatting Times
|
-- TODO: provide common utility function for formatting Times
|
||||||
-- TODO: turn into proper table
|
-- TODO: turn into proper table
|
||||||
|
-- TODO Edit-Links only $if isAdmin, otherwise breadcrumb navigation
|
||||||
[whamlet|
|
[whamlet|
|
||||||
<h2>
|
<h2>
|
||||||
Liste der freigeschalteten Semester:
|
Liste der freigeschalteten Semester:
|
||||||
@ -30,7 +31,7 @@ getShowTermsR = do
|
|||||||
$else
|
$else
|
||||||
<ul>
|
<ul>
|
||||||
$forall Entity _ term <- terms
|
$forall Entity _ term <- terms
|
||||||
<li>
|
<li>
|
||||||
<a href=@{EditTermExistR $ termName term}>
|
<a href=@{EditTermExistR $ termName term}>
|
||||||
#{termToText $ termName term}
|
#{termToText $ termName term}
|
||||||
von #{formatTimeGerWD $ termStart term}
|
von #{formatTimeGerWD $ termStart term}
|
||||||
|
|||||||
@ -56,7 +56,7 @@ seasonFromChar c
|
|||||||
data TermIdentifier = TermIdentifier
|
data TermIdentifier = TermIdentifier
|
||||||
{ year :: Integer -- ^ Using 'Integer' to model years is consistent with 'Data.Time.Calendar'
|
{ year :: Integer -- ^ Using 'Integer' to model years is consistent with 'Data.Time.Calendar'
|
||||||
, season :: Season
|
, season :: Season
|
||||||
} deriving (Show, Read, Eq, Ord, Generic, Typeable)
|
} deriving (Show, Read, Eq, Generic, Typeable)
|
||||||
|
|
||||||
--TODO: Enforce the number of digits within year, with parsing filling in the current leading digits? Goal: short urls
|
--TODO: Enforce the number of digits within year, with parsing filling in the current leading digits? Goal: short urls
|
||||||
termToText :: TermIdentifier -> Text
|
termToText :: TermIdentifier -> Text
|
||||||
@ -70,6 +70,11 @@ termFromText t
|
|||||||
= Right TermIdentifier{..}
|
= Right TermIdentifier{..}
|
||||||
| otherwise = Left $ "Invalid TermIdentifier: “" <> t <> "”"
|
| otherwise = Left $ "Invalid TermIdentifier: “" <> t <> "”"
|
||||||
|
|
||||||
|
instance Ord TermIdentifier where
|
||||||
|
ti1 <= ti2 =
|
||||||
|
year ti1 <= year ti2 ||
|
||||||
|
(year ti1 == year ti2 || season ti1 <= season ti2)
|
||||||
|
|
||||||
instance PersistField TermIdentifier where
|
instance PersistField TermIdentifier where
|
||||||
toPersistValue = PersistText . termToText
|
toPersistValue = PersistText . termToText
|
||||||
fromPersistValue (PersistText t) = termFromText t
|
fromPersistValue (PersistText t) = termFromText t
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user