forked from enviPath/enviPy
[Enhancement] Refactor of license django model (#187)
Fixes #119 Licenses are now created in the bootstrap management command. To only create the licenses use the command line argument `-ol` or `--only-licenses`. These licenses are then fetched by there `cc_string` when adding a license to a package. Co-authored-by: Liam Brydon <62733830+MyCreativityOutlet@users.noreply.github.com> Co-authored-by: jebus <lorsbach@envipath.com> Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#187 Co-authored-by: liambrydon <lbry121@aucklanduni.ac.nz> Co-committed-by: liambrydon <lbry121@aucklanduni.ac.nz>
This commit is contained in:
@ -1084,9 +1084,7 @@ def package(request, package_uuid):
|
||||
write = request.POST.get("write") == "on"
|
||||
owner = request.POST.get("owner") == "on"
|
||||
|
||||
license = request.POST.get("license")
|
||||
license_link = request.POST.get("license-link")
|
||||
license_image_link = request.POST.get("license-image-link")
|
||||
cc_string = request.POST.get("license")
|
||||
|
||||
if new_package_name:
|
||||
current_package.name = new_package_name
|
||||
@ -1114,24 +1112,15 @@ def package(request, package_uuid):
|
||||
|
||||
PackageManager.update_permissions(current_user, current_package, grantee, max_perm)
|
||||
return redirect(current_package.url)
|
||||
elif license is not None:
|
||||
if license == "no-license":
|
||||
if current_package.license is not None:
|
||||
current_package.license.delete()
|
||||
|
||||
elif cc_string is not None:
|
||||
cc_string = cc_string.strip()
|
||||
if cc_string == "no-license": # Reset the package's license
|
||||
current_package.license = None
|
||||
current_package.save()
|
||||
return redirect(current_package.url)
|
||||
else:
|
||||
if current_package.license is not None:
|
||||
current_package.license.delete()
|
||||
|
||||
license = License()
|
||||
license.link = license_link
|
||||
license.image_link = license_image_link
|
||||
license.save()
|
||||
|
||||
current_package.license = license
|
||||
else: # Get the license and assign it to the package
|
||||
current_package.license = License.objects.get(cc_string=cc_string)
|
||||
current_package.save()
|
||||
|
||||
return redirect(current_package.url)
|
||||
|
||||
Reference in New Issue
Block a user