Skip to content

Commit

Permalink
[api] allow revoke of requests when source project got locked, cleanu…
Browse files Browse the repository at this point in the history
…p double code
  • Loading branch information
adrianschroeter committed Mar 27, 2012
1 parent 353f697 commit da810d6
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/api/app/controllers/request_controller.rb
Expand Up @@ -1268,16 +1268,6 @@ def command_changestate
target_package = target_project.db_packages.find_by_name(action.source.package)
end
end
if source_project and req.state.name == "new" and params[:newstate] == "revoked" and not permission_granted
# source project owners should be able to revoke submit requests as well
source_package = source_project.db_packages.find_by_name(action.source.package)
if ( source_package and not @http_user.can_modify_package? source_package ) or
( not source_package and not @http_user.can_modify_project? source_project )
render_error :status => 403, :errorcode => "post_request_no_permission",
:message => "No permission to revoke request #{req.id} (type #{action.value('type')})"
return
end
end

elsif [ "delete", "add_role", "set_bugowner" ].include? action.value("type")
# target must exist
Expand Down Expand Up @@ -1305,8 +1295,8 @@ def command_changestate
end

# general source write permission check (for revoke)
if ( source_package and @http_user.can_modify_package? source_package ) or
( not source_package and source_project and @http_user.can_modify_project? source_project )
if ( source_package and @http_user.can_modify_package?(source_package,true) ) or
( not source_package and source_project and @http_user.can_modify_project?(source_project,true) )
write_permission_in_some_source = true
end

Expand Down

0 comments on commit da810d6

Please sign in to comment.