Does not compile. Initial Model
This commit is contained in:
parent
bb946e1b11
commit
8a03284e07
121
config/models
121
config/models
@ -7,11 +7,130 @@ Email
|
|||||||
email Text
|
email Text
|
||||||
userId UserId Maybe
|
userId UserId Maybe
|
||||||
verkey Text Maybe
|
verkey Text Maybe
|
||||||
UniqueEmail email
|
UniqueEmail email
|
||||||
Comment json -- Adding "json" causes ToJSON and FromJSON instances to be derived.
|
Comment json -- Adding "json" causes ToJSON and FromJSON instances to be derived.
|
||||||
message Text
|
message Text
|
||||||
userId UserId Maybe
|
userId UserId Maybe
|
||||||
deriving Eq
|
deriving Eq
|
||||||
deriving Show
|
deriving Show
|
||||||
|
--
|
||||||
|
-- above from Template, needs editing
|
||||||
|
--
|
||||||
|
Term json
|
||||||
|
name Text
|
||||||
|
start UTCTime
|
||||||
|
end UTCTime
|
||||||
|
UniqueTerm name
|
||||||
|
deriving Eq
|
||||||
|
School json
|
||||||
|
name Text
|
||||||
|
UniqueSchool name
|
||||||
|
deriving Eq
|
||||||
|
Course json
|
||||||
|
name Text
|
||||||
|
owner UserId
|
||||||
|
schoolId SchoolId
|
||||||
|
termId TermId Maybe
|
||||||
|
capacity Int Maybe
|
||||||
|
created UTCTime
|
||||||
|
changed UTCTime
|
||||||
|
registerFrom UTCTime
|
||||||
|
registerTo UTCTime
|
||||||
|
Lecturer
|
||||||
|
userId UserId
|
||||||
|
courseId CourseId
|
||||||
|
UniqueLecturer userId courseId
|
||||||
|
CourseParticipant
|
||||||
|
userId UserId
|
||||||
|
courseId CourseId
|
||||||
|
registration UTCTime
|
||||||
|
UniqueCourseParticipant userId courseId
|
||||||
|
Sheet
|
||||||
|
courseId CourseId
|
||||||
|
name Text
|
||||||
|
sheetType SheetType
|
||||||
|
maxPoints Double Maybe
|
||||||
|
requiredPoints Double Maybe
|
||||||
|
exerciseId FileId Maybe
|
||||||
|
hintId FileId Maybe
|
||||||
|
solutionId FileId Maybe
|
||||||
|
markingId FIleID Maybe
|
||||||
|
markingText Text
|
||||||
|
activeFrom UTCTime
|
||||||
|
activeTo UTCTime
|
||||||
|
hintFrom UTCTime Maybe
|
||||||
|
solutionFrom UTCTime Maybe
|
||||||
|
created UTCTime
|
||||||
|
changed UTCTime
|
||||||
|
createdBy UserId
|
||||||
|
changedBy UserId
|
||||||
|
File
|
||||||
|
name Text
|
||||||
|
content ByteStream
|
||||||
|
Submission
|
||||||
|
sheetId SheetId
|
||||||
|
fileId FileId
|
||||||
|
updateId FileId Maybe
|
||||||
|
ratingBy UserId Maybe
|
||||||
|
ratingPoints Double Maybe
|
||||||
|
ratingComment Text Maybe
|
||||||
|
rated UTCTime Maybe
|
||||||
|
created UTCTime
|
||||||
|
changed UTCTime
|
||||||
|
createdBy UserId
|
||||||
|
changedBy UserId
|
||||||
|
SubmissionUser
|
||||||
|
userId UserId
|
||||||
|
submissionId SubmissionId
|
||||||
|
UniqueSubmissionUser userId submissionId
|
||||||
|
SubmissionGroup
|
||||||
|
courseId CourseId
|
||||||
|
name Text
|
||||||
|
created UTCTime
|
||||||
|
changed UTCTime
|
||||||
|
createdBy UserId
|
||||||
|
changedBy UserId
|
||||||
|
SubmissionGroupUser
|
||||||
|
solutionGroupId SolutionGroupId
|
||||||
|
userId UserId
|
||||||
|
UniqueSubmissionGroupUser solutionGroupId userId
|
||||||
|
--
|
||||||
|
Tutorial json
|
||||||
|
name Text
|
||||||
|
tutor UserId
|
||||||
|
TutorialParticipant
|
||||||
|
userId UserId
|
||||||
|
tutorialId TutorialId
|
||||||
|
UniqueTutorialParticipant userId tutorialId
|
||||||
|
-- Unclear how to model this correctly
|
||||||
|
Room
|
||||||
|
name Text
|
||||||
|
capacity Int Maybe
|
||||||
|
building Text
|
||||||
|
RoomCourse
|
||||||
|
roomId RoomId
|
||||||
|
courseId CourseId
|
||||||
|
-- not unique, as a course might happen several times
|
||||||
|
RoomTutorial
|
||||||
|
roomId RoomId
|
||||||
|
tutorialId TutorialId
|
||||||
|
RoomExam
|
||||||
|
roomId RoomId
|
||||||
|
examId ExamId
|
||||||
|
RoomBookingRecurring
|
||||||
|
roomId RoomId
|
||||||
|
termId termId
|
||||||
|
start TimeOfDay
|
||||||
|
end TimeOfDay
|
||||||
|
day Weekday
|
||||||
|
created UTCTime
|
||||||
|
changed UTCTime
|
||||||
|
RoomBooking
|
||||||
|
roomId RoomId
|
||||||
|
begin UTCTime
|
||||||
|
end UTCTime
|
||||||
|
created UTCTime
|
||||||
|
changed UTCTime
|
||||||
|
|
||||||
|
|
||||||
-- By default this file is used in Model.hs (which is imported by Foundation.hs)
|
-- By default this file is used in Model.hs (which is imported by Foundation.hs)
|
||||||
|
|||||||
@ -18,3 +18,9 @@ import Database.Persist.Quasi
|
|||||||
-- http://www.yesodweb.com/book/persistent/
|
-- http://www.yesodweb.com/book/persistent/
|
||||||
share [mkPersist sqlSettings, mkMigrate "migrateAll"]
|
share [mkPersist sqlSettings, mkMigrate "migrateAll"]
|
||||||
$(persistFileWith lowerCaseSettings "config/models")
|
$(persistFileWith lowerCaseSettings "config/models")
|
||||||
|
|
||||||
|
instance Show Term where
|
||||||
|
show = termName
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
32
src/ModelData.hs
Normal file
32
src/ModelData.hs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{-# LANGUAGE NamedFieldPuns #-}
|
||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
module ModelData where
|
||||||
|
|
||||||
|
import Database.Persist.TH
|
||||||
|
|
||||||
|
|
||||||
|
data SheetType = Regular | Bonus | Extra
|
||||||
|
deriving (Show, Read, Eq, Ord, Enum, Bounded)
|
||||||
|
derivePersistField "SheetType"
|
||||||
|
|
||||||
|
{- Not needed
|
||||||
|
data Weekday = Mon | Tue | Wed | Thu | Fri | Sat | Sun
|
||||||
|
deriving (Show, Read, Eq, Ord, Enum, Bounded)
|
||||||
|
derivePersistField "Weekday"
|
||||||
|
-}
|
||||||
|
|
||||||
|
{-
|
||||||
|
data Season = WS | SO
|
||||||
|
deriving (Show, Read, Eq, Enum)
|
||||||
|
derivePersistField "Season"
|
||||||
|
|
||||||
|
data Term = Term { season:: Season, year :: Int }
|
||||||
|
|
||||||
|
instance Show Term where
|
||||||
|
show (Term {season, year}) = take 1 (show season) ++ (show year)
|
||||||
|
-}
|
||||||
|
-- instance PersistField Term where
|
||||||
|
-- toPersistValue (Term {season, year}) = undefined
|
||||||
|
-- fromPersistValue (Term {season, year}) = undefined
|
||||||
|
-- sqlType _ = SqlInteger
|
||||||
|
-- isNullable _ = False
|
||||||
Loading…
Reference in New Issue
Block a user