Skip to content

Commit

Permalink
refactor: Add show_ad... flag to prepare_document_table
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifer-richards committed Jan 12, 2024
1 parent f5fd9ac commit 50e5bff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
16 changes: 9 additions & 7 deletions ietf/doc/utils_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def augment_docs_with_related_docs_info(docs):
originalDoc = d.related_that_doc('conflrev')[0]
d.pages = originalDoc.pages

def prepare_document_table(request, docs, query=None, max_results=200):
def prepare_document_table(request, docs, query=None, max_results=200, show_ad_and_shepherd=True):
"""Take a queryset of documents and a QueryDict with sorting info
and return list of documents with attributes filled in for
displaying a full table of information about the documents, plus
Expand Down Expand Up @@ -259,12 +259,14 @@ def num(i):
if len(docs) == max_results:
meta['max'] = max_results

meta['headers'] = [{'title': 'Document', 'key':'document'},
{'title': 'Title', 'key':'title'},
{'title': 'Date', 'key':'date'},
{'title': 'Status', 'key':'status'},
{'title': 'IPR', 'key':'ipr'},
{'title': 'AD / Shepherd', 'key':'ad'}]
meta['headers'] = [{'title': 'Document', 'key': 'document'},
{'title': 'Title', 'key': 'title'},
{'title': 'Date', 'key': 'date'},
{'title': 'Status', 'key': 'status'},
{'title': 'IPR', 'key': 'ipr'}]
if show_ad_and_shepherd:
meta['headers'].append({'title': 'AD / Shepherd', 'key': 'ad'})
meta['show_ad_and_shepherd'] = show_ad_and_shepherd

if query and hasattr(query, "urlencode"): # fed a Django QueryDict
d = query.copy()
Expand Down
5 changes: 3 additions & 2 deletions ietf/doc/views_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,10 @@ def sort_key(doc):
if not ad:
raise Http404

results, meta = prepare_document_table(request, Document.objects.filter(ad=ad), max_results=500)
results, meta = prepare_document_table(
request, Document.objects.filter(ad=ad), max_results=500, show_ad_and_shepherd=False
)
results.sort(key=lambda d: sort_key(d))
del meta["headers"][-1]

# filter out some results
results = [
Expand Down
2 changes: 1 addition & 1 deletion ietf/templates/doc/search/search_result_row.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
</a>
{% endif %}
</td>
{% if ad is None %}
{% if meta.show_ad_and_shepherd %}
<td class="d-none d-sm-table-cell bg-transparent">
{% if doc.ad %}
{% person_link doc.ad title="Area Director" %}
Expand Down

0 comments on commit 50e5bff

Please sign in to comment.