From bfc0a716372e45bd8d5d5e422f7511e987a84c0f Mon Sep 17 00:00:00 2001 From: Charley Cunningham Date: Mon, 11 Sep 2023 16:54:54 -0400 Subject: [PATCH] Update attribute descriptions on registrarimport, if changed --- backend/courses/util.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/courses/util.py b/backend/courses/util.py index 0ea62b117..24afcbd56 100644 --- a/backend/courses/util.py +++ b/backend/courses/util.py @@ -516,10 +516,15 @@ def add_attributes(course, attributes): course.attributes.clear() for attribute in attributes: school = identify_school(attribute.get("attribute_code")) + desc = attribute.get("attribute_desc") attr, _ = Attribute.objects.get_or_create( code=attribute.get("attribute_code"), - defaults={"description": attribute.get("attribute_desc"), "school": school}, + defaults={"description": desc, "school": school}, ) + if attr.description != desc or attr.school != school: + attr.description = desc + attr.school = school + attr.save() attr.courses.add(course)