File tree Expand file tree Collapse file tree 6 files changed +521
-51
lines changed
contentcuration/contentcuration Expand file tree Collapse file tree 6 files changed +521
-51
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,35 @@ def log_lock_time_spent(timespent):
4747 logging .debug ("Spent {} seconds inside an mptt lock" .format (timespent ))
4848
4949
50+ # Fields that are allowed to be overridden on copies coming from a source that the user
51+ # does not have edit rights to.
52+ ALLOWED_OVERRIDES = {
53+ "node_id" ,
54+ "title" ,
55+ "description" ,
56+ "aggregator" ,
57+ "provider" ,
58+ "language_id" ,
59+ "grade_levels" ,
60+ "resource_types" ,
61+ "learning_activities" ,
62+ "accessibility_labels" ,
63+ "categories" ,
64+ "learner_needs" ,
65+ "role" ,
66+ "extra_fields" ,
67+ "suggested_duration" ,
68+ }
69+
70+ EDIT_ALLOWED_OVERRIDES = ALLOWED_OVERRIDES .union ({
71+ "license_id" ,
72+ "license_description" ,
73+ "extra_fields" ,
74+ "copyright_holder" ,
75+ "author" ,
76+ })
77+
78+
5079class CustomContentNodeTreeManager (TreeManager .from_queryset (CustomTreeQuerySet )):
5180 # Added 7-31-2018. We can remove this once we are certain we have eliminated all cases
5281 # where root nodes are getting prepended rather than appended to the tree list.
@@ -262,7 +291,10 @@ def _clone_node(
262291 copy .update (self .get_source_attributes (source ))
263292
264293 if isinstance (mods , dict ):
265- copy .update (mods )
294+ allowed_keys = EDIT_ALLOWED_OVERRIDES if can_edit_source_channel else ALLOWED_OVERRIDES
295+ for key , value in mods .items ():
296+ if key in copy and key in allowed_keys :
297+ copy [key ] = value
266298
267299 # There might be some legacy nodes that don't have these, so ensure they are added
268300 if (
Original file line number Diff line number Diff line change 2727from .testdata import create_studio_file
2828from .testdata import node as create_node
2929from .testdata import slideshow
30+ from .testdata import thumbnail_bytes
3031from contentcuration import models as cc
3132from contentcuration .utils .publish import convert_channel_thumbnail
3233from contentcuration .utils .publish import create_content_database
3940pytestmark = pytest .mark .django_db
4041
4142
42- thumbnail_bytes = b'\x89 PNG\r \n \x1a \n \x00 \x00 \x00 \r IHDR\x00 \x00 \x00 \x01 \x00 \x00 \x00 \x01 \x08 \x06 \x00 \x00 \x00 \x1f \x15 \xc4 \x89 \x00 \x00 \x00 \n IDATx\x9c c\x00 \x01 \x00 \x00 \x05 \x00 \x01 \r \n -\xb4 \x00 \x00 \x00 \x00 IEND\xae B`\x82 ' # noqa E501
43-
44-
4543def description ():
4644 return "" .join (random .sample (string .printable , 20 ))
4745
Original file line number Diff line number Diff line change 2222pytestmark = pytest .mark .django_db
2323
2424
25+ thumbnail_bytes = b'\x89 PNG\r \n \x1a \n \x00 \x00 \x00 \r IHDR\x00 \x00 \x00 \x01 \x00 \x00 \x00 \x01 \x08 \x06 \x00 \x00 \x00 \x1f \x15 \xc4 \x89 \x00 \x00 \x00 \n IDATx\x9c c\x00 \x01 \x00 \x00 \x05 \x00 \x01 \r \n -\xb4 \x00 \x00 \x00 \x00 IEND\xae B`\x82 ' # noqa E501
26+
27+
2528def video ():
2629 """
2730 Create a video content kind entry.
You can’t perform that action at this time.
0 commit comments