Skip to content

Commit

Permalink
Remove default nationality from payment personmodule and allow upsert…
Browse files Browse the repository at this point in the history
… to update it
  • Loading branch information
SalamaGofore committed Jan 9, 2025
1 parent 3a06791 commit 9a2afc4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
10 changes: 0 additions & 10 deletions spec/ataru/forms/form_access_control_spec.clj
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,6 @@
(.getMessage e)))]
(should= "Ei oikeuksia muokata lomaketta" result))))

(it "Fails to upsert application payment module when form already has applications"
(with-redefs [form-store/fetch-by-key-for-kk-payment-module-job (fn [_] field-id-test-form)
form-store/form-has-applications (fn [form-key]
(= "test-field-id-change-form" form-key))]
(let [superuser-session (update session :identity assoc :superuser true)
failure-reason (try (fac/upsert-kk-application-payment-module "test-field-id-change-form" superuser-session nil)
(catch Throwable e
(.getMessage e)))]
(should= "Lomakkeella test-field-id-change-form on hakemuksia." failure-reason))))

(it "Updates application payment module"
(with-redefs [form-store/fetch-by-key-for-kk-payment-module-job (fn [_] form-fixtures/person-info-form)
form-store/create-form-or-increment-version! (fn [_ _ _])
Expand Down
4 changes: 1 addition & 3 deletions src/clj/ataru/forms/form_access_control.clj
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,8 @@
(defn upsert-kk-application-payment-module [form-key session audit-logger]
(log/info (str "Upserting kk-application-payment-module to form " form-key))
(when (not (-> session :identity :superuser)) (throw (user-feedback-exception "Ei oikeuksia muokata lomaketta")))
(let [form (form-store/fetch-by-key-for-kk-payment-module-job form-key)
has-applications? (form-store/form-has-applications form-key)]
(let [form (form-store/fetch-by-key-for-kk-payment-module-job form-key)]
(when (nil? form) (throw (user-feedback-exception (str "Lomaketta avaimella " form-key " ei löytynyt"))))
(when has-applications? (throw (user-feedback-exception (str "Lomakkeella " (:key form) " on hakemuksia."))))
(if (payment-utils/has-payment-module? form)
(update-payment-module-to-form form session audit-logger)
(add-payment-module-to-form form session audit-logger))))
Expand Down
8 changes: 7 additions & 1 deletion src/clj/ataru/kk_application_payment/utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,14 @@
(let [sections (:content form)
payment-section (kk-application-payment-module)
update-fn (fn[section]
(if (= (:id section) kk-application-payment-wrapper-key)
(cond
(= (:id section) kk-application-payment-wrapper-key)
payment-section

(= :person-info (keyword (:module section)))
(person-info-module :onr-kk-application-payment)

:else
section))
updated-content (map update-fn sections)]
(assoc form :content updated-content)))
2 changes: 1 addition & 1 deletion src/cljc/ataru/component_data/person_info_module.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
:rules (if gender?
{:toggle-ssn-based-fields nil}
{:toggle-ssn-based-fields-without-gender nil})
:koodisto-source {:uri "maatjavaltiot2" :version 2 :default-option "Suomi"}})]})))
:koodisto-source {:uri "maatjavaltiot2" :version 2}})]})))

(defn- country-of-residence-component
[metadata]
Expand Down

0 comments on commit 9a2afc4

Please sign in to comment.