handle avatar delete error while avatar is in use

This commit is contained in:
nek0 2015-04-18 00:04:13 +02:00
parent 19b115ad94
commit f8e5d0e8a2
4 changed files with 12 additions and 3 deletions

View file

@ -118,9 +118,15 @@ getAvatarDeleteR aId = do
ma <- runDB $ get aId ma <- runDB $ get aId
case ma of case ma of
Just _ -> do Just _ -> do
runDB $ delete aId c <- runDB $ selectList [UserAvatar ==. Just aId] []
setMessageI MsgAvatarDeleted case null c of
redirect $ HomeR True -> do
runDB $ delete aId
setMessageI MsgAvatarDeleted
redirect $ HomeR
False -> do
setMessageI MsgAvatarInUseError
redirect $ AvatarR
Nothing -> do Nothing -> do
setMessageI MsgAvatarUnknown setMessageI MsgAvatarUnknown
redirect $ AvatarR redirect $ AvatarR

View file

@ -96,3 +96,4 @@ NewAvatar: Nový avatar
AvatarUploadSuccessfull: Avatar úspěšně nahrán AvatarUploadSuccessfull: Avatar úspěšně nahrán
DeleteAvatar: Smazat avatar DeleteAvatar: Smazat avatar
AvatarDeleted: Avatar úspěšně smazán AvatarDeleted: Avatar úspěšně smazán
AvatarInUseError: Avatar nelze smazat dokud je v užitku

View file

@ -96,3 +96,4 @@ NewAvatar: Neuer Avatar
AvatarUploadSuccessfull: Avatar erfolgreich hochgeladen AvatarUploadSuccessfull: Avatar erfolgreich hochgeladen
DeleteAvatar: Diesen Avatar löschen DeleteAvatar: Diesen Avatar löschen
AvatarDeleted: Avatar gelöscht AvatarDeleted: Avatar gelöscht
AvatarInUseError: Avatare können nicht gelöscht werden, solange sie in Benutzung sind.

View file

@ -96,3 +96,4 @@ NewAvatar: New avatar
AvatarUploadSuccessfull: Avatar upload successfull AvatarUploadSuccessfull: Avatar upload successfull
DeleteAvatar: Delete avatar DeleteAvatar: Delete avatar
AvatarDeleted: Avatar successfully deleted AvatarDeleted: Avatar successfully deleted
AvatarInUseError: You can not delete avatars that are currently in use