From 1c1dc70066553422df757e6f0eb06919f5900c07 Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Wed, 20 Mar 2019 14:09:46 +0100 Subject: [PATCH] Various minor fixes --- ChangeLog.md | 4 ++++ messages/uniworx/de.msg | 4 ++-- models/courses | 4 ++-- models/tutorials | 2 +- src/Handler/Course.hs | 10 +++++----- src/Handler/Utils/TermCandidates.hs | 8 ++++---- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 59d7755a2..c1ce2db41 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,7 @@ + * Version 20.03.2019 + + Kursanmeldung benötigen assoziertes Hauptfach (für Studierende mit mehreren Hauptfächern) + * Version 30.01.2019 Designänderungen diff --git a/messages/uniworx/de.msg b/messages/uniworx/de.msg index 0155c491a..0b5ad6e65 100644 --- a/messages/uniworx/de.msg +++ b/messages/uniworx/de.msg @@ -71,8 +71,8 @@ CourseNewHeading: Neuen Kurs anlegen CourseEditHeading tid@TermId ssh@SchoolId csh@CourseShorthand: Kurs #{display tid}-#{display ssh}-#{csh} editieren CourseEditTitle: Kurs editieren/anlegen CourseMembers: Teilnehmer -CourseMembersCount num@Int64: #{display num} -CourseMembersCountLimited num@Int64 max@Int64: #{display num}/#{display max} +CourseMembersCount n@Int: #{display n} +CourseMembersCountLimited n@Int max@Int: #{display n}/#{display max} CourseName: Name CourseDescription: Beschreibung CourseDescriptionTip: Beliebiges HTML-Markup ist gestattet diff --git a/models/courses b/models/courses index c2720cccf..fb9b06462 100644 --- a/models/courses +++ b/models/courses @@ -10,7 +10,7 @@ Course -- Information about a single course; contained info is always visible shorthand (CI Text) -- practical shorthand of course name, used for identification term TermId -- semester this course is taught school SchoolId - capacity Int64 Maybe -- number of allowed enrolements, if restricted + capacity Int Maybe -- number of allowed enrolements, if restricted -- canRegisterNow = maybe False (<= currentTime) registerFrom && maybe True (>= currentTime) registerTo registerFrom UTCTime Maybe -- enrolement allowed from a given day onwwards or prohibited registerTo UTCTime Maybe -- enrolement may be prohibited from a given date onwards @@ -20,7 +20,7 @@ Course -- Information about a single course; contained info is always visible TermSchoolCourseShort term school shorthand -- shorthand must be unique within school and semester TermSchoolCourseName term school name -- name must be unique within school and semester deriving Generic -CourseEdit -- who edited when a row in table "Course", kept indefinitely +CourseEdit -- who edited when a row in table "Course", kept indefinitely (might be replaced by generic Audit Table; like all ...-Edit tables) user UserId time UTCTime course CourseId diff --git a/models/tutorials b/models/tutorials index 8e657a672..3afed739e 100644 --- a/models/tutorials +++ b/models/tutorials @@ -4,7 +4,7 @@ Tutorial json name Text tutor UserId course CourseId - capacity Int64 Maybe -- limit for enrolement in this tutorial + capacity Int Maybe -- limit for enrolement in this tutorial TutorialUser user UserId tutorial TutorialId diff --git a/src/Handler/Course.hs b/src/Handler/Course.hs index 823504dcc..838f81fe7 100644 --- a/src/Handler/Course.hs +++ b/src/Handler/Course.hs @@ -31,7 +31,7 @@ import qualified Database.Esqueleto as E -- NOTE: Outdated way to use dbTable; see ProfileDataR Handler for a more recent method. -type CourseTableData = DBRow (Entity Course, Int64, Bool, Entity School) +type CourseTableData = DBRow (Entity Course, Int, Bool, Entity School) colCourse :: IsDBTable m a => Colonnade Sortable CourseTableData (DBCell m a) colCourse = sortable (Just "course") (i18nCell MsgCourse) @@ -108,10 +108,10 @@ colRegistered = sortable (Just "registered") (i18nCell MsgRegistered) type CourseTableExpr = E.SqlExpr (Entity Course) `E.InnerJoin` E.SqlExpr (Entity School) -course2Participants :: CourseTableExpr -> E.SqlExpr (E.Value Int64) +course2Participants :: CourseTableExpr -> E.SqlExpr (E.Value Int) course2Participants (course `E.InnerJoin` _school) = E.sub_select . E.from $ \courseParticipant -> do E.where_ $ courseParticipant E.^. CourseParticipantCourse E.==. course E.^. CourseId - return (E.countRows :: E.SqlExpr (E.Value Int64)) + return (E.countRows :: E.SqlExpr (E.Value Int)) course2Registered :: Maybe UserId -> CourseTableExpr -> E.SqlExpr (E.Value Bool) course2Registered muid (course `E.InnerJoin` _school) = E.exists . E.from $ \courseParticipant -> @@ -281,7 +281,7 @@ getCShowR tid ssh csh = do E.limit 1 -- we know that there is at most one match, but we tell the DB this info too let numParticipants = E.sub_select . E.from $ \part -> do E.where_ $ part E.^. CourseParticipantCourse E.==. course E.^. CourseId - return ( E.countRows :: E.SqlExpr (E.Value Int64)) + return ( E.countRows :: E.SqlExpr (E.Value Int)) return (course,school E.^. SchoolName, numParticipants, participant) defSFid <- ifMaybeM mbAid Nothing $ \uid -> lift $ selectFirst [StudyFeaturesUser ==. uid, StudyFeaturesType ==. FieldPrimary, StudyFeaturesValid ==. True] [Desc StudyFeaturesUpdated, Desc StudyFeaturesDegree, Desc StudyFeaturesField] -- sorting by degree & field is an heuristic only, but this is okay for a default suggestion lecturers <- lift . E.select $ E.from $ \(lecturer `E.InnerJoin` user) -> do @@ -532,7 +532,7 @@ data CourseForm = CourseForm , cfShort :: CourseShorthand , cfTerm :: TermId , cfSchool :: SchoolId - , cfCapacity :: Maybe Int64 + , cfCapacity :: Maybe Int , cfSecret :: Maybe Text , cfMatFree :: Bool , cfRegFrom :: Maybe UTCTime diff --git a/src/Handler/Utils/TermCandidates.hs b/src/Handler/Utils/TermCandidates.hs index 0832c343d..5eeba9a56 100644 --- a/src/Handler/Utils/TermCandidates.hs +++ b/src/Handler/Utils/TermCandidates.hs @@ -37,9 +37,9 @@ data FailedCandidateInference = FailedCandidateInference [Entity StudyTerms] instance Exception FailedCandidateInference -- Default Instance --- | Just an heuristik to fill in defaults -shortenStudyTerm :: Text -> Text -shortenStudyTerm = concatMap (take 4) . splitCamel +-- -- | Just an heuristik to fill in defaults +-- shortenStudyTerm :: Text -> Text +-- shortenStudyTerm = concatMap (take 4) . splitCamel -- | Attempt to identify new StudyTerms based on observations, returning: -- * list of ambiguous instances that were discarded outright (identical names for differents keys observed in single incidences) @@ -162,7 +162,7 @@ acceptSingletons = do -- registerFixed :: (STKey, Text) -> DB (Key StudyTerms) registerFixed :: (STKey, Text) -> DB () - registerFixed (key, name) = repsert (StudyTermsKey' key) $ StudyTerms key (Just $ shortenStudyTerm name) (Just name) + registerFixed (key, name) = repsert (StudyTermsKey' key) $ StudyTerms key Nothing (Just name) -- register newly fixed candidates forM_ fixedKeys registerFixed