@@ -357,11 +357,15 @@ def set_assigned_tags_from_license_profile(self, request, obj):
357357 self .message_user (request , msg )
358358
359359 def save_model (self , request , obj , form , change ):
360+ # Needs to be set before the `save_model` method call.
361+ if obj .license_profile :
362+ obj .set_usage_policy_from_license_profile ()
363+
360364 if change :
361365 obj_before_save = License .objects .get (id = obj .id )
362366 super ().save_model (request , obj , form , change )
363367 # If a LicenseProfile is set or changed, apply the values of the
364- # this Profile to the license assigned tags.
368+ # Profile to the license assigned tags.
365369 if obj .license_profile and obj .license_profile != obj_before_save .license_profile :
366370 self .set_assigned_tags_from_license_profile (request , obj )
367371 else :
@@ -452,7 +456,7 @@ class LicenseTagHolderBaseAdmin(DataspacedAdmin):
452456 The purpose of this class is to be extended by LicenseProfileAdmin and
453457 LicenseTagGroupAdmin. It's used to add a LicenseTag queryset in the context
454458 of the add and changes views, to display special data (added through
455- javascript ) about tags in the page like text and guidance information.
459+ avascript ) about tags in the page like text and guidance information.
456460 """
457461
458462 change_form_template = "admin/license_library/tag_holder/change_form.html"
@@ -519,11 +523,12 @@ class LicenseProfileAdmin(LicenseTagHolderBaseAdmin):
519523 "name" ,
520524 "get_assigned_tags_html" ,
521525 "examples" ,
526+ "default_usage_policy" ,
522527 "get_dataspace" ,
523528 )
524529 fieldsets = (
525530 ("" , {"fields" : ("name" ,)}),
526- ("" , {"fields" : ("examples" , "notes" , "dataspace" , "uuid" )}),
531+ ("" , {"fields" : ("examples" , "notes" , "default_usage_policy" , " dataspace" , "uuid" )}),
527532 )
528533 search_fields = ("name" ,)
529534 list_filter = DataspacedAdmin .list_filter + (ReportingQueryListFilter ,)
@@ -553,10 +558,6 @@ class LicenseProfileAdmin(LicenseTagHolderBaseAdmin):
553558 will be Unknown." ,
554559 )
555560
556- def get_queryset (self , request ):
557- qs = super ().get_queryset (request )
558- return qs .prefetch_related ("licenseprofileassignedtag_set__license_tag" )
559-
560561
561562@admin .register (LicenseCategory , site = dejacode_site )
562563class LicenseCategoryAdmin (DataspacedAdmin ):
0 commit comments