openedx-learning 0.12.0__py2.py3-none-any.whl → 0.13.0__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  """
2
2
  Open edX Learning ("Learning Core").
3
3
  """
4
- __version__ = "0.12.0"
4
+ __version__ = "0.13.0"
@@ -0,0 +1,27 @@
1
+ """
2
+ Django Admin pages for Collection models.
3
+ """
4
+ from django.contrib import admin
5
+
6
+ from .models import Collection
7
+
8
+
9
+ class CollectionAdmin(admin.ModelAdmin):
10
+ """
11
+ The Collection model admin.
12
+
13
+ Allows users to easily disable/enable (aka soft delete and restore) or bulk delete Collections.
14
+ """
15
+ readonly_fields = ["key", "learning_package"]
16
+ list_filter = ["enabled"]
17
+ list_display = ["key", "title", "enabled", "modified"]
18
+ list_editable = ["enabled"]
19
+
20
+ def has_add_permission(self, request, *args, **kwargs):
21
+ """
22
+ Disallow adding new collections via Django Admin.
23
+ """
24
+ return False # pragma: no cover
25
+
26
+
27
+ admin.site.register(Collection, CollectionAdmin)
@@ -20,10 +20,12 @@ from .models import Collection
20
20
  __all__ = [
21
21
  "add_to_collection",
22
22
  "create_collection",
23
+ "delete_collection",
23
24
  "get_collection",
24
25
  "get_collections",
25
26
  "get_entity_collections",
26
27
  "remove_from_collection",
28
+ "restore_collection",
27
29
  "update_collection",
28
30
  ]
29
31
 
@@ -84,6 +86,42 @@ def update_collection(
84
86
  return collection
85
87
 
86
88
 
89
+ def delete_collection(
90
+ learning_package_id: int,
91
+ key: str,
92
+ *,
93
+ hard_delete=False,
94
+ ) -> Collection:
95
+ """
96
+ Disables or deletes a collection identified by the given learning_package + key.
97
+
98
+ By default (hard_delete=False), the collection is "soft deleted", i.e disabled.
99
+ Soft-deleted collections can be re-enabled using restore_collection.
100
+ """
101
+ collection = get_collection(learning_package_id, key)
102
+
103
+ if hard_delete:
104
+ collection.delete()
105
+ else:
106
+ collection.enabled = False
107
+ collection.save()
108
+ return collection
109
+
110
+
111
+ def restore_collection(
112
+ learning_package_id: int,
113
+ key: str,
114
+ ) -> Collection:
115
+ """
116
+ Undo a "soft delete" by re-enabling a Collection.
117
+ """
118
+ collection = get_collection(learning_package_id, key)
119
+
120
+ collection.enabled = True
121
+ collection.save()
122
+ return collection
123
+
124
+
87
125
  def add_to_collection(
88
126
  learning_package_id: int,
89
127
  key: str,
@@ -42,6 +42,7 @@ __all__ = [
42
42
  "get_component_by_uuid",
43
43
  "get_component_version_by_uuid",
44
44
  "component_exists_by_key",
45
+ "get_collection_components",
45
46
  "get_components",
46
47
  "create_component_version_content",
47
48
  "look_up_component_version_content",
@@ -339,6 +340,21 @@ def get_components(
339
340
  return qset
340
341
 
341
342
 
343
+ def get_collection_components(
344
+ learning_package_id: int,
345
+ collection_key: str,
346
+ ) -> QuerySet[Component]:
347
+ """
348
+ Returns a QuerySet of Components relating to the PublishableEntities in a Collection.
349
+
350
+ Components have a one-to-one relationship with PublishableEntity, but the reverse may not always be true.
351
+ """
352
+ return Component.objects.filter(
353
+ learning_package_id=learning_package_id,
354
+ publishable_entity__collections__key=collection_key,
355
+ ).order_by('pk')
356
+
357
+
342
358
  def look_up_component_version_content(
343
359
  learning_package_key: str,
344
360
  component_key: str,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: openedx-learning
3
- Version: 0.12.0
3
+ Version: 0.13.0
4
4
  Summary: Open edX Learning Core and Tagging.
5
5
  Home-page: https://github.com/openedx/openedx-learning
6
6
  Author: David Ormsbee
@@ -18,11 +18,11 @@ Classifier: Programming Language :: Python :: 3.11
18
18
  Classifier: Programming Language :: Python :: 3.12
19
19
  Requires-Python: >=3.11
20
20
  License-File: LICENSE.txt
21
- Requires-Dist: celery
22
21
  Requires-Dist: Django<5.0
23
- Requires-Dist: djangorestframework<4.0
24
- Requires-Dist: rules<4.0
25
22
  Requires-Dist: edx-drf-extensions
23
+ Requires-Dist: celery
24
+ Requires-Dist: rules<4.0
25
+ Requires-Dist: djangorestframework<4.0
26
26
  Requires-Dist: attrs
27
27
 
28
28
  Open edX Learning Core (and Tagging)
@@ -1,4 +1,4 @@
1
- openedx_learning/__init__.py,sha256=A3F2eIt1aRYsY0WQV1upYl-XM-eKJqIdLO55kEcvNuc,68
1
+ openedx_learning/__init__.py,sha256=-YYutFGkUCqVYEkmZ-RWMqx_I_OYmVPZ95MLLscQ9ZE,68
2
2
  openedx_learning/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  openedx_learning/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  openedx_learning/api/authoring.py,sha256=vbRpiQ2wOfN3oR2bbN0-bI2ra0QRtha9tVixKW1ENis,929
@@ -6,7 +6,8 @@ openedx_learning/api/authoring_models.py,sha256=PrhEYozI7nzC7N1v_sP1QgjwjRvLX6it
6
6
  openedx_learning/apps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  openedx_learning/apps/authoring/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  openedx_learning/apps/authoring/collections/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- openedx_learning/apps/authoring/collections/api.py,sha256=8jNn_S43JqWIGWyDvR7McxGJ-3TboibdHF3LWyQMFWE,4978
9
+ openedx_learning/apps/authoring/collections/admin.py,sha256=ErQ4rGUFgBQ1z62o2RHMenpebe8l47Na51yZGnUZR3Y,713
10
+ openedx_learning/apps/authoring/collections/api.py,sha256=Lui-9mvlUjXSfCcaHrYJc2y2aJ1obJPCIp5hvxYwnkI,5894
10
11
  openedx_learning/apps/authoring/collections/apps.py,sha256=67imy9vnyXml4cfLNGFJhuZr2yx1q92-xz4ih3yJgNU,416
11
12
  openedx_learning/apps/authoring/collections/models.py,sha256=YAwDf8igFbs8Fox3QpbkzBOvYL39cBsRdelxlXx6IYs,8545
12
13
  openedx_learning/apps/authoring/collections/migrations/0001_initial.py,sha256=xcJoqMLROW9FTILYrz6UsyotVu9wBN5tRBwRoAWG6dg,1496
@@ -16,7 +17,7 @@ openedx_learning/apps/authoring/collections/migrations/0004_collection_key.py,sh
16
17
  openedx_learning/apps/authoring/collections/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
18
  openedx_learning/apps/authoring/components/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
19
  openedx_learning/apps/authoring/components/admin.py,sha256=QE7e76C6X2V1AQPxQe6SayQPfCMmbs4RZPEPIGcvTWw,4672
19
- openedx_learning/apps/authoring/components/api.py,sha256=FXYUUL6Q-MdsH78WKr9yRftJ9YcP5YfGDlJIIUT2zeA,21878
20
+ openedx_learning/apps/authoring/components/api.py,sha256=uIgJYLV6jfazt8rZgtKwhTKpgHhFurLwAfHL1cUMH9I,22410
20
21
  openedx_learning/apps/authoring/components/apps.py,sha256=YoYPsI9gcleA3uEs8CiLIrjUncRMo2DKbYt4mDfzePg,770
21
22
  openedx_learning/apps/authoring/components/models.py,sha256=T-wc7vxaWMlulQmMsVH7m6Pd857P3Eguo0vtflTLURI,13415
22
23
  openedx_learning/apps/authoring/components/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -108,8 +109,8 @@ openedx_tagging/core/tagging/rest_api/v1/serializers.py,sha256=gbvEBLvsmfPc3swWz
108
109
  openedx_tagging/core/tagging/rest_api/v1/urls.py,sha256=dNUKCtUCx_YzrwlbEbpDfjGVQbb2QdJ1VuJCkladj6E,752
109
110
  openedx_tagging/core/tagging/rest_api/v1/views.py,sha256=ZRkSILdb8g5k_BcuuVVfdffEdY9vFQ_YtMa3JrN0Xz8,35581
110
111
  openedx_tagging/core/tagging/rest_api/v1/views_import.py,sha256=kbHUPe5A6WaaJ3J1lFIcYCt876ecLNQfd19m7YYub6c,1470
111
- openedx_learning-0.12.0.dist-info/LICENSE.txt,sha256=QTW2QN7q3XszgUAXm9Dzgtu5LXYKbR1SGnqMa7ufEuY,35139
112
- openedx_learning-0.12.0.dist-info/METADATA,sha256=QwEYCY9OeCr03fC0GgdLy7eEpptZEaVFx1KcR8JoYeI,8777
113
- openedx_learning-0.12.0.dist-info/WHEEL,sha256=muXAwoPanksrVvf9Mcykr8l6Q0JyBrGUVYr50kE4bxo,109
114
- openedx_learning-0.12.0.dist-info/top_level.txt,sha256=IYFbr5mgiEHd-LOtZmXj3q3a0bkGK1M9LY7GXgnfi4M,33
115
- openedx_learning-0.12.0.dist-info/RECORD,,
112
+ openedx_learning-0.13.0.dist-info/LICENSE.txt,sha256=QTW2QN7q3XszgUAXm9Dzgtu5LXYKbR1SGnqMa7ufEuY,35139
113
+ openedx_learning-0.13.0.dist-info/METADATA,sha256=U_D0d38me8joSRyJDRbjsbeBK8uB2dlH2RokRkGVS9s,8777
114
+ openedx_learning-0.13.0.dist-info/WHEEL,sha256=muXAwoPanksrVvf9Mcykr8l6Q0JyBrGUVYr50kE4bxo,109
115
+ openedx_learning-0.13.0.dist-info/top_level.txt,sha256=IYFbr5mgiEHd-LOtZmXj3q3a0bkGK1M9LY7GXgnfi4M,33
116
+ openedx_learning-0.13.0.dist-info/RECORD,,