-
Notifications
You must be signed in to change notification settings - Fork 19
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
[do not merge] restricted runs modeling spike (again) #953
Draft
pwnage101
wants to merge
14
commits into
master
Choose a base branch
from
pwnage101/spike
base: master
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.
Draft
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
72b56bb
todo
pwnage101 8c94294
squash
pwnage101 c3306e2
squash
pwnage101 35c4ead
squash
pwnage101 56ae3aa
squash
pwnage101 767ebd9
squash
pwnage101 204941d
squash
pwnage101 44f9d70
beginnings of v2 views
pwnage101 a44a01d
squash
pwnage101 304c967
squash
pwnage101 ff57cb0
squash
pwnage101 eaa9198
squash
pwnage101 2f8152a
squash
pwnage101 1865ace
squash
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 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
Empty file.
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,37 @@ | ||
""" | ||
URL definitions for enterprise catalog API version 2. | ||
""" | ||
from django.urls import path, re_path | ||
from rest_framework.routers import DefaultRouter | ||
|
||
from enterprise_catalog.apps.api.v2.views.enterprise_catalog_contains_content_items import ( | ||
EnterpriseCatalogContainsContentItemsV2, | ||
) | ||
from enterprise_catalog.apps.api.v2.views.enterprise_catalog_get_content_metadata import ( | ||
EnterpriseCatalogGetContentMetadataV2, | ||
) | ||
from enterprise_catalog.apps.api.v2.views.enterprise_customer import ( | ||
EnterpriseCustomerViewSetV2, | ||
) | ||
|
||
|
||
app_name = 'v2' | ||
|
||
router = DefaultRouter() | ||
router.register(r'enterprise-catalogs', EnterpriseCatalogContainsContentItemsV2, basename='enterprise-catalog-content-v2') | ||
router.register(r'enterprise-customer', EnterpriseCustomerViewSetV2, basename='enterprise-customer-v2') | ||
|
||
urlpatterns = [ | ||
re_path( | ||
r'^enterprise-catalogs/(?P<uuid>[\S]+)/get_content_metadata', | ||
EnterpriseCatalogGetContentMetadataV2.as_view({'get': 'get'}), | ||
name='get-content-metadata-v2' | ||
), | ||
path( | ||
'enterprise-customer/<enterprise_uuid>/content-metadata/<content_identifier>/', | ||
EnterpriseCustomerViewSetV2.as_view({'get': 'content_metadata'}), | ||
name='customer-content-metadata-retrieve-v2' | ||
), | ||
] | ||
|
||
urlpatterns += router.urls |
Empty file.
8 changes: 8 additions & 0 deletions
8
enterprise_catalog/apps/api/v2/views/enterprise_catalog_contains_content_items.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,8 @@ | ||
from enterprise_catalog.apps.api.v1.views.enterprise_catalog_contains_content_items import EnterpriseCatalogContainsContentItems | ||
|
||
|
||
class EnterpriseCatalogContainsContentItemsV2(EnterpriseCatalogContainsContentItems): | ||
""" | ||
View to determine if an enterprise catalog contains certain content | ||
""" | ||
pass |
18 changes: 18 additions & 0 deletions
18
enterprise_catalog/apps/api/v2/views/enterprise_catalog_get_content_metadata.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,18 @@ | ||
from enterprise_catalog.apps.api.v1.views.enterprise_catalog_get_content_metadata import EnterpriseCatalogGetContentMetadata | ||
|
||
|
||
class EnterpriseCatalogGetContentMetadataV2(EnterpriseCatalogGetContentMetadata): | ||
""" | ||
View for retrieving all the content metadata associated with a catalog. | ||
""" | ||
def get_queryset(self, **kwargs): | ||
""" | ||
Returns all of the json of content metadata associated with the catalog. | ||
""" | ||
# Avoids ordering the content metadata by any field on that model to avoid using a temporary table / filesort | ||
queryset = self.enterprise_catalog.content_metadata_with_restricted | ||
content_filter = kwargs.get('content_keys_filter') | ||
if content_filter: | ||
queryset = self.enterprise_catalog.get_matching_content(content_keys=content_filter, include_restricted=True) | ||
|
||
return queryset.order_by('catalog_queries') |
10 changes: 10 additions & 0 deletions
10
enterprise_catalog/apps/api/v2/views/enterprise_customer.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,10 @@ | ||
from enterprise_catalog.apps.api.v1.views.enterprise_customer import EnterpriseCustomerViewSet | ||
|
||
|
||
class EnterpriseCustomerViewSetV2(EnterpriseCustomerViewSet): | ||
""" | ||
Viewset for operations on enterprise customers. | ||
|
||
Although we don't have a specific EnterpriseCustomer model, this viewset handles operations that use an enterprise | ||
identifier to perform operations on their associated catalogs, etc. | ||
""" |
58 changes: 58 additions & 0 deletions
58
enterprise_catalog/apps/catalog/migrations/0040_restrictedcoursemetadata_and_more.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,58 @@ | ||
# Generated by Django 4.2.16 on 2024-10-01 19:40 | ||
|
||
import collections | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django.utils.timezone | ||
import jsonfield.encoder | ||
import jsonfield.fields | ||
import model_utils.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('catalog', '0039_alter_catalogquery_unique_together_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='RestrictedCourseMetadata', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')), | ||
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')), | ||
('content_uuid', models.UUIDField(blank=True, help_text='The UUID that represents a piece of content. This value is usually a secondary identifier to content_key in the enterprise environment.', null=True, verbose_name='Content UUID')), | ||
('content_type', models.CharField(choices=[('course', 'Course'), ('courserun', 'Course Run'), ('program', 'Program'), ('learnerpathway', 'Learner Pathway')], max_length=255)), | ||
('parent_content_key', models.CharField(blank=True, db_index=True, help_text="The key represents this content's parent. For example for course_runs content their parent course key.", max_length=255, null=True)), | ||
('_json_metadata', jsonfield.fields.JSONField(blank=True, default={}, dump_kwargs={'cls': jsonfield.encoder.JSONEncoder, 'indent': 4, 'separators': (',', ':')}, help_text="The metadata about a particular piece content as retrieved from the discovery service's search/all endpoint results, specified as a JSON object.", load_kwargs={'object_pairs_hook': collections.OrderedDict}, null=True)), | ||
('content_key', models.CharField(help_text='The key that represents a piece of content, such as a course, course run, or program.', max_length=255)), | ||
], | ||
options={ | ||
'verbose_name': 'Restricted Content Metadata', | ||
'verbose_name_plural': 'Restricted Content Metadata', | ||
}, | ||
), | ||
migrations.RenameField( | ||
model_name='contentmetadata', | ||
old_name='json_metadata', | ||
new_name='_json_metadata', | ||
), | ||
migrations.AlterField( | ||
model_name='catalogquery', | ||
name='content_filter', | ||
field=jsonfield.fields.JSONField(default=dict, dump_kwargs={'cls': jsonfield.encoder.JSONEncoder, 'ensure_ascii': False, 'indent': 4, 'separators': (',', ':')}, help_text="Query parameters which will be used to filter the discovery service's search/all endpoint results, specified as a JSON object.", load_kwargs={'object_pairs_hook': collections.OrderedDict}), | ||
), | ||
migrations.DeleteModel( | ||
name='HistoricalContentMetadata', | ||
), | ||
migrations.AddField( | ||
model_name='restrictedcoursemetadata', | ||
name='catalog_query', | ||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='restricted_content_metadata', to='catalog.catalogquery'), | ||
), | ||
migrations.AlterUniqueTogether( | ||
name='restrictedcoursemetadata', | ||
unique_together={('content_key', 'catalog_query')}, | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
enterprise_catalog/apps/catalog/migrations/0041_contentmetadata_is_restricted_run.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,18 @@ | ||
# Generated by Django 4.2.16 on 2024-10-01 20:01 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('catalog', '0040_restrictedcoursemetadata_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='contentmetadata', | ||
name='is_restricted_run', | ||
field=models.BooleanField(default=False, help_text='If true, cause this run to be included in various v2 endpoints.'), | ||
), | ||
] |
19 changes: 19 additions & 0 deletions
19
...rise_catalog/apps/catalog/migrations/0042_restrictedcoursemetadata_unrestricted_parent.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,19 @@ | ||
# Generated by Django 4.2.16 on 2024-10-01 20:34 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('catalog', '0041_contentmetadata_is_restricted_run'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='restrictedcoursemetadata', | ||
name='unrestricted_parent', | ||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='restricted_courses', to='catalog.contentmetadata'), | ||
), | ||
] |
Oops, something went wrong.
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.
This is what makes it so that the name of the field in the database doesn't actually change, but the reference to it in django is renamed.