Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul admin views to support searching and browsing #3345

Merged
merged 54 commits into from Mar 16, 2023

Conversation

joemull
Copy link
Member

@joemull joemull commented Jan 11, 2023

This overhaul of the admin views addresses navigation issues related to bad search fields, filters that populate thousands of items as choices, and a lack of connections between related models. Closes #3256.

Design goals:

  • Display the most relevant fields in list views
  • Search support for visible fields
  • Always filter by journal or repository, if possible, using custom filters
  • Add other filters that narrow down the content, based on likely lookups when providing tech support
  • Use inlines on article and preprint models to represent metadata elements
  • Use inlines to connect related models where relevant, but not when the inline could ever load hundreds of lines
  • Add an admin_utils file to hold custom filter and inline classes
  • Add unit tests via a meta-class to run a search query against every admin view, to make sure all prescribed fields are actually searchable

@joemull joemull linked an issue Jan 24, 2023 that may be closed by this pull request
@joemull
Copy link
Member Author

joemull commented Jan 24, 2023

This is ready for review, or, if we want to fix the underlying failing tests first, I can rebase it.

@joemull joemull marked this pull request as ready for review January 24, 2023 16:08
@joemull joemull requested review from ajrbyers and mauromsl and removed request for ajrbyers January 24, 2023 16:08
@joemull joemull linked an issue Jan 24, 2023 that may be closed by this pull request
Copy link
Member

@mauromsl mauromsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this was a lot of work, and I really appreciate the classes under utils/admin_utils.py which make the entire processes so much more DRY.

Well done @joemull

Comment on lines 445 to 469
def truncate(value, limit=80):

"""
Truncates strings keeping whole words.

Safe to use with HTML strings, because it does not mark them as safe.

Some lines of templatetags.truncate.py are duplicated to avoid circular imports.
"""

if not value:
return ''

try:
limit = int(limit)
except ValueError:
return value

if len(value) <= limit:
return value

value = value[:limit]
words = value.split(' ')[:-1]

return ' '.join(words) + ' [...]'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can make use of django's Truncator functions under django.template.defaultfilters

@mauromsl mauromsl merged commit 506e401 into django_three_two Mar 16, 2023
@mauromsl mauromsl deleted the 3256-brush-up-admin-views branch March 16, 2023 09:17
mauromsl added a commit that referenced this pull request Mar 17, 2023
* #3256 Brush up CMS admin

* #3256 More on CMS admin

* #3256 Brush up comms admin

* #3256 Brush up copyediting admin

* #3256 Wrap line

* #3256 Add inline view for author reviews on assignment page

* #3256 Use better syntax for Inline option

* #3256 Brush up core models

* Fix typo

* Brush up cron models

* #3256 Brush up discussion admin

* #3256 Brush up identifier models

* #3256 Brush up journal admin views

* #3256 Brush up metrics admin views

* #3224 #3256 Brush up log entry admin

* #3256 Brush up admin views

* Edits to comments

* #3256 Brush up review admin

* #3256 Make core changes on admin not models

* #3256 Improve workflow element log list view

* #3256 Add comments about verbose names

* #3256 Raw ID fields for workflow log inline

* #3256 Consolidate admin utils in own file

* #3256 Brush up submission models

* #3256 Truncate long article titles in __str__

* #3256 Brush up repository admin views

* #3256 Brush up carousel admin view

* #3256 Better CMS admin filtering

* #3256 Better filtering on news item admin

* #3256 Typo in search field

* #3256 Better filtering of copyediting admin views

* #3256 Better filtering on core admin views

* #3256 Improve cron admin filters

* #3256 Improve discussion admin filters

* #3256 Fill out featured article admin

* #3256 Better identifier admin filters

* #3256 Improve journal admin filters

* #3256 Better filters for metrics admin

* #3256 Use base class for most journal list display functions

* #3256 Minor adjustments to review admin

* #3256 Only use date_hierarchy for models with one date

* #3256 Only use inlines when they won't return long lists

* Remove enum34 from requirements.txt

* #3256 Remove deprecated field

* #3256 Improve date filters in article admin

* #3256 Add unit tests for search with metaclass

* #3256 Fix bugs in search_fields attributes

* #3256: Small abstraction for the admin test metaclass

* #3256 Clean up fields and methods after browsing checks

* Fix bug that occurred when no crossref statuses in database

* Add verbose name plural for fixed pub check items

* #3256 Use Django's built-in truncation filters

* #3256 Add a list display and inline for comms tags

* #3256 Add missing migration

---------

Co-authored-by: mauromsl <mauro.msl@outlook.com>
mauromsl added a commit that referenced this pull request Mar 17, 2023
* #3256 Brush up CMS admin

* #3256 More on CMS admin

* #3256 Brush up comms admin

* #3256 Brush up copyediting admin

* #3256 Wrap line

* #3256 Add inline view for author reviews on assignment page

* #3256 Use better syntax for Inline option

* #3256 Brush up core models

* Fix typo

* Brush up cron models

* #3256 Brush up discussion admin

* #3256 Brush up identifier models

* #3256 Brush up journal admin views

* #3256 Brush up metrics admin views

* #3224 #3256 Brush up log entry admin

* #3256 Brush up admin views

* Edits to comments

* #3256 Brush up review admin

* #3256 Make core changes on admin not models

* #3256 Improve workflow element log list view

* #3256 Add comments about verbose names

* #3256 Raw ID fields for workflow log inline

* #3256 Consolidate admin utils in own file

* #3256 Brush up submission models

* #3256 Truncate long article titles in __str__

* #3256 Brush up repository admin views

* #3256 Brush up carousel admin view

* #3256 Better CMS admin filtering

* #3256 Better filtering on news item admin

* #3256 Typo in search field

* #3256 Better filtering of copyediting admin views

* #3256 Better filtering on core admin views

* #3256 Improve cron admin filters

* #3256 Improve discussion admin filters

* #3256 Fill out featured article admin

* #3256 Better identifier admin filters

* #3256 Improve journal admin filters

* #3256 Better filters for metrics admin

* #3256 Use base class for most journal list display functions

* #3256 Minor adjustments to review admin

* #3256 Only use date_hierarchy for models with one date

* #3256 Only use inlines when they won't return long lists

* Remove enum34 from requirements.txt

* #3256 Remove deprecated field

* #3256 Improve date filters in article admin

* #3256 Add unit tests for search with metaclass

* #3256 Fix bugs in search_fields attributes

* #3256: Small abstraction for the admin test metaclass

* #3256 Clean up fields and methods after browsing checks

* Fix bug that occurred when no crossref statuses in database

* Add verbose name plural for fixed pub check items

* #3256 Use Django's built-in truncation filters

* #3256 Add a list display and inline for comms tags

* #3256 Add missing migration

---------

Co-authored-by: mauromsl <mauro.msl@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Brush up admin views Logs should be able to be filtered by source, type, actor
2 participants