-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addons: allow users to show/hide notifications on latest/non-stable (#…
…11718) We currently allow users to disable the latest and non-stable notifications with only one checkbox. This PR split this checkbox into two, so users can decide to show a notification on latest and/or on non-stable versions individually. Note this PR also changes the addons API response: `non_latest_version_warning` and `external_version_warning` are combined into `notifications`. I think nobody is using this yet, so I'm not expecting issues with it. Let me know if you think differently here. Required by readthedocs/addons#133 --------- Co-authored-by: Eric Holscher <[email protected]> Co-authored-by: Eric Holscher <[email protected]>
- Loading branch information
1 parent
63f3926
commit 7120315
Showing
11 changed files
with
186 additions
and
40 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
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,26 @@ | ||
Documentation notifications | ||
=========================== | ||
|
||
Documentation notifications alert users to information about the documentation they are viewing. | ||
These notifications can be enabled or disabled by the project maintainer, | ||
and are displayed to the user in the rendered documentation. | ||
|
||
Overview | ||
-------- | ||
|
||
The current notifications are: | ||
|
||
- **Pull request warning**: Show a notification on builds from pull requests, with a link back to the pull request for giving feedback. | ||
- **Latest version warning**: Show a notification on latest version, warning users that they are reading docs from a development version. | ||
- **Non-stable version warning**: Show a notification on non-stable versions, warning users that they are reading docs from a non-stable release. | ||
|
||
Manage notifications | ||
-------------------- | ||
|
||
To manage notifications for your project: | ||
|
||
1. Go to the :term:`dashboard`. | ||
2. Click on a project name. | ||
3. Go to :guilabel:`Settings`. | ||
4. In the left bar, go to :guilabel:`Addons`. | ||
5. Configure each Addon in the :guilabel:`Notifications` section. |
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
80 changes: 80 additions & 0 deletions
80
readthedocs/projects/migrations/0128_addons_notifications.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,80 @@ | ||
# Generated by Django 4.2.16 on 2024-10-29 14:05 | ||
|
||
from django.db import migrations, models | ||
from django_safemigrate import Safe | ||
|
||
|
||
def forward_add_fields(apps, schema_editor): | ||
AddonsConfig = apps.get_model("projects", "AddonsConfig") | ||
for addons in AddonsConfig.objects.filter(project__isnull=False): | ||
addons.notifications_show_on_latest = ( | ||
addons.stable_latest_version_warning_enabled | ||
) | ||
addons.notifications_show_on_non_stable = ( | ||
addons.stable_latest_version_warning_enabled | ||
) | ||
addons.notifications_show_on_external = addons.external_version_warning_enabled | ||
addons.save() | ||
|
||
|
||
def reverse_remove_fields(apps, schema_editor): | ||
AddonsConfig = apps.get_model("projects", "AddonsConfig") | ||
for addons in AddonsConfig.objects.filter(project__isnull=False): | ||
addons.stable_latest_version_warning_enabled = ( | ||
addons.notifications_show_on_latest | ||
or addons.notifications_show_on_non_stable | ||
) | ||
addons.external_version_warning_enabled = addons.notifications_show_on_external | ||
addons.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
safe = Safe.before_deploy | ||
|
||
dependencies = [ | ||
("projects", "0127_default_to_semver"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="addonsconfig", | ||
name="notifications_enabled", | ||
field=models.BooleanField(default=True), | ||
), | ||
migrations.AddField( | ||
model_name="addonsconfig", | ||
name="notifications_show_on_external", | ||
field=models.BooleanField(default=True), | ||
), | ||
migrations.AddField( | ||
model_name="addonsconfig", | ||
name="notifications_show_on_latest", | ||
field=models.BooleanField(default=True), | ||
), | ||
migrations.AddField( | ||
model_name="addonsconfig", | ||
name="notifications_show_on_non_stable", | ||
field=models.BooleanField(default=True), | ||
), | ||
migrations.AddField( | ||
model_name="historicaladdonsconfig", | ||
name="notifications_enabled", | ||
field=models.BooleanField(default=True), | ||
), | ||
migrations.AddField( | ||
model_name="historicaladdonsconfig", | ||
name="notifications_show_on_external", | ||
field=models.BooleanField(default=True), | ||
), | ||
migrations.AddField( | ||
model_name="historicaladdonsconfig", | ||
name="notifications_show_on_latest", | ||
field=models.BooleanField(default=True), | ||
), | ||
migrations.AddField( | ||
model_name="historicaladdonsconfig", | ||
name="notifications_show_on_non_stable", | ||
field=models.BooleanField(default=True), | ||
), | ||
migrations.RunPython(forward_add_fields, reverse_remove_fields), | ||
] |
31 changes: 31 additions & 0 deletions
31
readthedocs/projects/migrations/0129_addons_remove_old_fields.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,31 @@ | ||
# Generated by Django 4.2.16 on 2024-10-29 14:09 | ||
|
||
from django.db import migrations | ||
from django_safemigrate import Safe | ||
|
||
|
||
class Migration(migrations.Migration): | ||
safe = Safe.after_deploy | ||
|
||
dependencies = [ | ||
("projects", "0128_addons_notifications"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="addonsconfig", | ||
name="external_version_warning_enabled", | ||
), | ||
migrations.RemoveField( | ||
model_name="addonsconfig", | ||
name="stable_latest_version_warning_enabled", | ||
), | ||
migrations.RemoveField( | ||
model_name="historicaladdonsconfig", | ||
name="external_version_warning_enabled", | ||
), | ||
migrations.RemoveField( | ||
model_name="historicaladdonsconfig", | ||
name="stable_latest_version_warning_enabled", | ||
), | ||
] |
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
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