Skip to content

Commit

Permalink
Merge pull request #3811 from learningequality/hotfixes
Browse files Browse the repository at this point in the history
Patch release v2022.11.10
  • Loading branch information
bjester authored Nov 14, 2022
2 parents 6d91350 + 4e120ad commit 517a965
Show file tree
Hide file tree
Showing 15 changed files with 105 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,21 @@ function selectNode(wrapper) {
}

describe('CurrentTopicView', () => {
let wrapper;

afterEach(() => {
wrapper && wrapper.destroy();
});

it('smoke test', () => {
const store = storeFactory(STORE_CONFIG);
const wrapper = makeWrapper({ store });
wrapper = makeWrapper({ store });

expect(wrapper.isVueInstance()).toBe(true);
});

describe('for a topic with nodes', () => {
let store, wrapper;
let store;

beforeEach(() => {
global.CHANNEL_EDIT_GLOBAL.channel_id = CHANNEL.id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
</div>
</VFadeTransition>

<VToolbarItems>
<VToolbarItems v-if="!loadingAncestors">
<Menu class="pa-1">
<template #activator="{ on }">
<IconButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<span v-if="canManage && isRicecooker" class="font-weight-bold grey--text subheading">
{{ $tr('apiGenerated') }}
</span>
<VTooltip v-if="canManage" bottom attach="body" lazy>
<VTooltip v-if="!loading && canManage" bottom attach="body" lazy>
<template #activator="{ on }">
<!-- Need to wrap in div to enable tooltip when button is disabled -->
<div style="height: 100%;" v-on="on">
Expand All @@ -82,7 +82,7 @@
</template>
<span>{{ publishButtonTooltip }}</span>
</VTooltip>
<span v-else class="font-weight-bold grey--text subheading">
<span v-else-if="!loading" class="font-weight-bold grey--text subheading">
{{ $tr('viewOnly') }}
</span>
</template>
Expand Down Expand Up @@ -279,6 +279,12 @@
MessageDialog,
},
mixins: [titleMixin],
props: {
loading: {
type: Boolean,
default: false,
},
},
data() {
return {
drawer: false,
Expand Down Expand Up @@ -331,7 +337,9 @@
}
},
showChannelMenu() {
return this.$vuetify.breakpoint.xsOnly || this.canManage || this.isPublished;
return (
!this.loading && (this.$vuetify.breakpoint.xsOnly || this.canManage || this.isPublished)
);
},
viewChannelDetailsLink() {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>

<TreeViewBase @dropToClipboard="handleDropToClipboard">
<TreeViewBase :loading="loading" @dropToClipboard="handleDropToClipboard">
<template v-if="hasStagingTree && canManage" #extension>
<Banner
:value="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,7 @@ export function UPDATE_ASSESSMENTITEM_FROM_INDEXEDDB(state, { id, ...mods }) {
}

export function DELETE_ASSESSMENTITEM(state, assessmentItem) {
Vue.delete(state.assessmentItemsMap[assessmentItem.contentnode], assessmentItem.assessment_id);
if (state.assessmentItemsMap[assessmentItem.contentnode]) {
Vue.delete(state.assessmentItemsMap[assessmentItem.contentnode], assessmentItem.assessment_id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export default {
getPublishTaskForChannel(state) {
return function(channelId) {
return Object.values(state.asyncTasksMap).find(
t => t.channel_id.replace('-', '') === channelId && t.task_name === 'export-channel'
t =>
t.task_name === 'export-channel' &&
t.channel_id &&
t.channel_id.replace('-', '') === channelId
);
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
props: {
items: {
type: Array,
required: true,
default: () => [],
},
max: {
Expand Down
21 changes: 11 additions & 10 deletions contentcuration/contentcuration/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1700,18 +1700,19 @@ def get_details(self, channel_id=None):
"resource_count": node.get("resource_count", 0),
"resource_size": node.get("resource_size", 0),
"includes": for_educators,
"kind_count": node.get("kind_count", []),
"languages": node.get("languages", ""),
"accessible_languages": node.get("accessible_languages", ""),
"licenses": node.get("licenses", ""),
"tags": node.get("tags_list", []),
"copyright_holders": node["copyright_holders"],
"authors": node["authors"],
"aggregators": node["aggregators"],
"providers": node["providers"],
"sample_pathway": pathway,
"kind_count": node.get("kind_count") or [],
"languages": node.get("languages") or [],
"accessible_languages": node.get("accessible_languages") or [],
"licenses": node.get("licenses") or [],
"tags": node.get("tags_list") or [],
"original_channels": original_channels,
"sample_pathway": pathway,
"sample_nodes": sample_nodes,
# source model fields for the below default to an empty string, but can also be null
"authors": list(filter(bool, node["authors"])),
"aggregators": list(filter(bool, node["aggregators"])),
"providers": list(filter(bool, node["providers"])),
"copyright_holders": list(filter(bool, node["copyright_holders"])),
}

# Set cache with latest data
Expand Down
4 changes: 4 additions & 0 deletions contentcuration/contentcuration/tests/test_contentnodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ def test_get_node_details(self):
assert details["resource_count"] > 0
assert details["resource_size"] > 0
assert len(details["kind_count"]) > 0
assert len(details["authors"]) == len([author for author in details["authors"] if author])
assert len(details["aggregators"]) == len([aggregator for aggregator in details["aggregators"] if aggregator])
assert len(details["providers"]) == len([provider for provider in details["providers"] if provider])
assert len(details["copyright_holders"]) == len([holder for holder in details["copyright_holders"] if holder])


class NodeOperationsTestCase(StudioTestCase):
Expand Down
13 changes: 11 additions & 2 deletions contentcuration/contentcuration/utils/sentry.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
from django.conf import settings


def report_exception(exception=None):
def report_exception(exception=None, user=None, contexts=None):
if getattr(settings, "SENTRY_ACTIVE", False):
from sentry_sdk import capture_exception

capture_exception(exception)
scope_args = {
"contexts": contexts
}

if user and not user.is_anonymous:
scope_args["user"] = {
"email": user.email,
}

capture_exception(exception, **scope_args)
10 changes: 5 additions & 5 deletions contentcuration/contentcuration/viewsets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ def create_from_changes(self, changes):
change.update({"errors": serializer.errors})
errors.append(change)
except Exception as e:
log_sync_exception(e)
log_sync_exception(e, user=self.request.user, change=change)
change["errors"] = [str(e)]
errors.append(change)

Expand Down Expand Up @@ -693,7 +693,7 @@ def delete_from_changes(self, changes):
# job done!
pass
except Exception as e:
log_sync_exception(e)
log_sync_exception(e, user=self.request.user, change=change)
change["errors"] = [str(e)]
errors.append(change)
return errors
Expand Down Expand Up @@ -731,7 +731,7 @@ def update_from_changes(self, changes):
change.update({"errors": ValidationError("Not found").detail})
errors.append(change)
except Exception as e:
log_sync_exception(e)
log_sync_exception(e, user=self.request.user, change=change)
change["errors"] = [str(e)]
errors.append(change)
return errors
Expand Down Expand Up @@ -768,7 +768,7 @@ def create_from_changes(self, changes):
try:
self.perform_bulk_create(serializer)
except Exception as e:
log_sync_exception(e)
log_sync_exception(e, user=self.request.user, changes=changes)
for change in changes:
change["errors"] = [str(e)]
errors.extend(changes)
Expand Down Expand Up @@ -807,7 +807,7 @@ def update_from_changes(self, changes):
try:
self.perform_bulk_update(serializer)
except Exception as e:
log_sync_exception(e)
log_sync_exception(e, user=self.request.user, changes=changes)
for change in changes:
change["errors"] = [str(e)]
errors.extend(changes)
Expand Down
4 changes: 2 additions & 2 deletions contentcuration/contentcuration/viewsets/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def publish_from_changes(self, changes):
publish["key"], version_notes=publish.get("version_notes"), language=publish.get("language")
)
except Exception as e:
log_sync_exception(e)
log_sync_exception(e, user=self.request.user, change=publish)
publish["errors"] = [str(e)]
errors.append(publish)
return errors
Expand Down Expand Up @@ -518,7 +518,7 @@ def sync_from_changes(self, changes):
assessment_items=sync.get("assessment_items")
)
except Exception as e:
log_sync_exception(e)
log_sync_exception(e, user=self.request.user, change=sync)
sync["errors"] = [str(e)]
errors.append(sync)
return errors
Expand Down
2 changes: 1 addition & 1 deletion contentcuration/contentcuration/viewsets/sync/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def apply_changes(changes_queryset):
change.applied = True
changed_fields = ("applied",)
except Exception as e:
log_sync_exception(e)
log_sync_exception(e, user=change.created_by, change=change.serialize_to_change_dict())
change.errored = True
change.kwargs["errors"] = [str(e)]
change.save(update_fields=changed_fields)
13 changes: 11 additions & 2 deletions contentcuration/contentcuration/viewsets/sync/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,19 @@ def generate_publish_event(
return event


def log_sync_exception(e):
def log_sync_exception(e, user=None, change=None, changes=None):
# Capture exception and report, but allow sync
# to complete properly.
report_exception(e)

contexts = {}

if change is not None:
contexts["change"] = change

elif changes is not None:
contexts["changes"] = changes

report_exception(e, user=user, contexts=contexts)

# make sure we leave a record in the logs just in case.
logging.error(e)
72 changes: 31 additions & 41 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1605,57 +1605,47 @@
estree-walker "^1.0.1"
picomatch "^2.2.2"

"@sentry/browser@7.11.1":
version "7.11.1"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.11.1.tgz#377d417e833ef54c78a93ef720a742bda5022625"
integrity sha512-k2XHuzPfnm8VJPK5eWd1+Y5VCgN42sLveb8Qxc3prb5PSL416NWMLZaoB7RMIhy430fKrSFiosnm6QDk2M6pbA==
dependencies:
"@sentry/core" "7.11.1"
"@sentry/types" "7.11.1"
"@sentry/utils" "7.11.1"
"@sentry/browser@7.19.0":
version "7.19.0"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.19.0.tgz#ce21544b843d5c4d5dcb9fe9b7ee31c5c4e91f42"
integrity sha512-dWi5VjEwiLb4ofata0UCLdTbXLD1uDUebe9rNSBkHZ3fHF4eap4ZJlu3dYePKB0CKZhZrjzbydimMhaMUNdnug==
dependencies:
"@sentry/core" "7.19.0"
"@sentry/types" "7.19.0"
"@sentry/utils" "7.19.0"
tslib "^1.9.3"

"@sentry/core@7.11.1":
version "7.11.1"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.11.1.tgz#d68e796f3b6428aefd6086a1db00118df7a9a9e4"
integrity sha512-kaDSZ6VNuO4ZZdqUOOX6XM6x+kjo2bMnDQ3IJG51FPvVjr8lXYhXj1Ccxcot3pBYAIWPPby2+vNDOXllmXqoBA==
"@sentry/core@7.19.0":
version "7.19.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.19.0.tgz#74e0eaf4b9f42bb0290f4b3f3b0ea3e272dd693e"
integrity sha512-YF9cTBcAnO4R44092BJi5Wa2/EO02xn2ziCtmNgAVTN2LD31a/YVGxGBt/FDr4Y6yeuVehaqijVVvtpSmXrGJw==
dependencies:
"@sentry/hub" "7.11.1"
"@sentry/types" "7.11.1"
"@sentry/utils" "7.11.1"
"@sentry/types" "7.19.0"
"@sentry/utils" "7.19.0"
tslib "^1.9.3"

"@sentry/[email protected]":
version "7.11.1"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-7.11.1.tgz#1749b2b102ea1892ff388d65d66d3b402b393958"
integrity sha512-M6ClgdXdptS0lUBKB5KpXXe2qMQhsoiEN2pEGRI6+auqhfHCUQB1ZXsfjiOYexKC9fwx7TyFyZ9Jcaf2DTxEhw==
dependencies:
"@sentry/types" "7.11.1"
"@sentry/utils" "7.11.1"
tslib "^1.9.3"

"@sentry/[email protected]":
version "7.11.1"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.11.1.tgz#06e2827f6ba37159c33644208a0453b86d25e232"
integrity sha512-gIEhOPxC2cjrxQ0+K2SFJ1P6e/an5osSxVc9OOtekN28eHtVsXFCLB8XVWeNQnS7N2VkrVrkqORMBz1kvIcvVQ==
"@sentry/[email protected]":
version "7.19.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.19.0.tgz#3ebb96670399b637a945fa499fa7436f7b930147"
integrity sha512-oGRAT6lfzoKrxO1mvxiSj0XHxWPd6Gd1wpPGuu6iJo03xgWDS+MIlD1h2unqL4N5fAzLjzmbC2D2lUw50Kn2pA==

"@sentry/utils@7.11.1":
version "7.11.1"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.11.1.tgz#1635c5b223369d9428bc83c9b8908c9c3287ee10"
integrity sha512-tRVXNT5O9ilkV31pyHeTqA1PcPQfMV/2OR6yUYM4ah+QVISovC0f0ybhByuH5nYg6x/Gsnx1o7pc8L1GE3+O7A==
"@sentry/utils@7.19.0":
version "7.19.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.19.0.tgz#0e039fe57056074c3a5e47bd50d9cb4ac9a6e909"
integrity sha512-2L6lq+c9Ol2uiRxQDdcgoapmHJp24MhMN0gIkn2alSfMJ+ls6bGXzQHx6JAIdoOiwFQXRZHKL9ecfAc8O+vItA==
dependencies:
"@sentry/types" "7.11.1"
"@sentry/types" "7.19.0"
tslib "^1.9.3"

"@sentry/vue@^7.11.1":
version "7.11.1"
resolved "https://registry.yarnpkg.com/@sentry/vue/-/vue-7.11.1.tgz#dc3a1d4868a3400222053465dac154a9e30aedce"
integrity sha512-4RiaMbvGITpKpnzJBixCR874HjYCmK11yt9YRt/rwXE185TKCVyq54h+57l3680WgNz4MU9oI+PF6C/1E/LfXg==
dependencies:
"@sentry/browser" "7.11.1"
"@sentry/core" "7.11.1"
"@sentry/types" "7.11.1"
"@sentry/utils" "7.11.1"
version "7.19.0"
resolved "https://registry.yarnpkg.com/@sentry/vue/-/vue-7.19.0.tgz#3352eb1dac349045c71c522bf12770be310422c0"
integrity sha512-d8voF9B+Dqnn9YiTQaiaNUC7p0dq+UxMWjtVatC9YVR7efgQPyTbgTmw6N4yRmWtlD2Itaspwz7UNZdeCGQbHw==
dependencies:
"@sentry/browser" "7.19.0"
"@sentry/core" "7.19.0"
"@sentry/types" "7.19.0"
"@sentry/utils" "7.19.0"
tslib "^1.9.3"

"@sinclair/typebox@^0.24.1":
Expand Down

0 comments on commit 517a965

Please sign in to comment.