From 30a366a7fefaf2fd0001b4e28cf0a2d712c6c49c Mon Sep 17 00:00:00 2001 From: Martin Tobias Degner Date: Thu, 5 Sep 2024 08:08:33 +0200 Subject: [PATCH 01/24] edited package.json --- package-lock.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index c729f1aed..58059218e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5055,7 +5055,6 @@ "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-5.1.4.tgz", "integrity": "sha512-pIDJHIEI9LR0yxHXQ+Qh95k2EvXpWzZ5l+d+jIo+RdSm9MiHfzazIxwwni/p7+x4eJZuvG1AJwgC4TNQ7NRgsg==", "dev": true, - "license": "MIT", "dependencies": { "@discoveryjs/json-ext": "^0.5.0", "@webpack-cli/configtest": "^2.1.1", From 429fbd4a2ceb3c9fc277cdd8c5c19c863e0d128b Mon Sep 17 00:00:00 2001 From: Martin Tobias Degner Date: Fri, 6 Sep 2024 10:06:14 +0200 Subject: [PATCH 02/24] wrote sceletion for test search results for user integration --- .../test/scripts/test_main_page.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/webcentral/test/06_system_test/test/scripts/test_main_page.py b/webcentral/test/06_system_test/test/scripts/test_main_page.py index 509a17815..5f278c7f8 100644 --- a/webcentral/test/06_system_test/test/scripts/test_main_page.py +++ b/webcentral/test/06_system_test/test/scripts/test_main_page.py @@ -449,6 +449,23 @@ def testPageStructure(self): == self.GLOBAL_COLOR ) + def testUserIntegrationInResults(self): + """Test if user_integration elements are on the search results-page. + + """ + self.driver.get(os.environ["siteUnderTest"]) + startPAgeObj = StartPage(self.driver) + + searchInputField = startPageObj.getSearchInputField() + searchInputField.send_keys("Participant Observation") + searchInputField.send_keys(Keys.RETURN) + + listOfRowsInResultsTable = startPageObj.getSearchResults() + self.assertGreaterEqual(len(listOfRowsInResultsTable), 1) + for result in listOfRowsInResultsTable: + breakpoint() + + def _checkFocusContainer(self, focusName, dataDict): """ """ From 2abd718f61fa8b42d9c93de0202536c0256bfc8d Mon Sep 17 00:00:00 2001 From: expeditionengineer Date: Fri, 6 Sep 2024 08:07:49 +0000 Subject: [PATCH 03/24] Apply automatic changes --- .../test/06_system_test/test/scripts/test_main_page.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/webcentral/test/06_system_test/test/scripts/test_main_page.py b/webcentral/test/06_system_test/test/scripts/test_main_page.py index 5f278c7f8..2509dcfc9 100644 --- a/webcentral/test/06_system_test/test/scripts/test_main_page.py +++ b/webcentral/test/06_system_test/test/scripts/test_main_page.py @@ -450,12 +450,10 @@ def testPageStructure(self): ) def testUserIntegrationInResults(self): - """Test if user_integration elements are on the search results-page. - - """ + """Test if user_integration elements are on the search results-page.""" self.driver.get(os.environ["siteUnderTest"]) startPAgeObj = StartPage(self.driver) - + searchInputField = startPageObj.getSearchInputField() searchInputField.send_keys("Participant Observation") searchInputField.send_keys(Keys.RETURN) @@ -465,7 +463,6 @@ def testUserIntegrationInResults(self): for result in listOfRowsInResultsTable: breakpoint() - def _checkFocusContainer(self, focusName, dataDict): """ """ From 7830ccbefdeab943e17f145bfa5edfe58163e313 Mon Sep 17 00:00:00 2001 From: Martin Tobias Degner Date: Fri, 6 Sep 2024 11:15:24 +0200 Subject: [PATCH 04/24] included user integration in results search --- webcentral/src/StartSearch/views.py | 31 ++++++++++++++++--- .../templates/start_search/result_search.html | 16 +++++----- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/webcentral/src/StartSearch/views.py b/webcentral/src/StartSearch/views.py index f418aac23..3586085e8 100644 --- a/webcentral/src/StartSearch/views.py +++ b/webcentral/src/StartSearch/views.py @@ -12,9 +12,6 @@ Tag, Topic, ) -from tools_over.models import Tools -from project_listing.models import Subproject -from TechnicalStandards.models import Norm, Protocol from django.shortcuts import render from django.db.models import Q @@ -34,7 +31,7 @@ Norm, Protocol, ) - +from user_integration.models import UserEngagement def findPicturesForFocus(searchResultObj, tool=False): """Return the path to the picture, showing the Focus. @@ -58,6 +55,8 @@ def findPicturesForFocus(searchResultObj, tool=False): focusStrList = ["technisch"] if searchResultObj["kindOfItem"] == "Kriterienkatalog": focusStrList = ["rechtlich"] + if searchResultObj["kindOfItem"] == "Nutzendenintegration": + focusStrList = ["betrieblich"] pathStr = "assets/images/" if len(focusStrList) == 1: @@ -166,6 +165,19 @@ def resultSearch(request): criterionProejctsTwo = Q( enargusData__shortDescriptionDe__icontains=searchInput ) + + criterionUserIntegrationOne = Q( + category__icontains=searchInput + ) + criterionUserIntegrationTwo = Q( + subCategoryShortDescription__icontains=searchInput + ) + filteredUserIntegration = UserEngagement.objects.values( + "id", + "category", + "subCategoryShortDescription", + ).filter(criterionUserIntegrationOne | criterionUserIntegrationTwo) + filteredProjects = Subproject.objects.values( "referenceNumber_id", "enargusData__collaborativeProject", @@ -299,6 +311,16 @@ def resultSearch(request): "criteriaCatalog" ] + for userIntegration in filteredUserIntegration: + userIntegration["name"] = userIntegration["category"] + userIntegration["kindOfItem"] = "Nutzendenintegration" + userIntegration["classificationAgg"] = _("Nutzendenintegration") + userIntegration["date"] = _("2024-07-01") + userIntegration["virtDate"] = date.fromisoformat("2049-09-09") + userIntegration["pathToFocusImage"] = findPicturesForFocus( + userIntegration + ) + # concat the prepared querySets to one QuerySet filteredData = list( chain( @@ -307,6 +329,7 @@ def resultSearch(request): filteredNorms, filteredProtocols, filteredTopicsOfCriteriaCatalog, + filteredUserIntegration, ) ) # sort data list by name/kindOfItem and so on diff --git a/webcentral/src/templates/start_search/result_search.html b/webcentral/src/templates/start_search/result_search.html index 7c23f7ad8..49cdadaf4 100644 --- a/webcentral/src/templates/start_search/result_search.html +++ b/webcentral/src/templates/start_search/result_search.html @@ -94,13 +94,15 @@

{% translate "Suchergebnisse" %}

{% elif dataSet.kindOfItem == "digitales Werkzeug" %} - {% elif dataSet.kindOfItem == "Norm" %} - - {% elif dataSet.kindOfItem == "Protokoll" %} - - {% elif dataSet.kindOfItem == "Kriterienkatalog" %} - - {% endif %} + {% elif dataSet.kindOfItem == "Norm" %} + + {% elif dataSet.kindOfItem == "Protokoll" %} + + {% elif dataSet.kindOfItem == "Kriterienkatalog" %} + + {% elif dataSet.kindOfItem == "Nutzendenintegration" %} + + {% endif %} From cac78a531edc1de452f0d186a616e24276b76e5a Mon Sep 17 00:00:00 2001 From: expeditionengineer Date: Fri, 6 Sep 2024 09:17:32 +0000 Subject: [PATCH 05/24] Apply automatic changes --- webcentral/src/StartSearch/views.py | 5 +- .../templates/start_search/result_search.html | 158 +++++++++--------- 2 files changed, 81 insertions(+), 82 deletions(-) diff --git a/webcentral/src/StartSearch/views.py b/webcentral/src/StartSearch/views.py index 3586085e8..3efbd7108 100644 --- a/webcentral/src/StartSearch/views.py +++ b/webcentral/src/StartSearch/views.py @@ -33,6 +33,7 @@ ) from user_integration.models import UserEngagement + def findPicturesForFocus(searchResultObj, tool=False): """Return the path to the picture, showing the Focus. @@ -166,9 +167,7 @@ def resultSearch(request): enargusData__shortDescriptionDe__icontains=searchInput ) - criterionUserIntegrationOne = Q( - category__icontains=searchInput - ) + criterionUserIntegrationOne = Q(category__icontains=searchInput) criterionUserIntegrationTwo = Q( subCategoryShortDescription__icontains=searchInput ) diff --git a/webcentral/src/templates/start_search/result_search.html b/webcentral/src/templates/start_search/result_search.html index 49cdadaf4..9e5c51daa 100644 --- a/webcentral/src/templates/start_search/result_search.html +++ b/webcentral/src/templates/start_search/result_search.html @@ -94,89 +94,89 @@

{% translate "Suchergebnisse" %}

{% elif dataSet.kindOfItem == "digitales Werkzeug" %} - {% elif dataSet.kindOfItem == "Norm" %} - - {% elif dataSet.kindOfItem == "Protokoll" %} - - {% elif dataSet.kindOfItem == "Kriterienkatalog" %} - - {% elif dataSet.kindOfItem == "Nutzendenintegration" %} - - {% endif %} - - - -
+ {% elif dataSet.kindOfItem == "Norm" %} + + {% elif dataSet.kindOfItem == "Protokoll" %} + + {% elif dataSet.kindOfItem == "Kriterienkatalog" %} + + {% elif dataSet.kindOfItem == "Nutzendenintegration" %} + + {% endif %} + + + +
+
+
{{ dataSet.name }}
+
+
+ + + +
-
{{ dataSet.name }}
+
{{ dataSet.classificationAgg|title }}
-
- - - - -
-
{{ dataSet.classificationAgg|title }}
-
- + - - - icon - - -
-
{{ dataSet.date }}
-
- - - - {% endfor %} - - - - + + + icon + + +
+
{{ dataSet.date }}
+
+ + + + {% endfor %} + + + + + + - - - - - - + {% if data.has_next %} + {% translate "nächste" %} +     + + {% translate "letzte" %} » + +     + {% endif %} + + + + {% else %} +

{% translate "Die Suche hat keine Ergebnisse ergeben." %}

+ {% endif %} + + - - {% endblock %} + + {% endblock %} From cb20eaa82e5bef1ae35f13adb87acb080824707c Mon Sep 17 00:00:00 2001 From: Martin Tobias Degner Date: Fri, 6 Sep 2024 15:33:26 +0200 Subject: [PATCH 06/24] added user_integration and businessModels to search results, working on debugging of TestMainPage --- webcentral/src/StartSearch/views.py | 28 +++++- webcentral/src/businessModel/views.py | 1 + .../templates/start_search/result_search.html | 34 +++---- webcentral/src/user_integration/views.py | 3 + .../src/test_base/webdriver_setup.py | 18 ++++ .../test/scripts/test_main_page.py | 90 +++++++++++++++---- .../test/scripts/test_user_integration.py | 2 +- 7 files changed, 142 insertions(+), 34 deletions(-) diff --git a/webcentral/src/StartSearch/views.py b/webcentral/src/StartSearch/views.py index 3efbd7108..e04d5c241 100644 --- a/webcentral/src/StartSearch/views.py +++ b/webcentral/src/StartSearch/views.py @@ -32,6 +32,7 @@ Protocol, ) from user_integration.models import UserEngagement +from businessModel.models import BusinessModel def findPicturesForFocus(searchResultObj, tool=False): @@ -58,6 +59,9 @@ def findPicturesForFocus(searchResultObj, tool=False): focusStrList = ["rechtlich"] if searchResultObj["kindOfItem"] == "Nutzendenintegration": focusStrList = ["betrieblich"] + if searchResultObj["kindOfItem"] == "Geschäftsmodelle": + focusStrList = ["betrieblich"] + pathStr = "assets/images/" if len(focusStrList) == 1: @@ -177,6 +181,18 @@ def resultSearch(request): "subCategoryShortDescription", ).filter(criterionUserIntegrationOne | criterionUserIntegrationTwo) + criterionBusinessModelOne = Q( + challenge__icontains=searchInput + ) + criterionBusinessModelTwo = Q( + shortDescription__icontains=searchInput + ) + filteredBusinessModels = BusinessModel.objects.values( + "id", + "challenge", + "shortDescription", + ).filter(criterionBusinessModelOne | criterionBusinessModelTwo) + filteredProjects = Subproject.objects.values( "referenceNumber_id", "enargusData__collaborativeProject", @@ -319,7 +335,16 @@ def resultSearch(request): userIntegration["pathToFocusImage"] = findPicturesForFocus( userIntegration ) - + + for businessModel in filteredBusinessModels: + businessModel["name"] = businessModel["challenge"] + businessModel["kindOfItem"] = "Geschäftsmodelle" + businessModel["classificationAgg"] = _("Geschäftsmodelle") + businessModel["date"] = _("2024-07-01") + businessModel["virtDate"] = date.fromisoformat("2049-09-09") + businessModel["pathToFocusImage"] = findPicturesForFocus( + businessModel + ) # concat the prepared querySets to one QuerySet filteredData = list( chain( @@ -329,6 +354,7 @@ def resultSearch(request): filteredProtocols, filteredTopicsOfCriteriaCatalog, filteredUserIntegration, + filteredBusinessModels, ) ) # sort data list by name/kindOfItem and so on diff --git a/webcentral/src/businessModel/views.py b/webcentral/src/businessModel/views.py index 53bbdc528..4ba4949eb 100644 --- a/webcentral/src/businessModel/views.py +++ b/webcentral/src/businessModel/views.py @@ -37,6 +37,7 @@ def businessModelsChallengeDetails(request, challengeId): businessModelObj = BusinessModel.objects.get(id=challengeId) allBusinessModellObjs = BusinessModel.objects.all() context = { + "pageTitle": _("Geschäftsmodelle") + " - " + businessModelObj.challenge, "imageInBackButton": "assets/images/backArrowOperational.svg", "boxObject": businessModelObj, "focusBorder": "operational", diff --git a/webcentral/src/templates/start_search/result_search.html b/webcentral/src/templates/start_search/result_search.html index 9e5c51daa..2e3f70e30 100644 --- a/webcentral/src/templates/start_search/result_search.html +++ b/webcentral/src/templates/start_search/result_search.html @@ -94,22 +94,24 @@

{% translate "Suchergebnisse" %}

{% elif dataSet.kindOfItem == "digitales Werkzeug" %} - {% elif dataSet.kindOfItem == "Norm" %} - - {% elif dataSet.kindOfItem == "Protokoll" %} - - {% elif dataSet.kindOfItem == "Kriterienkatalog" %} - - {% elif dataSet.kindOfItem == "Nutzendenintegration" %} - - {% endif %} - - - -
-
-
{{ dataSet.name }}
-
+ {% elif dataSet.kindOfItem == "Norm" %} + + {% elif dataSet.kindOfItem == "Protokoll" %} + + {% elif dataSet.kindOfItem == "Kriterienkatalog" %} + + {% elif dataSet.kindOfItem == "Nutzendenintegration" %} + + {% elif dataSet.kindOfItem == "Geschäftsmodelle" %} + + + {% endif %} + + + +
+
+
{{ dataSet.name }}
diff --git a/webcentral/src/user_integration/views.py b/webcentral/src/user_integration/views.py index e1f5d1fa6..8fb467133 100644 --- a/webcentral/src/user_integration/views.py +++ b/webcentral/src/user_integration/views.py @@ -10,6 +10,8 @@ def userEngagementDetails(request, engagementId): """Serve the user engagement details page.""" userEngagementObj = UserEngagement.objects.get(id=engagementId) context = _defineContextForView() + context["pageTitle"] = _("Nutzendenintegration") + " - " + userEngagementObj.category + context["boxObject"] = userEngagementObj context["idOfSelectedObj"] = engagementId @@ -28,6 +30,7 @@ def userEngagementDetailsTitle(request, engagmentTitle): engagementId = userEngagementObj.id context = _defineContextForView() + context["pageTitle"] = _("Nutzendenintegration") + " - " + userEngagementObj.category context["boxObject"] = userEngagementObj context["idOfSelectedObj"] = engagementId context["pageTitle"] = userEngagementObj.category diff --git a/webcentral/test/06_system_test/src/test_base/webdriver_setup.py b/webcentral/test/06_system_test/src/test_base/webdriver_setup.py index 9ca4f6248..2ddaf5ff7 100644 --- a/webcentral/test/06_system_test/src/test_base/webdriver_setup.py +++ b/webcentral/test/06_system_test/src/test_base/webdriver_setup.py @@ -34,6 +34,7 @@ class WebDriverSetup(unittest.TestCase): GLOBAL_COLOR = "rgb(120, 117, 117)" TECHNICAL_COLOR = "rgb(143, 171, 247)" OPERATIONAL_COLOR = "rgb(244, 151, 131)" + LEGAL_COLOR = "rgb(228, 216, 92)" def setUp(self): """Start a webdriver-instance for every test in headless-mode. @@ -254,3 +255,20 @@ def waitUntilPageIsLoaded(self, elementId=None): else: wait.until(EC.presence_of_element_located((By.ID, f"{elementId}"))) + + def waitUntilConditionIsMet(self, functionHandler): + """Wait until the condition `condition` is met, before sricpt execution + is continued + + Parameters + ========== + condition : bool + condition, which must be met before continuation. + + Returns + ======= + None + """ + wait = WebDriverWait(self.driver, timeout=10) + wait.until(functionHandler) + diff --git a/webcentral/test/06_system_test/test/scripts/test_main_page.py b/webcentral/test/06_system_test/test/scripts/test_main_page.py index 2509dcfc9..66debda89 100644 --- a/webcentral/test/06_system_test/test/scripts/test_main_page.py +++ b/webcentral/test/06_system_test/test/scripts/test_main_page.py @@ -86,8 +86,11 @@ def testIfCriteriaCatalogTopicsInResults(self): startPageObj = StartPage(self.driver) searchInput = startPageObj.getSearchInputField() + if self.getLanguage() == "en": + searchInput.send_keys("Purpose specification") + else: + searchInput.send_keys("Zweckspezifizierung") - searchInput.send_keys("Zweckspezifizierung") searchInput.send_keys(Keys.RETURN) self.waitUntilPageIsLoaded("searchResultH2") @@ -104,7 +107,7 @@ def testIfCriteriaCatalogTopicsInResults(self): ) # click one of the criteria catalog results: - result.click() + self.scrollElementIntoViewAndClickIt(result) criteriaCatalogObj = CriteriaCatalogDetailsPage(self.driver) greyBoxes = criteriaCatalogObj.getNormsInforContainers() @@ -112,7 +115,6 @@ def testIfCriteriaCatalogTopicsInResults(self): for box in greyBoxes: self.assertTrue(not box.is_displayed()) # chck if we are on the criteria catalog: - breakpoint() def testImpressum(self): """Test if on click of Impressum link on the bottom of the site @@ -303,10 +305,10 @@ def testSearchFieldForBim2Sim(self): "last-search-results-page should be present, but it is not!", ) currentPageNumberElement = startPageObj.getCurrentSearchResultNumber() - self.assertIn( - "Seite 2", - currentPageNumberElement.text, - "Current Page Number should say 'Seite 2'", + self.assertTrue( + ("Seite 2" in currentPageNumberElement.text + or "Site 2" in currentPageNumberElement.text), + "Current Page Number should say 'Seite 2' or 'site 2'", ) self.driver.execute_script( "arguments[0].scrollIntoView({block: 'center', inline: 'nearest'})", @@ -315,9 +317,9 @@ def testSearchFieldForBim2Sim(self): time.sleep(1) listOfPreviousElement[0].click() currentPageNumberElement = startPageObj.getCurrentSearchResultNumber() - self.assertIn( - "Seite 1", - currentPageNumberElement.text, + self.assertTrue( + ("Seite 1" in currentPageNumberElement.text + or "Site 1" in currentPageNumberElement.text), "Current Page Number should say 'Seite 1'", ) @@ -389,8 +391,8 @@ def testContainers(self): "heading_de": "Ökologischer Fokus", "heading_en": "Ecological Focus", "linkNamesEnglish": [ - "Negative environmental impacts ", - "Positive environmental impacts", + "Negative environmental impacts", + "Positive environmental impacts - Good-practice", ], "linkNamesGerman": [ "Negative Umweltwirkungen", @@ -406,13 +408,13 @@ def testContainers(self): "heading_de": "Rechtlicher Fokus", "heading_en": "Legal Focus", "linkNamesEnglish": [ - "Privacy Overview", "Catalog of criteria", + "Privacy Overview", "Icons and visualization", ], "linkNamesGerman": [ - "Datenschutz-übersicht", "Kriterienkatalog", + "Daten­schutz­übersicht", "Icons und Visualisierung", ], "borderColor": self.LEGAL_COLOR, @@ -452,16 +454,72 @@ def testPageStructure(self): def testUserIntegrationInResults(self): """Test if user_integration elements are on the search results-page.""" self.driver.get(os.environ["siteUnderTest"]) - startPAgeObj = StartPage(self.driver) + startPageObj = StartPage(self.driver) searchInputField = startPageObj.getSearchInputField() searchInputField.send_keys("Participant Observation") searchInputField.send_keys(Keys.RETURN) + # wait until results page is loaded: + self.waitUntilConditionIsMet(lambda d: self.driver.title == "Search results" + or self.driver.title == "Suchergebnisse") + + listOfRowsInResultsTable = startPageObj.getSearchResults() + + self.assertGreaterEqual(len(listOfRowsInResultsTable), 1) + for result in listOfRowsInResultsTable: + if "Participant Observation" in result.text: + self.assertTrue("User integration" in result.text + or "Nutzendenintegration" in result.text) + result.click() + self.titleEnDe = [ + "User integration - Style guide", + "Nutzendenintegration - Styleguide"] + self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoadedByTitle) + + def testBusinessModelsInResults(self): + """Test if user_integration elements are on the search results-page.""" + self.driver.get(os.environ["siteUnderTest"]) + startPageObj = StartPage(self.driver) + + searchInputField = startPageObj.getSearchInputField() + searchInputField.send_keys("Social Factors") + searchInputField.send_keys(Keys.RETURN) + + # wait until results page is loaded: + self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoaded + ) + listOfRowsInResultsTable = startPageObj.getSearchResults() + self.assertGreaterEqual(len(listOfRowsInResultsTable), 1) for result in listOfRowsInResultsTable: - breakpoint() + if "Social Factors" in result.text: + self.assertTrue("Business Models" in result.text + or "Geschäftsmodelle" in result.text) + breakpoint() + self.scrollElementIntoViewAndClickIt(result) + self.titleEnDe = [ + "Business models - Social Factors", + "Geschäftsmodelle - Soziale Faktoren"] + self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoadedByTitle) + + + def _checkIfResultsPageIsLoaded(self, secondArg): + """ + + """ + return (self.driver.title == "Search results" + or self.driver.title == "Suchergebnisse") + + def _checkIfResultsPageIsLoadedByTitle(self, titleEnDe): + """ + + """ + return (self.driver.title == self.titleEnDe[1] + or self.driver.title == self.titleEnDe[0]) + + def _checkFocusContainer(self, focusName, dataDict): """ """ diff --git a/webcentral/test/06_system_test/test/scripts/test_user_integration.py b/webcentral/test/06_system_test/test/scripts/test_user_integration.py index 779a209f3..80025ace6 100644 --- a/webcentral/test/06_system_test/test/scripts/test_user_integration.py +++ b/webcentral/test/06_system_test/test/scripts/test_user_integration.py @@ -22,7 +22,7 @@ from src.page_obj.pages.comparison_page_section import ComparisonPageSection from src.page_obj.pages.user_integration_page import UserIntegrationPage from src.page_obj.pages.overview_page_section import OverviewPageSection -from src.page_obj.pages.details_page import DetailsPage +# from src.page_obj.pages.details_page import DetailsPage class TestUserIntegration(WebDriverSetup): From 046d9f07436b3eae413d67a2b151014ac2acff39 Mon Sep 17 00:00:00 2001 From: Martin Tobias Degner Date: Fri, 6 Sep 2024 15:57:41 +0200 Subject: [PATCH 07/24] working on TestMainPage debuggin --- webcentral/src/templates/start_search/result_search.html | 3 +-- webcentral/test/06_system_test/test/scripts/test_main_page.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/webcentral/src/templates/start_search/result_search.html b/webcentral/src/templates/start_search/result_search.html index 2e3f70e30..f237d6990 100644 --- a/webcentral/src/templates/start_search/result_search.html +++ b/webcentral/src/templates/start_search/result_search.html @@ -104,7 +104,6 @@

{% translate "Suchergebnisse" %}

{% elif dataSet.kindOfItem == "Geschäftsmodelle" %} - {% endif %} @@ -133,7 +132,7 @@
{{ dataSet.date }}
- {% endfor %} + {% endfor %} diff --git a/webcentral/test/06_system_test/test/scripts/test_main_page.py b/webcentral/test/06_system_test/test/scripts/test_main_page.py index 66debda89..b6b0f3d2f 100644 --- a/webcentral/test/06_system_test/test/scripts/test_main_page.py +++ b/webcentral/test/06_system_test/test/scripts/test_main_page.py @@ -497,8 +497,8 @@ def testBusinessModelsInResults(self): if "Social Factors" in result.text: self.assertTrue("Business Models" in result.text or "Geschäftsmodelle" in result.text) - breakpoint() - self.scrollElementIntoViewAndClickIt(result) + + self.scrollElementIntoViewAndClickIt(result.find_element(By.XPATH, "./td")) self.titleEnDe = [ "Business models - Social Factors", "Geschäftsmodelle - Soziale Faktoren"] From 7b7ac122dcb417b37474241a938f07113bfca326 Mon Sep 17 00:00:00 2001 From: Martin Tobias Degner Date: Fri, 6 Sep 2024 16:05:12 +0200 Subject: [PATCH 08/24] added selenium test to testyml github actions workflow --- .github/workflows/test.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index be3333dc2..fbf14c860 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,5 @@ -name: Django tests +name: Django tests and Selenium tests on: [push] @@ -32,3 +32,9 @@ jobs: - name: Execute first test run: docker exec -w /webcentral/src webcentral python manage.py test project_listing + + - name: Setup selenium dev-environment + run python -m venv webcentral/test/testing_venv && source webcentral/test/testing_venv/bin/activate && pip install -r webcentral/test/requirements_testing.txt + + - name: Run selenium test + run ./run test Selenium TestMainPage From 32e7c3c76252074535f2c31cf1b49d2be276f912 Mon Sep 17 00:00:00 2001 From: Martin Tobias Degner Date: Fri, 6 Sep 2024 16:07:41 +0200 Subject: [PATCH 09/24] fixed synatax errors of test github actions worflow config file --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fbf14c860..52a650968 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,7 +34,7 @@ jobs: run: docker exec -w /webcentral/src webcentral python manage.py test project_listing - name: Setup selenium dev-environment - run python -m venv webcentral/test/testing_venv && source webcentral/test/testing_venv/bin/activate && pip install -r webcentral/test/requirements_testing.txt + run: python -m venv webcentral/test/testing_venv && source webcentral/test/testing_venv/bin/activate && pip install -r webcentral/test/requirements_testing.txt - name: Run selenium test - run ./run test Selenium TestMainPage + run: ./run test Selenium TestMainPage From ff0683462a555b94dd1dfba4b57058f14a6637b0 Mon Sep 17 00:00:00 2001 From: Martin Tobias Degner Date: Mon, 9 Sep 2024 13:15:53 +0200 Subject: [PATCH 10/24] added positive environemtal impact to startsearch, working on creating seperate view for component list to open details for searched item --- webcentral/src/StartSearch/views.py | 56 +++++++++++++- webcentral/src/component_list/urls.py | 2 + webcentral/src/component_list/views.py | 10 +++ .../templates/start_search/result_search.html | 2 + .../static/js/criteriaCatalogFunctions.js | 20 ++++- .../test/scripts/test_main_page.py | 74 ++++++++++++++++++- 6 files changed, 157 insertions(+), 7 deletions(-) diff --git a/webcentral/src/StartSearch/views.py b/webcentral/src/StartSearch/views.py index e04d5c241..4ec70b58b 100644 --- a/webcentral/src/StartSearch/views.py +++ b/webcentral/src/StartSearch/views.py @@ -33,7 +33,8 @@ ) from user_integration.models import UserEngagement from businessModel.models import BusinessModel - +from positive_environmental_impact.models import EnvironmentalImpact +from component_list.models import Component def findPicturesForFocus(searchResultObj, tool=False): """Return the path to the picture, showing the Focus. @@ -61,7 +62,11 @@ def findPicturesForFocus(searchResultObj, tool=False): focusStrList = ["betrieblich"] if searchResultObj["kindOfItem"] == "Geschäftsmodelle": focusStrList = ["betrieblich"] - + if searchResultObj["kindOfItem"] == "Positive Umweltwirkungen": + focusStrList = ["ökologisch"] + if searchResultObj["kindOfItem"] == "Negative Umweltwirkungen": + focusStrList = ["ökologisch"] + pathStr = "assets/images/" if len(focusStrList) == 1: @@ -181,6 +186,16 @@ def resultSearch(request): "subCategoryShortDescription", ).filter(criterionUserIntegrationOne | criterionUserIntegrationTwo) + criterionPositiveEnvironmentalImpactOne = Q(relevance__icontains=searchInput) + criterionPositiveEnvironmentalImpactTwo = Q( + description__icontains=searchInput + ) + filteredPosEnvImpact = EnvironmentalImpact.objects.values( + "id", + "relevance", + "description", + ).filter(criterionPositiveEnvironmentalImpactOne | criterionPositiveEnvironmentalImpactTwo) + criterionBusinessModelOne = Q( challenge__icontains=searchInput ) @@ -192,6 +207,22 @@ def resultSearch(request): "challenge", "shortDescription", ).filter(criterionBusinessModelOne | criterionBusinessModelTwo) + + criterionComponentListOne = Q( + category__category__icontains=searchInput + ) + criterionComponentListTwo = Q( + componentClass__componentClass__icontains=searchInput + ) + criterionComponentListThree = Q( + category__category__icontains=searchInput + ) + filteredComponents = Component.objects.values( + "id", + "category__category", + "componentClass__componentClass", + "description", + ).filter(criterionComponentListOne | criterionComponentListTwo | criterionComponentListThree) filteredProjects = Subproject.objects.values( "referenceNumber_id", @@ -345,6 +376,25 @@ def resultSearch(request): businessModel["pathToFocusImage"] = findPicturesForFocus( businessModel ) + for posEnvImpact in filteredPosEnvImpact: + posEnvImpact["name"] = posEnvImpact["relevance"] + posEnvImpact["kindOfItem"] = "Positive Umweltwirkungen" + posEnvImpact["classificationAgg"] = _("Positive Umweltwirkungen") + posEnvImpact["date"] = _("2024-07-01") + posEnvImpact["virtDate"] = date.fromisoformat("2049-09-09") + posEnvImpact["pathToFocusImage"] = findPicturesForFocus( + posEnvImpact + ) + for component in filteredComponents: + component["name"] = component["category__category"] + " - " + component["componentClass__componentClass"] + component["kindOfItem"] = "Negative Umweltwirkungen" + component["classificationAgg"] = _("Negative Umweltwirkungen") + component["date"] = _("2024-07-01") + component["virtDate"] = date.fromisoformat("2049-09-09") + component["pathToFocusImage"] = findPicturesForFocus( + component + ) + # concat the prepared querySets to one QuerySet filteredData = list( chain( @@ -355,6 +405,8 @@ def resultSearch(request): filteredTopicsOfCriteriaCatalog, filteredUserIntegration, filteredBusinessModels, + filteredPosEnvImpact, + filteredComponents, ) ) # sort data list by name/kindOfItem and so on diff --git a/webcentral/src/component_list/urls.py b/webcentral/src/component_list/urls.py index 99c83c34f..30adb916c 100644 --- a/webcentral/src/component_list/urls.py +++ b/webcentral/src/component_list/urls.py @@ -4,6 +4,8 @@ urlpatterns = [ path("components/", views.components, name="components"), + path("components/", views.componentsOpenId, name="componentsOpenId"), + path("dataProcessing/", views.dataProcessing, name="dataProcessing"), path( "showImage/", diff --git a/webcentral/src/component_list/views.py b/webcentral/src/component_list/views.py index 29a9d6b80..5b4977d89 100644 --- a/webcentral/src/component_list/views.py +++ b/webcentral/src/component_list/views.py @@ -11,6 +11,16 @@ ComponentClass, ) +def componentsOpenId(request, componentId): + """Render component-objects and open details for specified componentId + + Parameters + ========== + componentId : int + Id of the component, whose details view should be opened. + """ + pass + def components(request): """Load the Component Modeldata and render the components-template""" diff --git a/webcentral/src/templates/start_search/result_search.html b/webcentral/src/templates/start_search/result_search.html index f237d6990..2b3cc1c33 100644 --- a/webcentral/src/templates/start_search/result_search.html +++ b/webcentral/src/templates/start_search/result_search.html @@ -104,6 +104,8 @@

{% translate "Suchergebnisse" %}

{% elif dataSet.kindOfItem == "Geschäftsmodelle" %} + {% elif dataSet.kindOfItem == "Positive Umweltwirkungen" %} + {% endif %} diff --git a/webcentral/src/webcentral_app/static/js/criteriaCatalogFunctions.js b/webcentral/src/webcentral_app/static/js/criteriaCatalogFunctions.js index c4f7c80c6..a25f96fa4 100644 --- a/webcentral/src/webcentral_app/static/js/criteriaCatalogFunctions.js +++ b/webcentral/src/webcentral_app/static/js/criteriaCatalogFunctions.js @@ -1,14 +1,32 @@ - +$(window).on('load', function(element) { + // Your code here will execute after the entire page has fully loaded + console.log('Page fully loaded, including all resources.'); + + // Example: Scroll to an element with the attribute topicId="221" + + if (searchedElementToJumpTo != undefined) { + searchedElementToJumpTo.scrollIntoView({ + behavior: 'smooth', + block: 'center' + }); + } +}); // the criteria catalog is modified, so that the layer deeper than the 2. layer is shown in one element modifyCatalogToBeShownInOneElement(); depthFirstWalkForParagraphs(); +jumpToSearchedElement = false; +var searchedElementToJumpTo = undefined if (idOfTopicToBeOpened != "") { var elementsToBeSearched = document.getElementById("hi").querySelectorAll("button, p");; for (var i = 0; i < elementsToBeSearched.length; i++) { if (elementsToBeSearched[i].getAttribute("topicId").includes(idOfTopicToBeOpened)) { + if (jumpToSearchedElement == false) { + searchedElementToJumpTo = elementsToBeSearched[i]; + jumpToSearchedElement = true; + } var rootElement = findRootElement(elementsToBeSearched[i]); depthFirstWalk(rootElement, elementsToBeSearched[i]); } diff --git a/webcentral/test/06_system_test/test/scripts/test_main_page.py b/webcentral/test/06_system_test/test/scripts/test_main_page.py index b6b0f3d2f..765a23d3f 100644 --- a/webcentral/test/06_system_test/test/scripts/test_main_page.py +++ b/webcentral/test/06_system_test/test/scripts/test_main_page.py @@ -107,14 +107,22 @@ def testIfCriteriaCatalogTopicsInResults(self): ) # click one of the criteria catalog results: - self.scrollElementIntoViewAndClickIt(result) + self.titleEnDe = [ + "Operations and operational optimization", + "Betrieb und Betriebsoptimierung"] + self.waitUntilConditionIsMet(lambda d: self.driver.title == "Search results" + or self.driver.title == "Suchergebnisse") + result.find_element(By.XPATH, "./td").click() + self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoadedByTitle) criteriaCatalogObj = CriteriaCatalogDetailsPage(self.driver) - greyBoxes = criteriaCatalogObj.getNormsInforContainers() + greyBoxes = criteriaCatalogObj.getNormsInfoContainers() for box in greyBoxes: self.assertTrue(not box.is_displayed()) - # chck if we are on the criteria catalog: + + # test if it is directly jumped to the searched element: + def testImpressum(self): """Test if on click of Impressum link on the bottom of the site @@ -503,7 +511,65 @@ def testBusinessModelsInResults(self): "Business models - Social Factors", "Geschäftsmodelle - Soziale Faktoren"] self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoadedByTitle) - + + def testPosEnvImpactInResults(self): + """Test if positive_environemntal_impact elements are on the search results-page.""" + self.driver.get(os.environ["siteUnderTest"]) + startPageObj = StartPage(self.driver) + + self._setLanguageToGerman() + searchInputField = startPageObj.getSearchInputField() + searchInputField.send_keys("Verbrauchsreduktion in komplexe") + searchInputField.send_keys(Keys.RETURN) + + # wait until results page is loaded: + self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoaded + ) + + listOfRowsInResultsTable = startPageObj.getSearchResults() + + self.assertGreaterEqual(len(listOfRowsInResultsTable), 1) + for result in listOfRowsInResultsTable: + if "Verbrauchsreduktion in komplexe" in result.text: + self.assertTrue("Positive environmental impact" in result.text + or "Positive Umweltwirkungen" in result.text) + + self.scrollElementIntoViewAndClickIt(result.find_element(By.XPATH, "./td")) + self.titleEnDe = [ + "LLEC - Administration building: Climate-neutral administration building as an active part of the Living Lab Energy Campus; EnOB: LLEC: Living Lab Energy Campus", + "LLEC – Verwaltungsbau: Klimaneutraler Verwaltungsbau als aktiver Teil des Living Lab Energy Campus; EnOB: LLEC: Living Lab Energy Campus", + ] + self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoadedByTitle) + + def testNegEnvImpactInResults(self): + """Test if positive_environemntal_impact elements are on the search results-page.""" + self.driver.get(os.environ["siteUnderTest"]) + startPageObj = StartPage(self.driver) + + self._setLanguageToGerman() + searchInputField = startPageObj.getSearchInputField() + searchInputField.send_keys("Verbrauchsreduktion in komplexe") + searchInputField.send_keys(Keys.RETURN) + + # wait until results page is loaded: + self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoaded + ) + + listOfRowsInResultsTable = startPageObj.getSearchResults() + + self.assertGreaterEqual(len(listOfRowsInResultsTable), 1) + for result in listOfRowsInResultsTable: + if "Verbrauchsreduktion in komplexe" in result.text: + self.assertTrue("Positive environmental impact" in result.text + or "Positive Umweltwirkungen" in result.text) + + self.scrollElementIntoViewAndClickIt(result.find_element(By.XPATH, "./td")) + self.titleEnDe = [ + "LLEC - Administration building: Climate-neutral administration building as an active part of the Living Lab Energy Campus; EnOB: LLEC: Living Lab Energy Campus", + "LLEC – Verwaltungsbau: Klimaneutraler Verwaltungsbau als aktiver Teil des Living Lab Energy Campus; EnOB: LLEC: Living Lab Energy Campus", + ] + self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoadedByTitle) + def _checkIfResultsPageIsLoaded(self, secondArg): """ From a884d1760a754ac449d7385e04bb13d9b93ec152 Mon Sep 17 00:00:00 2001 From: expeditionengineer Date: Mon, 9 Sep 2024 11:17:56 +0000 Subject: [PATCH 11/24] Apply automatic changes --- webcentral/src/StartSearch/views.py | 61 +++---- webcentral/src/component_list/urls.py | 7 +- webcentral/src/component_list/views.py | 1 + .../templates/start_search/result_search.html | 172 +++++++++--------- webcentral/src/user_integration/views.py | 8 +- .../src/test_base/webdriver_setup.py | 3 +- .../test/scripts/test_main_page.py | 146 +++++++++------ .../test/scripts/test_user_integration.py | 1 + 8 files changed, 216 insertions(+), 183 deletions(-) diff --git a/webcentral/src/StartSearch/views.py b/webcentral/src/StartSearch/views.py index 4ec70b58b..fbb61cdcb 100644 --- a/webcentral/src/StartSearch/views.py +++ b/webcentral/src/StartSearch/views.py @@ -32,10 +32,11 @@ Protocol, ) from user_integration.models import UserEngagement -from businessModel.models import BusinessModel -from positive_environmental_impact.models import EnvironmentalImpact +from businessModel.models import BusinessModel +from positive_environmental_impact.models import EnvironmentalImpact from component_list.models import Component + def findPicturesForFocus(searchResultObj, tool=False): """Return the path to the picture, showing the Focus. @@ -66,7 +67,6 @@ def findPicturesForFocus(searchResultObj, tool=False): focusStrList = ["ökologisch"] if searchResultObj["kindOfItem"] == "Negative Umweltwirkungen": focusStrList = ["ökologisch"] - pathStr = "assets/images/" if len(focusStrList) == 1: @@ -186,7 +186,9 @@ def resultSearch(request): "subCategoryShortDescription", ).filter(criterionUserIntegrationOne | criterionUserIntegrationTwo) - criterionPositiveEnvironmentalImpactOne = Q(relevance__icontains=searchInput) + criterionPositiveEnvironmentalImpactOne = Q( + relevance__icontains=searchInput + ) criterionPositiveEnvironmentalImpactTwo = Q( description__icontains=searchInput ) @@ -194,35 +196,34 @@ def resultSearch(request): "id", "relevance", "description", - ).filter(criterionPositiveEnvironmentalImpactOne | criterionPositiveEnvironmentalImpactTwo) - - criterionBusinessModelOne = Q( - challenge__icontains=searchInput - ) - criterionBusinessModelTwo = Q( - shortDescription__icontains=searchInput + ).filter( + criterionPositiveEnvironmentalImpactOne + | criterionPositiveEnvironmentalImpactTwo ) + + criterionBusinessModelOne = Q(challenge__icontains=searchInput) + criterionBusinessModelTwo = Q(shortDescription__icontains=searchInput) filteredBusinessModels = BusinessModel.objects.values( "id", "challenge", "shortDescription", ).filter(criterionBusinessModelOne | criterionBusinessModelTwo) - - criterionComponentListOne = Q( - category__category__icontains=searchInput - ) + + criterionComponentListOne = Q(category__category__icontains=searchInput) criterionComponentListTwo = Q( componentClass__componentClass__icontains=searchInput ) - criterionComponentListThree = Q( - category__category__icontains=searchInput - ) + criterionComponentListThree = Q(category__category__icontains=searchInput) filteredComponents = Component.objects.values( "id", "category__category", "componentClass__componentClass", "description", - ).filter(criterionComponentListOne | criterionComponentListTwo | criterionComponentListThree) + ).filter( + criterionComponentListOne + | criterionComponentListTwo + | criterionComponentListThree + ) filteredProjects = Subproject.objects.values( "referenceNumber_id", @@ -366,35 +367,33 @@ def resultSearch(request): userIntegration["pathToFocusImage"] = findPicturesForFocus( userIntegration ) - + for businessModel in filteredBusinessModels: businessModel["name"] = businessModel["challenge"] businessModel["kindOfItem"] = "Geschäftsmodelle" businessModel["classificationAgg"] = _("Geschäftsmodelle") businessModel["date"] = _("2024-07-01") businessModel["virtDate"] = date.fromisoformat("2049-09-09") - businessModel["pathToFocusImage"] = findPicturesForFocus( - businessModel - ) + businessModel["pathToFocusImage"] = findPicturesForFocus(businessModel) for posEnvImpact in filteredPosEnvImpact: posEnvImpact["name"] = posEnvImpact["relevance"] posEnvImpact["kindOfItem"] = "Positive Umweltwirkungen" posEnvImpact["classificationAgg"] = _("Positive Umweltwirkungen") posEnvImpact["date"] = _("2024-07-01") posEnvImpact["virtDate"] = date.fromisoformat("2049-09-09") - posEnvImpact["pathToFocusImage"] = findPicturesForFocus( - posEnvImpact - ) + posEnvImpact["pathToFocusImage"] = findPicturesForFocus(posEnvImpact) for component in filteredComponents: - component["name"] = component["category__category"] + " - " + component["componentClass__componentClass"] + component["name"] = ( + component["category__category"] + + " - " + + component["componentClass__componentClass"] + ) component["kindOfItem"] = "Negative Umweltwirkungen" component["classificationAgg"] = _("Negative Umweltwirkungen") component["date"] = _("2024-07-01") component["virtDate"] = date.fromisoformat("2049-09-09") - component["pathToFocusImage"] = findPicturesForFocus( - component - ) - + component["pathToFocusImage"] = findPicturesForFocus(component) + # concat the prepared querySets to one QuerySet filteredData = list( chain( diff --git a/webcentral/src/component_list/urls.py b/webcentral/src/component_list/urls.py index 30adb916c..dd094f3a6 100644 --- a/webcentral/src/component_list/urls.py +++ b/webcentral/src/component_list/urls.py @@ -4,8 +4,11 @@ urlpatterns = [ path("components/", views.components, name="components"), - path("components/", views.componentsOpenId, name="componentsOpenId"), - + path( + "components/", + views.componentsOpenId, + name="componentsOpenId", + ), path("dataProcessing/", views.dataProcessing, name="dataProcessing"), path( "showImage/", diff --git a/webcentral/src/component_list/views.py b/webcentral/src/component_list/views.py index 5b4977d89..66ee93e65 100644 --- a/webcentral/src/component_list/views.py +++ b/webcentral/src/component_list/views.py @@ -11,6 +11,7 @@ ComponentClass, ) + def componentsOpenId(request, componentId): """Render component-objects and open details for specified componentId diff --git a/webcentral/src/templates/start_search/result_search.html b/webcentral/src/templates/start_search/result_search.html index 2b3cc1c33..303227959 100644 --- a/webcentral/src/templates/start_search/result_search.html +++ b/webcentral/src/templates/start_search/result_search.html @@ -94,92 +94,92 @@

{% translate "Suchergebnisse" %}

{% elif dataSet.kindOfItem == "digitales Werkzeug" %} - {% elif dataSet.kindOfItem == "Norm" %} - - {% elif dataSet.kindOfItem == "Protokoll" %} - - {% elif dataSet.kindOfItem == "Kriterienkatalog" %} - - {% elif dataSet.kindOfItem == "Nutzendenintegration" %} - - {% elif dataSet.kindOfItem == "Geschäftsmodelle" %} - - {% elif dataSet.kindOfItem == "Positive Umweltwirkungen" %} - - {% endif %} - - - -
-
-
{{ dataSet.name }}
-
- - - - -
-
{{ dataSet.classificationAgg|title }}
-
- + {% elif dataSet.kindOfItem == "Norm" %} + + {% elif dataSet.kindOfItem == "Protokoll" %} + + {% elif dataSet.kindOfItem == "Kriterienkatalog" %} + + {% elif dataSet.kindOfItem == "Nutzendenintegration" %} + + {% elif dataSet.kindOfItem == "Geschäftsmodelle" %} + + {% elif dataSet.kindOfItem == "Positive Umweltwirkungen" %} + + {% endif %} + + + +
+
+
{{ dataSet.name }}
+
+ + + + +
+
{{ dataSet.classificationAgg|title }}
+
+ - - - icon - - -
-
{{ dataSet.date }}
-
- - - - {% endfor %} - - - - -
- -
- - - + +
+ + + + + {% else %} +

{% translate "Die Suche hat keine Ergebnisse ergeben." %}

{% endif %} - -
- - {% else %} -

{% translate "Die Suche hat keine Ergebnisse ergeben." %}

- {% endif %} - - + + - - {% endblock %} + + {% endblock %} diff --git a/webcentral/src/user_integration/views.py b/webcentral/src/user_integration/views.py index 8fb467133..375dd15a9 100644 --- a/webcentral/src/user_integration/views.py +++ b/webcentral/src/user_integration/views.py @@ -10,7 +10,9 @@ def userEngagementDetails(request, engagementId): """Serve the user engagement details page.""" userEngagementObj = UserEngagement.objects.get(id=engagementId) context = _defineContextForView() - context["pageTitle"] = _("Nutzendenintegration") + " - " + userEngagementObj.category + context["pageTitle"] = ( + _("Nutzendenintegration") + " - " + userEngagementObj.category + ) context["boxObject"] = userEngagementObj context["idOfSelectedObj"] = engagementId @@ -30,7 +32,9 @@ def userEngagementDetailsTitle(request, engagmentTitle): engagementId = userEngagementObj.id context = _defineContextForView() - context["pageTitle"] = _("Nutzendenintegration") + " - " + userEngagementObj.category + context["pageTitle"] = ( + _("Nutzendenintegration") + " - " + userEngagementObj.category + ) context["boxObject"] = userEngagementObj context["idOfSelectedObj"] = engagementId context["pageTitle"] = userEngagementObj.category diff --git a/webcentral/test/06_system_test/src/test_base/webdriver_setup.py b/webcentral/test/06_system_test/src/test_base/webdriver_setup.py index 2ddaf5ff7..5099d4eba 100644 --- a/webcentral/test/06_system_test/src/test_base/webdriver_setup.py +++ b/webcentral/test/06_system_test/src/test_base/webdriver_setup.py @@ -34,7 +34,7 @@ class WebDriverSetup(unittest.TestCase): GLOBAL_COLOR = "rgb(120, 117, 117)" TECHNICAL_COLOR = "rgb(143, 171, 247)" OPERATIONAL_COLOR = "rgb(244, 151, 131)" - LEGAL_COLOR = "rgb(228, 216, 92)" + LEGAL_COLOR = "rgb(228, 216, 92)" def setUp(self): """Start a webdriver-instance for every test in headless-mode. @@ -271,4 +271,3 @@ def waitUntilConditionIsMet(self, functionHandler): """ wait = WebDriverWait(self.driver, timeout=10) wait.until(functionHandler) - diff --git a/webcentral/test/06_system_test/test/scripts/test_main_page.py b/webcentral/test/06_system_test/test/scripts/test_main_page.py index 765a23d3f..2212d9cfb 100644 --- a/webcentral/test/06_system_test/test/scripts/test_main_page.py +++ b/webcentral/test/06_system_test/test/scripts/test_main_page.py @@ -108,10 +108,13 @@ def testIfCriteriaCatalogTopicsInResults(self): # click one of the criteria catalog results: self.titleEnDe = [ - "Operations and operational optimization", - "Betrieb und Betriebsoptimierung"] - self.waitUntilConditionIsMet(lambda d: self.driver.title == "Search results" - or self.driver.title == "Suchergebnisse") + "Operations and operational optimization", + "Betrieb und Betriebsoptimierung", + ] + self.waitUntilConditionIsMet( + lambda d: self.driver.title == "Search results" + or self.driver.title == "Suchergebnisse" + ) result.find_element(By.XPATH, "./td").click() self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoadedByTitle) @@ -123,7 +126,6 @@ def testIfCriteriaCatalogTopicsInResults(self): # test if it is directly jumped to the searched element: - def testImpressum(self): """Test if on click of Impressum link on the bottom of the site the Impressum page opens, which is located on $siteunderTtest + /pages/Impressum @@ -314,8 +316,10 @@ def testSearchFieldForBim2Sim(self): ) currentPageNumberElement = startPageObj.getCurrentSearchResultNumber() self.assertTrue( - ("Seite 2" in currentPageNumberElement.text - or "Site 2" in currentPageNumberElement.text), + ( + "Seite 2" in currentPageNumberElement.text + or "Site 2" in currentPageNumberElement.text + ), "Current Page Number should say 'Seite 2' or 'site 2'", ) self.driver.execute_script( @@ -326,8 +330,10 @@ def testSearchFieldForBim2Sim(self): listOfPreviousElement[0].click() currentPageNumberElement = startPageObj.getCurrentSearchResultNumber() self.assertTrue( - ("Seite 1" in currentPageNumberElement.text - or "Site 1" in currentPageNumberElement.text), + ( + "Seite 1" in currentPageNumberElement.text + or "Site 1" in currentPageNumberElement.text + ), "Current Page Number should say 'Seite 1'", ) @@ -468,23 +474,30 @@ def testUserIntegrationInResults(self): searchInputField.send_keys("Participant Observation") searchInputField.send_keys(Keys.RETURN) - # wait until results page is loaded: - self.waitUntilConditionIsMet(lambda d: self.driver.title == "Search results" - or self.driver.title == "Suchergebnisse") + # wait until results page is loaded: + self.waitUntilConditionIsMet( + lambda d: self.driver.title == "Search results" + or self.driver.title == "Suchergebnisse" + ) listOfRowsInResultsTable = startPageObj.getSearchResults() self.assertGreaterEqual(len(listOfRowsInResultsTable), 1) for result in listOfRowsInResultsTable: if "Participant Observation" in result.text: - self.assertTrue("User integration" in result.text - or "Nutzendenintegration" in result.text) + self.assertTrue( + "User integration" in result.text + or "Nutzendenintegration" in result.text + ) result.click() self.titleEnDe = [ "User integration - Style guide", - "Nutzendenintegration - Styleguide"] - self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoadedByTitle) - + "Nutzendenintegration - Styleguide", + ] + self.waitUntilConditionIsMet( + self._checkIfResultsPageIsLoadedByTitle + ) + def testBusinessModelsInResults(self): """Test if user_integration elements are on the search results-page.""" self.driver.get(os.environ["siteUnderTest"]) @@ -494,98 +507,111 @@ def testBusinessModelsInResults(self): searchInputField.send_keys("Social Factors") searchInputField.send_keys(Keys.RETURN) - # wait until results page is loaded: - self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoaded - ) + # wait until results page is loaded: + self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoaded) listOfRowsInResultsTable = startPageObj.getSearchResults() self.assertGreaterEqual(len(listOfRowsInResultsTable), 1) for result in listOfRowsInResultsTable: if "Social Factors" in result.text: - self.assertTrue("Business Models" in result.text - or "Geschäftsmodelle" in result.text) - - self.scrollElementIntoViewAndClickIt(result.find_element(By.XPATH, "./td")) + self.assertTrue( + "Business Models" in result.text + or "Geschäftsmodelle" in result.text + ) + + self.scrollElementIntoViewAndClickIt( + result.find_element(By.XPATH, "./td") + ) self.titleEnDe = [ "Business models - Social Factors", - "Geschäftsmodelle - Soziale Faktoren"] - self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoadedByTitle) + "Geschäftsmodelle - Soziale Faktoren", + ] + self.waitUntilConditionIsMet( + self._checkIfResultsPageIsLoadedByTitle + ) def testPosEnvImpactInResults(self): """Test if positive_environemntal_impact elements are on the search results-page.""" self.driver.get(os.environ["siteUnderTest"]) startPageObj = StartPage(self.driver) - + self._setLanguageToGerman() searchInputField = startPageObj.getSearchInputField() searchInputField.send_keys("Verbrauchsreduktion in komplexe") searchInputField.send_keys(Keys.RETURN) - # wait until results page is loaded: - self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoaded - ) + # wait until results page is loaded: + self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoaded) listOfRowsInResultsTable = startPageObj.getSearchResults() self.assertGreaterEqual(len(listOfRowsInResultsTable), 1) for result in listOfRowsInResultsTable: if "Verbrauchsreduktion in komplexe" in result.text: - self.assertTrue("Positive environmental impact" in result.text - or "Positive Umweltwirkungen" in result.text) - - self.scrollElementIntoViewAndClickIt(result.find_element(By.XPATH, "./td")) + self.assertTrue( + "Positive environmental impact" in result.text + or "Positive Umweltwirkungen" in result.text + ) + + self.scrollElementIntoViewAndClickIt( + result.find_element(By.XPATH, "./td") + ) self.titleEnDe = [ "LLEC - Administration building: Climate-neutral administration building as an active part of the Living Lab Energy Campus; EnOB: LLEC: Living Lab Energy Campus", "LLEC – Verwaltungsbau: Klimaneutraler Verwaltungsbau als aktiver Teil des Living Lab Energy Campus; EnOB: LLEC: Living Lab Energy Campus", - ] - self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoadedByTitle) - + ] + self.waitUntilConditionIsMet( + self._checkIfResultsPageIsLoadedByTitle + ) + def testNegEnvImpactInResults(self): """Test if positive_environemntal_impact elements are on the search results-page.""" self.driver.get(os.environ["siteUnderTest"]) startPageObj = StartPage(self.driver) - + self._setLanguageToGerman() searchInputField = startPageObj.getSearchInputField() searchInputField.send_keys("Verbrauchsreduktion in komplexe") searchInputField.send_keys(Keys.RETURN) - # wait until results page is loaded: - self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoaded - ) + # wait until results page is loaded: + self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoaded) listOfRowsInResultsTable = startPageObj.getSearchResults() self.assertGreaterEqual(len(listOfRowsInResultsTable), 1) for result in listOfRowsInResultsTable: if "Verbrauchsreduktion in komplexe" in result.text: - self.assertTrue("Positive environmental impact" in result.text - or "Positive Umweltwirkungen" in result.text) - - self.scrollElementIntoViewAndClickIt(result.find_element(By.XPATH, "./td")) + self.assertTrue( + "Positive environmental impact" in result.text + or "Positive Umweltwirkungen" in result.text + ) + + self.scrollElementIntoViewAndClickIt( + result.find_element(By.XPATH, "./td") + ) self.titleEnDe = [ "LLEC - Administration building: Climate-neutral administration building as an active part of the Living Lab Energy Campus; EnOB: LLEC: Living Lab Energy Campus", "LLEC – Verwaltungsbau: Klimaneutraler Verwaltungsbau als aktiver Teil des Living Lab Energy Campus; EnOB: LLEC: Living Lab Energy Campus", - ] - self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoadedByTitle) - + ] + self.waitUntilConditionIsMet( + self._checkIfResultsPageIsLoadedByTitle + ) def _checkIfResultsPageIsLoaded(self, secondArg): - """ - - """ - return (self.driver.title == "Search results" - or self.driver.title == "Suchergebnisse") + """ """ + return ( + self.driver.title == "Search results" + or self.driver.title == "Suchergebnisse" + ) def _checkIfResultsPageIsLoadedByTitle(self, titleEnDe): - """ - - """ - return (self.driver.title == self.titleEnDe[1] - or self.driver.title == self.titleEnDe[0]) - - + """ """ + return ( + self.driver.title == self.titleEnDe[1] + or self.driver.title == self.titleEnDe[0] + ) def _checkFocusContainer(self, focusName, dataDict): """ """ diff --git a/webcentral/test/06_system_test/test/scripts/test_user_integration.py b/webcentral/test/06_system_test/test/scripts/test_user_integration.py index 80025ace6..3d712715e 100644 --- a/webcentral/test/06_system_test/test/scripts/test_user_integration.py +++ b/webcentral/test/06_system_test/test/scripts/test_user_integration.py @@ -22,6 +22,7 @@ from src.page_obj.pages.comparison_page_section import ComparisonPageSection from src.page_obj.pages.user_integration_page import UserIntegrationPage from src.page_obj.pages.overview_page_section import OverviewPageSection + # from src.page_obj.pages.details_page import DetailsPage From 3b8c42fab5fe1d298ba36983be5471d1dc44f819 Mon Sep 17 00:00:00 2001 From: Martin Tobias Degner Date: Tue, 10 Sep 2024 09:27:44 +0200 Subject: [PATCH 12/24] components are scrolled into view and details view is triggered wehen clicking on a search result in result_search --- webcentral/src/component_list/urls.py | 4 +- webcentral/src/component_list/views.py | 620 +++++++++--------- .../src/templates/partials/listing-row.html | 14 + .../templates/start_search/result_search.html | 2 + 4 files changed, 336 insertions(+), 304 deletions(-) diff --git a/webcentral/src/component_list/urls.py b/webcentral/src/component_list/urls.py index dd094f3a6..0be3bbdbd 100644 --- a/webcentral/src/component_list/urls.py +++ b/webcentral/src/component_list/urls.py @@ -3,10 +3,10 @@ from . import views urlpatterns = [ - path("components/", views.components, name="components"), + path("components/", views.ComponentListView.as_view(), name="components"), path( "components/", - views.componentsOpenId, + views.ComponentListView.as_view(), name="componentsOpenId", ), path("dataProcessing/", views.dataProcessing, name="dataProcessing"), diff --git a/webcentral/src/component_list/views.py b/webcentral/src/component_list/views.py index 66ee93e65..0e7f6b092 100644 --- a/webcentral/src/component_list/views.py +++ b/webcentral/src/component_list/views.py @@ -4,6 +4,7 @@ from django.db.models import Q from django.http import JsonResponse from django.template import Template, Context +from django.views import View from .models import ( Category, @@ -12,319 +13,334 @@ ) -def componentsOpenId(request, componentId): - """Render component-objects and open details for specified componentId +class ComponentListView(View): + """ - Parameters - ========== - componentId : int - Id of the component, whose details view should be opened. """ - pass - - -def components(request): - """Load the Component Modeldata and render the components-template""" - - # if request.method == "POST": - listingShowOrCollapse = "collapse" - - # get the values of the multi-level dropdown field: - firstLevelDropdown = "" - secondLevelDropdown = "" - - # get the values of the input-fields: - searchInputValue = request.GET.get("searched", "") - # searchInputValues = searchInputValue.split(",") - # searchInputValues = _removeEmtpyStringsFromList(searchInputValues) - categoryValue = request.GET.get("category-hidden", "") - - # the values in category are a comma separated list: - categoryValues = categoryValue.split(",") - categoryValues = _removeEmtpyStringsFromList(categoryValues) - componentValue = request.GET.get("component-hidden", "") - componentValues = componentValue.split(",") - componentValues = _removeEmtpyStringsFromList(componentValues) - # sortingValue = request.GET.get("sorting", "") - overviewValue = request.GET.get("overview", "") - - sortingValue = request.GET.get("sorting-hidden", "") - - if sortingValue != "": - firstLevelDropdown = sortingValue.split("_")[0] - secondLevelDropdown = sortingValue.split("_")[1] - filtering = bool(request.GET.get("filtering", False)) - - searchQuery = Q() - searchQueryInput = Q() - # if len(searchInputValues) > 0: - # for searchInputValue in searchInputValues: - searchQueryInput = searchQueryInput | Q( - category__category__icontains=searchInputValue - ) - searchQueryInput = searchQueryInput | Q( - componentClass__componentClass__icontains=searchInputValue - ) - searchQueryInput = searchQueryInput | Q( - description__icontains=searchInputValue - ) - searchQueryInput = searchQueryInput | Q( - furtherInformationNotes__icontains=searchInputValue - ) - searchQueryInput = searchQueryInput | Q(sources__icontains=searchInputValue) - - searchQueryCategory = Q() - if len(categoryValues) > 0: - for category in categoryValues: - searchQueryCategory = searchQueryCategory | Q( - category__category__icontains=category - ) - searchQueryComponents = Q() - if len(componentValues) > 0: - for component in componentValues: - searchQueryComponents = searchQueryComponents | Q( - componentClass__componentClass__icontains=component - ) + def get(self, request, componentId=None): + """Render component-objects and open details for specified componentId - # componentForSelectValue = ComponentClass.objects.filter( - # componentClass=componentValues) - # if len(componentForSelectValue) == 1: - # searchQuery = searchQuery | Q(component=componentForSelectValue[0]) - - searchQuery = searchQueryInput & searchQueryCategory & searchQueryComponents - - if overviewValue: - if overviewValue == _("Ausgeklappt"): - listingShowOrCollapse = "show" - - if firstLevelDropdown and secondLevelDropdown: - if secondLevelDropdown == "Ascending" or secondLevelDropdown == "A...Z": - if firstLevelDropdown == "category": - firstLevelDropdown = "category__category" - elif firstLevelDropdown == "component": - firstLevelDropdown = "componentClass__componentClass" - componentsObj = Component.objects.filter(searchQuery).order_by( - firstLevelDropdown - ) + Parameters + ========== + componentId : int + Id of the component, whose details view should be opened. + """ + + + listingShowOrCollapse = "collapse" + + # get the values of the multi-level dropdown field: + firstLevelDropdown = "" + secondLevelDropdown = "" + + # get the values of the input-fields: + searchInputValue = request.GET.get("searched", "") + # searchInputValues = searchInputValue.split(",") + # searchInputValues = _removeEmtpyStringsFromList(searchInputValues) + categoryValue = request.GET.get("category-hidden", "") + + # the values in category are a comma separated list: + categoryValues = categoryValue.split(",") + categoryValues = _removeEmtpyStringsFromList(categoryValues) + componentValue = request.GET.get("component-hidden", "") + componentValues = componentValue.split(",") + componentValues = _removeEmtpyStringsFromList(componentValues) + # sortingValue = request.GET.get("sorting", "") + overviewValue = request.GET.get("overview", "") + + sortingValue = request.GET.get("sorting-hidden", "") + + if sortingValue != "": + firstLevelDropdown = sortingValue.split("_")[0] + secondLevelDropdown = sortingValue.split("_")[1] + filtering = bool(request.GET.get("filtering", False)) + + searchQuery = Q() + searchQueryInput = Q() + # if len(searchInputValues) > 0: + # for searchInputValue in searchInputValues: + searchQueryInput = searchQueryInput | Q( + category__category__icontains=searchInputValue + ) + searchQueryInput = searchQueryInput | Q( + componentClass__componentClass__icontains=searchInputValue + ) + searchQueryInput = searchQueryInput | Q( + description__icontains=searchInputValue + ) + searchQueryInput = searchQueryInput | Q( + furtherInformationNotes__icontains=searchInputValue + ) + searchQueryInput = searchQueryInput | Q(sources__icontains=searchInputValue) + + searchQueryCategory = Q() + if len(categoryValues) > 0: + for category in categoryValues: + searchQueryCategory = searchQueryCategory | Q( + category__category__icontains=category + ) + + searchQueryComponents = Q() + if len(componentValues) > 0: + for component in componentValues: + searchQueryComponents = searchQueryComponents | Q( + componentClass__componentClass__icontains=component + ) + + # componentForSelectValue = ComponentClass.objects.filter( + # componentClass=componentValues) + # if len(componentForSelectValue) == 1: + # searchQuery = searchQuery | Q(component=componentForSelectValue[0]) + + searchQuery = searchQueryInput & searchQueryCategory & searchQueryComponents + + if overviewValue: + if overviewValue == _("Ausgeklappt"): + listingShowOrCollapse = "show" + + if firstLevelDropdown and secondLevelDropdown: + if secondLevelDropdown == "Ascending" or secondLevelDropdown == "A...Z": + if firstLevelDropdown == "category": + firstLevelDropdown = "category__category" + elif firstLevelDropdown == "component": + firstLevelDropdown = "componentClass__componentClass" + componentsObj = Component.objects.filter(searchQuery).order_by( + firstLevelDropdown + ) + else: + if firstLevelDropdown == "category": + firstLevelDropdown = "category__category" + elif firstLevelDropdown == "component": + firstLevelDropdown = "componentClass__componentClass" + componentsObj = Component.objects.filter(searchQuery).order_by( + f"-{firstLevelDropdown}" + ) else: - if firstLevelDropdown == "category": - firstLevelDropdown = "category__category" - elif firstLevelDropdown == "component": - firstLevelDropdown = "componentClass__componentClass" - componentsObj = Component.objects.filter(searchQuery).order_by( - f"-{firstLevelDropdown}" - ) - else: - componentsObj = Component.objects.filter(searchQuery) + componentsObj = Component.objects.filter(searchQuery) - componentsObjList = list(componentsObj) - componentsPaginator = Paginator(componentsObjList, 10) - pageNum = request.GET.get("page", None) - page = componentsPaginator.get_page(pageNum) + componentsObjList = list(componentsObj) + componentsPaginator = Paginator(componentsObjList, 10) + pageNum = request.GET.get("page", None) + page = componentsPaginator.get_page(pageNum) - if request.LANGUAGE_CODE == "de": - descriptionImage = "backbone_de.svg" - else: - descriptionImage = "backbone_en.svg" - - explanationFirstPart = _( - "Die Durchführung der Prozessschritte entlang der Daten-Wertschöpfungskette (siehe auch" - ) + if request.LANGUAGE_CODE == "de": + descriptionImage = "backbone_de.svg" + else: + descriptionImage = "backbone_en.svg" - explanationRaw = "{% load i18n %} „{% translate 'Aufwände für Datenverarbeitungsprozesse' %}“) " - explanationSecondPart = ( - _( - """ist immer mit einem materiellen Einsatz für die Komponenten verbunden. In Analogie zu den Prozessschritten der Daten-Wertschöpfungskette können wichtige Komponenten von der Datenerfassung (Sensoren) bis zur Datennutzung (Aktuatoren) gedacht werden. Abbildung 2 zeigt Komponenten, die zur Realisierung digitaler Anwendungen in Gebäuden und Quartieren häufig zur Anwendung kommen (hier Fokus auf Betriebsoptimierung). Je nachdem, welche dieser – oder weitere – Komponenten zusätzlich für die digitale Anwendung verbaut werden mussten, müssen die entsprechenden Umweltlasten mitbetrachtet werden. Die Umweltlasten umfassen dabei die Emissionen, die bei der Herstellung von der Gewinnung der Rohstoffe bis zur Fertigung der Komponente reichen, über Emissionen durch den Ressourcen- und Energieverbrauch während der Nutzung der Komponente, bis zur Entsorgung und dem Recycling der Materialien. Diese Wirkungen wurden mit der Methode der Ökobilanz erfasst. - """ + explanationFirstPart = _( + "Die Durchführung der Prozessschritte entlang der Daten-Wertschöpfungskette (siehe auch" ) - .replace("\n", "
") - .replace("'", "") - ) - templateObj = Template(explanationRaw) - explanationText = templateObj.render(Context({})) - context = { - "renderDetailsRadio": True, - "heading": _("Aufwände für verwendete Komponenten"), - "explanaitionText": explanationFirstPart - + explanationText - + explanationSecondPart, - "focusBorder": "ecological", - "focusName": "ecological", - "urlName": "components", - "page": page, - "model": "Component", - "listElementsShowOrCollapse": listingShowOrCollapse, - "elementsFirstColumn": [ - { - "objectReference": "componentClass", - "description": "", - }, - { - "objectReference": "category", - "description": "", - }, - { - "objectReference": "description", - "description": "", - }, - { - "objectReference": "furtherInformationNotesRendered", - "description": _("Weitere Informationen"), - }, - { - "objectReference": "sources", - "description": _("Quelle"), - }, - ], - "elementsSecondColumn": [ - { - "objectReference": "energyConsumptionUsePhaseTotalRounded", - "description": _( - "Energieverbrauch Nutzungsphase (gesamt; in kWh/Jahr)" - ), - }, - { - "objectReference": "specificGlobalWarmingPotentialRounded", - "description": _( - "Spezifisches Teibhauspotential Gesamt (in kg CO2-e/Jahr)" - ), - }, - { - "objectReference": "globalWarmingPotentialTotalRounded", - "description": _("Treibhauspotenzial (gesamt; in kg CO2-e)"), - }, - { - "objectReference": "componentWeightRounded", - "description": _("Bauteilgewicht (in kg)"), - }, - { - "objectReference": "lifetime", - "description": _("Lebensdauer (in Jahre)"), - }, - { - "objectReference": "energyConsumptionUsePhaseActiveRoundedSup", - "description": _("Leistung Nutzungsphase (akitv; in W)"), - }, - { - "objectReference": "energyConsumptionUsePhasePassiveRounded", - "description": _( - "Leistung Nutzungsphase (passiv/ Stand-by; in W)" - ), - }, - { - "objectReference": "globalWarmingPotentialProductionRoundedSub", - "description": _( - "Treibhauspotenzial (Herstellung; in kg CO2-e)" - ), - }, - { - "objectReference": "globalWarmingPotentialUsePhaseRoundedSub", - "description": _("Treibhauspotenzial (Nutzung; in kg CO2-e)"), - }, - { - "objectReference": "globalWarmingPotentialEndOfLifeRounded", - "description": _( - "Treibhauspotenzial (Entsorgung; in kg CO2-e)" - ), - }, - { - "objectReference": "operationTimeRendered", - "description": _("Betriebsdauer (h/Jahr)"), - }, - ], - "optionList": [ - { - "placeholder": "Kategorie", - "filtered": categoryValue, - "objects": [ - categoryItem.category - for categoryItem in Category.objects.all() - ], - "fieldName": "category", - }, - { - "placeholder": _("Komponente"), - "objects": [ - componentItem.componentClass - for componentItem in ComponentClass.objects.all() - ], - "fieldName": "component", - "filtered": componentValue, - }, - { - "placeholder": _("Sortierung"), - "multiDimensional": True, - "objects": [ - { - "shown": _("Komponente"), - "name": "component", - "type": "alphabetic", - }, - { - "shown": _("Kategorie"), - "name": "category", - "type": "alphabetic", - }, - { - "shown": _("Energieverbrauch Nutzung (gesamt; in W)"), - "name": "energyConsumptionUsePhaseTotal", - "type": "numeric", - }, - { - "shown": _("Treibhauspotenzial (gesamt; in kg CO2-e)"), - "name": "globalWarmingPotentialTotal", - "type": "numeric", - }, - { - "shown": _("Bauteilgewicht (in kg)"), - "name": "componentWeight", - "type": "numeric", - }, - { - "shown": _("Lebensdauer (in Jahren)"), - "name": "lifetime", - "type": "numeric", - }, - ], - "fieldName": "sorting", + explanationRaw = "{% load i18n %} „{% translate 'Aufwände für Datenverarbeitungsprozesse' %}“) " + explanationSecondPart = ( + _( + """ist immer mit einem materiellen Einsatz für die Komponenten verbunden. In Analogie zu den Prozessschritten der Daten-Wertschöpfungskette können wichtige Komponenten von der Datenerfassung (Sensoren) bis zur Datennutzung (Aktuatoren) gedacht werden. Abbildung 2 zeigt Komponenten, die zur Realisierung digitaler Anwendungen in Gebäuden und Quartieren häufig zur Anwendung kommen (hier Fokus auf Betriebsoptimierung). Je nachdem, welche dieser – oder weitere – Komponenten zusätzlich für die digitale Anwendung verbaut werden mussten, müssen die entsprechenden Umweltlasten mitbetrachtet werden. Die Umweltlasten umfassen dabei die Emissionen, die bei der Herstellung von der Gewinnung der Rohstoffe bis zur Fertigung der Komponente reichen, über Emissionen durch den Ressourcen- und Energieverbrauch während der Nutzung der Komponente, bis zur Entsorgung und dem Recycling der Materialien. Diese Wirkungen wurden mit der Methode der Ökobilanz erfasst. + """ + ) + .replace("\n", "
") + .replace("'", "") + ) + templateObj = Template(explanationRaw) + explanationText = templateObj.render(Context({})) + + context = { + "renderDetailsRadio": True, + "heading": _("Aufwände für verwendete Komponenten"), + "explanaitionText": explanationFirstPart + + explanationText + + explanationSecondPart, + "focusBorder": "ecological", + "focusName": "ecological", + "urlName": "components", + "page": page, + "model": "Component", + "listElementsShowOrCollapse": listingShowOrCollapse, + "elementsFirstColumn": [ + { + "objectReference": "componentClass", + "description": "", + }, + { + "objectReference": "category", + "description": "", + }, + { + "objectReference": "description", + "description": "", + }, + { + "objectReference": "furtherInformationNotesRendered", + "description": _("Weitere Informationen"), + }, + { + "objectReference": "sources", + "description": _("Quelle"), + }, + ], + "elementsSecondColumn": [ + { + "objectReference": "energyConsumptionUsePhaseTotalRounded", + "description": _( + "Energieverbrauch Nutzungsphase (gesamt; in kWh/Jahr)" + ), + }, + { + "objectReference": "specificGlobalWarmingPotentialRounded", + "description": _( + "Spezifisches Teibhauspotential Gesamt (in kg CO2-e/Jahr)" + ), + }, + { + "objectReference": "globalWarmingPotentialTotalRounded", + "description": _("Treibhauspotenzial (gesamt; in kg CO2-e)"), + }, + { + "objectReference": "componentWeightRounded", + "description": _("Bauteilgewicht (in kg)"), + }, + { + "objectReference": "lifetime", + "description": _("Lebensdauer (in Jahre)"), + }, + { + "objectReference": "energyConsumptionUsePhaseActiveRoundedSup", + "description": _("Leistung Nutzungsphase (akitv; in W)"), + }, + { + "objectReference": "energyConsumptionUsePhasePassiveRounded", + "description": _( + "Leistung Nutzungsphase (passiv/ Stand-by; in W)" + ), + }, + { + "objectReference": "globalWarmingPotentialProductionRoundedSub", + "description": _( + "Treibhauspotenzial (Herstellung; in kg CO2-e)" + ), + }, + { + "objectReference": "globalWarmingPotentialUsePhaseRoundedSub", + "description": _("Treibhauspotenzial (Nutzung; in kg CO2-e)"), + }, + { + "objectReference": "globalWarmingPotentialEndOfLifeRounded", + "description": _( + "Treibhauspotenzial (Entsorgung; in kg CO2-e)" + ), + }, + { + "objectReference": "operationTimeRendered", + "description": _("Betriebsdauer (h/Jahr)"), + }, + ], + "optionList": [ + { + "placeholder": "Kategorie", + "filtered": categoryValue, + "objects": [ + categoryItem.category + for categoryItem in Category.objects.all() + ], + "fieldName": "category", + }, + { + "placeholder": _("Komponente"), + "objects": [ + componentItem.componentClass + for componentItem in ComponentClass.objects.all() + ], + "fieldName": "component", + "filtered": componentValue, + }, + { + "placeholder": _("Sortierung"), + "multiDimensional": True, + "objects": [ + { + "shown": _("Komponente"), + "name": "component", + "type": "alphabetic", + }, + { + "shown": _("Kategorie"), + "name": "category", + "type": "alphabetic", + }, + { + "shown": _("Energieverbrauch Nutzung (gesamt; in W)"), + "name": "energyConsumptionUsePhaseTotal", + "type": "numeric", + }, + { + "shown": _("Treibhauspotenzial (gesamt; in kg CO2-e)"), + "name": "globalWarmingPotentialTotal", + "type": "numeric", + }, + { + "shown": _("Bauteilgewicht (in kg)"), + "name": "componentWeight", + "type": "numeric", + }, + { + "shown": _("Lebensdauer (in Jahren)"), + "name": "lifetime", + "type": "numeric", + }, + ], + "fieldName": "sorting", + }, + ], + # "radioButtons": [ + # { + # "description": + # } + # ], + "image": f"img/componentList/{descriptionImage}", + "caption": _( + "Abbildung 2: Wichtige Komponenten für das Beispiel Betriebsoptimierung, die zur Realisierung der Daten-Wertschöpfungskette notwendig sind." + ), + "linkOnRightSiteBool": True, + "linkOnRightSiteName": "dataProcessing", + "linkOnRightSiteDescription": _( + "Zu den Aufwänden für Datenverarbeitungsprozesse" + ), + "imageInBackButton": "img/componentList/caret-left.svg", + "backLink": "environmentalIntegrityNegativ", + "backLinkText": _("Negative Umweltwirkungen"), + "filters": { + "searched": searchInputValue, + "category": categoryValues, + "component": componentValues, + "sorting": "", + "overview": overviewValue, }, - ], - # "radioButtons": [ - # { - # "description": - # } - # ], - "image": f"img/componentList/{descriptionImage}", - "caption": _( - "Abbildung 2: Wichtige Komponenten für das Beispiel Betriebsoptimierung, die zur Realisierung der Daten-Wertschöpfungskette notwendig sind." - ), - "linkOnRightSiteBool": True, - "linkOnRightSiteName": "dataProcessing", - "linkOnRightSiteDescription": _( - "Zu den Aufwänden für Datenverarbeitungsprozesse" - ), - "imageInBackButton": "img/componentList/caret-left.svg", - "backLink": "environmentalIntegrityNegativ", - "backLinkText": _("Negative Umweltwirkungen"), - "filters": { - "searched": searchInputValue, - "category": categoryValues, - "component": componentValues, - "sorting": "", - "overview": overviewValue, - }, - "pathToArrow": "assets/images/arrowDownEcological.svg", - "renderComparisonRadio": True, - "headerOfImage": _("Die Daten-Wertschöpfungkette"), - # "assets/images/arrow.svg", - } - if filtering: - # context["page"] = page_to_dict(context["page"]) - return render(request, "partials/listing-row.html", context) - else: - return render(request, "component_list/components.html", context) + "pathToArrow": "assets/images/arrowDownEcological.svg", + "renderComparisonRadio": True, + "headerOfImage": _("Die Daten-Wertschöpfungkette"), + # "assets/images/arrow.svg", + } + if componentId is not None: + componentShowDetails = Component.objects.get(id=componentId) + context["componentDetails"] = componentShowDetails + context["componentDetailsId"] = componentShowDetails.id + for pageNumber in range(1, page.paginator.num_pages+1): + for componentObj in page.paginator.page(pageNumber).object_list: + if componentObj == componentShowDetails: + context["componentDetailsPage"] = pageNumber + # set the current page of the paginator to the page + # were the search component was found. + page = page.paginator.get_page(pageNumber) + found = True # Set flag to True + break + if found: + break + if filtering: + # context["page"] = page_to_dict(context["page"]) + return render(request, "partials/listing-row.html", context) + else: + return render(request, "component_list/components.html", context) def dataProcessing(request): diff --git a/webcentral/src/templates/partials/listing-row.html b/webcentral/src/templates/partials/listing-row.html index f43e4c63b..6d9beee12 100644 --- a/webcentral/src/templates/partials/listing-row.html +++ b/webcentral/src/templates/partials/listing-row.html @@ -83,3 +83,17 @@
{% include "partials/pagination.html" %}
+ diff --git a/webcentral/src/templates/start_search/result_search.html b/webcentral/src/templates/start_search/result_search.html index 303227959..354719de3 100644 --- a/webcentral/src/templates/start_search/result_search.html +++ b/webcentral/src/templates/start_search/result_search.html @@ -106,6 +106,8 @@

{% translate "Suchergebnisse" %}

{% elif dataSet.kindOfItem == "Positive Umweltwirkungen" %} + {% elif dataSet.kindOfItem == "Negative Umweltwirkungen" %} + {% endif %} From 92c759249821bd358c895d1fcea992c60d5fd291 Mon Sep 17 00:00:00 2001 From: Martin Tobias Degner Date: Tue, 10 Sep 2024 13:22:46 +0200 Subject: [PATCH 13/24] fixed not showing image in useCaseDetails --- webcentral/src/StartSearch/views.py | 44 +++++++++- webcentral/src/publications/views.py | 4 +- .../publications/publications-detail.html | 2 +- .../templates/start_search/result_search.html | 6 +- .../templates/use_cases/usecase-detail.html | 9 +- .../test/scripts/test_main_page.py | 86 +++++++++++++++++-- 6 files changed, 134 insertions(+), 17 deletions(-) diff --git a/webcentral/src/StartSearch/views.py b/webcentral/src/StartSearch/views.py index fbb61cdcb..d2308fd95 100644 --- a/webcentral/src/StartSearch/views.py +++ b/webcentral/src/StartSearch/views.py @@ -35,7 +35,8 @@ from businessModel.models import BusinessModel from positive_environmental_impact.models import EnvironmentalImpact from component_list.models import Component - +from use_cases.models import UseCase +from publications.models.publication import Publication def findPicturesForFocus(searchResultObj, tool=False): """Return the path to the picture, showing the Focus. @@ -53,6 +54,7 @@ def findPicturesForFocus(searchResultObj, tool=False): if tool: toolObj = Tools.objects.filter(id=searchResultObj["id"])[0] focusStrList = toolObj.focus.all().values_list("focus_de", flat=True) + else: # for other Objects, than Tools set the default-value "Technisch" # this needs to be adapted later @@ -67,6 +69,12 @@ def findPicturesForFocus(searchResultObj, tool=False): focusStrList = ["ökologisch"] if searchResultObj["kindOfItem"] == "Negative Umweltwirkungen": focusStrList = ["ökologisch"] + if searchResultObj["kindOfItem"] == "Anwendungsfall": + obj = UseCase.objects.get(id=searchResultObj["id"]) + focusStrList = obj.focus.all().values_list("focus_de", flat=True) + if searchResultObj["kindOfItem"] == "Veröffentlichung": + obj = Publication.objects.get(id=searchResultObj["id"]) + focusStrList = obj.focus.all().values_list("focus_de", flat=True) pathStr = "assets/images/" if len(focusStrList) == 1: @@ -258,6 +266,21 @@ def resultSearch(request): filteredTopicsOfCriteriaCatalog = Topic.objects.filter( criterionCriteriaCatalog ).values("id", "heading", "text", "criteriaCatalog") + + criterionUseCaseOne = Q(effectName__icontains=searchInput) + criterionUseCaseTwo = Q(effectDescription__icontains=searchInput) + # get topics for tags: + filteredUseCases = UseCase.objects.filter( + criterionUseCaseOne | criterionUseCaseTwo + ).values("id", "useCase", "effectDescription", "effectName", "degreeOfDetail") + + criterionPublicationOne = Q(title__icontains=searchInput) + criterionPublicationTwo = Q(authors__icontains=searchInput) + criterionPublicationThree = Q(abstract__icontains=searchInput) + # get topics for tags: + filteredPublications = Publication.objects.filter( + criterionPublicationOne | criterionPublicationTwo | criterionPublicationThree + ).values("id", "title", "authors", "abstract") # filteredTopicsOfCriteriaCatalog = Topic.objects.values( # "id", # "heading", @@ -269,6 +292,16 @@ def resultSearch(request): # rename fields in queryset list-dicts # for filteredTools (bezeichung > name, kurzbeschreibung > description ) # and extend list by needed fields like kindOfItems + + for publicationObj in filteredPublications: + publicationObj["name"] = publicationObj["title"] + publicationObj["kindOfItem"] = "Veröffentlichung" + publicationObj["classificationAgg"] = _("Veröffentlichung") + publicationObj["date"] = "2024-07-01" + publicationObj["virtDate"] = date.fromisoformat("2049-09-09") + publicationObj["pathToFocusImage"] = findPicturesForFocus(publicationObj) + + for tool in filteredTools: tool["name"] = tool.pop("name") if len(tool["name"]) > 40: @@ -394,6 +427,13 @@ def resultSearch(request): component["virtDate"] = date.fromisoformat("2049-09-09") component["pathToFocusImage"] = findPicturesForFocus(component) + for useCaseObj in filteredUseCases: + useCaseObj["name"] = useCaseObj["degreeOfDetail"] + " - " + useCaseObj["effectName"] + useCaseObj["kindOfItem"] = "Anwendungsfall" + useCaseObj["classificationAgg"] = _("Anwendungsfall") + useCaseObj["date"] = _("2024-07-01") + useCaseObj["virtDate"] = date.fromisoformat("2049-09-09") + useCaseObj["pathToFocusImage"] = findPicturesForFocus(useCaseObj) # concat the prepared querySets to one QuerySet filteredData = list( chain( @@ -406,6 +446,8 @@ def resultSearch(request): filteredBusinessModels, filteredPosEnvImpact, filteredComponents, + filteredUseCases, + filteredPublications, ) ) # sort data list by name/kindOfItem and so on diff --git a/webcentral/src/publications/views.py b/webcentral/src/publications/views.py index 6595ac415..63f4c4982 100644 --- a/webcentral/src/publications/views.py +++ b/webcentral/src/publications/views.py @@ -87,14 +87,14 @@ def publicationView(request, id): keywords = publication.keywords.split(",") if publication.keywords else [] focus_options = Focus.objects.all() - firstElementOfPublicationFocus = publication.focus.first().focus + firstElementOfPublicationFocus = publication.focus.first().focus_en context = { "publication": publication, "title": title, "type": type, "keywords": keywords, "focus_options": focus_options, - "focusBorder": _translateFocusStr(firstElementOfPublicationFocus), + "focusBorder": firstElementOfPublicationFocus, } return render(request, "publications/publications-detail.html", context) diff --git a/webcentral/src/templates/publications/publications-detail.html b/webcentral/src/templates/publications/publications-detail.html index 1f3a15700..70204b643 100644 --- a/webcentral/src/templates/publications/publications-detail.html +++ b/webcentral/src/templates/publications/publications-detail.html @@ -1,6 +1,6 @@ {% extends 'base.html' %} -{% block title %}{{ pblication.name }}{% endblock %} +{% block title %}{{ publication.title }}{% endblock %} {% load static %} {% load i18n %} diff --git a/webcentral/src/templates/start_search/result_search.html b/webcentral/src/templates/start_search/result_search.html index 354719de3..90bfaa85f 100644 --- a/webcentral/src/templates/start_search/result_search.html +++ b/webcentral/src/templates/start_search/result_search.html @@ -108,7 +108,11 @@

{% translate "Suchergebnisse" %}

{% elif dataSet.kindOfItem == "Negative Umweltwirkungen" %} - {% endif %} + {% elif dataSet.kindOfItem == "Anwendungsfall" %} + + {% elif dataSet.kindOfItem == "Veröffentlichung" %} + + {% endif %} diff --git a/webcentral/src/templates/use_cases/usecase-detail.html b/webcentral/src/templates/use_cases/usecase-detail.html index c4646176a..ec07ab902 100644 --- a/webcentral/src/templates/use_cases/usecase-detail.html +++ b/webcentral/src/templates/use_cases/usecase-detail.html @@ -31,11 +31,11 @@

{{ useCase.effectName }}

-
+
-
+
@@ -68,11 +68,10 @@
Perspektive
-
+
{% if useCase.icon %} - useCase icon {% else %} Date: Tue, 10 Sep 2024 13:43:01 +0200 Subject: [PATCH 14/24] added selenium image to github actions selenium test workflow --- .github/workflows/test.yml | 5 ++++- webcentral/src/StartSearch/views.py | 2 +- .../test/06_system_test/test/scripts/test_main_page.py | 10 +++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 52a650968..ca9d6238e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,10 @@ jobs: docker: timeout-minutes: 10 runs-on: ubuntu-latest - + services: + selenium: + image: selenium/standalone-firefox + options: --shm-size=2gb steps: - uses: actions/checkout@v4 with: diff --git a/webcentral/src/StartSearch/views.py b/webcentral/src/StartSearch/views.py index d2308fd95..12fb4388f 100644 --- a/webcentral/src/StartSearch/views.py +++ b/webcentral/src/StartSearch/views.py @@ -428,7 +428,7 @@ def resultSearch(request): component["pathToFocusImage"] = findPicturesForFocus(component) for useCaseObj in filteredUseCases: - useCaseObj["name"] = useCaseObj["degreeOfDetail"] + " - " + useCaseObj["effectName"] + useCaseObj["name"] = useCaseObj["effectName"] + " - " + useCaseObj["degreeOfDetail"] useCaseObj["kindOfItem"] = "Anwendungsfall" useCaseObj["classificationAgg"] = _("Anwendungsfall") useCaseObj["date"] = _("2024-07-01") diff --git a/webcentral/test/06_system_test/test/scripts/test_main_page.py b/webcentral/test/06_system_test/test/scripts/test_main_page.py index cec11aa50..25cbf472a 100644 --- a/webcentral/test/06_system_test/test/scripts/test_main_page.py +++ b/webcentral/test/06_system_test/test/scripts/test_main_page.py @@ -608,17 +608,16 @@ def testUseCasesInResults(self): self._setLanguageToGerman() searchInputField = startPageObj.getSearchInputField() - searchInputField.send_keys("Anwendung der Datenschutz-Grundverordnung") + searchInputField.send_keys("Keine Anwendung der Datenschutz-Grundverordnung") searchInputField.send_keys(Keys.RETURN) # wait until results page is loaded: self.waitUntilConditionIsMet(self._checkIfResultsPageIsLoaded) listOfRowsInResultsTable = startPageObj.getSearchResults() - self.assertGreaterEqual(len(listOfRowsInResultsTable), 1) for result in listOfRowsInResultsTable: - if "Anwendung der Datenschutz-Grundverordnung" in result.text: + if "Keine Anwendung der Datenschutz-Grundverordnung" in result.text: self.assertTrue( "Use case" in result.text or "Anwendungsfall" in result.text @@ -628,12 +627,13 @@ def testUseCasesInResults(self): result.find_element(By.XPATH, "./td") ) self.titleEnDe = [ - "Anwendung der Datenschutz-Grundverordnung", - "Anwendung der Datenschutz-Grundverordnung", + "Keine Anwendung der Datenschutz-Grundverordnung", + "Keine Anwendung der Datenschutz-Grundverordnung", ] self.waitUntilConditionIsMet( self._checkIfResultsPageIsLoadedByTitle ) + break def testPublicationsInResults(self): """Test if positive_environemntal_impact elements are on the search results-page.""" From 2fcf2e9265ac06ff33e0a2ca8b149fe650b76598 Mon Sep 17 00:00:00 2001 From: expeditionengineer Date: Tue, 10 Sep 2024 11:44:43 +0000 Subject: [PATCH 15/24] Apply automatic changes --- webcentral/src/StartSearch/views.py | 28 +-- webcentral/src/component_list/views.py | 40 +++-- .../templates/start_search/result_search.html | 160 +++++++++--------- .../templates/use_cases/usecase-detail.html | 4 +- .../test/scripts/test_main_page.py | 15 +- 5 files changed, 132 insertions(+), 115 deletions(-) diff --git a/webcentral/src/StartSearch/views.py b/webcentral/src/StartSearch/views.py index 12fb4388f..f72c3f8be 100644 --- a/webcentral/src/StartSearch/views.py +++ b/webcentral/src/StartSearch/views.py @@ -35,9 +35,10 @@ from businessModel.models import BusinessModel from positive_environmental_impact.models import EnvironmentalImpact from component_list.models import Component -from use_cases.models import UseCase +from use_cases.models import UseCase from publications.models.publication import Publication + def findPicturesForFocus(searchResultObj, tool=False): """Return the path to the picture, showing the Focus. @@ -266,20 +267,24 @@ def resultSearch(request): filteredTopicsOfCriteriaCatalog = Topic.objects.filter( criterionCriteriaCatalog ).values("id", "heading", "text", "criteriaCatalog") - + criterionUseCaseOne = Q(effectName__icontains=searchInput) criterionUseCaseTwo = Q(effectDescription__icontains=searchInput) # get topics for tags: filteredUseCases = UseCase.objects.filter( - criterionUseCaseOne | criterionUseCaseTwo - ).values("id", "useCase", "effectDescription", "effectName", "degreeOfDetail") - + criterionUseCaseOne | criterionUseCaseTwo + ).values( + "id", "useCase", "effectDescription", "effectName", "degreeOfDetail" + ) + criterionPublicationOne = Q(title__icontains=searchInput) criterionPublicationTwo = Q(authors__icontains=searchInput) criterionPublicationThree = Q(abstract__icontains=searchInput) # get topics for tags: filteredPublications = Publication.objects.filter( - criterionPublicationOne | criterionPublicationTwo | criterionPublicationThree + criterionPublicationOne + | criterionPublicationTwo + | criterionPublicationThree ).values("id", "title", "authors", "abstract") # filteredTopicsOfCriteriaCatalog = Topic.objects.values( # "id", @@ -292,15 +297,16 @@ def resultSearch(request): # rename fields in queryset list-dicts # for filteredTools (bezeichung > name, kurzbeschreibung > description ) # and extend list by needed fields like kindOfItems - + for publicationObj in filteredPublications: publicationObj["name"] = publicationObj["title"] publicationObj["kindOfItem"] = "Veröffentlichung" publicationObj["classificationAgg"] = _("Veröffentlichung") publicationObj["date"] = "2024-07-01" publicationObj["virtDate"] = date.fromisoformat("2049-09-09") - publicationObj["pathToFocusImage"] = findPicturesForFocus(publicationObj) - + publicationObj["pathToFocusImage"] = findPicturesForFocus( + publicationObj + ) for tool in filteredTools: tool["name"] = tool.pop("name") @@ -428,7 +434,9 @@ def resultSearch(request): component["pathToFocusImage"] = findPicturesForFocus(component) for useCaseObj in filteredUseCases: - useCaseObj["name"] = useCaseObj["effectName"] + " - " + useCaseObj["degreeOfDetail"] + useCaseObj["name"] = ( + useCaseObj["effectName"] + " - " + useCaseObj["degreeOfDetail"] + ) useCaseObj["kindOfItem"] = "Anwendungsfall" useCaseObj["classificationAgg"] = _("Anwendungsfall") useCaseObj["date"] = _("2024-07-01") diff --git a/webcentral/src/component_list/views.py b/webcentral/src/component_list/views.py index 0e7f6b092..c542a59cd 100644 --- a/webcentral/src/component_list/views.py +++ b/webcentral/src/component_list/views.py @@ -14,9 +14,7 @@ class ComponentListView(View): - """ - - """ + """ """ def get(self, request, componentId=None): """Render component-objects and open details for specified componentId @@ -26,7 +24,6 @@ def get(self, request, componentId=None): componentId : int Id of the component, whose details view should be opened. """ - listingShowOrCollapse = "collapse" @@ -72,7 +69,9 @@ def get(self, request, componentId=None): searchQueryInput = searchQueryInput | Q( furtherInformationNotes__icontains=searchInputValue ) - searchQueryInput = searchQueryInput | Q(sources__icontains=searchInputValue) + searchQueryInput = searchQueryInput | Q( + sources__icontains=searchInputValue + ) searchQueryCategory = Q() if len(categoryValues) > 0: @@ -93,14 +92,19 @@ def get(self, request, componentId=None): # if len(componentForSelectValue) == 1: # searchQuery = searchQuery | Q(component=componentForSelectValue[0]) - searchQuery = searchQueryInput & searchQueryCategory & searchQueryComponents + searchQuery = ( + searchQueryInput & searchQueryCategory & searchQueryComponents + ) if overviewValue: if overviewValue == _("Ausgeklappt"): listingShowOrCollapse = "show" if firstLevelDropdown and secondLevelDropdown: - if secondLevelDropdown == "Ascending" or secondLevelDropdown == "A...Z": + if ( + secondLevelDropdown == "Ascending" + or secondLevelDropdown == "A...Z" + ): if firstLevelDropdown == "category": firstLevelDropdown = "category__category" elif firstLevelDropdown == "component": @@ -194,7 +198,9 @@ def get(self, request, componentId=None): }, { "objectReference": "globalWarmingPotentialTotalRounded", - "description": _("Treibhauspotenzial (gesamt; in kg CO2-e)"), + "description": _( + "Treibhauspotenzial (gesamt; in kg CO2-e)" + ), }, { "objectReference": "componentWeightRounded", @@ -222,7 +228,9 @@ def get(self, request, componentId=None): }, { "objectReference": "globalWarmingPotentialUsePhaseRoundedSub", - "description": _("Treibhauspotenzial (Nutzung; in kg CO2-e)"), + "description": _( + "Treibhauspotenzial (Nutzung; in kg CO2-e)" + ), }, { "objectReference": "globalWarmingPotentialEndOfLifeRounded", @@ -269,12 +277,16 @@ def get(self, request, componentId=None): "type": "alphabetic", }, { - "shown": _("Energieverbrauch Nutzung (gesamt; in W)"), + "shown": _( + "Energieverbrauch Nutzung (gesamt; in W)" + ), "name": "energyConsumptionUsePhaseTotal", "type": "numeric", }, { - "shown": _("Treibhauspotenzial (gesamt; in kg CO2-e)"), + "shown": _( + "Treibhauspotenzial (gesamt; in kg CO2-e)" + ), "name": "globalWarmingPotentialTotal", "type": "numeric", }, @@ -325,17 +337,17 @@ def get(self, request, componentId=None): componentShowDetails = Component.objects.get(id=componentId) context["componentDetails"] = componentShowDetails context["componentDetailsId"] = componentShowDetails.id - for pageNumber in range(1, page.paginator.num_pages+1): + for pageNumber in range(1, page.paginator.num_pages + 1): for componentObj in page.paginator.page(pageNumber).object_list: if componentObj == componentShowDetails: context["componentDetailsPage"] = pageNumber - # set the current page of the paginator to the page + # set the current page of the paginator to the page # were the search component was found. page = page.paginator.get_page(pageNumber) found = True # Set flag to True break if found: - break + break if filtering: # context["page"] = page_to_dict(context["page"]) return render(request, "partials/listing-row.html", context) diff --git a/webcentral/src/templates/start_search/result_search.html b/webcentral/src/templates/start_search/result_search.html index 90bfaa85f..8ad01dcf1 100644 --- a/webcentral/src/templates/start_search/result_search.html +++ b/webcentral/src/templates/start_search/result_search.html @@ -106,86 +106,86 @@

{% translate "Suchergebnisse" %}

{% elif dataSet.kindOfItem == "Positive Umweltwirkungen" %} - {% elif dataSet.kindOfItem == "Negative Umweltwirkungen" %} - - {% elif dataSet.kindOfItem == "Anwendungsfall" %} - - {% elif dataSet.kindOfItem == "Veröffentlichung" %} - - {% endif %} - - - -
-
-
{{ dataSet.name }}
-
- - - - -
-
{{ dataSet.classificationAgg|title }}
-
- + {% elif dataSet.kindOfItem == "Negative Umweltwirkungen" %} + + {% elif dataSet.kindOfItem == "Anwendungsfall" %} + + {% elif dataSet.kindOfItem == "Veröffentlichung" %} + + {% endif %} + + + +
+
+
{{ dataSet.name }}
+
+ + + + +
+
{{ dataSet.classificationAgg|title }}
+
+ - - - icon - - -
-
{{ dataSet.date }}
-
- - - - {% endfor %} - - - - -
- -
- - - + +
+ + + + + {% else %} +

{% translate "Die Suche hat keine Ergebnisse ergeben." %}

{% endif %} - -
- - {% else %} -

{% translate "Die Suche hat keine Ergebnisse ergeben." %}

- {% endif %} -
-
+ + - - {% endblock %} + + {% endblock %} diff --git a/webcentral/src/templates/use_cases/usecase-detail.html b/webcentral/src/templates/use_cases/usecase-detail.html index ec07ab902..a79fd48fa 100644 --- a/webcentral/src/templates/use_cases/usecase-detail.html +++ b/webcentral/src/templates/use_cases/usecase-detail.html @@ -70,9 +70,7 @@
Perspektive
{% if useCase.icon %} - useCase icon + useCase icon {% else %} Date: Tue, 10 Sep 2024 13:46:10 +0200 Subject: [PATCH 16/24] corrected synatax in test github actions file --- .github/workflows/test.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ca9d6238e..52d8c7688 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,14 +7,14 @@ jobs: docker: timeout-minutes: 10 runs-on: ubuntu-latest - services: - selenium: - image: selenium/standalone-firefox - options: --shm-size=2gb + + services: + selenium: + image: selenium/standalone-firefox + options: --shm-size=2gb + steps: - uses: actions/checkout@v4 - with: - ref: ${{ github.head_ref }} - name: Create .env-file run: cp .env.example .env @@ -37,7 +37,11 @@ jobs: run: docker exec -w /webcentral/src webcentral python manage.py test project_listing - name: Setup selenium dev-environment - run: python -m venv webcentral/test/testing_venv && source webcentral/test/testing_venv/bin/activate && pip install -r webcentral/test/requirements_testing.txt + run: | + python -m venv webcentral/test/testing_venv + source webcentral/test/testing_venv/bin/activate + pip install -r webcentral/test/requirements_testing.txt - name: Run selenium test run: ./run test Selenium TestMainPage + From 8b72ee359fa205f67c9edba53f63119eb19e5868 Mon Sep 17 00:00:00 2001 From: Martin Tobias Degner Date: Tue, 10 Sep 2024 14:14:44 +0200 Subject: [PATCH 17/24] added sourcing of .env file and execute directly testunner to get exit code --- .github/workflows/test.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 52d8c7688..67acd7709 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,7 +41,8 @@ jobs: python -m venv webcentral/test/testing_venv source webcentral/test/testing_venv/bin/activate pip install -r webcentral/test/requirements_testing.txt - - - name: Run selenium test - run: ./run test Selenium TestMainPage + source .env + cd webcentral/test/06_system_test + python testrunner.py --test_file TestMainPage + From f165a9fbbe5b7ba3451a0ec85268095de346d474 Mon Sep 17 00:00:00 2001 From: Martin Tobias Degner Date: Tue, 10 Sep 2024 14:26:05 +0200 Subject: [PATCH 18/24] trying to run the tests in headless mode --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 67acd7709..9baed7c20 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,6 +43,6 @@ jobs: pip install -r webcentral/test/requirements_testing.txt source .env cd webcentral/test/06_system_test - python testrunner.py --test_file TestMainPage + HEADLESS=1 python testrunner.py --test_file TestMainPage From ff25713e2d21fa5d458605a54715871bcf273007 Mon Sep 17 00:00:00 2001 From: Martin Tobias Degner Date: Tue, 10 Sep 2024 14:46:34 +0200 Subject: [PATCH 19/24] changed code so .env file is sourced and env vars can be used in test execution in github actions pipline and popagating exit code to github actions VM machine so it fails on test failue --- .github/workflows/test.yml | 2 ++ webcentral/test/06_system_test/testrunner.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9baed7c20..ff212bd6a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,7 +41,9 @@ jobs: python -m venv webcentral/test/testing_venv source webcentral/test/testing_venv/bin/activate pip install -r webcentral/test/requirements_testing.txt + set -o allexport source .env + set +o allexport cd webcentral/test/06_system_test HEADLESS=1 python testrunner.py --test_file TestMainPage diff --git a/webcentral/test/06_system_test/testrunner.py b/webcentral/test/06_system_test/testrunner.py index eb4e9b951..46d39006e 100644 --- a/webcentral/test/06_system_test/testrunner.py +++ b/webcentral/test/06_system_test/testrunner.py @@ -98,10 +98,12 @@ ) testRunner = TextTestRunner(verbosity=2) - testRunner.run(testSuite) + result = testRunner.run(testSuite) # Refer https://testtools.readthedocs.io/en/latest/api.html for more information parallelSuite = testtools.ConcurrentStreamTestSuite( lambda: ((case, None) for case in testSuite) ) parallelSuite.run(testtools.StreamResult()) + + sys.exit(not result.wasSuccessful()) From 40c9e7ef0e7fc695fbc53a91279a8e1ff3ce49e8 Mon Sep 17 00:00:00 2001 From: Martin Tobias Degner Date: Tue, 10 Sep 2024 15:17:30 +0200 Subject: [PATCH 20/24] changed .env.example file to use for siteUnderTest port 8000 --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 695514260..5711a7b1b 100644 --- a/.env.example +++ b/.env.example @@ -53,6 +53,6 @@ POSTGRES_PASSWORD=abc123 POSTGRES_DB=m4_db_serv_22070 # Test env-vars: -siteUnderTest=http://127.0.0.1:8070 +siteUnderTest=http://127.0.0.1:8000 From 25060197bb979037a5bbb043efd66a275ed50031 Mon Sep 17 00:00:00 2001 From: Martin Tobias Degner Date: Tue, 10 Sep 2024 15:47:23 +0200 Subject: [PATCH 21/24] added a step to test pipeline, in which the the database dump is donloaded using curl --- .github/workflows/test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ff212bd6a..674366e91 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,8 +30,11 @@ jobs: - name: Execute build_initial command run: ./run build_initial dev + - name: download db dump: + run curl -o dump.sql https://tubcloud.tu-berlin.de/s/9i3NSdoQ6xYnHdM/download + - name: Run dev-environment - run: docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d + run: ./run up_initial dev dunp.sql - name: Execute first test run: docker exec -w /webcentral/src webcentral python manage.py test project_listing From 02383cd6c366196caa1f4b60432fa8f16a7f90d0 Mon Sep 17 00:00:00 2001 From: Martin Tobias Degner Date: Tue, 10 Sep 2024 15:59:31 +0200 Subject: [PATCH 22/24] fixd synax errors in test.yml --- .github/workflows/test.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 674366e91..b70f7dde7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,3 @@ - name: Django tests and Selenium tests on: [push] @@ -30,11 +29,11 @@ jobs: - name: Execute build_initial command run: ./run build_initial dev - - name: download db dump: - run curl -o dump.sql https://tubcloud.tu-berlin.de/s/9i3NSdoQ6xYnHdM/download + - name: Download db dump + run: curl -o dump.sql https://tubcloud.tu-berlin.de/s/9i3NSdoQ6xYnHdM/download - name: Run dev-environment - run: ./run up_initial dev dunp.sql + run: ./run up_initial dev dump.sql - name: Execute first test run: docker exec -w /webcentral/src webcentral python manage.py test project_listing @@ -44,10 +43,6 @@ jobs: python -m venv webcentral/test/testing_venv source webcentral/test/testing_venv/bin/activate pip install -r webcentral/test/requirements_testing.txt - set -o allexport - source .env - set +o allexport + export $(cat .env | xargs) # Export variables from .env file cd webcentral/test/06_system_test HEADLESS=1 python testrunner.py --test_file TestMainPage - - From e4bd38015d7880e4a3960042a65eac744574922f Mon Sep 17 00:00:00 2001 From: Martin Tobias Degner Date: Tue, 10 Sep 2024 16:09:36 +0200 Subject: [PATCH 23/24] changed exit code of up_inital to exit code of the docker beforehand command --- run | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/run b/run index 7ec78842c..e383e242a 100755 --- a/run +++ b/run @@ -245,7 +245,8 @@ case $command in cat $3 | docker exec -i database psql -U ${POSTGRES_USER} -d ${POSTGRES_DB} $COMPOSE_COMMAND -f docker-compose.yml -f docker-compose.dev.yml down $COMPOSE_COMMAND -f docker-compose.yml -f docker-compose.dev.yml up -d - exit 1 + echo "Exit code: $?" + exit $? fi fi if [ "$2" = "prod" ]; then @@ -261,7 +262,8 @@ case $command in $COMPOSE_COMMAND -f docker-compose.yml -f docker-compose.prod.yml down $COMPOSE_COMMAND -f docker-compose.yml -f docker-compose.prod.yml up -d docker cp $PWD/01_application/webcentral_app/media/. webcentral:/home/$WEBCENTRAL_UNPRIVILEGED_USER/webcentral/media/ - exit 1 + echo "Exit code: $?" + exit $? fi fi fi From 936d2b444fcc88d797fce45f1d2708d7cbafbee5 Mon Sep 17 00:00:00 2001 From: Martin Tobias Degner Date: Tue, 10 Sep 2024 16:31:46 +0200 Subject: [PATCH 24/24] rm export statement back to source statement --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b70f7dde7..25f01ddd7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,6 +43,8 @@ jobs: python -m venv webcentral/test/testing_venv source webcentral/test/testing_venv/bin/activate pip install -r webcentral/test/requirements_testing.txt - export $(cat .env | xargs) # Export variables from .env file + set -o allexport + source .env + set +o allexport cd webcentral/test/06_system_test HEADLESS=1 python testrunner.py --test_file TestMainPage