Commit adceb398 authored by Bas Lijnse's avatar Bas Lijnse

Restored inclusion of user management for admin user in BasicAPIExamples

parent a31ae2bc
...@@ -34,7 +34,8 @@ makeExs :: [FilePath] -> [String] ...@@ -34,7 +34,8 @@ makeExs :: [FilePath] -> [String]
makeExs i = makeExs i =
[ "module BasicAPIExamples\n" [ "module BasicAPIExamples\n"
, "\n" , "\n"
, "import iTasks" , "import iTasks\n"
, "import qualified iTasks.Extensions.Admin.UserAdmin\n"
, "\n" , "\n"
, join "\n" ["import qualified " +++ toDots i\\i<-i] , join "\n" ["import qualified " +++ toDots i\\i<-i]
, "\n\n" , "\n\n"
...@@ -45,8 +46,10 @@ makeExs i = ...@@ -45,8 +46,10 @@ makeExs i =
, "\n" , "\n"
, "basicAPIExamples :: [Workflow]\n" , "basicAPIExamples :: [Workflow]\n"
, "basicAPIExamples =\n" , "basicAPIExamples =\n"
, "\t[",join "\n\t," (map (\i->concat ["'", toDots i, "'.wf \"", toString (insertSpaces 0 (dropExtension i)), "\""]) i), "\n\t]\n"] , "\t[",join "\n\t," (defaultWfs ++ exampleWfs), "\n\t]\n"]
where where
defaultWfs = ["restrictedTransientWorkflow \"Users\" \"User management\" [\"admin\"] 'iTasks.Extensions.Admin.UserAdmin'.manageUsers"]
exampleWfs = map (\i->concat ["'", toDots i, "'.wf \"", toString (insertSpaces 0 (dropExtension i)), "\""]) i
toDots = join "." o split (toString pathSeparator) o dropExtension toDots = join "." o split (toString pathSeparator) o dropExtension
insertSpaces i s insertSpaces i s
| i == size s = [] | i == size s = []
......
...@@ -98,6 +98,7 @@ instance Startable WorkflowCollection ...@@ -98,6 +98,7 @@ instance Startable WorkflowCollection
where where
toStartable {WorkflowCollection|name,workflows} = toStartable {WorkflowCollection|name,workflows} =
[onStartup (installWorkflows workflows) [onStartup (installWorkflows workflows)
,onStartup installDemoUsers
,onRequest "/" (loginAndManageWork name) ,onRequest "/" (loginAndManageWork name)
] ]
...@@ -105,10 +106,15 @@ installWorkflows :: ![Workflow] -> Task () ...@@ -105,10 +106,15 @@ installWorkflows :: ![Workflow] -> Task ()
installWorkflows [] = return () installWorkflows [] = return ()
installWorkflows iflows installWorkflows iflows
= try (get workflows) (\(StoreReadBuildVersionError _) -> return []) = try (get workflows) (\(StoreReadBuildVersionError _) -> return [])
>>= \flows -> case flows of >>- \flows -> case flows of
[] = set iflows workflows @! () [] = set iflows workflows @! ()
_ = return () _ = return ()
installDemoUsers :: Task ()
installDemoUsers
= try (get users) (\(StoreReadBuildVersionError _) -> return [])
>>- \us -> if (length us <= 1) (importDemoUsersFlow @! ()) (return ()) //No users, or just a single root user
loginAndManageWork :: !String -> Task () loginAndManageWork :: !String -> Task ()
loginAndManageWork welcome loginAndManageWork welcome
= forever = forever
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment