From 0cc3983f94ddc7a4c8d66d03d1ea30808869363a Mon Sep 17 00:00:00 2001
From: leevi-identio
Date: Mon, 26 May 2025 10:28:45 +0300
Subject: [PATCH 01/37] Merge pull request #739 from City-of-Helsinki/ASU-1753
Add custom elasticsearch_connector module that allows self-signed certs
---
ElasticsearchConnectorTest.php | 72 +++++++++++++++++++
HelfiConnector.php | 33 +++++++++
...ector.connector.helfi_connector.schema.yml | 2 +
3 files changed, 107 insertions(+)
create mode 100644 ElasticsearchConnectorTest.php
create mode 100644 HelfiConnector.php
create mode 100644 elasticsearch_connector.connector.helfi_connector.schema.yml
diff --git a/ElasticsearchConnectorTest.php b/ElasticsearchConnectorTest.php
new file mode 100644
index 000000000..221b3de88
--- /dev/null
+++ b/ElasticsearchConnectorTest.php
@@ -0,0 +1,72 @@
+installEntitySchema('search_api_server');
+ }
+
+ /**
+ * Tests custom elasticsearch connector.
+ */
+ public function testSearchApiConnector() {
+ // Add elasticsearch server configuration.
+ $config = $this->config('search_api.server.default');
+ $config->setData([
+ 'status' => TRUE,
+ 'id' => 'default',
+ 'name' => 'elasticsearch_server',
+ 'description' => 'Test server',
+ 'backend' => 'elasticsearch',
+ 'backend_config' => [
+ 'connector' => 'helfi_connector',
+ 'connector_config' => [
+ 'url' => 'http://elasticsearch.example.com:9200',
+ 'username' => '123',
+ 'password' => '456',
+ ],
+ ],
+ ]);
+ $config->save();
+
+ /** @var \Drupal\search_api\ServerInterface $server */
+ $server = $this->container
+ ->get(EntityTypeManagerInterface::class)
+ ->getStorage('search_api_server')
+ ->load('default');
+
+ $backend = $server->getBackend();
+ assert($backend instanceof ElasticSearchBackend);
+ $connector = $backend->getConnector();
+ $this->assertInstanceOf(HelfiConnector::class, $connector);
+ $this->assertInstanceOf(Client::class, $connector->getClient());
+ }
+
+}
diff --git a/HelfiConnector.php b/HelfiConnector.php
new file mode 100644
index 000000000..e323968c5
--- /dev/null
+++ b/HelfiConnector.php
@@ -0,0 +1,33 @@
+setHosts([$this->configuration['url']])
+ ->setBasicAuthentication($this->configuration['username'], $this->configuration['password'])
+ ->setSSLVerification(FALSE)
+ ->build();
+ }
+
+}
diff --git a/elasticsearch_connector.connector.helfi_connector.schema.yml b/elasticsearch_connector.connector.helfi_connector.schema.yml
new file mode 100644
index 000000000..03b540f9d
--- /dev/null
+++ b/elasticsearch_connector.connector.helfi_connector.schema.yml
@@ -0,0 +1,2 @@
+plugin.plugin_configuration.elasticsearch_connector.helfi_connector:
+ type: plugin.plugin_configuration.elasticsearch_connector.basicauth
From 3a6953f11a31e180e70d490acf1add59f96e08cd Mon Sep 17 00:00:00 2001
From: leevi-identio
Date: Mon, 26 May 2025 08:29:55 +0300
Subject: [PATCH 02/37] Merge pull request #738 from City-of-Helsinki/ASU-1754
ASU-1754: Remove completion estimate from top bar of Project and Apartment
---
.../templates/content/node--apartment--full.html.twig | 4 ----
.../templates/content/node--project--full.html.twig | 3 ---
2 files changed, 7 deletions(-)
diff --git a/public/themes/custom/asuntotuotanto/templates/content/node--apartment--full.html.twig b/public/themes/custom/asuntotuotanto/templates/content/node--apartment--full.html.twig
index 5e6ec9168..efa874659 100644
--- a/public/themes/custom/asuntotuotanto/templates/content/node--apartment--full.html.twig
+++ b/public/themes/custom/asuntotuotanto/templates/content/node--apartment--full.html.twig
@@ -119,10 +119,6 @@
-
- Completion {{ estimated_completion_date }}
-
{% if is_application_period_active %}
{% trans %}
From 4e70a4e599916b61d771b9d678453174251de099 Mon Sep 17 00:00:00 2001
From: leevi-identio
Date: Mon, 26 May 2025 13:19:55 +0300
Subject: [PATCH 03/37] Merge pull request #742 from City-of-Helsinki/ASU-1751
ASU-1751: Add disallow mediabank to robots.txt
---
composer.json | 3 +-
composer.lock | 2 +-
public/.gitignore | 1 -
public/robots.txt | 76 +++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 79 insertions(+), 3 deletions(-)
create mode 100644 public/robots.txt
diff --git a/composer.json b/composer.json
index d7422d8b1..aeb19de29 100644
--- a/composer.json
+++ b/composer.json
@@ -102,7 +102,8 @@
"web-root": "./public"
},
"file-mapping": {
- "[project-root]/.editorconfig": false
+ "[project-root]/.editorconfig": false,
+ "[web-root]/robots.txt": false
}
},
"enable-patching": true,
diff --git a/composer.lock b/composer.lock
index 1c1930237..c048a7907 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "e0652285a356edc453cd54774c910f3b",
+ "content-hash": "10fcaea6ed077e98d4e5b3cfcc7ac721",
"packages": [
{
"name": "asm89/stack-cors",
diff --git a/public/.gitignore b/public/.gitignore
index 8f7998bd4..e2e879f4c 100644
--- a/public/.gitignore
+++ b/public/.gitignore
@@ -8,6 +8,5 @@ README.txt
autoload.php
example.gitignore
index.php
-robots.txt
update.php
web.config
\ No newline at end of file
diff --git a/public/robots.txt b/public/robots.txt
new file mode 100644
index 000000000..65d859632
--- /dev/null
+++ b/public/robots.txt
@@ -0,0 +1,76 @@
+#
+# robots.txt
+#
+# This file is to prevent the crawling and indexing of certain parts
+# of your site by web crawlers and spiders run by sites like Yahoo!
+# and Google. By telling these "robots" where not to go on your site,
+# you save bandwidth and server resources.
+#
+# This file will be ignored unless it is at the root of your host:
+# Used: http://example.com/robots.txt
+# Ignored: http://example.com/site/robots.txt
+#
+# For more information about the robots.txt standard, see:
+# http://www.robotstxt.org/robotstxt.html
+
+# disallow mediabank/aineistopankki
+Disallow: */mediabank/*
+
+User-agent: *
+# CSS, JS, Images
+Allow: /core/*.css$
+Allow: /core/*.css?
+Allow: /core/*.js$
+Allow: /core/*.js?
+Allow: /core/*.gif
+Allow: /core/*.jpg
+Allow: /core/*.jpeg
+Allow: /core/*.png
+Allow: /core/*.svg
+Allow: /profiles/*.css$
+Allow: /profiles/*.css?
+Allow: /profiles/*.js$
+Allow: /profiles/*.js?
+Allow: /profiles/*.gif
+Allow: /profiles/*.jpg
+Allow: /profiles/*.jpeg
+Allow: /profiles/*.png
+Allow: /profiles/*.svg
+# Directories
+Disallow: /core/
+Disallow: /profiles/
+# Files
+Disallow: /README.md
+Disallow: /composer/Metapackage/README.txt
+Disallow: /composer/Plugin/ProjectMessage/README.md
+Disallow: /composer/Plugin/Scaffold/README.md
+Disallow: /composer/Plugin/VendorHardening/README.txt
+Disallow: /composer/Template/README.txt
+Disallow: /modules/README.txt
+Disallow: /sites/README.txt
+Disallow: /themes/README.txt
+Disallow: /web.config
+# Paths (clean URLs)
+Disallow: /admin/
+Disallow: /comment/reply/
+Disallow: /filter/tips
+Disallow: /node/add/
+Disallow: /search/
+Disallow: /user/register
+Disallow: /user/password
+Disallow: /user/login
+Disallow: /user/logout
+Disallow: /media/oembed
+Disallow: /*/media/oembed
+# Paths (no clean URLs)
+Disallow: /index.php/admin/
+Disallow: /index.php/comment/reply/
+Disallow: /index.php/filter/tips
+Disallow: /index.php/node/add/
+Disallow: /index.php/search/
+Disallow: /index.php/user/password
+Disallow: /index.php/user/register
+Disallow: /index.php/user/login
+Disallow: /index.php/user/logout
+Disallow: /index.php/media/oembed
+Disallow: /index.php/*/media/oembed
From 5ec0ea44ccad68d7d9cddbb78d68d3aeaff2790d Mon Sep 17 00:00:00 2001
From: leevi-identio
Date: Mon, 26 May 2025 12:16:44 +0300
Subject: [PATCH 04/37] Merge pull request #741 from
City-of-Helsinki/ASU-1753-enable-helfi-connector
ASU-1753: enable helfi_connector for elasticsearch
---
public/sites/default/settings.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/public/sites/default/settings.php b/public/sites/default/settings.php
index 80dd9dd16..b7895de02 100755
--- a/public/sites/default/settings.php
+++ b/public/sites/default/settings.php
@@ -423,7 +423,7 @@ function drupal_get_env(string|array $variables) : mixed {
$config['search_api.server.asuntotuotanto']['backend_config']['connector_config']['url'] = getenv('ASU_ELASTICSEARCH_URL');
if (getenv('ASU_ELASTICSEARCH_USERNAME') && getenv('ASU_ELASTICSEARCH_PASSWORD')) {
- $config['search_api.server.asuntotuotanto']['backend_config']['connector'] = 'basicauth';
+ $config['search_api.server.asuntotuotanto']['backend_config']['connector'] = 'helfi_connector';
$config['search_api.server.asuntotuotanto']['backend_config']['connector_config']['username'] = getenv('ASU_ELASTICSEARCH_USERNAME');
$config['search_api.server.asuntotuotanto']['backend_config']['connector_config']['password'] = getenv('ASU_ELASTICSEARCH_PASSWORD');
}
From 37cdd7bbab8dd31273069035415222ba9c51babe Mon Sep 17 00:00:00 2001
From: andreybaklanov
Date: Thu, 26 Jun 2025 09:31:28 +0300
Subject: [PATCH 05/37] ASU-1743 sender hotfix
---
public/modules/custom/asu_user/asu_user.module | 1 +
public/modules/custom/asu_user/src/AuthService.php | 1 +
public/modules/custom/asu_user/src/RegisterForm.php | 3 +++
3 files changed, 5 insertions(+)
diff --git a/public/modules/custom/asu_user/asu_user.module b/public/modules/custom/asu_user/asu_user.module
index 2880fec7d..08e8e15df 100644
--- a/public/modules/custom/asu_user/asu_user.module
+++ b/public/modules/custom/asu_user/asu_user.module
@@ -47,6 +47,7 @@ function asu_user_user_login(UserInterface $account) {
];
$request = new CreateUserRequest($account, $accountData, 'salesperson');
+ $request->setSender($account);
/** @var \Drupal\asu_api\Api\BackendApi\BackendApi $backendApi */
$backendApi = \Drupal::service('asu_api.backendapi');
diff --git a/public/modules/custom/asu_user/src/AuthService.php b/public/modules/custom/asu_user/src/AuthService.php
index 939a23353..ba5f48612 100644
--- a/public/modules/custom/asu_user/src/AuthService.php
+++ b/public/modules/custom/asu_user/src/AuthService.php
@@ -246,6 +246,7 @@ private function createAuthUserRequest($account, $attributes) {
$accountData,
'customer'
);
+ $request->setSender($account);
try {
/** @var \Drupal\asu_api\Api\BackendApi\Response\CreateUserResponse $response */
diff --git a/public/modules/custom/asu_user/src/RegisterForm.php b/public/modules/custom/asu_user/src/RegisterForm.php
index 26c874d32..5af2ffe03 100644
--- a/public/modules/custom/asu_user/src/RegisterForm.php
+++ b/public/modules/custom/asu_user/src/RegisterForm.php
@@ -176,6 +176,7 @@ public function saveCustomer(FormStateInterface $form_state) {
}
$request = new CreateUserRequest($account, $form_state->getUserInput());
+ $request->setSender($account);
$this->sendToBackend($account, $request);
$form_state->set('user', $account);
@@ -241,6 +242,7 @@ private function salespersonCreatesCustomer(FormStateInterface $form_state) {
}
$request = new CreateUserRequest($user, $form_state->getUserInput());
+ $request->setSender($user);
$this->sendToBackend($user, $request);
$form_state->set('user', $user);
@@ -296,6 +298,7 @@ private function saveSalesperson(FormStateInterface $form_state) {
];
$request = new CreateUserRequest($account, $accountData, 'salesperson');
+ $request->setSender($account);
$this->sendToBackend($account, $request);
$form_state->set('user', $account);
From a33baeef532bc9d2d6e84fcc5926793e43d58450 Mon Sep 17 00:00:00 2001
From: Andrey Baklanov
Date: Mon, 14 Jul 2025 15:14:57 +0300
Subject: [PATCH 06/37] ASU-1736 Fix phpcs errors
---
public/modules/custom/asu_application/src/Applications.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/public/modules/custom/asu_application/src/Applications.php b/public/modules/custom/asu_application/src/Applications.php
index 5d59f61ef..176739635 100644
--- a/public/modules/custom/asu_application/src/Applications.php
+++ b/public/modules/custom/asu_application/src/Applications.php
@@ -107,8 +107,8 @@ public function getApplicationsProjectPairs(): array {
$applicationId = $application->id();
if ($projectId && $applicationId) {
$result[] = [
- 'project_id' => (int)$projectId,
- 'application_id' => (int)$applicationId,
+ 'project_id' => (int) $projectId,
+ 'application_id' => (int) $applicationId,
];
}
}
From 26ee42c1b4afdda5681638023082cadb33bb521d Mon Sep 17 00:00:00 2001
From: leevi-identio
Date: Thu, 23 Oct 2025 14:14:24 +0300
Subject: [PATCH 07/37] Cherry-pick PRs 787, 788 to release
Fix showing wrong url, bump asuntomyynti-react to new version
---
composer.json | 6 +++---
composer.lock | 4 ++--
public/modules/custom/asu_content/src/Entity/Project.php | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/composer.json b/composer.json
index be6cef2d5..59b9293a2 100644
--- a/composer.json
+++ b/composer.json
@@ -7,7 +7,7 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
- "asuntomyynti/react": "1.4.5",
+ "asuntomyynti/react": "1.4.6b",
"composer/installers": "^2.0",
"cweagans/composer-patches": "^1.7.3",
"dinbror/blazy": "^1.8",
@@ -186,9 +186,9 @@
"type": "package",
"package": {
"name": "asuntomyynti/react",
- "version": "1.4.5",
+ "version": "1.4.6b",
"dist": {
- "url": "https://github.com/City-of-Helsinki/asuntomyynti-react/releases/download/v1.4.5b/asuntomyynti-react-1.4.5b.zip",
+ "url": "https://github.com/City-of-Helsinki/asuntomyynti-react/releases/download/v1.4.6b/asuntomyynti-react-1.4.6b.zip",
"type": "zip"
}
}
diff --git a/composer.lock b/composer.lock
index abfeb0fe3..88f339a08 100644
--- a/composer.lock
+++ b/composer.lock
@@ -59,10 +59,10 @@
},
{
"name": "asuntomyynti/react",
- "version": "1.4.5",
+ "version": "1.4.6b",
"dist": {
"type": "zip",
- "url": "https://github.com/City-of-Helsinki/asuntomyynti-react/releases/download/v1.4.5b/asuntomyynti-react-1.4.5b.zip"
+ "url": "https://github.com/City-of-Helsinki/asuntomyynti-react/releases/download/v1.4.6b/asuntomyynti-react-1.4.6b.zip"
},
"type": "library"
},
diff --git a/public/modules/custom/asu_content/src/Entity/Project.php b/public/modules/custom/asu_content/src/Entity/Project.php
index 3544c4f0b..0018480db 100644
--- a/public/modules/custom/asu_content/src/Entity/Project.php
+++ b/public/modules/custom/asu_content/src/Entity/Project.php
@@ -110,7 +110,7 @@ public function getApplicationUrl($apartmentId = NULL): string {
return sprintf('%s/application/add/%s/%s', $baseurl, $apartmentType, $this->id());
}
- if ($this->isApplicationPeriod('after')) {
+ if ($this->isApplicationPeriod('after') && $this->getCanApplyAfterwards() == TRUE) {
$queryParameter = $apartmentId ? "?apartment=$apartmentId" . '&project=' . $this->id() : '?project=' . $this->id();
if ($this->getOwnershipType() == 'haso') {
From a8a50bf23c9a576d281cf9076393ff069ce38ef3 Mon Sep 17 00:00:00 2001
From: leevi-identio
Date: Thu, 23 Oct 2025 15:19:17 +0300
Subject: [PATCH 08/37] Disable "contact us"-button temporarily
---
.../custom/asu_application/src/Form/ApplicationForm.php | 3 ---
.../templates/misc/project-apartments-listing.html.twig | 4 ++--
.../views-view-table--project-apartments-listing.html.twig | 4 ++--
3 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/public/modules/custom/asu_application/src/Form/ApplicationForm.php b/public/modules/custom/asu_application/src/Form/ApplicationForm.php
index 7c1813b0a..521696334 100644
--- a/public/modules/custom/asu_application/src/Form/ApplicationForm.php
+++ b/public/modules/custom/asu_application/src/Form/ApplicationForm.php
@@ -276,9 +276,6 @@ public function buildForm(array $form, FormStateInterface $form_state) {
strtolower($project_data['ownership_type']) != 'haso' &&
$this->isApplicationPeriod('after', $startDate, $endDate)
) {
- $this->messenger()->addMessage(
- 'ownership_type is: ' . $project_data["ownership_type"]
- );
$freeApplicationUrl = $this->requestStack->getCurrentRequest()->getSchemeAndHttpHost() .
'/contact/apply_for_free_apartment?project=' . $project_id;
return new RedirectResponse($freeApplicationUrl);
diff --git a/public/themes/custom/asuntotuotanto/templates/misc/project-apartments-listing.html.twig b/public/themes/custom/asuntotuotanto/templates/misc/project-apartments-listing.html.twig
index dc3fcd05b..b447d504c 100644
--- a/public/themes/custom/asuntotuotanto/templates/misc/project-apartments-listing.html.twig
+++ b/public/themes/custom/asuntotuotanto/templates/misc/project-apartments-listing.html.twig
@@ -190,14 +190,14 @@
|
- {% include '@asuntotuotanto/button/button.html.twig' with {
+ {# {% include '@asuntotuotanto/button/button.html.twig' with {
type: 'supplementary',
disabled: false,
size: 'small',
label: 'Learn more'|t,
href: url('entity.node.canonical', { 'node': nid }),
}
- %}
+ %} #}
{% if is_application_period_active %}
{% include '@asuntotuotanto/button/button.html.twig' with {
type: 'secondary',
diff --git a/public/themes/custom/asuntotuotanto/templates/views/project/views-view-table--project-apartments-listing.html.twig b/public/themes/custom/asuntotuotanto/templates/views/project/views-view-table--project-apartments-listing.html.twig
index 4ab615052..deb8d6f73 100644
--- a/public/themes/custom/asuntotuotanto/templates/views/project/views-view-table--project-apartments-listing.html.twig
+++ b/public/themes/custom/asuntotuotanto/templates/views/project/views-view-table--project-apartments-listing.html.twig
@@ -322,7 +322,7 @@
}
%}
- {% if (is_application_period_active or (is_free or can_apply_afterwards)) %}
+ {# {% if (is_application_period_active or (is_free or can_apply_afterwards)) %}
{% include '@asuntotuotanto/button/button.html.twig' with {
type: 'primary',
disabled: false,
@@ -332,7 +332,7 @@
aria_label: 'Create an application'|t ~ ', ' ~ 'apartment'|t ~ ' ' ~ apartment_number
}
%}
- {% endif %}
+ {% endif %} #}
|
{% endfor %}
From f22878749122b05c3db42932b0513efc8d5a5e61 Mon Sep 17 00:00:00 2001
From: leevi-identio
Date: Thu, 23 Oct 2025 15:22:24 +0300
Subject: [PATCH 09/37] Bump asuntomyynti-react version number to 1.4.7b
---
composer.json | 6 +++---
composer.lock | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/composer.json b/composer.json
index 59b9293a2..b0eddc727 100644
--- a/composer.json
+++ b/composer.json
@@ -7,7 +7,7 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
- "asuntomyynti/react": "1.4.6b",
+ "asuntomyynti/react": "1.4.7b",
"composer/installers": "^2.0",
"cweagans/composer-patches": "^1.7.3",
"dinbror/blazy": "^1.8",
@@ -186,9 +186,9 @@
"type": "package",
"package": {
"name": "asuntomyynti/react",
- "version": "1.4.6b",
+ "version": "1.4.7b",
"dist": {
- "url": "https://github.com/City-of-Helsinki/asuntomyynti-react/releases/download/v1.4.6b/asuntomyynti-react-1.4.6b.zip",
+ "url": "https://github.com/City-of-Helsinki/asuntomyynti-react/releases/download/v1.4.7b/asuntomyynti-react-1.4.7b.zip",
"type": "zip"
}
}
diff --git a/composer.lock b/composer.lock
index 88f339a08..21cd91b68 100644
--- a/composer.lock
+++ b/composer.lock
@@ -59,10 +59,10 @@
},
{
"name": "asuntomyynti/react",
- "version": "1.4.6b",
+ "version": "1.4.7b",
"dist": {
"type": "zip",
- "url": "https://github.com/City-of-Helsinki/asuntomyynti-react/releases/download/v1.4.6b/asuntomyynti-react-1.4.6b.zip"
+ "url": "https://github.com/City-of-Helsinki/asuntomyynti-react/releases/download/v1.4.7b/asuntomyynti-react-1.4.7b.zip"
},
"type": "library"
},
From ca66c228c88d702b6e46dc1fcdde6ab461c67a7b Mon Sep 17 00:00:00 2001
From: leevi-identio
Date: Mon, 13 Oct 2025 12:06:14 +0300
Subject: [PATCH 10/37] Cherry-pick PR 776 to release
ASU-1712: Edit translation file and texts
- Add missing translations to translation file
- Change status message after submitting apartment application
- Adjust order of after-application form buttons
ASU-1712: Fix lint err
ASU-1712: Fix lint err
From 6cc501a5d1a73427ec53239c5e2dcd5d6cf27fbb Mon Sep 17 00:00:00 2001
From: Andrey Baklanov
Date: Thu, 16 Oct 2025 12:55:00 +0300
Subject: [PATCH 11/37] Cherry-pick PR 777 to release ASU-1786 publish
appartment if status chenge to free in django
ASU-1786: fix phpcs
From da1f762bcbe6298351b3a9d3ff4ebd9c384d5a77 Mon Sep 17 00:00:00 2001
From: Andrey Baklanov
Date: Wed, 22 Oct 2025 16:36:52 +0300
Subject: [PATCH 12/37] Cherry-pick PR 785 to release ASU-1786 fix publish
logic
---
public/modules/custom/asu_api/asu_api.module | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/public/modules/custom/asu_api/asu_api.module b/public/modules/custom/asu_api/asu_api.module
index aee2e44c9..73b622806 100644
--- a/public/modules/custom/asu_api/asu_api.module
+++ b/public/modules/custom/asu_api/asu_api.module
@@ -139,7 +139,7 @@ function asu_api_get_apartment_status_request_cron() {
$dirty = TRUE;
}
}
- elseif ($current === 'sold' && in_array($new, $free_states, TRUE)) {
+ elseif (in_array($new, $free_states, TRUE)) {
if (!$node->isPublished()) {
$node->setPublished(TRUE);
$dirty = TRUE;
From 6103d79f18c5270b21d567ee21871c1bab3e2690 Mon Sep 17 00:00:00 2001
From: Andrey Baklanov
Date: Fri, 7 Nov 2025 10:58:23 +0200
Subject: [PATCH 13/37] Cherry-pick PR 795 to release ASU-1786 publish reserved
appartment
---
public/modules/custom/asu_api/asu_api.module | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/public/modules/custom/asu_api/asu_api.module b/public/modules/custom/asu_api/asu_api.module
index 73b622806..a63a8d147 100644
--- a/public/modules/custom/asu_api/asu_api.module
+++ b/public/modules/custom/asu_api/asu_api.module
@@ -105,7 +105,7 @@ function asu_api_get_apartment_status_request_cron() {
return;
}
- $free_states = ['for_sale', 'free_for_reservations'];
+ $free_states = ['for_sale', 'free_for_reservations', 'reserved'];
foreach ($nids as $nid) {
/** @var \Drupal\node\Entity\Node $node */
From f07bcc2b4eb7d932a0a86b0ff0a094242f6fe007 Mon Sep 17 00:00:00 2001
From: leevi-identio
Date: Thu, 30 Oct 2025 14:59:06 +0200
Subject: [PATCH 14/37] Cherry-pick PR 797 to release
ASU-1712: Show notification and prevent adding applications if user has a reservation on apartment
- Show notification and prevent adding applications if user has a reservation on apartment
- Add new functions for checking if user has reservations on a project
ASU-1712: Fix some lint errs
ASU-1712: Fix further lint errs
ASU-1712: Fix more lint errs
ASU-1712: More lint error fixes
---
.../src/Form/ApplicationForm.php | 11 +++-
.../custom/asu_content/src/Entity/Project.php | 54 ++++++++++++++++++-
.../custom/asu_content/translations/fi.po | 3 ++
.../asuntotuotanto/asuntotuotanto.theme | 27 +++++++++-
.../content/apartment/_apartment-cta.scss | 4 ++
.../content/node--apartment--full.html.twig | 1 +
.../content/node--project--full.html.twig | 15 +++++-
...able--project-apartments-listing.html.twig | 5 +-
8 files changed, 113 insertions(+), 7 deletions(-)
diff --git a/public/modules/custom/asu_application/src/Form/ApplicationForm.php b/public/modules/custom/asu_application/src/Form/ApplicationForm.php
index 521696334..b43ff1631 100644
--- a/public/modules/custom/asu_application/src/Form/ApplicationForm.php
+++ b/public/modules/custom/asu_application/src/Form/ApplicationForm.php
@@ -197,6 +197,15 @@ public function buildForm(array $form, FormStateInterface $form_state) {
array_push($limit, ['reserved', 'reserved_haso']);
}
+ // Dont allow users who have a reservation with the state
+ // 'offered', 'offer_accepted' or 'sold' on the project to apply.
+ // This shouldn't normally be shown except if the user uses
+ // the application/add// link directly.
+ if ($project->getUserHasReservedOrSoldApartments($this->currentUser->id())) {
+ $this->messenger()->addError($this->t('You already have an offer or have been sold an apartment in this project and cannot submit a new application.'));
+ return new RedirectResponse($form['#project_url']->toString());
+ }
+
if (!$project_data = $this->getApartments($project, $limit)) {
$this->logger('asu_application')->critical('User tried to access nonexistent project of id ' . $project_id);
$this->messenger()->addMessage($this->t('Unfortunately the project you are trying to apply for is unavailable.'));
@@ -318,7 +327,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
$form['actions']['draft'] = [
'#type' => 'submit',
'#value' => $this->t('Save as a draft'),
- '#attributes' => ['class' => ['hds-button--secondary']],
+ '#attributes' => ['class' => ['hds-button--secondary application-as-draft-button']],
'#limit_validation_errors' => [],
'#name' => 'submit-draft',
'#submit' => ['::submitDraft'],
diff --git a/public/modules/custom/asu_content/src/Entity/Project.php b/public/modules/custom/asu_content/src/Entity/Project.php
index 0018480db..0b3784356 100644
--- a/public/modules/custom/asu_content/src/Entity/Project.php
+++ b/public/modules/custom/asu_content/src/Entity/Project.php
@@ -4,6 +4,8 @@
use Drupal\node\Entity\Node;
use Drupal\user\UserInterface;
+use Drupal\user\Entity\User;
+use Drupal\asu_api\Api\BackendApi\Request\ApplicationLotteryResult;
/**
* Class for node's project bundle.
@@ -70,7 +72,7 @@ public function getCanApplyAfterwards(): string {
if ($field_can_apply_afterwards->isEmpty()) {
return "";
}
- \Drupal::logger('asu_application')->info("field_can_apply_afterwards: " . $field_can_apply_afterwards->value);
+
return $field_can_apply_afterwards->value;
}
@@ -163,6 +165,56 @@ public function isArchievable(): bool {
return TRUE;
}
+ /**
+ * Get reservations the given user has for the project's apartments.
+ *
+ * @param int $userId
+ * Id of the user to check.
+ *
+ * @return array
+ * reservations
+ */
+ public function getUserReservations($userId): array {
+ $user = User::load(\Drupal::currentUser()->id());
+
+ // Fetch reservations for this project.
+ $request = new ApplicationLotteryResult($this->uuid());
+ $request->setSender($user);
+ $backendApi = \Drupal::service('asu_api.backendapi');
+
+ $userReservations = $backendApi
+ ->send($request)
+ ->getContent();
+
+ return $userReservations;
+ }
+
+ /**
+ * Checks if the given user has a reservation with the state 'offered'.
+ *
+ * 'offer_accepted' or 'sold' on the project.
+ *
+ * @param int $userId
+ * Id of the user to check.
+ *
+ * @return bool
+ * If user has a reservation with those states.
+ */
+ public function getUserHasReservedOrSoldApartments($userId): bool {
+ $userHasReservedOrSoldApartment = FALSE;
+ $userReservations = $this->getUserReservations($userId);
+ $states = ['offered', 'offer_accepted', 'sold'];
+
+ // phpcs:ignore
+ foreach ($userReservations as $key => $reservation) {
+
+ if (in_array($reservation['state'], $states)) {
+ $userHasReservedOrSoldApartment = TRUE;
+ }
+ }
+ return $userHasReservedOrSoldApartment;
+ }
+
/**
* Get project sales person information.
*
diff --git a/public/modules/custom/asu_content/translations/fi.po b/public/modules/custom/asu_content/translations/fi.po
index 43a957258..47dd9343b 100644
--- a/public/modules/custom/asu_content/translations/fi.po
+++ b/public/modules/custom/asu_content/translations/fi.po
@@ -43323,3 +43323,6 @@ msgid "Tunnistamo"
msgstr ""
msgid "Helsinki Logo"
msgstr "Helsingin kaupungin logo"
+
+msgid "You already have an offer or have been sold an apartment in this project and cannot submit a new application."
+msgstr "Sinulla on jo myyty tai tarjottu asunto tässä kohteessa etkä siksi voi tehdä uutta hakemusta."
diff --git a/public/themes/custom/asuntotuotanto/asuntotuotanto.theme b/public/themes/custom/asuntotuotanto/asuntotuotanto.theme
index ca12f8697..797b1f0f8 100644
--- a/public/themes/custom/asuntotuotanto/asuntotuotanto.theme
+++ b/public/themes/custom/asuntotuotanto/asuntotuotanto.theme
@@ -229,9 +229,12 @@ function asuntotuotanto_preprocess_views_view(&$variables) {
}
/**
+ * Passes variables to project-apartments-listing.html.twig.
+ *
* Implements hook_preprocess_HOOK().
*/
function asuntotuotanto_preprocess_views_view_table(&$variables) {
+
if ($variables['view']->id() === 'project_apartments_listing') {
$results = $variables['result'];
@@ -251,6 +254,14 @@ function asuntotuotanto_preprocess_views_view_table(&$variables) {
$variables['header']['field_debt_free_sales_price']['content'] = $price_title;
unset($variables['header']['field_release_payment']);
+ $userHasReservedOrSoldApartment = FALSE;
+ if (\Drupal::currentUser()->isAuthenticated()) {
+ // Check if user has offered, offer_accepted or sold reservations.
+ $userHasReservedOrSoldApartment = $project->getUserHasReservedOrSoldApartments(
+ \Drupal::currentUser()->id()
+ );
+ }
+
foreach ($results as $key => $row) {
/** @var \Drupal\asu_content\Entity\Apartment $entity */
$apartment = $row->_entity;
@@ -282,6 +293,7 @@ function asuntotuotanto_preprocess_views_view_table(&$variables) {
$variables['rows'][$key]['application_url_title'] = $apartment->getApplicationUrlTitle();
$variables['rows'][$key]['is_free'] = $apartment->isFree();
$variables['rows'][$key]['can_apply_afterwards'] = $project->getCanApplyAfterwards();
+ $variables['rows'][$key]['user_has_reserved_or_sold_apartment'] = $userHasReservedOrSoldApartment;
}
usort($variables['rows'], function ($a, $b) {
@@ -589,6 +601,14 @@ function asuntotuotanto_preprocess_node(&$variables) {
);
}
+ $userHasReservedOrSoldApartment = FALSE;
+ if (\Drupal::currentUser()->isAuthenticated()) {
+ // Check if user has offered, offer_accepted or sold reservations.
+ $userHasReservedOrSoldApartment = $project->getUserHasReservedOrSoldApartments(
+ \Drupal::currentUser()->id()
+ );
+ }
+
if (!empty($node->field_street_address->value)) {
$street_address_splitted = split_address_line($node->field_street_address->value);
@@ -618,6 +638,9 @@ function asuntotuotanto_preprocess_node(&$variables) {
$variables['estimated_completion_date'] = $estimated_completion_date;
$variables['is_application_period_active'] = $is_application_period_active;
$variables['project_type'] = $project_type;
+ // No idea why, but shows up as null if it has.
+ // The more sensible name of 'user_has_reserved_or_sold_apartment'.
+ $variables['current_user_has_reserved_or_sold_apartment'] = $userHasReservedOrSoldApartment;
$variables['apartment_prices'] = $prices_string;
break;
@@ -1017,7 +1040,9 @@ function get_project_apartment_teaser_values($project_id) {
$values['project_ownership_type'] = $project->field_ownership_type->entity ? $project->field_ownership_type->entity->name->value : '';
$values['project_district'] = $project->field_district->entity ? $project->field_district->entity->name->value : '';
$values['project_main_image_url'] = isset($project->field_main_image[0]) ? \Drupal::service('file_url_generator')->generateAbsoluteString($project->field_main_image[0]->entity->getFileUri()) : '';
- $values['can_apply_afterwards'] = $project->getCanApplyAfterwards();
+ if ($project) {
+ $values['can_apply_afterwards'] = $project->get('field_can_apply_afterwards')->value;
+ }
foreach ($fields as $key => $field) {
if ($project && $project->hasField($field)) {
diff --git a/public/themes/custom/asuntotuotanto/src/scss/06_components/content/apartment/_apartment-cta.scss b/public/themes/custom/asuntotuotanto/src/scss/06_components/content/apartment/_apartment-cta.scss
index ecd51abd4..ce9e1ab63 100644
--- a/public/themes/custom/asuntotuotanto/src/scss/06_components/content/apartment/_apartment-cta.scss
+++ b/public/themes/custom/asuntotuotanto/src/scss/06_components/content/apartment/_apartment-cta.scss
@@ -111,4 +111,8 @@ line-height: $lineheight-m;
background-color: transparent;
}
}
+
+ .application-as-draft-button {
+ opacity: 0.75;
+ }
}
diff --git a/public/themes/custom/asuntotuotanto/templates/content/node--apartment--full.html.twig b/public/themes/custom/asuntotuotanto/templates/content/node--apartment--full.html.twig
index d40c68a1c..1ed77d8b3 100644
--- a/public/themes/custom/asuntotuotanto/templates/content/node--apartment--full.html.twig
+++ b/public/themes/custom/asuntotuotanto/templates/content/node--apartment--full.html.twig
@@ -189,6 +189,7 @@
{% endif %}
+