feat(allocations): delete allocation-users
This commit is contained in:
parent
300c378786
commit
6a1a64a611
@ -241,4 +241,9 @@ AllocationMatchingsLog: Protokoll
|
|||||||
AllocationMatchingsTime: Zeitpunkt
|
AllocationMatchingsTime: Zeitpunkt
|
||||||
AllocationMatchingsFingerprint: Prüfsumme
|
AllocationMatchingsFingerprint: Prüfsumme
|
||||||
|
|
||||||
AllocationMatchingLogFileName tid@TermId ssh@SchoolId ash@AllocationShorthand cID@CryptoUUIDAllocationMatching: za-verteilung.#{toPathPiece tid}-#{ssh}-#{ash}.#{toPathPiece cID}.log
|
AllocationMatchingLogFileName tid@TermId ssh@SchoolId ash@AllocationShorthand cID@CryptoUUIDAllocationMatching: za-verteilung.#{toPathPiece tid}-#{ssh}-#{ash}.#{toPathPiece cID}.log
|
||||||
|
|
||||||
|
AllocationUserDeleteQuestion: Wollen Sie den/die unten aufgeführten Benutzer:in wirklich aus der Zentralanmeldung entfernen?
|
||||||
|
AllocationUserDeleted: Benutzer:in erfolgreich entfernt
|
||||||
|
AllocationApplicationsCount n@Word64: #{n} #{pluralDE n "Bewerbung" "Bewerbungen"}
|
||||||
|
AllocationAllocationsCount n@Word64: #{n} #{pluralDE n "Zuweisung" "Zuweisungen"}
|
||||||
@ -241,3 +241,8 @@ AllocationMatchingsTime: Timestamp
|
|||||||
AllocationMatchingsFingerprint: Fingerprint
|
AllocationMatchingsFingerprint: Fingerprint
|
||||||
|
|
||||||
AllocationMatchingLogFileName tid ssh ash cID: allocation-matching.#{toPathPiece tid}-#{ssh}-#{ash}.#{toPathPiece cID}.log
|
AllocationMatchingLogFileName tid ssh ash cID: allocation-matching.#{toPathPiece tid}-#{ssh}-#{ash}.#{toPathPiece cID}.log
|
||||||
|
|
||||||
|
AllocationUserDeleteQuestion: Do you really want to remove the allocation participant listed below?
|
||||||
|
AllocationUserDeleted: Participant successfully removed
|
||||||
|
AllocationApplicationsCount n: #{n} #{pluralENs n "application"}
|
||||||
|
AllocationAllocationsCount n: #{n} #{pluralENs n "allocation"}
|
||||||
|
|||||||
@ -74,6 +74,7 @@ BreadcrumbAllocationCompute: Platzvergabe berechnen
|
|||||||
BreadcrumbAllocationAccept: Platzvergabe akzeptieren
|
BreadcrumbAllocationAccept: Platzvergabe akzeptieren
|
||||||
BreadcrumbAllocationAddUser: Bewerber:in hinzufügen
|
BreadcrumbAllocationAddUser: Bewerber:in hinzufügen
|
||||||
BreadcrumbAllocationEditUser: Bewerber:in bearbeiten
|
BreadcrumbAllocationEditUser: Bewerber:in bearbeiten
|
||||||
|
BreadcrumbAllocationDelUser: Bewerber:in entfernen
|
||||||
BreadcrumbMessageHide: Verstecken
|
BreadcrumbMessageHide: Verstecken
|
||||||
BreadcrumbFaq !ident-ok: FAQ
|
BreadcrumbFaq !ident-ok: FAQ
|
||||||
BreadcrumbSheetPersonalisedFiles: Personalisierte Dateien herunterladen
|
BreadcrumbSheetPersonalisedFiles: Personalisierte Dateien herunterladen
|
||||||
|
|||||||
@ -74,6 +74,7 @@ BreadcrumbAllocationCompute: Compute allocation
|
|||||||
BreadcrumbAllocationAccept: Accept allocation
|
BreadcrumbAllocationAccept: Accept allocation
|
||||||
BreadcrumbAllocationAddUser: Add applicant
|
BreadcrumbAllocationAddUser: Add applicant
|
||||||
BreadcrumbAllocationEditUser: Edit applicant
|
BreadcrumbAllocationEditUser: Edit applicant
|
||||||
|
BreadcrumbAllocationDelUser: Remove participant
|
||||||
BreadcrumbMessageHide: Hide
|
BreadcrumbMessageHide: Hide
|
||||||
BreadcrumbFaq: FAQ
|
BreadcrumbFaq: FAQ
|
||||||
BreadcrumbSheetPersonalisedFiles: Download personalised sheet files
|
BreadcrumbSheetPersonalisedFiles: Download personalised sheet files
|
||||||
|
|||||||
@ -110,6 +110,7 @@ MenuAllocationPriorities: Zentrale Dringlichkeiten
|
|||||||
MenuAllocationCompute: Platzvergabe berechnen
|
MenuAllocationCompute: Platzvergabe berechnen
|
||||||
|
|
||||||
MenuAllocationAddUser: Bewerber:in hinzufügen
|
MenuAllocationAddUser: Bewerber:in hinzufügen
|
||||||
|
MenuAllocationDelUser: Bewerber:in entfernen
|
||||||
MenuFaq !ident-ok: FAQ
|
MenuFaq !ident-ok: FAQ
|
||||||
MenuSheetPersonalisedFiles: Personalisierte Dateien herunterladen
|
MenuSheetPersonalisedFiles: Personalisierte Dateien herunterladen
|
||||||
MenuCourseSheetPersonalisedFiles: Vorlage für personalisierte Übungsblatt-Dateien herunterladen
|
MenuCourseSheetPersonalisedFiles: Vorlage für personalisierte Übungsblatt-Dateien herunterladen
|
||||||
|
|||||||
@ -111,6 +111,7 @@ MenuAllocationPriorities: Central priorities
|
|||||||
MenuAllocationCompute: Compute allocation
|
MenuAllocationCompute: Compute allocation
|
||||||
|
|
||||||
MenuAllocationAddUser: Add applicant
|
MenuAllocationAddUser: Add applicant
|
||||||
|
MenuAllocationDelUser: Remove participant
|
||||||
MenuFaq: FAQ
|
MenuFaq: FAQ
|
||||||
MenuSheetPersonalisedFiles: Download personalised sheet files
|
MenuSheetPersonalisedFiles: Download personalised sheet files
|
||||||
MenuCourseSheetPersonalisedFiles: Download template for personalised sheet files
|
MenuCourseSheetPersonalisedFiles: Download template for personalised sheet files
|
||||||
|
|||||||
1
routes
1
routes
@ -162,6 +162,7 @@
|
|||||||
/course/#CryptoUUIDCourse/apply AApplyR POST !timeANDallocation-registered
|
/course/#CryptoUUIDCourse/apply AApplyR POST !timeANDallocation-registered
|
||||||
/users AUsersR GET POST !allocation-admin
|
/users AUsersR GET POST !allocation-admin
|
||||||
/users/#CryptoUUIDUser AEditUserR GET POST !allocation-admin
|
/users/#CryptoUUIDUser AEditUserR GET POST !allocation-admin
|
||||||
|
/users/#CryptoUUIDUser/delete ADelUserR GET POST !allocation-admin
|
||||||
!/users/add AAddUserR GET POST !allocation-admin
|
!/users/add AAddUserR GET POST !allocation-admin
|
||||||
/priorities APriosR GET POST !allocation-admin
|
/priorities APriosR GET POST !allocation-admin
|
||||||
/compute AComputeR GET POST !allocation-admin
|
/compute AComputeR GET POST !allocation-admin
|
||||||
|
|||||||
@ -172,6 +172,15 @@ data Transaction
|
|||||||
{ transactionUser :: UserId
|
{ transactionUser :: UserId
|
||||||
, transactionAssimilatedUser :: UserId
|
, transactionAssimilatedUser :: UserId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
| TransactionAllocationUserEdited
|
||||||
|
{ transactionUser :: UserId
|
||||||
|
, transactionAllocation :: AllocationId
|
||||||
|
}
|
||||||
|
| TransactionAllocationUserDeleted
|
||||||
|
{ transactionUser :: UserId
|
||||||
|
, transactionAllocation :: AllocationId
|
||||||
|
}
|
||||||
|
|
||||||
deriving (Eq, Ord, Read, Show, Generic, Typeable)
|
deriving (Eq, Ord, Read, Show, Generic, Typeable)
|
||||||
|
|
||||||
|
|||||||
@ -66,20 +66,20 @@ import Foundation.I18n.TH
|
|||||||
|
|
||||||
|
|
||||||
pluralDE :: (Eq a, Num a)
|
pluralDE :: (Eq a, Num a)
|
||||||
=> a -- ^ Count
|
=> a -- ^ Count
|
||||||
-> Text -- ^ Singular
|
-> Text -- ^ Singular
|
||||||
-> Text -- ^ Plural
|
-> Text -- ^ Plural
|
||||||
-> Text
|
-> Text
|
||||||
pluralDE num singularForm pluralForm
|
pluralDE num singularForm pluralForm
|
||||||
| num == 1 = singularForm
|
| num == 1 = singularForm
|
||||||
| otherwise = pluralForm
|
| otherwise = pluralForm
|
||||||
|
|
||||||
noneOneMoreDE :: (Eq a, Num a)
|
noneOneMoreDE :: (Eq a, Num a)
|
||||||
=> a -- ^ Count
|
=> a -- ^ Count
|
||||||
-> Text -- ^ None
|
-> Text -- ^ None
|
||||||
-> Text -- ^ Singular
|
-> Text -- ^ Singular
|
||||||
-> Text -- ^ Plural
|
-> Text -- ^ Plural
|
||||||
-> Text
|
-> Text
|
||||||
noneOneMoreDE num noneText singularForm pluralForm
|
noneOneMoreDE num noneText singularForm pluralForm
|
||||||
| num == 0 = noneText
|
| num == 0 = noneText
|
||||||
| num == 1 = singularForm
|
| num == 1 = singularForm
|
||||||
@ -95,20 +95,27 @@ noneOneMoreDE num noneText singularForm pluralForm
|
|||||||
-- | otherwise = someText
|
-- | otherwise = someText
|
||||||
|
|
||||||
pluralEN :: (Eq a, Num a)
|
pluralEN :: (Eq a, Num a)
|
||||||
=> a -- ^ Count
|
=> a -- ^ Count
|
||||||
-> Text -- ^ Singular
|
-> Text -- ^ Singular
|
||||||
-> Text -- ^ Plural
|
-> Text -- ^ Plural
|
||||||
-> Text
|
-> Text
|
||||||
pluralEN num singularForm pluralForm
|
pluralEN num singularForm pluralForm
|
||||||
| num == 1 = singularForm
|
| num == 1 = singularForm
|
||||||
| otherwise = pluralForm
|
| otherwise = pluralForm
|
||||||
|
|
||||||
|
pluralENs :: (Eq a, Num a)
|
||||||
|
=> a -- ^ Count
|
||||||
|
-> Text -- ^ Singular
|
||||||
|
-> Text
|
||||||
|
-- ^ @pluralENs n "foo" = pluralEN n "foo" "foos"@
|
||||||
|
pluralENs n t = pluralEN n t $ t `snoc` 's'
|
||||||
|
|
||||||
noneOneMoreEN :: (Eq a, Num a)
|
noneOneMoreEN :: (Eq a, Num a)
|
||||||
=> a -- ^ Count
|
=> a -- ^ Count
|
||||||
-> Text -- ^ None
|
-> Text -- ^ None
|
||||||
-> Text -- ^ Singular
|
-> Text -- ^ Singular
|
||||||
-> Text -- ^ Plural
|
-> Text -- ^ Plural
|
||||||
-> Text
|
-> Text
|
||||||
noneOneMoreEN num noneText singularForm pluralForm
|
noneOneMoreEN num noneText singularForm pluralForm
|
||||||
| num == 0 = noneText
|
| num == 0 = noneText
|
||||||
| num == 1 = singularForm
|
| num == 1 = singularForm
|
||||||
|
|||||||
@ -218,6 +218,7 @@ breadcrumb (AllocationR tid ssh ash sRoute) = case sRoute of
|
|||||||
uid <- decrypt cID
|
uid <- decrypt cID
|
||||||
User{..} <- MaybeT $ get uid
|
User{..} <- MaybeT $ get uid
|
||||||
return (userDisplayName, Just $ AllocationR tid ssh ash AUsersR)
|
return (userDisplayName, Just $ AllocationR tid ssh ash AUsersR)
|
||||||
|
ADelUserR cID -> i18nCrumb MsgBreadcrumbAllocationDelUser . Just $ AllocationR tid ssh ash (AEditUserR cID)
|
||||||
|
|
||||||
breadcrumb ParticipantsListR = i18nCrumb MsgBreadcrumbParticipantsList $ Just CourseListR
|
breadcrumb ParticipantsListR = i18nCrumb MsgBreadcrumbParticipantsList $ Just CourseListR
|
||||||
breadcrumb (ParticipantsR _ _) = i18nCrumb MsgBreadcrumbParticipants $ Just ParticipantsListR
|
breadcrumb (ParticipantsR _ _) = i18nCrumb MsgBreadcrumbParticipants $ Just ParticipantsListR
|
||||||
@ -1556,6 +1557,18 @@ pageActions (AllocationR tid ssh ash AUsersR) = return
|
|||||||
, navChildren = []
|
, navChildren = []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
pageActions (AllocationR tid ssh ash (AEditUserR cID)) = return
|
||||||
|
[ NavPageActionSecondary
|
||||||
|
{ navLink = NavLink
|
||||||
|
{ navLabel = MsgMenuAllocationDelUser
|
||||||
|
, navRoute = AllocationR tid ssh ash $ ADelUserR cID
|
||||||
|
, navAccess' = NavAccessTrue
|
||||||
|
, navType = NavTypeLink { navModal = True }
|
||||||
|
, navQuick' = mempty
|
||||||
|
, navForceActive = False
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
pageActions CourseListR = do
|
pageActions CourseListR = do
|
||||||
participantsSecondary <- pageQuickActions NavQuickViewPageActionSecondary ParticipantsListR
|
participantsSecondary <- pageQuickActions NavQuickViewPageActionSecondary ParticipantsListR
|
||||||
return
|
return
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
module Handler.Allocation.EditUser
|
module Handler.Allocation.EditUser
|
||||||
( getAEditUserR, postAEditUserR
|
( getAEditUserR, postAEditUserR
|
||||||
|
, getADelUserR, postADelUserR
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Import
|
import Import
|
||||||
@ -9,9 +10,14 @@ import Handler.Allocation.UserForm
|
|||||||
import Handler.Utils
|
import Handler.Utils
|
||||||
|
|
||||||
import qualified Data.Map.Strict as Map
|
import qualified Data.Map.Strict as Map
|
||||||
|
import qualified Data.Set as Set
|
||||||
|
|
||||||
import qualified Data.Conduit.Combinators as C
|
import qualified Data.Conduit.Combinators as C
|
||||||
|
|
||||||
|
import Handler.Utils.Delete
|
||||||
|
|
||||||
|
import qualified Database.Esqueleto as E
|
||||||
|
|
||||||
|
|
||||||
getAEditUserR, postAEditUserR :: TermId -> SchoolId -> AllocationShorthand -> CryptoUUIDUser -> Handler Html
|
getAEditUserR, postAEditUserR :: TermId -> SchoolId -> AllocationShorthand -> CryptoUUIDUser -> Handler Html
|
||||||
getAEditUserR = postAEditUserR
|
getAEditUserR = postAEditUserR
|
||||||
@ -39,6 +45,7 @@ postAEditUserR tid ssh ash cID = do
|
|||||||
, allocationUserTotalCourses = aauTotalCourses
|
, allocationUserTotalCourses = aauTotalCourses
|
||||||
, allocationUserPriority = aauPriority
|
, allocationUserPriority = aauPriority
|
||||||
}
|
}
|
||||||
|
audit $ TransactionAllocationUserEdited aauUser aId
|
||||||
|
|
||||||
oldApps <- selectList [CourseApplicationUser ==. aauUser, CourseApplicationAllocation ==. Just aId] []
|
oldApps <- selectList [CourseApplicationUser ==. aauUser, CourseApplicationAllocation ==. Just aId] []
|
||||||
forM_ oldApps $ \(Entity appId CourseApplication{..}) -> do
|
forM_ oldApps $ \(Entity appId CourseApplication{..}) -> do
|
||||||
@ -88,3 +95,54 @@ postAEditUserR tid ssh ash cID = do
|
|||||||
, formAnchor = Nothing :: Maybe Text
|
, formAnchor = Nothing :: Maybe Text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getADelUserR, postADelUserR :: TermId -> SchoolId -> AllocationShorthand -> CryptoUUIDUser -> Handler Html
|
||||||
|
getADelUserR = postADelUserR
|
||||||
|
postADelUserR tid ssh ash cID = do
|
||||||
|
uid <- decrypt cID
|
||||||
|
(aId, auId) <- runDB . maybeT notFound $ do
|
||||||
|
aId <- MaybeT . getKeyBy $ TermSchoolAllocationShort tid ssh ash
|
||||||
|
auId <- MaybeT . getKeyBy $ UniqueAllocationUser aId uid
|
||||||
|
return (aId, auId)
|
||||||
|
|
||||||
|
deleteR DeleteRoute
|
||||||
|
{ drRecords = Set.singleton auId
|
||||||
|
, drGetInfo = \(allocationUser `E.InnerJoin` user) -> do
|
||||||
|
E.on $ allocationUser E.^. AllocationUserUser E.==. user E.^. UserId
|
||||||
|
|
||||||
|
let appsCount = E.subSelectCount . E.from $ \courseApplication ->
|
||||||
|
E.where_ $ courseApplication E.^. CourseApplicationUser E.==. allocationUser E.^. AllocationUserUser
|
||||||
|
E.&&. courseApplication E.^. CourseApplicationAllocation E.==. E.just (allocationUser E.^. AllocationUserAllocation)
|
||||||
|
allocsCount = E.subSelectCount . E.from $ \courseParticipant ->
|
||||||
|
E.where_ $ courseParticipant E.^. CourseParticipantUser E.==. allocationUser E.^. AllocationUserUser
|
||||||
|
E.&&. courseParticipant E.^. CourseParticipantAllocated E.==. E.just (allocationUser E.^. AllocationUserAllocation)
|
||||||
|
|
||||||
|
return ( ( user E.^. UserDisplayName, user E.^. UserSurname )
|
||||||
|
, appsCount :: E.SqlExpr (E.Value Word64)
|
||||||
|
, allocsCount :: E.SqlExpr (E.Value Word64)
|
||||||
|
)
|
||||||
|
, drUnjoin = \(allocationUser `E.InnerJoin` _user) -> allocationUser
|
||||||
|
, drRenderRecord = \((E.Value dName, E.Value sName), E.Value (assertM' (> 0) -> appsCount), E.Value (assertM' (> 0) -> allocsCount)) -> return
|
||||||
|
[whamlet|
|
||||||
|
$newline never
|
||||||
|
^{nameWidget dName sName}
|
||||||
|
$if is _Just appsCount || is _Just allocsCount
|
||||||
|
\ (
|
||||||
|
$maybe c <- appsCount
|
||||||
|
_{MsgAllocationApplicationsCount c}
|
||||||
|
$if is _Just appsCount || is _Just allocsCount
|
||||||
|
, #
|
||||||
|
$maybe c <- appsCount
|
||||||
|
_{MsgAllocationAllocationsCount c}
|
||||||
|
)
|
||||||
|
|]
|
||||||
|
, drRecordConfirmString = \((E.Value dName, _), _, _) -> return [st|#{dName}|]
|
||||||
|
, drFormMessage = \_ -> return Nothing
|
||||||
|
, drCaption = SomeMessage MsgAllocationUserDeleteQuestion
|
||||||
|
, drSuccessMessage = SomeMessage MsgAllocationUserDeleted
|
||||||
|
, drAbort = SomeRoute . AllocationR tid ssh ash $ AEditUserR cID
|
||||||
|
, drSuccess = SomeRoute $ AllocationR tid ssh ash AUsersR
|
||||||
|
, drDelete = \_k doDelete -> do
|
||||||
|
res <- doDelete
|
||||||
|
audit $ TransactionAllocationUserDeleted uid aId
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|||||||
@ -67,6 +67,7 @@ postARegisterR tid ssh ash = do
|
|||||||
}
|
}
|
||||||
[ AllocationUserTotalCourses =. arfTotalCourses
|
[ AllocationUserTotalCourses =. arfTotalCourses
|
||||||
]
|
]
|
||||||
|
audit $ TransactionAllocationUserEdited uid aId
|
||||||
if
|
if
|
||||||
| isRegistered -> addMessageI Success MsgAllocationRegistrationEdited
|
| isRegistered -> addMessageI Success MsgAllocationRegistrationEdited
|
||||||
| otherwise -> addMessageI Success MsgAllocationRegistered
|
| otherwise -> addMessageI Success MsgAllocationRegistered
|
||||||
|
|||||||
Reference in New Issue
Block a user