Skip to content

Commit

Permalink
Merge branch 'OK-774-peruutusmahdollisuus-ja-excel' of github.com:Ope…
Browse files Browse the repository at this point in the history
…tushallitus/ataru into koski-tutkinnot-dev

# Conflicts:
#	oph-configuration/config.edn.template
#	resources/ataru-oph.properties
#	resources/less/editor.less
#	resources/less/hakija.less
#	resources/templates/astu_decision_email_template.html
#	resources/templates/email_edit_confirmation_template_fi.html
#	resources/templates/email_kk_payment_link_en.html
#	resources/templates/email_kk_payment_link_fi.html
#	resources/templates/email_kk_payment_link_sv.html
#	resources/templates/email_kk_payment_reminder_en.html
#	resources/templates/email_kk_payment_reminder_fi.html
#	resources/templates/email_kk_payment_reminder_sv.html
#	spec/ataru/forms/form_access_control_spec.clj
#	spec/ataru/kk_application_payment/kk_application_payment_maksut_poller_job_spec.clj
#	spec/ataru/kk_application_payment/kk_application_payment_spec.clj
#	spec/ataru/kk_application_payment/kk_application_payment_status_updater_job_spec.clj
#	spec/ataru/kk_application_payment/kk_application_payment_store_spec.clj
#	spec/ataru/kk_application_payment/utils_spec.clj
#	spec/ataru/person_service/person_integration_spec.clj
#	spec/ataru/util_spec.clj
#	spec/ataru/virkailija/virkailija_routes_spec.clj
#	src/clj/ataru/applications/application_service.clj
#	src/clj/ataru/applications/filtering.clj
#	src/clj/ataru/background_job/maksut_poller_job.clj
#	src/clj/ataru/email/application_email.clj
#	src/clj/ataru/forms/form_access_control.clj
#	src/clj/ataru/forms/form_payment_info.clj
#	src/clj/ataru/hakija/hakija_application_service.clj
#	src/clj/ataru/hakija/validator.clj
#	src/clj/ataru/kk_application_payment/kk_application_payment.clj
#	src/clj/ataru/kk_application_payment/kk_application_payment_maksut_poller_job.clj
#	src/clj/ataru/kk_application_payment/kk_application_payment_module_job.clj
#	src/clj/ataru/kk_application_payment/kk_application_payment_status_updater_job.clj
#	src/clj/ataru/kk_application_payment/kk_application_payment_store.clj
#	src/clj/ataru/kk_application_payment/utils.clj
#	src/clj/ataru/koski/koski_service.clj
#	src/clj/ataru/person_service/person_integration.clj
#	src/clj/ataru/virkailija/virkailija_routes.clj
#	src/cljc/ataru/application/review_states.cljc
#	src/cljc/ataru/component_data/kk_application_payment_module.cljc
#	src/cljc/ataru/component_data/koski_tutkinnot_module.cljc
#	src/cljc/ataru/schema/form_properties_schema.cljc
#	src/cljc/ataru/schema/form_schema.cljc
#	src/cljc/ataru/schema/maksut_schema.cljc
#	src/cljc/ataru/translations/texts.cljc
#	src/cljc/ataru/tutkinto/tutkinto_util.cljc
#	src/cljc/ataru/util.cljc
#	src/cljs/ataru/hakija/application_form_components.cljs
#	src/cljs/ataru/hakija/application_handlers.cljs
#	src/cljs/ataru/hakija/application_tutkinto_handlers.cljs
#	src/cljs/ataru/hakija/application_view.cljs
#	src/cljs/ataru/hakija/components/tutkinnot.cljs
#	src/cljs/ataru/hakija/hakija_readonly.cljs
#	src/cljs/ataru/hakija/subs.cljs
#	src/cljs/ataru/virkailija/application/application_list/virkailija_application_list_view.cljs
#	src/cljs/ataru/virkailija/application/application_review_view.cljs
#	src/cljs/ataru/virkailija/application/handlers.cljs
#	src/cljs/ataru/virkailija/application/payment/payment_handlers.cljs
#	src/cljs/ataru/virkailija/application/payment/payment_subs.cljs
#	src/cljs/ataru/virkailija/application/payment/payment_view.cljs
#	src/cljs/ataru/virkailija/editor/component.cljs
#	src/cljs/ataru/virkailija/editor/handlers.cljs
#	src/cljs/ataru/virkailija/editor/view.cljs
  • Loading branch information
pitkamak committed Dec 30, 2024
2 parents f4f489a + b394f07 commit 927f6d3
Show file tree
Hide file tree
Showing 27 changed files with 10,538 additions and 85 deletions.
10,003 changes: 10,003 additions & 0 deletions dev-resources/koski/application-with-koski-tutkinnot.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
-- NOTE: the migration datestamp is reverse (YYYYDDMM instead of YYYYMMDD) and slightly misdated on purpose:
-- some of the previous migrations from 2024 were accidentally added that way, and we need to run this after those
-- to use the last modified procedure.

-- The original migration was removed before going forward to QA and production, but drop the tables just in case
-- if they still exist and aren't cleaned up manually.

DROP TABLE IF EXISTS kk_application_payment_events;
DROP TABLE IF EXISTS kk_application_payment_states;

-- Store payment info related to individual applications.
-- Use history table with automatic update triggers.

CREATE TABLE kk_application_payments
(
id serial PRIMARY KEY,
application_key varchar(40) UNIQUE,
state text NOT NULL,
reason text,
due_date date,
total_sum text,
maksut_secret text,
required_at timestamp with time zone,
reminder_sent_at timestamp with time zone,
approved_at timestamp with time zone,
created_at timestamp with time zone DEFAULT now(),
modified_at timestamp with time zone DEFAULT now()
);

COMMENT ON TABLE kk_application_payments IS 'Korkeakouluhakujen hakemusmaksujen tila hakemuksittain';

-- Automatic modification timestamps for the main table
CREATE OR REPLACE FUNCTION update_payment_modified_at() RETURNS trigger AS $$
BEGIN
NEW.modified_at := now();
RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER sync_lastmod
BEFORE UPDATE ON kk_application_payments
FOR EACH ROW EXECUTE PROCEDURE update_payment_modified_at();

-- Also update application modified at in sync whenever payment data changes
CREATE TRIGGER set_application_modified_time_on_kk_application_payment_update
AFTER INSERT OR UPDATE OR DELETE
ON kk_application_payments
FOR EACH ROW
EXECUTE PROCEDURE update_application_modified_time();

-- Automatic audit history for payment changes.
CREATE TABLE kk_application_payments_history
(
id serial PRIMARY KEY,
application_key varchar(40),
state text NOT NULL,
reason text,
due_date date,
total_sum text,
maksut_secret text,
required_at timestamp with time zone,
reminder_sent_at timestamp with time zone,
approved_at timestamp with time zone,
created_at timestamp with time zone DEFAULT now(),
modified_at timestamp with time zone DEFAULT now()
);

COMMENT ON TABLE kk_application_payments IS 'Korkeakouluhakujen hakemusmaksujen tilahistoria hakemuksittain';

CREATE OR REPLACE FUNCTION kk_application_payments_history_trigger() RETURNS TRIGGER AS
$$
begin
insert into kk_application_payments_history (
application_key,
state,
reason,
due_date,
total_sum,
maksut_secret,
required_at,
reminder_sent_at,
approved_at,
created_at,
modified_at
) values (
old.application_key,
old.state,
old.reason,
old.due_date,
old.total_sum,
old.maksut_secret,
old.required_at,
old.reminder_sent_at,
old.approved_at,
old.created_at,
old.modified_at
);
return null;
end;
$$ language plpgsql;

CREATE TRIGGER update_kk_application_payments
AFTER UPDATE ON kk_application_payments
FOR EACH ROW
EXECUTE PROCEDURE kk_application_payments_history_trigger();

CREATE TRIGGER delete_kk_application_payments
AFTER DELETE ON kk_application_payments
FOR EACH ROW
EXECUTE PROCEDURE kk_application_payments_history_trigger();

56 changes: 41 additions & 15 deletions resources/less/hakija.less
Original file line number Diff line number Diff line change
Expand Up @@ -3105,6 +3105,14 @@ i.arkistoitu {
}
}

.application__tutkinto-button-icon {
font-size: 22px;
}

.application__tutkinto-button-text {
font-weight: normal;
}

.application__tutkinto-header {
align-items: center;
display: flex;
Expand All @@ -3129,14 +3137,6 @@ i.arkistoitu {
border-radius: 0;
text-decoration: none;
}

.button-icon {
font-size: 22px;
}

.button-text {
font-weight: normal;
}
}
}

Expand All @@ -3150,7 +3150,7 @@ i.arkistoitu {
width: 100%;
}

.application__add-tutkinto {
.application__show-additional-tutkinnot {
display: flex;
flex-flow: row nowrap;
align-items: center;
Expand All @@ -3166,22 +3166,48 @@ i.arkistoitu {
font-size: 14px;
}

.button-icon {
font-size: 22px;
}

.button-text {
margin-left: 10px;
}
}

.application__hide-additional-tutkinnot {
display: flex;
flex-flow: row nowrap;
align-items: end;
justify-content: end;
padding-top: 10px;
padding-bottom: 5px;
column-gap: 10px;

.link {
color: @text-color;
cursor: pointer;
border-radius: 0;
text-decoration: none;
}
}

.application__fixed-koski-tutkinto-container {
align-items: center;
display: flex;
justify-content: space-between;
flex-flow: row nowrap;
padding: 19px;
margin-bottom: 1px;
font-size: 14px;
font-weight: bold;
background-color: @primary-green-700;
color: @white;
}

.application__fixed-koski-tutkinto-item {
align-items: flex-start;
cursor: pointer;
display: flex;
justify-content: space-between;
flex-flow: row nowrap;
padding: 19px;
justify-content: flex-start;
padding: 10px 19px;
margin-bottom: 1px;
font-size: 14px;
background-color: @primary-green-100;
Expand Down
19 changes: 19 additions & 0 deletions resources/templates/email_kk_payment_confirmation_en.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body style="margin: 0; font-family: 'Open Sans', Arial, sans-serif;">
<table style="width: 100%;">
<tr>
<td style="padding-left: 20px; padding-top: 40px;">
Kiitos hakemusmaksun maksamisesta (en)
</td>
</tr>
<tr>
<td style="padding-top: 50px;"></td>
</tr>
</table>
</body>
</html>
19 changes: 19 additions & 0 deletions resources/templates/email_kk_payment_confirmation_fi.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body style="margin: 0; font-family: 'Open Sans', Arial, sans-serif;">
<table style="width: 100%;">
<tr>
<td style="padding-left: 20px; padding-top: 40px;">
Kiitos hakemusmaksun maksamisesta (fi)
</td>
</tr>
<tr>
<td style="padding-top: 50px;"></td>
</tr>
</table>
</body>
</html>
19 changes: 19 additions & 0 deletions resources/templates/email_kk_payment_confirmation_sv.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body style="margin: 0; font-family: 'Open Sans', Arial, sans-serif;">
<table style="width: 100%;">
<tr>
<td style="padding-left: 20px; padding-top: 40px;">
Kiitos hakemusmaksun maksamisesta (sv)
</td>
</tr>
<tr>
<td style="padding-top: 50px;"></td>
</tr>
</table>
</body>
</html>
10 changes: 8 additions & 2 deletions spec/ataru/test_utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
[ataru.fixtures.db.browser-test-db :refer [insert-test-form]]
[ataru.fixtures.excel-fixtures :as fixtures]
[ataru.forms.form-store :as form-store]
[ataru.ohjausparametrit.ohjausparametrit-protocol :as ohjausparametrit-protocol :refer [OhjausparametritService]]
[ataru.ohjausparametrit.ohjausparametrit-protocol :refer [OhjausparametritService]]
[ataru.organization-service.organization-service :as organization-service]
[ataru.tarjonta-service.tarjonta-service :as tarjonta-service]
[ataru.koski.koski-service :refer [KoskiTutkintoService]]
[ataru.virkailija.authentication.virkailija-edit :as virkailija-edit]
[clojure.string :as clj-string]
[ring.mock.request :as mock]
Expand Down Expand Up @@ -134,6 +135,10 @@
OhjausparametritService
(get-parametri [this haku-oid] (get-param this haku-oid)))

(defrecord MockKoskiTutkintoService [koski-cas-client]
KoskiTutkintoService
(get-tutkinnot-for-oppija [_ _] {}))

(defn- default-get-parametri [_ _] {:jarjestetytHakutoiveet true})

(def liiteri-cas-client nil)
Expand All @@ -159,7 +164,8 @@
(tarjonta-service/new-tarjonta-service)
test-koodisto-cache
(organization-service/new-organization-service)
(->MockOhjausparametritServiceWithGetParametri default-get-parametri))))
(->MockOhjausparametritServiceWithGetParametri default-get-parametri)
MockKoskiTutkintoService)))

(defn with-excel-workbook [excel-data run-test]
(let [file (File/createTempFile (str "excel-" (UUID/randomUUID)) ".xlsx")]
Expand Down
13 changes: 13 additions & 0 deletions spec/ataru/tutkinto/tutkinto_util_spec.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(ns ataru.tutkinto.tutkinto-util-spec
(:require [speclj.core :refer :all]
[cheshire.core :as json]
[ataru.tutkinto.tutkinto-util :as tutkinto-util]))

(defn- read-application-json [file-name]
(:application (json/parse-string (slurp (str "dev-resources/koski/" file-name)) true)))

(describe "Finding tutkinto-data from application"
(tags :unit)
(it "should detect tutkinto id fields in application"
(should= true (tutkinto-util/koski-tutkinnot-in-application? (read-application-json "application-with-koski-tutkinnot.json")))
))
27 changes: 27 additions & 0 deletions spec/ataru/util_spec.clj
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,38 @@
(it "reject empty string"
(should-not (util/answered-in-group-idx {:value [""]} 0))
(should-not (util/answered-in-group-idx {:value [[""]]} 0)))
(it "reject blank string"
(should-not (util/answered-in-group-idx {:value [" "]} 0))
(should-not (util/answered-in-group-idx {:value [[" "]]} 0)))
(it "reject non-array answer"
(should-not (util/answered-in-group-idx {:value ""} 0)))
(it "reject index-out-of-bounds answer"
(should-not (util/answered-in-group-idx {:value [["answer"]]} 1))))

(describe "checking non-blank answers"
(tags :unit)
(it "accept non-empty answer"
(should (util/non-blank-answer? {:value "answer"})))
(it "accept non-empty array"
(should (util/non-blank-answer? {:value ["answer"]})))
(it "accept two dimensional non-empty answer"
(should (util/non-blank-answer? {:value [["answer"]]})))
(it "reject empty answer"
(should-not (util/non-blank-answer? {:value []}))
(should-not (util/non-blank-answer? {:value [[]]})))
(it "reject nil answer"
(should-not (util/non-blank-answer? {:value nil}))
(should-not (util/non-blank-answer? {:value [nil]}))
(should-not (util/non-blank-answer? {:value [[nil]]})))
(it "reject empty string"
(should-not (util/non-blank-answer? {:value ""}))
(should-not (util/non-blank-answer? {:value [""]}))
(should-not (util/non-blank-answer? {:value [[""]]})))
(it "reject blank string"
(should-not (util/non-blank-answer? {:value " "}))
(should-not (util/non-blank-answer? {:value [" "]}))
(should-not (util/non-blank-answer? {:value [[" "]]}))))

(def field-descriptor-id "64d4a625-370b-4814-ae4f-d5956e8881be")
(def field-descriptor {:id field-descriptor-id
:label {:fi "Pohjakoulutuksesi?" :sv ""}
Expand Down
6 changes: 3 additions & 3 deletions src/clj/ataru/applications/application_service.clj
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,7 @@
koski-tutkinnot (future (some->> (when requested-tutkinto-levels (:person-oid application))
(koski/get-tutkinnot-for-oppija koski-service)
:opiskeluoikeudet
(parse-koski-tutkinnot
(str/split requested-tutkinto-levels #","))))]
(parse-koski-tutkinnot requested-tutkinto-levels)))]
(util/remove-nil-values {:application (-> application
(dissoc :person-oid)
(assoc :person (get-person this application))
Expand Down Expand Up @@ -583,7 +582,8 @@
tarjonta-service
koodisto-cache
organization-service
ohjausparametrit-service))]
ohjausparametrit-service
koski-service))]
xls
(throw (new RuntimeException "Excelin muodostaminen ei onnistunut"))))))

Expand Down
Loading

0 comments on commit 927f6d3

Please sign in to comment.