Skip to content

Commit c20bba5

Browse files
authored
Merge pull request #3812 from learningequality/hotfixes
Merge down hotfixes into unstable
2 parents 6f99aac + 4e120ad commit c20bba5

46 files changed

Lines changed: 809 additions & 961 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

contentcuration/contentcuration/constants/completion_criteria.py

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,53 @@ def _build_validator():
2020
validator = _build_validator()
2121

2222

23+
ALLOWED_MODELS_PER_KIND = {
24+
content_kinds.DOCUMENT: {
25+
completion_criteria.PAGES,
26+
completion_criteria.TIME,
27+
completion_criteria.APPROX_TIME,
28+
completion_criteria.REFERENCE,
29+
},
30+
content_kinds.EXERCISE: {completion_criteria.MASTERY},
31+
content_kinds.HTML5: {
32+
completion_criteria.DETERMINED_BY_RESOURCE,
33+
completion_criteria.TIME,
34+
completion_criteria.APPROX_TIME,
35+
completion_criteria.REFERENCE,
36+
},
37+
content_kinds.H5P: {
38+
completion_criteria.DETERMINED_BY_RESOURCE,
39+
completion_criteria.TIME,
40+
completion_criteria.APPROX_TIME,
41+
completion_criteria.REFERENCE,
42+
},
43+
content_kinds.AUDIO: {
44+
completion_criteria.TIME,
45+
completion_criteria.APPROX_TIME,
46+
completion_criteria.REFERENCE,
47+
},
48+
content_kinds.VIDEO: {
49+
completion_criteria.TIME,
50+
completion_criteria.APPROX_TIME,
51+
completion_criteria.REFERENCE,
52+
},
53+
}
54+
55+
56+
def check_model_for_kind(data, kind):
57+
model = data.get("model")
58+
if kind is None or model is None or kind not in ALLOWED_MODELS_PER_KIND:
59+
return
60+
61+
# validate that content kind is allowed for the completion criteria model
62+
if model not in ALLOWED_MODELS_PER_KIND[kind]:
63+
raise ValidationError(
64+
"Completion criteria model '{}' is invalid for content kind '{}'".format(
65+
model, kind
66+
)
67+
)
68+
69+
2370
def validate(data, kind=None):
2471
"""
2572
:param data: Dictionary of data to validate
@@ -49,16 +96,4 @@ def validate(data, kind=None):
4996
e.error_list.extend(error_descriptions)
5097
raise e
5198

52-
model = data.get("model")
53-
if kind is None or model is None:
54-
return
55-
56-
# validate that content kind is allowed for the completion criteria model
57-
if (model == completion_criteria.PAGES and kind != content_kinds.DOCUMENT) or (
58-
model == completion_criteria.MASTERY and kind != content_kinds.EXERCISE
59-
):
60-
raise ValidationError(
61-
"Completion criteria model '{}' is invalid for content kind '{}'".format(
62-
model, kind
63-
)
64-
)
99+
check_model_for_kind(data, kind)

contentcuration/contentcuration/context_processors.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ def site_variables(request):
2222
"DEBUG": settings.DEBUG,
2323
"LANG_INFO": json_for_parse_from_data(language_globals()),
2424
"LOGGED_IN": not request.user.is_anonymous,
25+
"SENTRY_DSN": settings.SENTRY_DSN,
26+
"SENTRY_ENVIRONMENT": settings.SENTRY_ENVIRONMENT,
27+
"SENTRY_RELEASE": settings.SENTRY_RELEASE,
28+
"SENTRY_ACTIVE": settings.SENTRY_ACTIVE,
2529
}
2630

2731

contentcuration/contentcuration/frontend/channelEdit/__tests__/CurrentTopicView.spec.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,21 @@ function selectNode(wrapper) {
8181
}
8282

8383
describe('CurrentTopicView', () => {
84+
let wrapper;
85+
86+
afterEach(() => {
87+
wrapper && wrapper.destroy();
88+
});
89+
8490
it('smoke test', () => {
8591
const store = storeFactory(STORE_CONFIG);
86-
const wrapper = makeWrapper({ store });
92+
wrapper = makeWrapper({ store });
8793

8894
expect(wrapper.isVueInstance()).toBe(true);
8995
});
9096

9197
describe('for a topic with nodes', () => {
92-
let store, wrapper;
98+
let store;
9399

94100
beforeEach(() => {
95101
global.CHANNEL_EDIT_GLOBAL.channel_id = CHANNEL.id;

contentcuration/contentcuration/frontend/channelEdit/components/edit/ActivityDuration.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
:items="availableNumbers"
2424
:menu-props="menuProps"
2525
:attach="attach"
26+
:rules="minutesRules"
2627
/>
2728
</template>
2829
</DropdownWrapper>
@@ -102,10 +103,7 @@
102103
if (this.audioVideoUpload) {
103104
return false;
104105
}
105-
return (
106-
this.selectedDuration !== DurationDropdownMap.EXACT_TIME &&
107-
this.selectedCompletion === CompletionDropdownMap.completeDuration
108-
);
106+
return this.selectedCompletion === CompletionDropdownMap.completeDuration;
109107
},
110108
showOptionalLabel() {
111109
return this.selectedDuration !== DurationDropdownMap.EXACT_TIME;
@@ -153,8 +151,13 @@
153151
return getShortActivityDurationValidators().map(translateValidator);
154152
} else if (this.selectedDuration === DurationDropdownMap.LONG_ACTIVITY) {
155153
return getLongActivityDurationValidators().map(translateValidator);
154+
} else if (
155+
this.selectedDuration === DurationDropdownMap.EXACT_TIME &&
156+
this.selectedCompletion === CompletionDropdownMap.completeDuration
157+
) {
158+
return getActivityDurationValidators().map(translateValidator);
156159
}
157-
return getActivityDurationValidators().map(translateValidator);
160+
return [];
158161
},
159162
},
160163
created() {

0 commit comments

Comments
 (0)