Skip to content

Commit 0064cf9

Browse files
authored
Merge pull request #58 from omics-datascience/gonza
- Fixed font icons and biomarkers can be shared
2 parents adb2585 + e6aca83 commit 0064cf9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+88
-45
lines changed
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 4.2.15 on 2024-11-21 18:10
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('biomarkers', '0018_alter_biomarker_state'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='biomarker',
15+
name='is_public',
16+
field=models.BooleanField(default=False),
17+
),
18+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 4.2.15 on 2024-11-21 18:36
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('institutions', '0004_auto_20220923_2322'),
10+
('biomarkers', '0019_biomarker_is_public'),
11+
]
12+
13+
operations = [
14+
migrations.AddField(
15+
model_name='biomarker',
16+
name='shared_institutions',
17+
field=models.ManyToManyField(blank=True, related_name='biomarkers', to='institutions.institution'),
18+
),
19+
]

Diff for: src/biomarkers/models.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from django.db import models
44
from django.db.models import QuerySet
55
from queryset_sequence import QuerySetSequence
6+
7+
from institutions.models import Institution
68
from tags.models import Tag
79
from api_service.websocket_functions import send_update_biomarkers_command
810
from user_files.models_choices import MoleculeType
@@ -60,14 +62,15 @@ class Biomarker(models.Model):
6062
cnas: QuerySet['CNAIdentifier']
6163
mirnas: QuerySet['MiRNAIdentifier']
6264
mrnas: QuerySet['MRNAIdentifier']
63-
65+
is_public = models.BooleanField(blank=False, null=False, default=False)
6466
name: str = models.CharField(max_length=300)
6567
description: Optional[str] = models.TextField(null=True, blank=True)
6668
tag: Optional[Tag] = models.ForeignKey(Tag, on_delete=models.SET_NULL, default=None, blank=True, null=True)
6769
upload_date: Optional[models.DateTimeField] = models.DateTimeField(auto_now_add=True, blank=False, null=True)
6870
origin: int = models.IntegerField(choices=BiomarkerOrigin.choices)
6971
state: int = models.IntegerField(choices=BiomarkerState.choices)
7072
user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
73+
shared_institutions = models.ManyToManyField(Institution, related_name='biomarkers', blank=True)
7174

7275
def __str__(self) -> str:
7376
return self.name

Diff for: src/biomarkers/views.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@
1616
BiomarkerSimpleSerializer, BiomarkerSimpleUpdateSerializer
1717
from common.pagination import StandardResultsSetPagination
1818
from common.response import generate_json_response_or_404
19-
from django.db.models import QuerySet
19+
from django.db.models import QuerySet, Q
2020

2121

2222
class BiomarkerList(generics.ListAPIView):
2323
"""REST endpoint: list for Biomarker model"""
2424

2525
def get_queryset(self):
26+
user = self.request.user
2627
only_successful = self.request.GET.get('onlySuccessful') == 'true'
27-
biomarkers = Biomarker.objects.filter(user=self.request.user)
28+
biomarkers = Biomarker.objects.filter(
29+
Q(is_public=True) | Q(user=user) | Q(shared_institutions__institutionadministration__user=user)).distinct()
30+
2831
if only_successful:
2932
# FIXME: this is VERY slow. Taking more than 20secs in production. Must parametrize the DB, maybe
3033
# FIXME: autovacuum settings could help
@@ -112,7 +115,6 @@ def get(self, request: Request, pk: int):
112115
self.__copy_molecules_instances(biomarker_copy, biomarker.cnas.all())
113116
self.__copy_molecules_instances(biomarker_copy, biomarker.methylations.all())
114117

115-
116118
return Response({'ok': True})
117119

118120

@@ -142,6 +144,7 @@ def get_gene_aliases(genes_ids: List[str]) -> Optional[Dict]:
142144
method='post'
143145
)
144146

147+
145148
def find_genes_from_request(request: Request) -> List[Dict]:
146149
"""
147150
Generates the structure for the frontend for a list of genes. The needed structure is a list of dicts with
602 Bytes
Binary file not shown.
Binary file not shown.
666 Bytes
Binary file not shown.
1.26 KB
Binary file not shown.
720 Bytes
Binary file not shown.
618 Bytes
Binary file not shown.
516 Bytes
Binary file not shown.
616 Bytes
Binary file not shown.
256 Bytes
Binary file not shown.
758 Bytes
Binary file not shown.
532 Bytes
Binary file not shown.
414 Bytes
Binary file not shown.
356 Bytes
Binary file not shown.
1.19 KB
Binary file not shown.
552 Bytes
Binary file not shown.
574 Bytes
Binary file not shown.
470 Bytes
Binary file not shown.
478 Bytes
Binary file not shown.
1.91 KB
Binary file not shown.
638 Bytes
Binary file not shown.
Binary file not shown.
1.24 KB
Binary file not shown.
474 Bytes
Binary file not shown.
940 Bytes
Binary file not shown.
Binary file not shown.
1.79 KB
Binary file not shown.
394 Bytes
Binary file not shown.
404 Bytes
Binary file not shown.
450 Bytes
Binary file not shown.
522 Bytes
Binary file not shown.
532 Bytes
Binary file not shown.
638 Bytes
Binary file not shown.
Binary file not shown.
994 Bytes
Binary file not shown.
744 Bytes
Binary file not shown.
520 Bytes
Binary file not shown.
444 Bytes
Binary file not shown.
492 Bytes
Binary file not shown.
1.61 KB
Binary file not shown.
646 Bytes
Binary file not shown.
602 Bytes
Binary file not shown.
3.01 KB
Binary file not shown.

Diff for: src/frontend/static/frontend/src/components/biomarkers/biomarker-details-modal/molecules/genes/GeneInformation.tsx

+41-41
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)