only admin can publish
@@ -916,10 +916,8 @@ def create_new_version_resource_public(request, pk):
def publish(request, shortkey, *args, **kwargs):
- # TODO: drc only HIL admin approver should be able to publish, not even the owner!
- # only resource owners are allowed to change resource flags (e.g published)
- res, _, _ = authorize(request, shortkey, needed_permission=ACTION_TO_AUTHORIZE.SET_RESOURCE_FLAG)
-
+ if not request.user.is_superuser:
+ raise ValidationError("Resource can only be published by an admin user")
try:
hydroshare.publish_resource(request.user, shortkey)
except ValidationError as exp:
@@ -1674,8 +1672,12 @@ def metadata_review(request, uidb36, token, shortkey, action, **kwargs):
messages.error(request, "The link you clicked has expired. Please manually navigate to the resouce "
"to complete the metadata review.")
else:
- # TODO: drc, allow if request.user.is_superuser
- # TODO: drc actually publish the resource and send emai notifying requestor
+ res = get_resource_by_shortkey(shortkey)
+ res.raccess.review_pending = False
+ res.raccess.save()
+ if action == "approve":
+ hydroshare.publish_resource(user, shortkey)
+ # TODO: drc email to requestor confirming?
# user.uaccess.act_on_group_membership_request(membership_request, accept_request=True)
# auth_login(request, user)
@@ -1690,12 +1692,6 @@ def metadata_review(request, uidb36, token, shortkey, action, **kwargs):
# messages.info(request, message)
# redirect to group profile page
# return HttpResponseRedirect('/group/{}/'.format(membership_request.group_to_join.id))
- res = get_resource_by_shortkey(shortkey)
- res.raccess.review_pending = False
- res.raccess.save()
- if action == "approve":
- hydroshare.publish_resource(user, shortkey)
- # TODO: email to requestor confirming?
return redirect("/")
