Fix group deletion for config variables

This commit is contained in:
Finn Stutzenstein 2020-11-24 13:43:05 +01:00
parent 26e414e3d1
commit f609e6362f
No known key found for this signature in database
GPG Key ID: 9042F605C6324654
4 changed files with 19 additions and 4 deletions

View File

@ -159,9 +159,13 @@ export class HttpService {
} else {
const errorList = Object.keys(e.error).map(key => {
const capitalizedKey = key.charAt(0).toUpperCase() + key.slice(1);
return `${this.translate.instant(capitalizedKey)}: ${this.processErrorDetailResponse(
e.error[key]
)}`;
let detail = e.error[key];
if (detail instanceof Array) {
detail = detail.join(' ');
} else {
detail = this.processErrorDetailResponse(detail);
}
return `${this.translate.instant(capitalizedKey)}: ${detail}`;
});
error = errorList.join(', ');
}

View File

@ -346,7 +346,7 @@ export class AssignmentDetailComponent extends BaseViewComponentDirective implem
...this.assignmentPollService.getDefaultPollData(this.assignment.id)
};
this.pollDialog.openDialog(dialogData);
this.pollDialog.openDialog(dialogData).catch(this.raiseError);
}
/**

View File

@ -256,6 +256,16 @@ class ConfigHandler:
"""
return ConfigStore.get_collection_string()
def remove_group_id_from_all_group_configs(self, id: int) -> None:
for config_variable in self.config_variables.values():
if config_variable.input_type == "groups":
value = self[config_variable.name]
if isinstance(value, list) and id in value:
value = [x for x in value if x != id]
db_value = ConfigStore.objects.get(key=config_variable.name)
db_value.value = value
db_value.save()
config = ConfigHandler()
"""

View File

@ -657,6 +657,7 @@ class GroupViewSet(ModelViewSet):
# Delete the group
self.perform_destroy(instance)
config.remove_group_id_from_all_group_configs(instance.id)
# Get the updated user data from the DB.
affected_users = User.objects.filter(pk__in=affected_users_ids)