Skip to content

Commit

Permalink
Merge pull request #227 from MetaCell/develop
Browse files Browse the repository at this point in the history
Release 1.2.0
  • Loading branch information
filippomc authored Mar 23, 2024
2 parents 5295ecf + 80046d3 commit 1a7f148
Show file tree
Hide file tree
Showing 59 changed files with 2,467 additions and 780 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
harness:
env:
- name: SENTRY_DSN
value: https://57b1ca8a70634782bd6c90dd119eeab5@o4506739169951744.ingest.sentry.io/4506758817382404

value: https://57b1ca8a70634782bd6c90dd119eeab5@o4506739169951744.ingest.sentry.io/4506758817382404
285 changes: 180 additions & 105 deletions applications/portal/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,59 +112,6 @@ paths:
operationId: createAntibody
summary: Create a Antibody
description: Creates a new instance of a `Antibody`.
/antibodies/search:
summary: Path used to search on antibodies.
description: >-
The REST endpoint/path used to search and filter on `Antibody` entities. This path contains a
`GET` and `POST` operation to perform the search and filter tasks, respectively.
get:
tags:
- search
parameters:
-
name: page
description: 'Represents the page requested, considering the size parameter'
schema:
type: integer
in: query
-
name: size
description: Corresponds to the cardinality of antibodies requested
schema:
type: integer
in: query
-
name: search
description: The string to use for full text search on Antibodies
schema:
type: string
in: query
responses:
'200':
$ref: '#/components/responses/PaginatedAntibodies'
operationId: ftsAntibodies
summary: Full text search on Antibodies
description: Gets a list of `Antibody` entities related with the search query
post:
requestBody:
description: A new `FilterRequest` to be used on the antibodies search.
content:
application/json:
schema:
$ref: '#/components/schemas/FilterRequest'
required: true
tags:
- search
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedAntibodies'
description: Successful response - returns an array of `Antibody` entities.
operationId: filterAntibodies
summary: Search on Antibodies with custom filters
description: Gets a list of `Antibody` entities related with the body parameters
/ready:
summary: Path used to test readiness of the application.
description: The REST endpoint/path used to test the readiness of the application.
Expand Down Expand Up @@ -389,60 +336,61 @@ paths:
content:
text/csv: {}
description: All antibodies in csv format
components:
schemas:
FilterRequest:
description: The search request body that allows filtering combinations over multiple columns
type: object
properties:
contains:
description: >-
Array of key-value pairs, where key represents the column and value the string that
should be contained
type: array
items:
$ref: '#/components/schemas/KeyValuePair'
equals:
description: >-
Array of key-value pairs, where key represents the column and value the string that
should be equalled to
type: array
items:
$ref: '#/components/schemas/KeyValuePair'
page:
/antibodies/search:
summary: Path used to search on antibodies.
description: >-
The REST endpoint/path used to search and filter on `Antibody` entities. This path contains a
`GET` and `POST` operation to perform the search and filter tasks, respectively.
get:
tags:
- search
parameters:
-
name: page
description: 'Represents the page requested, considering the size parameter'
type: integer
size:
schema:
type: integer
in: query
-
name: size
description: Corresponds to the cardinality of antibodies requested
type: integer
search:
description: The string to use to search for Antibodies
type: string
endsWith:
description: >-
Array of key-value pairs, where key represents the column and value the string that
should be ending with
type: array
items:
$ref: '#/components/schemas/KeyValuePair'
sortOn:
description: >-
Array of key-value pairs, where key represents the column and value the string
ascending or descending
Order in the array, matches with the order of sorting filters, index 0 will be used to
sort first
type: array
items:
$ref: '#/components/schemas/KeyValuePair'
startsWith:
description: >-
Array of key-value pairs, where key represents the column and value the string that
should be starting with
type: array
items:
$ref: '#/components/schemas/KeyValuePair'
schema:
type: integer
in: query
-
name: search
description: The string to use for full text search on Antibodies
schema:
type: string
in: query
responses:
'200':
$ref: '#/components/responses/PaginatedAntibodies'
operationId: ftsAntibodies
summary: Full text search on Antibodies
description: Gets a list of `Antibody` entities related with the search query
post:
requestBody:
description: A new `FilterRequest` to be used on the antibodies search.
content:
application/json:
schema:
$ref: '#/components/schemas/FilterRequest'
required: true
tags:
- search
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedAntibodies'
description: Successful response - returns an array of `Antibody` entities.
operationId: filterAntibodies
summary: Search on Antibodies with custom filters
description: Gets a list of `Antibody` entities related with the body parameters
components:
schemas:
KeyValuePair:
description: Utility type to represent a key-value object
required:
Expand Down Expand Up @@ -741,6 +689,133 @@ components:
description: Whether to add directly to the current data without reset
type: boolean
example: 'false'
FilterRequest:
description: The search request body that allows filtering combinations over multiple columns
type: object
properties:
contains:
description: >-
Array of key-value pairs, where key represents the column and value the string that
should be contained
type: array
items:
$ref: '#/components/schemas/KeyValuePair'
equals:
description: >-
Array of key-value pairs, where key represents the column and value the string that
should be equalled to
type: array
items:
$ref: '#/components/schemas/KeyValuePair'
page:
description: 'Represents the page requested, considering the size parameter'
type: integer
size:
description: Corresponds to the cardinality of antibodies requested
type: integer
search:
description: The string to use to search for Antibodies
type: string
endsWith:
description: >-
Array of key-value pairs, where key represents the column and value the string that
should be ending with
type: array
items:
$ref: '#/components/schemas/KeyValuePair'
sortOn:
description: >-
Array of key-value pairs, where key represents the column and value the string
ascending or descending
Order in the array, matches with the order of sorting filters, index 0 will be used to
sort first
type: array
items:
$ref: '#/components/schemas/KeyValueSortOrderPair'
startsWith:
description: >-
Array of key-value pairs, where key represents the column and value the string that
should be starting with
type: array
items:
$ref: '#/components/schemas/KeyValuePair'
isEmpty:
description: 'Array of strings, where string represents the column which should be empty.'
type: array
items:
type: string
isNotEmpty:
description: 'Array of strings, where string represents the column which should not be empty.'
type: array
items:
type: string
isAnyOf:
description: 'Array of strings, where string represents the column which should not be empty.'
type: array
items:
$ref: '#/components/schemas/KeyValueArrayPair'
operation:
description: Which operation to perform in the Backend - AND or OR.
enum:
- and
- or
type: string
isUserScope:
description: Whether to get users antibodies or not.
type: boolean
KeyValueArrayPair:
description: >-
Utility type to represent a key-value object, where value is an array. This is helpful when
the filter is - isAnyOf, where filter column needs to be matched with multiple strings.
required:
- key
- value
type: object
properties:
key:
description: String representation of the key
type: string
value:
description: String representation of the value
type: array
items:
type: string
KeyValueSortOrderPair:
description: >-
Utility type to represent a key-value object, where value is enum - "asc" or "desc" to
describe if the sorting order is ascending or descending.
required:
- key
- value
type: object
properties:
key:
description: String representation of the key
type: string
sortorder:
description: String representation of the value
enum:
- asc
- desc
type: string
SearchCriteriaOptions:
enum:
- contains
- equals
- endsWith
- startsWith
- sortOn
- isEmpty
- isNotEmpty
- isAnyOf
- operation
- isUserScope
- page
- size
- search
type: string
responses:
PaginatedAntibodies:
content:
Expand Down
8 changes: 3 additions & 5 deletions applications/portal/api/templates/main.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ app.mount("/", get_asgi_application())
# import uvicorn
# uvicorn.run(app, host="0.0.0.0", port=8000)

try:
import cloudharness.sentry as sentry
sentry.init(appname="portal", traces_sample_rate=1.0)
except:
log.exception("Sentry initialization failed")
from api.helpers import init_sentry

init_sentry()
25 changes: 22 additions & 3 deletions applications/portal/backend/api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
Vendor,
Specie,
VendorDomain,
VendorSynonym, AntibodyFiles,
VendorSynonym, AntibodyFiles, CommercialType
)
from api.import_export import AntibodyResource
from api.services.keycloak_service import KeycloakService
Expand Down Expand Up @@ -309,6 +309,24 @@ class VendorDomainInline(admin.TabularInline):
extra = 0


class CommercialTypeFilter(admin.SimpleListFilter):
title = "Commercial Type"
parameter_name = "commercial_type"

def lookups(self, request, model_admin):
return [
(CommercialType.COMMERCIAL, ("Commercial vendors")),
(CommercialType.PERSONAL, ("Personal vendors")),
(CommercialType.NON_PROFIT, ("Non-profit vendors")),
(CommercialType.OTHER, ("Other vendors")),
]

def queryset(self, request, queryset):
if self.value():
return queryset.filter(vendor__commercial_type=self.value())
return queryset


@admin.register(VendorDomain)
class VendorDomainAdmin(admin.ModelAdmin):
list_display = (
Expand All @@ -318,13 +336,14 @@ class VendorDomainAdmin(admin.ModelAdmin):
"is_domain_visible",
)
list_editable = ("is_domain_visible",)

list_filter = [CommercialTypeFilter]

@admin.register(Vendor)
class VendorAdmin(admin.ModelAdmin):
delete_confirmation_template = "admin/vendor/delete_confirmation.html"
search_fields = ("name",)
list_display = ("name", "commercial_type", "nif_id", "eu_id")
list_display = ("id", "name", "commercial_type", "nif_id", "eu_id")
ordering = ("-id",)
list_filter = (NonCuratedDomains, "commercial_type",)
fields = (
"nb_antibodies",
Expand Down
Loading

0 comments on commit 1a7f148

Please sign in to comment.