^{modalTrigger}|]
Right _ -> [whamlet|^{modalTrigger}|]
diff --git a/src/Model/Migration.hs b/src/Model/Migration.hs
index 1aa9fe36a..ac11d3241 100644
--- a/src/Model/Migration.hs
+++ b/src/Model/Migration.hs
@@ -93,8 +93,8 @@ customMigrations = Map.fromListWith (>>)
, ( AppliedMigrationKey [migrationVersion|0.0.0|] [version|1.0.0|]
, whenM (tableExists "sheet") $ -- Better JSON encoding
[executeQQ|
- ALTER TABLE "sheet" ALTER COLUMN "type" TYPE json USING "type"::json;
- ALTER TABLE "sheet" ALTER COLUMN "grouping" TYPE json USING "grouping"::json;
+ ALTER TABLE "sheet" ALTER COLUMN "type" TYPE jsonb USING "type"::jsonb;
+ ALTER TABLE "sheet" ALTER COLUMN "grouping" TYPE jsonb USING "grouping"::jsonb;
|]
)
, ( AppliedMigrationKey [migrationVersion|1.0.0|] [version|2.0.0|]
@@ -154,7 +154,7 @@ customMigrations = Map.fromListWith (>>)
Just load -> update uid [SheetCorrectorLoad =. load]
_other -> error $ "Could not parse Load: " <> show str
[executeQQ|
- ALTER TABLE "sheet_corrector" ALTER COLUMN "load" TYPE json USING "load"::json;
+ ALTER TABLE "sheet_corrector" ALTER COLUMN "load" TYPE jsonb USING "load"::jsonb;
|]
)
, ( AppliedMigrationKey [migrationVersion|3.0.0|] [version|3.1.0|]
@@ -170,7 +170,7 @@ customMigrations = Map.fromListWith (>>)
, ( AppliedMigrationKey [migrationVersion|3.1.0|] [version|3.2.0|]
, whenM (tableExists "sheet") $
[executeQQ|
- ALTER TABLE "sheet" ADD COLUMN IF NOT EXISTS "upload_mode" json DEFAULT '{ "tag": "Upload", "unpackZips": true }';
+ ALTER TABLE "sheet" ADD COLUMN IF NOT EXISTS "upload_mode" jsonb DEFAULT '{ "tag": "Upload", "unpackZips": true }';
|]
)
, ( AppliedMigrationKey [migrationVersion|3.2.0|] [version|4.0.0|]
@@ -179,13 +179,13 @@ customMigrations = Map.fromListWith (>>)
[executeQQ|
DELETE FROM "user" WHERE "plugin" <> 'LDAP';
ALTER TABLE "user" DROP COLUMN "plugin";
- ALTER TABLE "user" ADD COLUMN IF NOT EXISTS "authentication" json DEFAULT '"ldap"';
+ ALTER TABLE "user" ADD COLUMN IF NOT EXISTS "authentication" jsonb DEFAULT '"ldap"';
|]
)
, ( AppliedMigrationKey [migrationVersion|4.0.0|] [version|5.0.0|]
, whenM (tableExists "user") $
[executeQQ|
- ALTER TABLE "user" ADD COLUMN IF NOT EXISTS "notification_settings" json NOT NULL DEFAULT '[]';
+ ALTER TABLE "user" ADD COLUMN IF NOT EXISTS "notification_settings" jsonb NOT NULL DEFAULT '[]';
|]
)
, ( AppliedMigrationKey [migrationVersion|5.0.0|] [version|6.0.0|]
@@ -199,6 +199,14 @@ customMigrations = Map.fromListWith (>>)
UPDATE "cluster_config" SET "setting" = 'secret-box-key' WHERE "setting" = 'error-message-key';
|]
)
+ , ( AppliedMigrationKey [migrationVersion|7.0.0|] [version|8.0.0|]
+ , whenM (tableExists "sheet") $
+ [executeQQ|
+ UPDATE "sheet" SET "type" = json_build_object('type', "type"->'type', 'grading', "type"->'') WHERE jsonb_exists("type", '');
+ UPDATE "sheet" SET "type" = json_build_object('type', "type"->'type', 'grading', json_build_object('type', "type"->'grading'->'type', 'max', "type"->'grading'->'points')) WHERE ("type"->'grading'->'type') = '"points"' AND jsonb_exists("type"->'grading', 'points');
+ UPDATE "sheet" SET "type" = json_build_object('type', "type"->'type', 'grading', json_build_object('type', "type"->'grading'->'type', 'max', "type"->'grading'->'points', 'passing', 0)) WHERE ("type"->'grading'->'type') = '"pass-points"' AND jsonb_exists("type"->'grading', 'points');
+ |]
+ )
]
diff --git a/src/Model/Types.hs b/src/Model/Types.hs
index e368419c4..4e592e279 100644
--- a/src/Model/Types.hs
+++ b/src/Model/Types.hs
@@ -119,11 +119,11 @@ data SheetGrading
= Points { maxPoints :: Points }
| PassPoints { maxPoints, passingPoints :: Points }
| PassBinary -- non-zero means passed
- deriving (Eq, Read, Show)
+ deriving (Eq, Read, Show, Generic)
deriveJSON defaultOptions
- { constructorTagModifier = intercalate "-" . map toLower . splitCamel
- , fieldLabelModifier = intercalate "-" . map toLower . drop 1 . splitCamel
+ { constructorTagModifier = camelToPathPiece
+ , fieldLabelModifier = intercalate "-" . map toLower . dropEnd 1 . splitCamel
, sumEncoding = TaggedObject "type" "data"
} ''SheetGrading
derivePersistFieldJSON ''SheetGrading
@@ -163,11 +163,11 @@ data SheetType
| Bonus { grading :: SheetGrading }
| Informational { grading :: SheetGrading }
| NotGraded
- deriving (Eq, Read, Show)
+ deriving (Eq, Read, Show, Generic)
deriveJSON defaultOptions
- { constructorTagModifier = intercalate "-" . map toLower . splitCamel
- , fieldLabelModifier = intercalate "-" . map toLower . drop 1 . splitCamel
+ { constructorTagModifier = camelToPathPiece
+ , fieldLabelModifier = camelToPathPiece
, sumEncoding = TaggedObject "type" "data"
} ''SheetType
derivePersistFieldJSON ''SheetType
diff --git a/src/Utils.hs b/src/Utils.hs
index 05e93753a..8965c0009 100644
--- a/src/Utils.hs
+++ b/src/Utils.hs
@@ -100,6 +100,25 @@ unsupportedAuthPredicate = do
|]
+class RedirectUrl site url => HasRoute site url where
+ urlRoute :: url -> Route site
+
+instance HasRoute site (Route site) where
+ urlRoute = id
+instance (key ~ Text, val ~ Text) => HasRoute site (Route site, Map key val) where
+ urlRoute = view _1
+instance (key ~ Text, val ~ Text) => HasRoute site (Route site, [(key, val)]) where
+ urlRoute = view _1
+instance (HasRoute site a, PathPiece b) => HasRoute site (Fragment a b) where
+ urlRoute (a :#: _) = urlRoute a
+
+data SomeRoute site = forall url. HasRoute site url => SomeRoute url
+
+instance RedirectUrl site (SomeRoute site) where
+ toTextUrl (SomeRoute url) = toTextUrl url
+instance HasRoute site (SomeRoute site) where
+ urlRoute (SomeRoute url) = urlRoute url
+
---------------------
-- Text and String --
diff --git a/templates/adminTest.hamlet b/templates/adminTest.hamlet
index 0693ea1cc..2cc3f24f3 100644
--- a/templates/adminTest.hamlet
+++ b/templates/adminTest.hamlet
@@ -32,7 +32,7 @@
^{btnWdgt}
Modals:
- ^{modal "Klick mich für Ajax-Test" (Left UsersR)}
+ ^{modal "Klick mich für Ajax-Test" (Left $ SomeRoute UsersR)}
^{modal "Klick mich für Content-Test" (Right "Test Inhalt für Modal")}
^{modal "Email-Test" (Right emailWidget')}
diff --git a/templates/authpreds.hamlet b/templates/authpreds.hamlet
index abb3042c3..d7430fbae 100644
--- a/templates/authpreds.hamlet
+++ b/templates/authpreds.hamlet
@@ -1,2 +1,4 @@
-