-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[api] additional route with extra owner ship informations for the web…
…ui only.
- Loading branch information
1 parent
cca842c
commit 54c4084
Showing
6 changed files
with
195 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
|
||
module SearchHelper | ||
|
||
def search_owner(params, obj) | ||
params[:attribute] ||= "OBS:OwnerRootProject" | ||
at = AttribType.find_by_name(params[:attribute]) | ||
unless at | ||
render_error :status => 404, :errorcode => "unknown_attribute_type", | ||
:message => "Attribute Type #{params[:attribute]} does not exist" | ||
return | ||
end | ||
|
||
limit = params[:limit] || 1 | ||
|
||
projects = [] | ||
if params[:project] | ||
# default project specified | ||
projects = [Project.get_by_name(params[:project])] | ||
else | ||
# Find all marked projects | ||
projects = Project.find_by_attribute_type(at) | ||
unless projects.length > 0 | ||
render_error :status => 400, :errorcode => "attribute_not_set", | ||
:message => "The attribute type #{params[:attribute]} is not set on any projects. No default projects defined." | ||
return | ||
end | ||
end | ||
|
||
# search in each marked project | ||
owners = [] | ||
projects.each do |project| | ||
|
||
attrib = project.attribs.where(attrib_type_id: at.id).first | ||
filter = ["maintainer","bugowner"] | ||
devel = true | ||
if params[:filter] | ||
filter=params[:filter].split(",") | ||
else | ||
if attrib and v=attrib.values.where(value: "BugownerOnly").first | ||
filter=["bugowner"] | ||
end | ||
end | ||
if params[:devel] | ||
devel=false if [ "0", "false" ].include? params[:devel] | ||
else | ||
if attrib and v=attrib.values.where(value: "DisableDevel").first | ||
devel=false | ||
end | ||
end | ||
|
||
if obj.nil? | ||
owners = project.find_containers_without_definition(devel, filter) | ||
elsif obj.class == String | ||
owners = project.find_assignees(obj, limit.to_i, devel, filter) | ||
else | ||
owners = project.find_containers(obj, limit.to_i, devel, filter) | ||
end | ||
|
||
end | ||
|
||
return owners | ||
end | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
xml.collection do | ||
@owners.each do |o| | ||
|
||
attribs={} | ||
attribs[:rootproject] = o[:rootproject] | ||
attribs[:project] = o[:project] | ||
attribs[:package] = o[:package] if o[:package] | ||
xml.owner(attribs) do | ||
|
||
roles = [] | ||
roles += o[:users].keys if o[:users] | ||
roles += o[:groups].keys if o[:groups] | ||
|
||
roles.each do |role| | ||
if o[:users] and o[:users][role] | ||
o[:users][role].each do |user| | ||
u = User.find_by_login user | ||
xml.person do | ||
xml.login user | ||
xml.email u.email | ||
xml.realname u.realname | ||
end | ||
end | ||
end | ||
if o[:groups] and o[:groups][role] | ||
o[:groups][role].each do |group| | ||
xml.group | ||
xml.name group | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters