-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Allow to change the privacy level of external versions #7825
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
bef3f8b
Allow to change the privacy level of external versions
stsewd d41a8f7
Merge branch 'master' into privacy-level-external-versions
stsewd 010d909
Update docs
stsewd 578838a
Update migration
stsewd b83e7a3
Merge branch 'master' into privacy-level-external-versions
stsewd 4c0be97
Updates
stsewd f37d600
Make default a function and bring querysets
stsewd f322708
Linter
stsewd 02ff1c7
Update tests
stsewd b045ccf
Explicit tests
stsewd 4b12b4c
Explicit tests
stsewd ea574df
save!
stsewd 1c4f9f3
Merge branch 'master' into privacy-level-external-versions
stsewd 8f68ea8
Update migration
stsewd e7436f8
Only filter for non-internal manager
stsewd 01bf545
Add external_only
stsewd 1995775
Merge branch 'master' into privacy-level-external-versions
stsewd 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
25 changes: 25 additions & 0 deletions
25
readthedocs/projects/migrations/0076_add_external_builds_privacy_level_field.py
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,25 @@ | ||
# Generated by Django 2.2.17 on 2021-01-12 22:39 | ||
|
||
from django.db import migrations, models | ||
|
||
import readthedocs.projects.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('projects', '0075_change_mkdocs_name'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='project', | ||
name='external_builds_privacy_level', | ||
field=models.CharField(choices=[('public', 'Public'), ('private', 'Private')], default=readthedocs.projects.models.default_privacy_level, help_text='Should builds from pull requests be public?', max_length=20, null=True, verbose_name='Privacy level of Pull Requests'), | ||
), | ||
migrations.AlterField( | ||
model_name='project', | ||
name='external_builds_enabled', | ||
field=models.BooleanField(default=False, help_text='More information in <a href="https://docs.readthedocs.io/page/guides/autobuild-docs-for-pull-requests.html">our docs</a>', verbose_name='Build pull requests for this project'), | ||
), | ||
] |
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
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
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.
I'm a little worried about performance here -- we're adding a join and a few more queries on all our super common querysets. Can we not just change this on the
external
manager instead?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.
Hmm, maybe, I'll need to take a look at where we are using those managers
readthedocs.org/readthedocs/builds/models.py
Lines 180 to 184 in ea574df
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.
I think we can make this happen only when executing objects and external, as the internal manager already filters them out.
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.
I have used a partial class to pass a parameter indicating if the manager being used is for internal only versions.
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.
@stsewd It seems like it might be cleaner to put this on a
public
method in theExternalVersionManager
instead of on the base VersionQueryset, since it only applies there (eg. we only want to run it onVersion.external.public
, I believe).We should also do the same logic for the other querier (eg. on the
ExternalBuildManager
)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 also want to include this on the default manager, since we do have calls to
Version.objects.public
/Build.objects.public
.And I'm not sure about moving these to the manager, these are more filters, and all of our querysets are there, we would nee to move all of those. I was about to use inheritance instead of the partial, but then we need to create three more classes (parent, InternalQuerysetBase, InternalQueryset(SeetingsOverride)) and one more override in .com :/
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 don't need to worry about filtering external builds on
Version.objects.public
though right? They will already be filtered out, regardless of privacy level?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.
I'm not sure if I understood what you mean 😅.
version.privacy_level
, and external versions are checked againstproject.external_builds_privacy_level
.version.privacy_level
project.external_builds_privacy_level
(for this case we could omit one filter from the current implementation, I'll do that)But anyway, Version.objects.public need to check for both external and internal as that manager is expected to include both types of versions.
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.
Ah yea, I was thinking
Version.internal.public
.