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
Conversation
This is ready for review, or, if we want to fix the underlying failing tests first, I can rebase it. |
d501d47
to
55cb9c8
Compare
There was a problem hiding this 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
src/utils/admin_utils.py
Outdated
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) + ' [...]' |
There was a problem hiding this comment.
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
* #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>
* #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>
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: