forked from filipg/gonito
submissions can be sent to review now
This commit is contained in:
parent
d63223837e
commit
e2c5ae179c
@ -121,6 +121,21 @@ $if canGiveUpWorkingOn
|
|||||||
canStartWorkingOn = determineWhetherCanStartWorkingOn (achievementInfoCurrentUser ainfo) (achievementInfoWorkingOn ainfo) (achievementInfoMaxWinners ainfo)
|
canStartWorkingOn = determineWhetherCanStartWorkingOn (achievementInfoCurrentUser ainfo) (achievementInfoWorkingOn ainfo) (achievementInfoMaxWinners ainfo)
|
||||||
canGiveUpWorkingOn = determineWhetherCanGiveUpWorkingOn (achievementInfoCurrentUser ainfo) (achievementInfoWorkingOn ainfo)
|
canGiveUpWorkingOn = determineWhetherCanGiveUpWorkingOn (achievementInfoCurrentUser ainfo) (achievementInfoWorkingOn ainfo)
|
||||||
|
|
||||||
|
getSubmissionForAchievementR :: SubmissionId -> WorkingOnId -> Handler Html
|
||||||
|
getSubmissionForAchievementR submissionId workingOnId = do
|
||||||
|
(Entity userId user) <- requireAuth
|
||||||
|
submission <- runDB $ get404 submissionId
|
||||||
|
workingOn <- runDB $ get404 workingOnId
|
||||||
|
if submissionSubmitter submission == userId && workingOnUser workingOn == userId
|
||||||
|
then
|
||||||
|
do
|
||||||
|
runDB $ update workingOnId [WorkingOnFinalSubmission =. Just submissionId]
|
||||||
|
setMessage $ toHtml ("OK! Your submission now awaits being accepted by a human reviewer" :: Text)
|
||||||
|
else
|
||||||
|
do
|
||||||
|
setMessage $ toHtml ("Not your submission" :: Text)
|
||||||
|
redirect $ EditSubmissionR submissionId
|
||||||
|
|
||||||
getStartWorkingOnR :: AchievementId -> Handler Html
|
getStartWorkingOnR :: AchievementId -> Handler Html
|
||||||
getStartWorkingOnR achievementId = do
|
getStartWorkingOnR achievementId = do
|
||||||
(Entity userId user) <- requireAuth
|
(Entity userId user) <- requireAuth
|
||||||
|
@ -45,6 +45,14 @@ postEditSubmissionR submissionId = do
|
|||||||
getEditSubmissionR submissionId
|
getEditSubmissionR submissionId
|
||||||
|
|
||||||
|
|
||||||
|
getPossibleAchievements userId submissionId = do
|
||||||
|
(Just submission) <- get submissionId
|
||||||
|
let challengeId = submissionChallenge submission
|
||||||
|
achievements <- selectList [AchievementChallenge ==. challengeId] []
|
||||||
|
workingOns <- mapM (\a -> getBy $ UniqueWorkingOnAchievementUser (entityKey a) userId) achievements
|
||||||
|
let rets = Import.zip achievements workingOns
|
||||||
|
return $ Import.map (\(a, (Just w)) -> (a, entityKey w)) $ Import.filter (\(_, mw) -> isJust mw) $ rets
|
||||||
|
|
||||||
addTags submissionId tagsAsText existingOnes = do
|
addTags submissionId tagsAsText existingOnes = do
|
||||||
tids <- tagsAsTextToTagIds tagsAsText
|
tids <- tagsAsTextToTagIds tagsAsText
|
||||||
|
|
||||||
@ -62,6 +70,10 @@ doEditSubmission formWidget formEnctype submissionId = do
|
|||||||
|
|
||||||
tagsAvailableAsJSON <- runDB $ getAvailableTagsAsJSON
|
tagsAvailableAsJSON <- runDB $ getAvailableTagsAsJSON
|
||||||
|
|
||||||
|
(Entity userId user) <- requireAuth
|
||||||
|
|
||||||
|
achievements <- runDB $ getPossibleAchievements userId submissionId
|
||||||
|
|
||||||
defaultLayout $ do
|
defaultLayout $ do
|
||||||
setTitle "Edit a submission"
|
setTitle "Edit a submission"
|
||||||
$(widgetFile "edit-submission")
|
$(widgetFile "edit-submission")
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
/achievements AchievementsR GET POST
|
/achievements AchievementsR GET POST
|
||||||
/start-working-on/#AchievementId StartWorkingOnR GET
|
/start-working-on/#AchievementId StartWorkingOnR GET
|
||||||
/give-up-working-on/#AchievementId GiveUpWorkingOnR GET
|
/give-up-working-on/#AchievementId GiveUpWorkingOnR GET
|
||||||
|
/submission-for-achievement/#SubmissionId/#WorkingOnId SubmissionForAchievementR GET
|
||||||
|
|
||||||
/edit-submission/#SubmissionId EditSubmissionR GET POST
|
/edit-submission/#SubmissionId EditSubmissionR GET POST
|
||||||
|
|
||||||
|
@ -4,3 +4,9 @@
|
|||||||
^{formWidget}
|
^{formWidget}
|
||||||
<button .btn .btn-primary type="submit">
|
<button .btn .btn-primary type="submit">
|
||||||
_{MsgSubmit} <span class="glyphicon glyphicon-upload"></span>
|
_{MsgSubmit} <span class="glyphicon glyphicon-upload"></span>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
$forall (achievement, workingOnId) <- achievements
|
||||||
|
<li><a href=@{SubmissionForAchievementR submissionId workingOnId}>send to review for #{achievementName $ entityVal achievement} achievement
|
||||||
|
Loading…
Reference in New Issue
Block a user