diff --git a/config/models b/config/models index ed0fe3941..c32c807b6 100644 --- a/config/models +++ b/config/models @@ -7,11 +7,130 @@ Email email Text userId UserId Maybe verkey Text Maybe - UniqueEmail email + UniqueEmail email Comment json -- Adding "json" causes ToJSON and FromJSON instances to be derived. message Text userId UserId Maybe deriving Eq 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) diff --git a/src/Model.hs b/src/Model.hs index 4420c164d..976c88117 100644 --- a/src/Model.hs +++ b/src/Model.hs @@ -18,3 +18,9 @@ import Database.Persist.Quasi -- http://www.yesodweb.com/book/persistent/ share [mkPersist sqlSettings, mkMigrate "migrateAll"] $(persistFileWith lowerCaseSettings "config/models") + +instance Show Term where + show = termName + + + diff --git a/src/ModelData.hs b/src/ModelData.hs new file mode 100644 index 000000000..d5f8a8881 --- /dev/null +++ b/src/ModelData.hs @@ -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 \ No newline at end of file