chore(letter): implement print center acknowledging list
This commit is contained in:
parent
ea2873476b
commit
efc13f4498
@ -1,9 +1,11 @@
|
||||
PJActAcknowledge: Druck und Versand bestätigen
|
||||
PrintJobName: Dummy TODO EN
|
||||
PrintJobId: Dummy TODO EN
|
||||
PrintJobCreated: Dummy TODO EN
|
||||
PrintJobAcknowledged: Dummy TODO EN
|
||||
PrintRecipient: Dummy TODO EN
|
||||
PrintSender: Dummy TODO EN
|
||||
PrintCourse: Dummy TODO EN
|
||||
PrintQualification: Dummy TODO EN
|
||||
PrintJobName: Bezeichnung
|
||||
PrintJobId !ident-ok: Id
|
||||
PrintJobCreated: Gesendet
|
||||
PrintJobAcknowledged: Bestätigt
|
||||
PrintJobAcknowledge n@Int64: #{n} #{pluralDE n "Druckauftrag" "Druckaufräge"} als gedruckt und versendet bestätigt
|
||||
PrintRecipient: Empfänger
|
||||
PrintSender !ident-ok: Sender
|
||||
PrintCourse: Kurse
|
||||
PrintQualification: Qualifikation
|
||||
PrintPDF !ident-ok: pdf
|
||||
@ -1,9 +1,11 @@
|
||||
PJActAcknowledge: Acknowledge printing and mailing
|
||||
PrintJobName: Dummy TODO DE
|
||||
PrintJobId: Dummy TODO DE
|
||||
PrintJobCreated: Dummy TODO DE
|
||||
PrintJobAcknowledged: Dummy TODO DE
|
||||
PrintRecipient: Dummy TODO DE
|
||||
PrintSender: Dummy TODO DE
|
||||
PrintCourse: Dummy TODO DE
|
||||
PrintQualification: Dummy TODO DE
|
||||
PrintJobName: Description
|
||||
PrintJobId: Id
|
||||
PrintJobCreated: Created
|
||||
PrintJobAcknowledged: Acknowledged
|
||||
PrintJobAcknowledge n@Int64: #{n} #{pluralENs n "print-job"} marked as printed and mailed
|
||||
PrintRecipient: Recipient
|
||||
PrintSender: Sender
|
||||
PrintCourse: Course
|
||||
PrintQualification: Qualification
|
||||
PrintPDF: pdf
|
||||
@ -56,8 +56,8 @@ MppOpening: Anrede
|
||||
MppClosing: Grußformel
|
||||
MppDate: Datum
|
||||
MppURL: Link Prüfung
|
||||
MppLogin: LOGIN
|
||||
MppPin: PIN
|
||||
MppLogin !ident-ok: Login
|
||||
MppPin !ident-ok: Pin
|
||||
MppRecipient: Empfänger
|
||||
MppAddress: Adresse
|
||||
MppLang: Sprache
|
||||
|
||||
@ -135,6 +135,7 @@ MenuLmsDirect: Direkter Upload
|
||||
MenuAvs: Schnittstelle AVS
|
||||
MenuApc: Druckerei
|
||||
MenuPrintSend: Manueller Briefversand
|
||||
MenuPrintDownload: Brief herunterladen
|
||||
|
||||
MenuApiDocs: API-Dokumentation (Englisch)
|
||||
MenuSwagger !ident-ok: OpenAPI 2.0 (Swagger)
|
||||
@ -45,7 +45,7 @@ MenuMessageList: System messages
|
||||
MenuAdminErrMsg: Decrypt error message
|
||||
MenuAdminTokens: Issue tokens
|
||||
MenuProfileData: Personal information
|
||||
MenuTermCreate: Create new semester
|
||||
MenuTermCreate: Create new semester
|
||||
MenuCourseNew: Create new course
|
||||
MenuTermEdit: Edit semester
|
||||
MenuTermCurrent: Current semester
|
||||
@ -128,7 +128,7 @@ MenuQualifications: Qualifcations
|
||||
MenuLms: E-Learning
|
||||
MenuLmsEdit: Edit E-Learning
|
||||
MenuLmsUsers: Download E-Learning Users
|
||||
MenuLmsUserlist: Upload E-Learning Users
|
||||
MenuLmsUserlist: Upload E-Learning Users
|
||||
MenuLmsResult: Upload E-Learning Results
|
||||
MenuLmsUpload: Upload
|
||||
MenuLmsDirect: Direct Upload
|
||||
@ -136,6 +136,7 @@ MenuLmsDirect: Direct Upload
|
||||
MenuAvs: AVS Interface
|
||||
MenuApc: Printing
|
||||
MenuPrintSend: Send Letter
|
||||
MenuPrintDownload: Download Letter
|
||||
|
||||
MenuApiDocs: API documentation
|
||||
MenuSwagger: OpenAPI 2.0 (Swagger)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
PrintJob
|
||||
name Text
|
||||
file FileContentReference
|
||||
filename FilePath
|
||||
file ByteString -- stores plain pdf; otherwise use FileContentReference Maybe
|
||||
created UTCTime
|
||||
acknowledged UTCTime Maybe
|
||||
recipient UserId Maybe -- optional as some letters may contain just an address
|
||||
|
||||
1
routes
1
routes
@ -63,6 +63,7 @@
|
||||
|
||||
/print PrintCenterR GET POST
|
||||
/print/send PrintSendR GET POST
|
||||
/print/download/#CryptoUUIDPrintJob PrintDownloadR GET
|
||||
|
||||
/health HealthR GET !free
|
||||
/instance InstanceR GET !free
|
||||
|
||||
@ -56,6 +56,7 @@ decCryptoIDs [ ''SubmissionId
|
||||
, ''ExternalExamId
|
||||
, ''MaterialFileId
|
||||
, ''AllocationMatchingId
|
||||
, ''PrintJobId
|
||||
]
|
||||
|
||||
decCryptoIDKeySize
|
||||
|
||||
@ -106,8 +106,9 @@ breadcrumb AdminTokensR = i18nCrumb MsgMenuAdminTokens $ Just AdminR
|
||||
breadcrumb AdminCrontabR = i18nCrumb MsgBreadcrumbAdminCrontab $ Just AdminR
|
||||
breadcrumb AdminAvsR = i18nCrumb MsgMenuAvs $ Just AdminR
|
||||
|
||||
breadcrumb PrintCenterR = i18nCrumb MsgMenuApc Nothing
|
||||
breadcrumb PrintSendR = i18nCrumb MsgMenuPrintSend $ Just PrintCenterR
|
||||
breadcrumb PrintCenterR = i18nCrumb MsgMenuApc Nothing
|
||||
breadcrumb PrintSendR = i18nCrumb MsgMenuPrintSend $ Just PrintCenterR
|
||||
breadcrumb (PrintDownloadR _) = i18nCrumb MsgMenuPrintDownload $ Just PrintCenterR
|
||||
|
||||
breadcrumb SchoolListR = i18nCrumb MsgMenuSchoolList $ Just AdminR
|
||||
breadcrumb (SchoolR ssh sRoute) = case sRoute of
|
||||
|
||||
@ -369,7 +369,7 @@ postLmsR sid qsh = do
|
||||
forM_ okUsers $ \(Entity lid LmsUser {lmsUserUser = uid, lmsUserQualification = qid'}) -> do
|
||||
when (isRenewPinAct action) $ do
|
||||
newPin <- liftIO randomLMSpw
|
||||
update lid [LmsUserPin =. newPin, LmsUserDatePin =. now] -- must be within its own runDB
|
||||
update lid [LmsUserPin =. newPin, LmsUserDatePin =. now]
|
||||
when (isNotifyAct action) $
|
||||
queueDBJob $ JobSendNotification { jRecipient = uid, jNotification = NotificationQualificationRenewal qid' }
|
||||
return $ length okUsers
|
||||
|
||||
@ -3,21 +3,23 @@
|
||||
module Handler.PrintCenter
|
||||
( getPrintCenterR, postPrintCenterR
|
||||
, getPrintSendR , postPrintSendR
|
||||
, getPrintDownloadR
|
||||
-- TODO: for testing only, remove exports
|
||||
, mprToMeta
|
||||
) where
|
||||
|
||||
import Import
|
||||
|
||||
--import qualified Data.Set as Set
|
||||
import qualified Data.Set as Set
|
||||
import qualified Data.Map as Map
|
||||
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Lazy as LT
|
||||
import qualified Data.ByteString.Lazy as LBS
|
||||
-- import qualified Data.ByteString.Lazy as LBS
|
||||
import qualified Text.Pandoc as P
|
||||
import qualified Text.Pandoc.Builder as P
|
||||
|
||||
import Database.Persist.Sql (updateWhereCount)
|
||||
import qualified Database.Esqueleto.Legacy as E
|
||||
import qualified Database.Esqueleto.Utils as E
|
||||
import Database.Esqueleto.Utils.TH
|
||||
@ -181,20 +183,21 @@ mkPJTable = do
|
||||
dbtProj = dbtProjFilteredPostId
|
||||
dbtColonnade = mconcat
|
||||
[ dbSelectIf (applying _2) id (return . view (resultPrintJob . _entityKey)) (\r -> isNothing $ r ^? resultPrintJob . _entityVal . _printJobAcknowledged)
|
||||
, sortable (Just "pj-name") (i18nCell MsgPrintJobName) $ \( view $ resultPrintJob . _entityVal . _printJobName -> n) -> textCell n
|
||||
, sortable (Just "pj-id") (i18nCell MsgPrintJobId) $ \( view $ resultPrintJob . _entityKey -> k) -> textCell (tshow k)
|
||||
, sortable (Just "pj-created") (i18nCell MsgPrintJobCreated) $ \( view $ resultPrintJob . _entityVal . _printJobCreated -> t) -> dateTimeCell t
|
||||
, sortable (Just "pj-acknowledged") (i18nCell MsgPrintJobAcknowledged) $ \( view $ resultPrintJob . _entityVal . _printJobAcknowledged -> t) -> maybeDateTimeCell t
|
||||
, sortable (Just "pj-name") (i18nCell MsgPrintJobName) $ \( view $ resultPrintJob . _entityVal . _printJobName -> n) -> textCell n
|
||||
, sortable (Just "pj-id") (i18nCell MsgPrintJobId) $ \( view $ resultPrintJob . _entityKey -> k) -> textCell (tshow k)
|
||||
, sortable (Just "pj-created") (i18nCell MsgPrintJobCreated) $ \( view $ resultPrintJob . _entityVal . _printJobCreated -> t) -> dateTimeCell t
|
||||
, sortable (Just "pj-acknowledged") (i18nCell MsgPrintJobAcknowledged) $ \( view $ resultPrintJob . _entityVal . _printJobAcknowledged -> t) -> maybeDateTimeCell t
|
||||
, sortable (toNothingS "pdf") (i18nCell MsgPrintPDF) $ \( view $ resultPrintJob . _entityKey -> k) -> anchorCellM (PrintDownloadR <$> encrypt k) (text2widget "pdf")
|
||||
, sortable (Just "pj-recipient") (i18nCell MsgPrintRecipient) $ \(preview resultRecipient -> u) -> maybeCell u $ cellHasUserLink AdminUserR
|
||||
, sortable (Just "pj-sender") (i18nCell MsgPrintSender) $ \(preview resultSender -> u) -> maybeCell u $ cellHasUserLink AdminUserR
|
||||
, sortable (Just "pj-course") (i18nCell MsgPrintCourse) $ \(preview $ resultCourse . _entityVal -> c) -> maybeCell c courseCell
|
||||
, sortable (Just "pj-qualification")(i18nCell MsgPrintQualification) $ \(preview $ resultQualification . _entityVal -> q) -> maybeCell q qualificationCell
|
||||
, sortable (Just "pj-sender") (i18nCell MsgPrintSender) $ \(preview resultSender -> u) -> maybeCell u $ cellHasUserLink AdminUserR
|
||||
, sortable (Just "pj-course") (i18nCell MsgPrintCourse) $ \(preview $ resultCourse . _entityVal -> c) -> maybeCell c courseCell
|
||||
, sortable (Just "pj-qualification")(i18nCell MsgPrintQualification) $ \(preview $ resultQualification . _entityVal -> q) -> maybeCell q qualificationCell
|
||||
]
|
||||
dbtSorting = mconcat
|
||||
[ single ("pj-name" , SortColumn $ queryPrintJob >>> (E.^. PrintJobName))
|
||||
, single ("pj-id" , SortColumn $ queryPrintJob >>> (E.^. PrintJobId))
|
||||
, single ("pj-created" , SortColumn $ queryPrintJob >>> (E.^. PrintJobCreated))
|
||||
, single ("pj-acknowledged" , SortColumn $ queryPrintJob >>> (E.^. PrintJobAcknowledged))
|
||||
, single ("pj-acknowledged" , SortColumn $ queryPrintJob >>> (E.^. PrintJobAcknowledged))
|
||||
, single ("pj-recipient" , sortUserNameBareM queryRecipient)
|
||||
, single ("pj-sender" , sortUserNameBareM querySender )
|
||||
, single ("pj-course" , SortColumn $ queryCourse >>> (E.?. CourseName))
|
||||
@ -243,18 +246,23 @@ mkPJTable = do
|
||||
getPrintCenterR, postPrintCenterR :: Handler Html
|
||||
getPrintCenterR = postPrintCenterR
|
||||
postPrintCenterR = do
|
||||
_currentRoute <- fromMaybe (error "printCenterR called from 404-handler") <$> getCurrentRoute -- This should never be called from a 404 handler
|
||||
(_pjRes, _pjTable) <- runDB mkPJTable
|
||||
-- actionUrl <- fromMaybe AdminAvsR <$> getCurrentRoute
|
||||
-- TODO: continue here
|
||||
-- formResult pjRes $ \case
|
||||
-- (PJActAcknowledgeData, pjIds) -> error "continue here"
|
||||
currentRoute <- fromMaybe (error "printCenterR called from 404-handler") <$> getCurrentRoute -- This should never be called from a 404 handler
|
||||
(pjRes, pjTable) <- runDB mkPJTable
|
||||
|
||||
formResult pjRes $ \case
|
||||
(PJActAcknowledgeData, pjIds) -> do
|
||||
let setPJIds = Set.toList pjIds
|
||||
now <- liftIO getCurrentTime
|
||||
num <- runDB $ updateWhereCount [PrintJobAcknowledged ==. Nothing, PrintJobId <-. setPJIds] [PrintJobAcknowledged =. Just now]
|
||||
addMessageI Success $ MsgPrintJobAcknowledge num
|
||||
redirect currentRoute
|
||||
|
||||
siteLayoutMsg MsgMenuApc $ do
|
||||
setTitleI MsgMenuApc
|
||||
$(widgetFile "print-center")
|
||||
|
||||
|
||||
getPrintSendR, postPrintSendR:: Handler Html
|
||||
getPrintSendR, postPrintSendR :: Handler Html
|
||||
getPrintSendR = postPrintSendR
|
||||
postPrintSendR = do
|
||||
((sendResult, sendWidget), sendEnctype) <- runFormPost $ makeRenewalForm Nothing
|
||||
@ -264,8 +272,11 @@ postPrintSendR = do
|
||||
-- now <- liftIO getCurrentTime
|
||||
case e_pdf of
|
||||
Right bs -> do
|
||||
liftIO $ LBS.writeFile "/tmp/generated.pdf" bs
|
||||
addMessage Warning "PDF momentan nur gespeicher unter /tmp/generated.pdf"
|
||||
-- liftIO $ LBS.writeFile "/tmp/generated.pdf" bs -- DEBUGGING ONLY
|
||||
-- addMessage Warning "PDF momentan nur gespeicher unter /tmp/generated.pdf"
|
||||
uID <- maybeAuthId
|
||||
filepath <- runDB $ sendLetter "Test-Brief" bs Nothing uID Nothing Nothing
|
||||
addMessage Success $ toHtml $ "Druckauftrag angelegt für " <> filepath
|
||||
Left err -> addMessage Error . toHtml $ P.renderError err
|
||||
-- TODO: continue here with acutal letter sending!
|
||||
return $ Just ()
|
||||
@ -279,3 +290,20 @@ postPrintSendR = do
|
||||
}
|
||||
-- TODO: use i18nWidgetFile instead if this is to become permanent
|
||||
$(widgetFile "print-send")
|
||||
|
||||
getPrintDownloadR :: CryptoUUIDPrintJob -> Handler TypedContent
|
||||
getPrintDownloadR cupj = do
|
||||
pjId <- decrypt cupj
|
||||
PrintJob {..} <- runDB $ get404 pjId
|
||||
sendByteStringAsFile printJobFilename printJobFile printJobCreated
|
||||
{- for PrintJobFile :: FileContentReference use this code, however, requires instances
|
||||
HasFileReference PrintJob and IsFileReference PrintJob which seemed to complicated... :(
|
||||
serveOneFile $ fileQuery .| C.map entityVal
|
||||
where
|
||||
fileQuery = E.selectSource $ E.from $
|
||||
\pj -> do
|
||||
-- filter to requested file
|
||||
E.where_ (pj E.^. PrintJobId E.==. E.val pjId)
|
||||
-- return file entity
|
||||
return pj
|
||||
-}
|
||||
@ -296,4 +296,3 @@ instance IsFileReference MaterialFile where
|
||||
fileReferenceTitleField = MaterialFileTitle
|
||||
fileReferenceContentField = MaterialFileContent
|
||||
fileReferenceModifiedField = MaterialFileModified
|
||||
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
<section>
|
||||
<p>
|
||||
Hier soll bald eine Tabelle mit allen Druckaufträgen einsehbar sein.
|
||||
^{pjTable}
|
||||
Loading…
Reference in New Issue
Block a user