-
-
Notifications
You must be signed in to change notification settings - Fork 6
add protein curation admin dashboard #350
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
Draft
tlambert03
wants to merge
5
commits into
main
Choose a base branch
from
claude/approve-spectrum-submissions-011CUq2kKSUKbX7XjTPnquCY
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
add protein curation admin dashboard #350
tlambert03
wants to merge
5
commits into
main
from
claude/approve-spectrum-submissions-011CUq2kKSUKbX7XjTPnquCY
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created a comprehensive moderation page for reviewing protein submissions
and changes, allowing moderators to review all field changes and related
objects before approving or rejecting.
**Key Features:**
- Custom dashboard at /pending-proteins/ showing all pending proteins
- Intelligent diff comparison between current version and last approved version
- Comprehensive change tracking for:
- Protein fields (name, sequence, chromophore, etc.)
- States (added/removed/modified with all properties)
- References (added/removed)
- Lineage changes (parent, mutations)
- State transitions (added/removed)
- OSER measurements (added/removed)
- Clean, collapsible UI showing only changed fields
- Bulk actions: approve/reject multiple proteins at once
- Individual actions per protein with email capability
- Special handling for new submissions vs modifications
- Sequence mutations display for changed sequences
- Toast notifications for user feedback
**Implementation:**
1. **Backend** (`backend/proteins/views/protein.py`):
- `_get_protein_changes()`: Helper function that compares pending protein
with last approved version using django-reversion
- `pending_proteins_dashboard()`: Main view rendering the dashboard
- `pending_protein_action()`: AJAX endpoint for approve/reject actions
2. **Frontend** (`backend/proteins/templates/pending_proteins_dashboard.html`):
- Card-based layout similar to spectrum moderation
- Collapsible sections for each category of changes
- Color-coded additions (green) and removals (red)
- Responsive design with sticky bulk action bar
3. **URLs** (`backend/proteins/urls.py`):
- `/pending-proteins/` - Main dashboard
- `/ajax/pending_protein_action/` - Action endpoint
**Technical Details:**
- Leverages django-reversion's `last_approved_version()` method
- Handles nested related objects (states, spectra, measurements)
- Smart state comparison by unique fields to handle ID changes
- Displays field-level changes with old → new formatting
- Shows mutation notation for sequence changes
- Revision tracking with comments and user attribution
Closes the request for protein moderation functionality.
The last_approved_version() method returns a Version object when the protein is pending, but was being treated as a Protein instance. Now properly deserialize the Version back to a Protein using the old_object() helper from history.py. Fixes AttributeError: 'Version' object has no attribute 'states'
- Use Version.field_dict instead of old_object() to avoid broken transactions - Skip related object comparisons when using field_dict (only show protein fields) - Handle choice field display values using CHOICES tuples - Update all references from last_approved to old_data variable This fixes the TransactionManagementError that occurred when trying to query related objects after the transaction rollback in old_object().
Added comprehensive sorting capabilities to the pending proteins dashboard: **Sort Criteria:** - Most/Least Recently Updated (modified date) - Newest/Oldest (created date) - Most/Least Viewed (Google Analytics data, 30-day window) - Most/Least Favorited (user favorites count) - Name (A-Z / Z-A) **Backend Changes:** - Fetch view data from Google Analytics via cached_ga_popular() - Fetch favorite counts from Favorite model - Add view_count and favorite_count to protein data - Add ISO formatted timestamps for JavaScript sorting **Frontend Changes:** - Added sort dropdown with 10 sorting options - Added data attributes to protein cards for client-side sorting - Implemented sortProteins() JavaScript function - Cards re-order dynamically without page reload Sorting is purely client-side after initial page load for instant feedback. Default sort remains 'Most Recently Updated' (modified desc).
for more information, see https://pre-commit.ci
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #350 +/- ##
==========================================
- Coverage 60.94% 58.38% -2.57%
==========================================
Files 104 104
Lines 8559 8758 +199
==========================================
- Hits 5216 5113 -103
- Misses 3343 3645 +302 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.