Skip to content

Commit

Permalink
OY-4309 virheenkäsittely ja toaster
Browse files Browse the repository at this point in the history
  • Loading branch information
marjakari committed Nov 14, 2023
1 parent 59bcd42 commit 847f05b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
15 changes: 11 additions & 4 deletions src/clj/ataru/applications/application_service.clj
Original file line number Diff line number Diff line change
Expand Up @@ -537,19 +537,26 @@
(save-application-review
[_ session review]
(let [application-key (:application-key review)]
(when (aac/applications-review-authorized?
(when (aac/applications-access-authorized?
organization-service
tarjonta-service
session
(keys (:hakukohde-reviews review))
[application-key]
[:edit-applications])
(when-let [event-id (application-store/save-application-review review session audit-logger)]
(tutkintojen-tunnustaminen/start-tutkintojen-tunnustaminen-review-state-changed-job
job-runner
event-id))
(save-application-hakukohde-reviews application-key (:hakukohde-reviews review) session audit-logger)
(save-attachment-hakukohde-reviews application-key (:attachment-reviews review) session audit-logger)
{:events (get-application-events organization-service application-key)})))
(if (aac/applications-review-authorized?
organization-service
tarjonta-service
session
(keys (:hakukohde-reviews review))
[:edit-applications])
(do (save-application-hakukohde-reviews application-key (:hakukohde-reviews review) session audit-logger)
{:events (get-application-events organization-service application-key)})
:forbidden))))

(payment-triggered-processing-state-change
[_ session application-key message payment-url state]
Expand Down
12 changes: 7 additions & 5 deletions src/clj/ataru/virkailija/virkailija_routes.clj
Original file line number Diff line number Diff line change
Expand Up @@ -706,14 +706,16 @@
:summary "Update existing application review"
:body [review ataru-schema/Review]
:return {:events [ataru-schema/Event]}
(if-let [result (application-service/save-application-review
(let [result (application-service/save-application-review
application-service
session
review)]
(response/ok result)
(response/forbidden {:error (str "Hakemuksen "
(:application-key review)
" käsittely ei ole sallittu")})))
(case result
:forbidden (response/forbidden {:error "Sinulla on valittuna hakukohde jonka käsittelyyn ei ole oikeuksia, käsittelytietoja ei tallennettu."})
nil (response/unauthorized {:error (str "Hakemuksen "
(:application-key review)
" käsittely ei ole sallittu")})
(-> (response/ok result)))))

(api/POST "/information-request" {session :session}
:body [information-request ataru-schema/NewInformationRequest]
Expand Down
12 changes: 7 additions & 5 deletions src/cljs/ataru/virkailija/virkailija_ajax.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@

(defn dispatch-toast-error-msg
[method response path]
(when
(or (>= (:status response) 500)
(= (:status response) 403))
(cond
(>= (:status response) 500)
(dispatch
[:add-toast-message
(str "Virhe kutsussa " (string/upper-case (name method)) " " path ": " (:status response) ", " (:response response))])))
[:add-toast-message
(str "Virhe kutsussa " (string/upper-case (name method)) " " path ": " (:status response) ", " (:response response))])
(= (:status response) 403)
(dispatch
[:add-toast-message (-> response :response :error)])))


(defn dispatch-flasher-error-msg
Expand Down

0 comments on commit 847f05b

Please sign in to comment.