Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
AstridKery committed Oct 18, 2024
1 parent 419669c commit f10d482
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
8 changes: 5 additions & 3 deletions backend/django/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,12 @@ def __str__(self):
return self.field_name

def get_unique_options(self):
unique_list = list(
set(self.labelmetadata_set.all().values_list("value", flat=True))
unique_list = (
self.labelmetadata_set.all()
.order_by("value")
.values_list("value", flat=True)
.distinct()
)
unique_list.sort()
return unique_list


Expand Down
17 changes: 11 additions & 6 deletions backend/django/core/views/api_annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,17 @@ def get_queryset(self):
filter_text = self.request.GET.get("searchString")

label_category = self.request.GET.get("category")
if label_category and label_category != "all":
if label_category == "None":
category_label_list = LabelMetaData.objects.filter(
label_metadata_field=project.category.label_metadata_field,
value="nan",
).values_list("label__pk", flat=True)
if hasattr(project, "category") and label_category != "all":
if label_category == "None" or label_category == "":
category_label_list = (
LabelMetaData.objects.filter(
label_metadata_field=project.category.label_metadata_field
)
.filter(
Q(value__isnull=True) | Q(value="nan"),
)
.values_list("label__pk", flat=True)
)
else:
category_label_list = LabelMetaData.objects.filter(
label_metadata_field=project.category.label_metadata_field,
Expand Down

0 comments on commit f10d482

Please sign in to comment.