-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow news items to be linked to all versions of a project (#2186)
Currently, news items can only be linked to a single version of a published project, but in many or most cases we would actually like news items to link to all versions of a published project. This pull request adds a flag to the news model that allows a news item to be linked to all versions of a project. Specifically, the changes are: - Add a `link_all_versions` flag to the News model - Allow the flag to be set in the form that is used to create news items - Adds a `get_all_news()` method to the `PublishedProject` model that makes it straightforward to retrieve all news items for the project (both news items that are directly linked, and news items that are linked through the `link_all_versions` flag). - Adds a migration that updates the News model. There may be better ways to implement this functionality, e.g. by: - linking the News model to a CoreProject instead of PublishedProject - setting a validator that requires linked CoreProjects to be associated with a PublishedProject (so that news items can only be added for published projects) - adding `project_version` to the News item - updating the form used to add news items so that the CoreProject and version (or "all versions" can be set). I would prefer to stick with the implementation in this pull request for timeliness (so that @briangow can respond to a user request). We can review and improve the approach in future.
- Loading branch information
Showing
5 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
20 changes: 20 additions & 0 deletions
20
physionet-django/notification/migrations/0010_news_link_all_versions.py
This file contains 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,20 @@ | ||
# Generated by Django 4.1.10 on 2024-01-30 20:50 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("notification", "0009_alter_news_slug"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="news", | ||
name="link_all_versions", | ||
field=models.BooleanField( | ||
default=False, | ||
help_text="Check this to link the news item to all versions of the selected project", | ||
), | ||
), | ||
] |
This file contains 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 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 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