Skip to content

Commit

Permalink
Improve Unsafes list table
Browse files Browse the repository at this point in the history
  • Loading branch information
vmordan committed Dec 13, 2023
1 parent 34d2b3a commit a500d52
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions web/reports/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,11 @@ def __unsafes_data(self):
ordered_ids = new_ids

attributes = {}
for r_id, a_name, a_value in ReportAttr.objects.filter(report_id__in=ordered_ids).order_by('id') \
.values_list('report_id', 'attr__name__name', 'attr__value'):
for r_id, a_name, a_value, a_assoc in ReportAttr.objects.filter(report_id__in=ordered_ids).order_by('id') \
.values_list('report_id', 'attr__name__name', 'attr__value', 'associate'):
if a_name not in attributes:
self.available_columns.append({'value': a_name, 'title': a_name})
if ALL_ATTRS in self.view['columns']:
if ALL_ATTRS in self.view['columns'] and a_assoc:
self.selected_columns.append({'value': a_name, 'title': a_name})
columns.append(a_name)
attributes[a_name] = {}
Expand Down Expand Up @@ -608,16 +608,13 @@ def __unsafes_data(self):
val = get_user_memory(self.user, unsafes[rep_id]['memory'])
elif col == 'reviewed':
reviews_total = 0
reviews_by_me = 0
reviews_by_me = "No"
for review in MarkUnsafeReview.objects.filter(report_id=rep_id):
if review.author == self.user:
reviews_by_me += 1
reviews_by_me = "Yes"
reviews_total += 1
if reviews_total:
val = f"{reviews_by_me} / {reviews_total}"
else:
val = "0"
if reviews_by_me:
val = f"{reviews_by_me} (in total {reviews_total})"
if reviews_by_me == "No":
style = "red-pale-link"
values_row.append({'value': val, 'color': color, 'href': href, 'style': style})
values_data.append(values_row)
Expand Down

0 comments on commit a500d52

Please sign in to comment.