-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Addons: allow users to opt-in into the beta addons #10733
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
Changes from 2 commits
c8b895b
509a17f
4595bd4
b172cc0
339f11d
2c493fc
c666621
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# Generated by Django 4.2.5 on 2023-09-14 09:21 | ||
|
||
import django.db.models.deletion | ||
import django_extensions.db.fields | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("projects", "0105_remove_project_urlconf"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="AddonsConfig", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"created", | ||
django_extensions.db.fields.CreationDateTimeField( | ||
auto_now_add=True, verbose_name="created" | ||
), | ||
), | ||
( | ||
"modified", | ||
django_extensions.db.fields.ModificationDateTimeField( | ||
auto_now=True, verbose_name="modified" | ||
), | ||
), | ||
( | ||
"enabled", | ||
models.BooleanField( | ||
default=True, | ||
help_text="Enable/Disable all the addons on this project", | ||
), | ||
), | ||
("analytics_enabled", models.BooleanField(default=True)), | ||
("doc_diff_enabled", models.BooleanField(default=True)), | ||
("doc_diff_show_additions", models.BooleanField(default=True)), | ||
("doc_diff_show_deletions", models.BooleanField(default=True)), | ||
("doc_diff_root_selector", models.CharField(blank=True, null=True)), | ||
("external_version_warning_enabled", models.BooleanField(default=True)), | ||
("ethicalads_enabled", models.BooleanField(default=True)), | ||
("flyout_enabled", models.BooleanField(default=True)), | ||
("hotkeys_enabled", models.BooleanField(default=True)), | ||
("search_enabled", models.BooleanField(default=True)), | ||
("search_default_filter", models.CharField(blank=True, null=True)), | ||
( | ||
"stable_latest_version_warning_enabled", | ||
models.BooleanField(default=True), | ||
), | ||
( | ||
"project", | ||
models.OneToOneField( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="addons", | ||
to="projects.project", | ||
), | ||
), | ||
], | ||
options={ | ||
"get_latest_by": "modified", | ||
"abstract": False, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name="AddonSearchFilter", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"created", | ||
django_extensions.db.fields.CreationDateTimeField( | ||
auto_now_add=True, verbose_name="created" | ||
), | ||
), | ||
( | ||
"modified", | ||
django_extensions.db.fields.ModificationDateTimeField( | ||
auto_now=True, verbose_name="modified" | ||
), | ||
), | ||
("name", models.CharField(max_length=128)), | ||
("syntaxt", models.CharField(max_length=128)), | ||
( | ||
"addons", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="projects.addonsconfig", | ||
), | ||
), | ||
], | ||
options={ | ||
"get_latest_by": "modified", | ||
"abstract": False, | ||
}, | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,6 +123,72 @@ def subproject_prefix(self): | |
return unsafe_join_url_path(prefix, self.alias, "/") | ||
|
||
|
||
class AddonsConfig(TimeStampedModel): | ||
|
||
""" | ||
Addons project configuration. | ||
|
||
Store all the configuration for each of the addons. | ||
Everything is enabled by default. | ||
""" | ||
|
||
DOC_DIFF_DEFAULT_ROOT_SELECTOR = "[role=main]" | ||
|
||
project = models.OneToOneField( | ||
"Project", | ||
related_name="addons", | ||
null=True, | ||
blank=True, | ||
on_delete=models.CASCADE, | ||
) | ||
|
||
enabled = models.BooleanField( | ||
default=True, | ||
help_text="Enable/Disable all the addons on this project", | ||
) | ||
|
||
# Analytics | ||
analytics_enabled = models.BooleanField(default=True) | ||
|
||
# Docdiff | ||
doc_diff_enabled = models.BooleanField(default=True) | ||
doc_diff_show_additions = models.BooleanField(default=True) | ||
doc_diff_show_deletions = models.BooleanField(default=True) | ||
doc_diff_root_selector = models.CharField(null=True, blank=True) | ||
|
||
# External version warning | ||
external_version_warning_enabled = models.BooleanField(default=True) | ||
|
||
# EthicalAds | ||
ethicalads_enabled = models.BooleanField(default=True) | ||
|
||
# Flyout | ||
flyout_enabled = models.BooleanField(default=True) | ||
|
||
# Hotkeys | ||
hotkeys_enabled = models.BooleanField(default=True) | ||
|
||
# Search | ||
search_enabled = models.BooleanField(default=True) | ||
search_default_filter = models.CharField(null=True, blank=True) | ||
|
||
# Stable/Latest version warning | ||
stable_latest_version_warning_enabled = models.BooleanField(default=True) | ||
|
||
|
||
class AddonSearchFilter(TimeStampedModel): | ||
|
||
""" | ||
Addon search user defined filter. | ||
|
||
Specific filter defined by the user to show on the search modal. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An example or use case here would probably be useful. Is this to allow users to default to subprojects enabled or similar? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can skip it for now if we are not sure how we are going to use this, tho. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't feel too strongly, just wanted to make sure we had a plan for this. I'm fine to include it if we can make the docstring obvious for the user, but perhaps it's better for the next version? 🤷 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Making these filters configurable has been the idea from the beginning of the re-work for the search as you type. However, they are not yet configurable by the user and they won't be in this iteration because it will require more UI. For now, we are only allowing them to opt-in into all the addons at once. In the following iteration we will be exposing specific configuration for each addon and they will be able to create these filters. This PR only creates the models we will use in the future. |
||
""" | ||
|
||
addons = models.ForeignKey("AddonsConfig", on_delete=models.CASCADE) | ||
name = models.CharField(max_length=128) | ||
syntaxt = models.CharField(max_length=128) | ||
|
||
|
||
class Project(models.Model): | ||
|
||
"""Project model.""" | ||
|
Uh oh!
There was an error while loading. Please reload this page.