-
Notifications
You must be signed in to change notification settings - Fork 0
FREYA-1549: Implement Data Highlights App #26
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
Open
misterabdullahAziz
wants to merge
5
commits into
main
Choose a base branch
from
FREYA-1549/Abdullah/highlights
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.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
af01b6a
feat(highlights): add highlights app with models, views, and templates
misterabdullahAziz a93d7bd
refactor(templates): remove unused title blocks from highlight templates
misterabdullahAziz 338370b
fix(template): improve HTML structure in highlights index
misterabdullahAziz 0da5436
fix(docs): add package documentation for highlights app
misterabdullahAziz db00e0e
fix(models): remove blank option from slug field in DataHighlight model
misterabdullahAziz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
misterabdullahAziz marked this conversation as resolved.
Show resolved
Hide resolved
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Highlights app package.""" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
from django.contrib import admin | ||
from django.contrib import messages | ||
from .models import DataHighlight | ||
|
||
|
||
@admin.register(DataHighlight) | ||
class DataHighlightAdmin(admin.ModelAdmin): | ||
"""Admin interface for DataHighlight model. | ||
|
||
Provides a comprehensive admin interface for managing data highlights | ||
with organized fieldsets, search functionality, filtering, and bulk actions. | ||
|
||
Features: | ||
- List display with title, slug, status, and timestamps | ||
- Filtering by active status, creation date, update date, and topics | ||
- Search by title, summary, content, announcement, and tags | ||
- Auto-populated slug field from title | ||
- Horizontal filter widget for topic selection | ||
- Bulk actions for activating/deactivating highlights | ||
- Organized fieldsets for better UX | ||
""" | ||
list_display = ["title", "slug", "is_active", "created_at", "updated_at"] | ||
list_filter = ["is_active", "created_at", "updated_at", "topics"] | ||
search_fields = ["title", "summary", "content", "announcement", "tags"] | ||
prepopulated_fields = {"slug": ("title",)} | ||
readonly_fields = ["created_at", "updated_at"] | ||
filter_horizontal = ["topics"] | ||
actions = ["activate_highlights", "deactivate_highlights"] | ||
|
||
fieldsets = ( | ||
("Basic Information", { | ||
"fields": ("title", "slug", "summary") | ||
}), | ||
("Content", { | ||
"fields": ("content", "announcement") | ||
}), | ||
("Categorization", { | ||
"fields": ("topics", "tags") | ||
}), | ||
("Media", { | ||
"fields": ("featured_image", "figure_caption") | ||
}), | ||
("Status", { | ||
"fields": ("is_active",) | ||
}), | ||
("Timestamps", { | ||
"fields": ("created_at", "updated_at"), | ||
"classes": ("collapse",) | ||
}), | ||
) | ||
|
||
def activate_highlights(self, request, queryset): | ||
"""Activate selected highlights.""" | ||
updated = queryset.update(is_active=True) | ||
self.message_user( | ||
request, | ||
f"Successfully activated {updated} highlight(s).", | ||
messages.SUCCESS | ||
) | ||
activate_highlights.short_description = "Activate selected highlights" | ||
|
||
def deactivate_highlights(self, request, queryset): | ||
"""Deactivate selected highlights.""" | ||
updated = queryset.update(is_active=False) | ||
self.message_user( | ||
request, | ||
f"Successfully deactivated {updated} highlight(s).", | ||
messages.SUCCESS | ||
) | ||
deactivate_highlights.short_description = "Deactivate selected highlights" | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class HighlightsConfig(AppConfig): | ||
"""Configuration for the highlights app. | ||
This app manages data highlights for the Swedish Pathogens Portal, | ||
providing a way to showcase important research findings and data insights. | ||
""" | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "pages.highlights" | ||
verbose_name = "Data Highlights" | ||
senthil10 marked this conversation as resolved.
Show resolved
Hide resolved
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Generated by Django 5.2.6 on 2025-10-13 14:23 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('topics', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='DataHighlight', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('title', models.CharField(help_text='Title of the data highlight', max_length=255, unique=True)), | ||
('slug', models.SlugField(help_text='URL-friendly version of the title (auto-generated from title)', max_length=255, unique=True)), | ||
('summary', models.TextField(help_text='Brief summary of the highlight for display in cards')), | ||
('content', models.TextField(help_text='Full content in markdown format displayed on detail page')), | ||
('announcement', models.TextField(blank=True, help_text='Optional announcement message displayed at the top of the highlight')), | ||
('tags', models.TextField(blank=True, help_text='Comma-separated tags for related content matching and search')), | ||
('featured_image', models.ImageField(help_text='Featured image for the highlight', upload_to='highlights/images/')), | ||
('figure_caption', models.TextField(blank=True, help_text='Caption for the featured image (optional)')), | ||
('is_active', models.BooleanField(default=True, help_text='Whether this highlight is active and visible')), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('topics', models.ManyToManyField(blank=True, help_text='Research topics associated with this highlight (optional)', to='topics.topic')), | ||
], | ||
options={ | ||
'verbose_name': 'Data Highlight', | ||
'verbose_name_plural': 'Data Highlights', | ||
'ordering': ['-created_at'], | ||
}, | ||
), | ||
] |
Empty file.
Oops, something went wrong.
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.
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.
We should discuss if we need all these component
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.
We can discuss, maybe app-specific or maybe we can reduce these components once we will have all major apps created.
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.
Yes, I mean among the components listed here, I think only topic badges will used in multiple pages/apps. Everything else is mostly specific to highlights (and maybe editorials). In that case I prefer to not have components and just use in-line styling using tailwind.
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.
Agreed, I would keep everything inline for now, we are not in the stage where we can really think about how to factor the styles and optimise the utility classes, so let's not bother and keep this for later when things will be more stable :)
For reference: https://tailwindcss.com/docs/styling-with-utility-classes#managing-duplication