diff --git a/service/src/main/inse/integrations/elasticsearch.py b/service/src/main/inse/integrations/elasticsearch.py index c0553de1..b48e6c78 100644 --- a/service/src/main/inse/integrations/elasticsearch.py +++ b/service/src/main/inse/integrations/elasticsearch.py @@ -261,11 +261,10 @@ async def search( payload["sort"] = sort if aggs is not None: payload["aggs"] = aggs - if track_total_hits: - payload["track_total_hits"] = True if highlight is not None: payload["highlight"] = highlight - + + payload["track_total_hits"] = True # always track total hits for accurate pagination and counts if len(payload) == 0: raise ValueError( "At least one of 'query', 'body', 'source', 'size', 'offset', 'sort', 'aggs' must be provided" diff --git a/service/src/main/inse/projects/logic.py b/service/src/main/inse/projects/logic.py index d224fc7f..69c99c61 100644 --- a/service/src/main/inse/projects/logic.py +++ b/service/src/main/inse/projects/logic.py @@ -9,42 +9,6 @@ from inse.projects.model import EuCordisProjectType logger = logging.getLogger(__name__) - -async def is_projects_access_forbidden( - access_token_metadata: AccessTokenMetadata, - raw_oa_institution_id: str | None, - raw_oa_author_id: str | None, -) -> bool: - """ - Determines if access to projects is forbidden based on the provided access token metadata - and the raw OpenAlex institution and author IDs. - - Args: - access_token_metadata (AccessTokenMetadata): Metadata from the access token. - raw_oa_institution_id (str | None): The raw OpenAlex institution ID. - raw_oa_author_id (str | None): The raw OpenAlex author ID. - - Returns: - bool: True if access is forbidden, False otherwise. - """ - effective_institution_id = access_token_metadata.effective_institution_id - - if raw_oa_institution_id and effective_institution_id != raw_oa_institution_id: - return True - - if raw_oa_author_id: - authors_profile = await author_service.get_author_by_id(raw_oa_author_id) - if not authors_profile: - return True # Author not found, access forbidden - - authors_last_known_institution_ids = [inst.id.split("/")[-1] for inst in (authors_profile.last_known_institutions)] - authors_affiliation_institution_ids = [aff.institution.id.split("/")[-1] for aff in (authors_profile.affiliations)] - print(f"Author's last known institution IDs: {authors_last_known_institution_ids}, {authors_affiliation_institution_ids}") - if effective_institution_id not in authors_last_known_institution_ids and effective_institution_id not in authors_affiliation_institution_ids: - return True # Effective institution ID does not match any of the author's last known institutions - - return False - async def get_dfg_author_names_by_ids(author_ids: list[int]) -> list[str] | None: try: body = { diff --git a/service/src/main/inse/projects/projects_search_client.py b/service/src/main/inse/projects/projects_search_client.py index 454622aa..0c8d126d 100644 --- a/service/src/main/inse/projects/projects_search_client.py +++ b/service/src/main/inse/projects/projects_search_client.py @@ -648,7 +648,7 @@ async def search_dfg_projects( # person["institute_name_en"] = institute.get("institute_name_en") # person["address_country_de"] = institute.get("address_country_de") # person["address_country_en"] = institute.get("address_country_en") - print("ENRIECHED",source.get("institutions", [])) + return _complete_response_to_dfg_project_page(response, page, size) def _complete_response_to_dfg_project_page( diff --git a/service/src/main/inse/projects/router.py b/service/src/main/inse/projects/router.py index d0430d63..3c3f2c97 100644 --- a/service/src/main/inse/projects/router.py +++ b/service/src/main/inse/projects/router.py @@ -7,9 +7,6 @@ from inse.auth.service import CurrentUserAccessTokenPayloadDep from inse.institutions.institutions_search_client import ( InstitutionsSearchClient, ) -from inse.projects.logic import ( - is_projects_access_forbidden -) from inse.institutions.router import get_institutions_search_client from inse.models.bund_project_details import BundProjectDetails from inse.models.dfg_project_details import DfgProjectDetails @@ -33,6 +30,7 @@ from inse.projects.model import ( SortDirection, ) from inse.tags import Tags +from inse.auth.service import can_fetch_gdpr_relevant_data from fastapi import HTTPException as HttpException logger = logging.getLogger(__name__) @@ -146,12 +144,13 @@ async def get_dfg_projects( sort_direction, fuzzy, ) - is_forbidden = await is_projects_access_forbidden(access_token_metadata, raw_oa_institution_id, author_id) - if is_forbidden: - raise HttpException( - status_code=403, - detail="Access denied for the provided author ID or institution ID", - ) + if (author_id or raw_oa_institution_id): + is_allowed = await can_fetch_gdpr_relevant_data(access_token = access_token_metadata, raw_oa_author_id = author_id, raw_oa_institution_id = raw_oa_institution_id) + if not is_allowed: + raise HttpException( + status_code=403, + detail="Access denied for the provided author ID or institution ID", + ) return await projects_service.get_dfg_projects( institutions_search_client=institutions_search_client, raw_oa_institution_id=raw_oa_institution_id, @@ -266,12 +265,13 @@ async def search_bund_projects( Query(description="Use OpenAlex topic-id resolution if true, otherwise raw keyword search."), ] = False, ) -> BundProjectPage: - is_forbidden = await is_projects_access_forbidden(access_token_metadata, raw_oa_institution_id, None) - if is_forbidden: - raise HttpException( - status_code=403, - detail="Access denied for the provided author ID or institution ID", - ) + if (raw_oa_institution_id): + is_allowed = await can_fetch_gdpr_relevant_data(access_token = access_token_metadata, raw_oa_author_id = None, raw_oa_institution_id = raw_oa_institution_id) + if not is_allowed: + raise HttpException( + status_code=403, + detail="Access denied for the provided author ID or institution ID", + ) return await projects_service.search_bund_projects_with_filters( institutions_search_client=institutions_search_client, executing_agency=executing_agency, @@ -450,12 +450,13 @@ async def search_eu_cordis_projects_endpoint( sort_direction, fuzzy, ) - is_forbidden = await is_projects_access_forbidden(access_token_metadata, raw_oa_institution_id, author_id) - if is_forbidden: - raise HttpException( - status_code=403, - detail="Access denied for the provided author ID or institution ID", - ) + if (author_id or raw_oa_institution_id): + is_allowed = await can_fetch_gdpr_relevant_data(access_token = access_token_metadata, raw_oa_author_id = author_id, raw_oa_institution_id = raw_oa_institution_id) + if not is_allowed: + raise HttpException( + status_code=403, + detail="Access denied for the provided author ID or institution ID", + ) return await search_eu_cordis_projects( institutions_search_client=institutions_search_client, raw_oa_institution_id=raw_oa_institution_id, diff --git a/webapp/src/app/custom-directives/sk-text.directive.ts b/webapp/src/app/custom-directives/sk-text.directive.ts index 14246539..07ef9d17 100644 --- a/webapp/src/app/custom-directives/sk-text.directive.ts +++ b/webapp/src/app/custom-directives/sk-text.directive.ts @@ -15,10 +15,6 @@ import { ResolverStateService } from '../../app/shared/services/resolver-state.s standalone: true, }) export class SkTextDirective implements OnChanges { - /** - * Optional manual loading state. - * The directive also reacts to global route/resolver loading. - */ @Input() skText = false; private readonly el = inject(ElementRef); diff --git a/webapp/src/app/modules/projects/dfg-details/dfg-details.component.html b/webapp/src/app/modules/projects/dfg-details/dfg-details.component.html index c9b6c1e9..8d6c9db9 100644 --- a/webapp/src/app/modules/projects/dfg-details/dfg-details.component.html +++ b/webapp/src/app/modules/projects/dfg-details/dfg-details.component.html @@ -37,8 +37,11 @@ circle {{ getStatusDisplay(dfgProject.funding_end) }} - @if (dfgProject.link) { - + @if (dfgProject.page_url) { + open_in_new Zum Projekt @@ -218,10 +221,7 @@ @if (getInstitutionsList().length > 0) {
- @for ( - institution of getInstitutionsList(); - track institution.institute_id + (institution.role_key || '') - ) { + @for (institution of getInstitutionsList(); track $index) {
- {{ getStartDate(element) | date: 'dd.MM.yyyy' }} + + {{ getStartDate(element) | date: 'dd.MM.yyyy' }} + - {{ getEndDate(element) | date: 'dd.MM.yyyy' }} + + {{ getEndDate(element) | date: 'dd.MM.yyyy' }} + - {{ getFundingAmount(element) | currency: 'EUR' : 'symbol' : '1.0-0' : 'de' }} + + {{ + getFundingAmount(element) | currency: 'EUR' : 'symbol' : '1.0-0' : 'de' + }} + @@ -31,20 +39,6 @@ open_in_new - -
- @for (classification of element.subject_classifications; track $index) { -

- {{ classification.wissenschaftsbereich || '-' }} - → {{ classification.fachkollegium || '-' }} → - {{ classification.fachgebiet || '-' }} → - {{ classification.fach || '-' }} -

- } @empty { - - - } -
-
@let institutions = getProjectInstitutions(project); @@ -79,7 +73,7 @@ matTooltipPosition="above" (click)="toggleFundingTypeFilter(project.funding_type)"> - {{ project.funding_type }} + {{ project.funding_type }} } @else { diff --git a/webapp/src/app/shared/ui/bund-project-table/bund-project-table.component.ts b/webapp/src/app/shared/ui/bund-project-table/bund-project-table.component.ts index 8b2424ce..2a89e462 100644 --- a/webapp/src/app/shared/ui/bund-project-table/bund-project-table.component.ts +++ b/webapp/src/app/shared/ui/bund-project-table/bund-project-table.component.ts @@ -25,6 +25,7 @@ import { ChipComponent } from '../chip/chip.component'; import { MatTooltip } from '@angular/material/tooltip'; import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors'; import { bundProjectQueryParamKeys } from '../../../resolvers/bund-projects.resolver'; +import { SkTextDirective } from '../../../custom-directives/sk-text.directive'; import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overflow-toggle.component'; @Component({ selector: 'app-bund-project-table', @@ -40,6 +41,7 @@ import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overfl DatePipe, ChipComponent, AppTopicChipComponent, + SkTextDirective, ], templateUrl: './bund-project-table.component.html', styleUrl: './bund-project-table.component.scss', diff --git a/webapp/src/app/shared/ui/data-table/data-table.component.html b/webapp/src/app/shared/ui/data-table/data-table.component.html index c7a62547..85b8df3f 100644 --- a/webapp/src/app/shared/ui/data-table/data-table.component.html +++ b/webapp/src/app/shared/ui/data-table/data-table.component.html @@ -30,7 +30,7 @@ context: { $implicit: row } "> } @else if (col.type === 'accessor') { - {{ row[col.accessorKey] }} + {{ row[col.accessorKey] }} } diff --git a/webapp/src/app/shared/ui/data-table/data-table.component.ts b/webapp/src/app/shared/ui/data-table/data-table.component.ts index 6be5c79e..092488b2 100644 --- a/webapp/src/app/shared/ui/data-table/data-table.component.ts +++ b/webapp/src/app/shared/ui/data-table/data-table.component.ts @@ -20,7 +20,7 @@ import { } from '@angular/material/sort'; import { MatTableDataSource, MatTableModule } from '@angular/material/table'; import { ActivatedRoute, Router } from '@angular/router'; - +import { SkTextDirective } from '../../../custom-directives/sk-text.directive'; export interface BaseColumn { id: string; header: string; @@ -43,7 +43,7 @@ export type GenericColumn = AccessorColumn | DisplayColumn; @Component({ selector: 'app-data-table', standalone: true, - imports: [MatTableModule, NgTemplateOutlet, MatSortModule], + imports: [MatTableModule, NgTemplateOutlet, MatSortModule, SkTextDirective], templateUrl: './data-table.component.html', styleUrl: './data-table.component.scss', }) diff --git a/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.html b/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.html index 6b9ad817..5f4d2e52 100644 --- a/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.html +++ b/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.html @@ -11,11 +11,13 @@ [pageSizeOptions]="[10, 25, 50]" /> - {{ - element.funding_end == '2999' || element.funding_end == null - ? 'laufend' - : element.funding_end - }} + + {{ + element.funding_end == '2999' || element.funding_end == null + ? 'laufend' + : element.funding_end + }} diff --git a/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.ts b/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.ts index df6b97e5..d0445497 100644 --- a/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.ts +++ b/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.ts @@ -23,6 +23,7 @@ import { ActivatedRoute, Router } from '@angular/router'; import { DfgPersonSummary } from '../../../api/model/dfgPersonSummary'; import { MatTooltip } from '@angular/material/tooltip'; import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors'; +import { SkTextDirective } from '../../../custom-directives/sk-text.directive'; import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overflow-toggle.component'; @Component({ selector: 'app-dfg-project-table', @@ -35,6 +36,7 @@ import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overfl QueryParamPaginatorComponent, MatTooltip, AppTopicChipComponent, + SkTextDirective, ], templateUrl: './dfg-project-table.component.html', styleUrl: './dfg-project-table.component.scss', diff --git a/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.html b/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.html index a0a9fc26..f0fd3563 100644 --- a/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.html +++ b/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.html @@ -20,7 +20,7 @@ matTooltipPosition="above" (click)="toggleTypeFilter(project.project_type)"> - {{ getProjectTypeLabel(project) }} + {{ getProjectTypeLabel(project) }} } @else { @@ -29,15 +29,17 @@ - {{ getStartDate(element) | date: 'dd.MM.yyyy' }} + {{ getStartDate(element) | date: 'dd.MM.yyyy' }} - {{ getEndDate(element) | date: 'dd.MM.yyyy' }} + {{ getEndDate(element) | date: 'dd.MM.yyyy' }} - {{ getFundingAmount(element) | currency: 'EUR' : 'symbol' : '1.0-0' : 'de' }} + {{ + getFundingAmount(element) | currency: 'EUR' : 'symbol' : '1.0-0' : 'de' + }} diff --git a/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.ts b/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.ts index 54f87520..8025ca52 100644 --- a/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.ts +++ b/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.ts @@ -14,7 +14,7 @@ import { MatIconModule } from '@angular/material/icon'; import { MatButtonModule } from '@angular/material/button'; import { MatTooltip } from '@angular/material/tooltip'; import { CurrencyPipe, DatePipe } from '@angular/common'; - +import { SkTextDirective } from '../../../custom-directives/sk-text.directive'; import { DataTableComponent, GenericColumn, @@ -48,6 +48,7 @@ import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overfl AppTopicChipComponent, ChipComponent, AppAuthorChipComponent, + SkTextDirective, ], templateUrl: './eu-project-table.component.html', styleUrl: './eu-project-table.component.scss',