From 807bc84e390db74dabfa5bc9dec6d87cc52fac3f Mon Sep 17 00:00:00 2001 From: Dmitry Marokhonov Date: Thu, 12 Dec 2024 13:47:52 +0200 Subject: [PATCH 1/4] =?UTF-8?q?OY-4826:=20Opinto-ohjaaja=20+=20hakemusten?= =?UTF-8?q?=20k=C3=A4sittelij=C3=A4=20-k=C3=A4ytt=C3=B6oikeuksien=20yhdist?= =?UTF-8?q?elm=C3=A4=20ei=20toimi=20oikein=20hakemuspalvelussa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/application_list/filters_view.cljs | 4 +++- src/cljs/ataru/virkailija/application/view.cljs | 4 ++-- .../ataru/virkailija/editor/editor_selectors.cljs | 13 ++++++++++++- src/cljs/ataru/virkailija/editor/subs.cljs | 6 ++++++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/cljs/ataru/virkailija/application/application_list/filters_view.cljs b/src/cljs/ataru/virkailija/application/application_list/filters_view.cljs index 40fc31456a..f995b83f38 100644 --- a/src/cljs/ataru/virkailija/application/application_list/filters_view.cljs +++ b/src/cljs/ataru/virkailija/application/application_list/filters_view.cljs @@ -305,6 +305,7 @@ tutu-form? (subscribe [:payment/tutu-form? @form-key]) astu-form? (subscribe [:payment/astu-form? @form-key]) opinto-ohjaaja-or-admin? (subscribe [:editor/opinto-ohjaaja-or-admin?]) + opo-and-hak-pal-paakyttaja? (subscribe [:editor/all-organizations-have-opinto-ohjaaja-and-hakemuspalvelun-paakaytajan-rights?]) question-search-id :filters-attachment-search filters-visible (r/atom false) rajaava-hakukohde-opened? (r/atom false) @@ -319,7 +320,8 @@ {:id "open-application-filters" :on-click #(do (when (and @opinto-ohjaaja-or-admin? @toisen-asteen-yhteishaku-selected?) - (dispatch [:application/do-organization-query-for-schools-of-departure ""])) + (when (not @opo-and-hak-pal-paakyttaja?) + (dispatch [:application/do-organization-query-for-schools-of-departure ""]))) (dispatch [:application/undo-filters]) (swap! filters-visible not))} [:span diff --git a/src/cljs/ataru/virkailija/application/view.cljs b/src/cljs/ataru/virkailija/application/view.cljs index 4b71a58026..3f29ab3528 100644 --- a/src/cljs/ataru/virkailija/application/view.cljs +++ b/src/cljs/ataru/virkailija/application/view.cljs @@ -35,7 +35,7 @@ (let [list-opened (r/atom false) open-list #(reset! list-opened true) close-list #(reset! list-opened false) - opinto-ohjaaja (subscribe [:editor/opinto-ohjaaja?]) + only-opinto-ohjaaja? (subscribe [:editor/all-organizations-have-only-opinto-ohjaaja-rights?]) toisen-asteen-yhteishaku? @(subscribe [:application/toisen-asteen-yhteishaku-selected?])] (fn [[haku-oid selected-hakukohde-oid @@ -47,7 +47,7 @@ (if-let [haku-name @(subscribe [:application/haku-name haku-oid])] haku-name [:i.zmdi.zmdi-spinner.spin])] - (when (not @opinto-ohjaaja) + (when (not @only-opinto-ohjaaja?) (closed-row (if @list-opened close-list open-list) (cond (some? selected-hakukohde-oid) @(subscribe [:application/hakukohde-name diff --git a/src/cljs/ataru/virkailija/editor/editor_selectors.cljs b/src/cljs/ataru/virkailija/editor/editor_selectors.cljs index 7b9d79ca5e..702fa23269 100644 --- a/src/cljs/ataru/virkailija/editor/editor_selectors.cljs +++ b/src/cljs/ataru/virkailija/editor/editor_selectors.cljs @@ -1,5 +1,10 @@ (ns ataru.virkailija.editor.editor-selectors) +(defn includes-all? [superset subset] + (every? (set superset) subset)) + +(def opo-ja-hakemuspalvelun-paakayttaja-vec ["form-edit" "edit-valinta" "opinto-ohjaaja" "edit-applications"]) + (defn get-virkailija-lang [db] (or (-> db :editor :user-info :lang keyword) :fi)) @@ -8,4 +13,10 @@ (defn get-all-organizations-have-only-opinto-ohjaaja-rights? [db] (let [user-info (-> db :editor :user-info)] - (every? (fn [org] (every? #(= "opinto-ohjaaja" %) (:rights org))) (:organizations user-info)))) \ No newline at end of file + (every? (fn [org] (every? #(= "opinto-ohjaaja" %) (:rights org))) (:organizations user-info)))) + +(defn get-all-organizations-have-opinto-ohjaaja-and-hakemuspalvelun-paakayttaja-rights? [db] + (let [user-info (-> db :editor :user-info)] + (every? (fn [org] + (includes-all? (:rights org) opo-ja-hakemuspalvelun-paakayttaja-vec)) + (:organizations user-info)))) \ No newline at end of file diff --git a/src/cljs/ataru/virkailija/editor/subs.cljs b/src/cljs/ataru/virkailija/editor/subs.cljs index f92a88fb42..5d3d40a2fb 100644 --- a/src/cljs/ataru/virkailija/editor/subs.cljs +++ b/src/cljs/ataru/virkailija/editor/subs.cljs @@ -4,6 +4,7 @@ [ataru.translations.translation-util :as translations] [ataru.util :as util :refer [collect-ids]] [ataru.virkailija.editor.editor-selectors :refer [get-all-organizations-have-only-opinto-ohjaaja-rights? + get-all-organizations-have-opinto-ohjaaja-and-hakemuspalvelun-paakayttaja-rights? get-email-template get-virkailija-lang]] [cljs-time.coerce :as time-coerce] @@ -587,6 +588,11 @@ (fn [db _] (get-all-organizations-have-only-opinto-ohjaaja-rights? db))) +(re-frame/reg-sub + :editor/all-organizations-have-opinto-ohjaaja-and-hakemuspalvelun-paakaytajan-rights? + (fn [db _] + (get-all-organizations-have-opinto-ohjaaja-and-hakemuspalvelun-paakayttaja-rights? db))) + (re-frame/reg-sub :editor/autosave-enabled? (fn [db _] From 0827a03f828f78c01e82e6e9dc5c3f022ed558cf Mon Sep 17 00:00:00 2001 From: Dmitry Marokhonov Date: Tue, 17 Dec 2024 17:27:12 +0200 Subject: [PATCH 2/4] OY-4826: typo fixes & renaming --- .../virkailija/application/application_list/filters_view.cljs | 4 ++-- src/cljs/ataru/virkailija/editor/subs.cljs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cljs/ataru/virkailija/application/application_list/filters_view.cljs b/src/cljs/ataru/virkailija/application/application_list/filters_view.cljs index f995b83f38..2e0143f8fd 100644 --- a/src/cljs/ataru/virkailija/application/application_list/filters_view.cljs +++ b/src/cljs/ataru/virkailija/application/application_list/filters_view.cljs @@ -305,7 +305,7 @@ tutu-form? (subscribe [:payment/tutu-form? @form-key]) astu-form? (subscribe [:payment/astu-form? @form-key]) opinto-ohjaaja-or-admin? (subscribe [:editor/opinto-ohjaaja-or-admin?]) - opo-and-hak-pal-paakyttaja? (subscribe [:editor/all-organizations-have-opinto-ohjaaja-and-hakemuspalvelun-paakaytajan-rights?]) + opo-and-hak-pal-paakayttaja? (subscribe [:editor/all-organizations-have-opinto-ohjaaja-and-hakemuspalvelun-paakayttaja-rights?]) question-search-id :filters-attachment-search filters-visible (r/atom false) rajaava-hakukohde-opened? (r/atom false) @@ -320,7 +320,7 @@ {:id "open-application-filters" :on-click #(do (when (and @opinto-ohjaaja-or-admin? @toisen-asteen-yhteishaku-selected?) - (when (not @opo-and-hak-pal-paakyttaja?) + (when (not @opo-and-hak-pal-paakayttaja?) (dispatch [:application/do-organization-query-for-schools-of-departure ""]))) (dispatch [:application/undo-filters]) (swap! filters-visible not))} diff --git a/src/cljs/ataru/virkailija/editor/subs.cljs b/src/cljs/ataru/virkailija/editor/subs.cljs index 5d3d40a2fb..c989980b16 100644 --- a/src/cljs/ataru/virkailija/editor/subs.cljs +++ b/src/cljs/ataru/virkailija/editor/subs.cljs @@ -589,7 +589,7 @@ (get-all-organizations-have-only-opinto-ohjaaja-rights? db))) (re-frame/reg-sub - :editor/all-organizations-have-opinto-ohjaaja-and-hakemuspalvelun-paakaytajan-rights? + :editor/all-organizations-have-opinto-ohjaaja-and-hakemuspalvelun-paakayttaja-rights? (fn [db _] (get-all-organizations-have-opinto-ohjaaja-and-hakemuspalvelun-paakayttaja-rights? db))) From 106b6a93bfede92e5c88f2d857d47e7f99cdf456 Mon Sep 17 00:00:00 2001 From: Dmitry Marokhonov Date: Tue, 7 Jan 2025 16:10:02 +0200 Subject: [PATCH 3/4] =?UTF-8?q?OY-4826:=20no=20l=C3=A4ht=C3=B6koulu=20in?= =?UTF-8?q?=20API=20request=20for=20double=20role:=20opo=20&=20hak.=20pal.?= =?UTF-8?q?=20p=C3=A4=C3=A4k=C3=A4ytt=C3=A4j=C3=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/application_list/filters_view.cljs | 3 ++- src/cljs/ataru/virkailija/editor/handlers.cljs | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cljs/ataru/virkailija/application/application_list/filters_view.cljs b/src/cljs/ataru/virkailija/application/application_list/filters_view.cljs index 2e0143f8fd..029f2a9b0c 100644 --- a/src/cljs/ataru/virkailija/application/application_list/filters_view.cljs +++ b/src/cljs/ataru/virkailija/application/application_list/filters_view.cljs @@ -320,7 +320,8 @@ {:id "open-application-filters" :on-click #(do (when (and @opinto-ohjaaja-or-admin? @toisen-asteen-yhteishaku-selected?) - (when (not @opo-and-hak-pal-paakayttaja?) + (if @opo-and-hak-pal-paakayttaja? + (dispatch [:application/do-organization-query-for-schools-of-departure-without-lahtokoulu ""]) (dispatch [:application/do-organization-query-for-schools-of-departure ""]))) (dispatch [:application/undo-filters]) (swap! filters-visible not))} diff --git a/src/cljs/ataru/virkailija/editor/handlers.cljs b/src/cljs/ataru/virkailija/editor/handlers.cljs index be21628a4a..1657688159 100644 --- a/src/cljs/ataru/virkailija/editor/handlers.cljs +++ b/src/cljs/ataru/virkailija/editor/handlers.cljs @@ -1460,6 +1460,15 @@ :skip-parse-times? true :handler-or-dispatch :editor/update-organization-query-results-for-schools-of-departure}}))) +(reg-event-fx + :application/do-organization-query-for-schools-of-departure-without-lahtokoulu + (fn [{db :db} [_]] + (when (empty? (get-in db [:editor :organizations :select])) + {:http {:method :get + :path "/lomake-editori/api/organization/user-organizations?organizations=true&hakukohde-groups=false&lahtokoulu-only=false&results-page=10000" + :skip-parse-times? true + :handler-or-dispatch :editor/update-organization-query-results-for-schools-of-departure}}))) + (reg-event-fx :editor/update-organization-query-results (fn [{db :db} [_ results]] From a356260a53cc2493d0978551b09ce40939bca2a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A4in=C3=B6=20Ala-H=C3=A4rk=C3=B6nen?= Date: Fri, 10 Jan 2025 13:40:05 +0200 Subject: [PATCH 4/4] Optimize get-latest-applications-for-kk-payment-processing not to use latest applications view --- .gitignore | 1 + resources/sql/application-queries.sql | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 875da7bcfb..b2661b0c03 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ npm-debug.log* /blob-report/ /playwright/.cache/ .testcontainers.properties +.vscode/ diff --git a/resources/sql/application-queries.sql b/resources/sql/application-queries.sql index d0c3f3db7c..230f48582e 100644 --- a/resources/sql/application-queries.sql +++ b/resources/sql/application-queries.sql @@ -1372,16 +1372,21 @@ WHERE a.id in (:ids); --name: yesql-get-latest-applications-for-kk-payment-processing SELECT - la.key, - la.submitted, - la.haku, - la.hakukohde, - la.person_oid AS "person-oid", + a.key, + a.submitted, + a.haku, + a.hakukohde, + a.person_oid AS "person-oid", (SELECT content - FROM answers_as_content - WHERE application_id = la.id) AS content -FROM latest_applications AS la -LEFT JOIN application_reviews AS ar ON ar.application_key = la.key -WHERE la.haku in (:haku_oids) AND - la.person_oid in (:person_oids) AND + FROM answers_as_content + WHERE application_id = a.id) AS content +FROM applications AS a +LEFT JOIN applications AS la + ON la.key = a.key AND + la.id > a.id +LEFT JOIN application_reviews AS ar + ON ar.application_key = a.key +WHERE la.id IS NULL AND + a.haku in (:haku_oids) AND + a.person_oid in (:person_oids) AND ar.state <> 'inactivated';