diff --git a/src/Foundation.hs b/src/Foundation.hs index 282b0111e..4295f1179 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -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 diff --git a/src/Handler/Admin.hs b/src/Handler/Admin.hs index 3df9b1b9d..fa09fba75 100644 --- a/src/Handler/Admin.hs +++ b/src/Handler/Admin.hs @@ -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) ) diff --git a/src/Model/Migration.hs b/src/Model/Migration.hs index 38de10773..7b5fcc375 100644 --- a/src/Model/Migration.hs +++ b/src/Model/Migration.hs @@ -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" = '' |] + ) ]