Merge branch '307-studiengange-behandeln' of gitlab.cip.ifi.lmu.de:jost/UniWorX into 307-studiengange-behandeln

This commit is contained in:
Steffen Jost 2019-03-20 13:15:29 +01:00
commit 7177631236
3 changed files with 12 additions and 3 deletions

View File

@ -42,6 +42,8 @@ import qualified Data.Set as Set
import Data.Map (Map, (!?))
import qualified Data.Map as Map
import Data.List (nubBy)
import Data.Monoid (Any(..))
import Data.Pool
@ -2087,7 +2089,7 @@ instance YesodAuth UniWorX where
Right str <- return $ Text.decodeUtf8' v'
return str
termNames = do
termNames = nubBy ((==) `on` CI.mk) $ do
(k, v) <- ldapData
guard $ k == Attr "dfnEduPersonFieldOfStudyString"
v' <- v

View File

@ -11,7 +11,7 @@ import Control.Monad.Trans.Writer (mapWriterT)
import Utils.Lens
-- import Data.Time
-- import qualified Data.Text as T
import qualified Data.Text as Text
-- import Data.Function ((&))
-- import Yesod.Form.Bootstrap3
@ -237,7 +237,7 @@ postAdminFeaturesR = do
$(widgetFile "adminFeatures")
where
textInputCell lensRes lensDefault = formCell id (return . view (_dbrOutput . _entityKey))
(\row _mkUnique -> (\(res,fieldView) -> (set lensRes <$> res, fvInput fieldView))
(\row _mkUnique -> (\(res,fieldView) -> (set lensRes . assertM (not . Text.null) <$> res, fvInput fieldView))
<$> mopt textField "" (Just $ row ^. lensDefault)
)

View File

@ -216,6 +216,13 @@ customMigrations = Map.fromListWith (>>)
users <- [sqlQQ| SELECT DISTINCT ON ("user"."id") "user"."id", "study_features"."id" FROM "user", "study_features" WHERE "study_features"."user" = "user"."id" AND "study_features"."valid" AND "study_features"."type" = 'FieldPrimary' ORDER BY "user"."id", random(); |]
forM_ users $ \(uid :: UserId, sfid :: StudyFeaturesId) -> [executeQQ| UPDATE "course_participant" SET "field" = #{sfid} WHERE "user" = #{uid} AND "field" IS NULL; |]
)
, ( AppliedMigrationKey [migrationVersion|9.0.0|] [version|10.0.0|]
, do
whenM (columnExists "study_degree" "shorthand") $ [executeQQ| UPDATE "study_degree" SET "shorthand" = NULL WHERE "shorthand" = '' |]
whenM (columnExists "study_degree" "name") $ [executeQQ| UPDATE "study_degree" SET "name" = NULL WHERE "shorthand" = '' |]
whenM (columnExists "study_terms" "shorthand") $ [executeQQ| UPDATE "study_terms" SET "shorthand" = NULL WHERE "shorthand" = '' |]
whenM (columnExists "study_terms" "name") $ [executeQQ| UPDATE "study_terms" SET "name" = NULL WHERE "shorthand" = '' |]
)
]