Skip to content

Commit

Permalink
Merge pull request #6858 from Ana06/api_obj
Browse files Browse the repository at this point in the history
 Get rid of api_obj
  • Loading branch information
coolo committed Jan 28, 2019
2 parents df1ea65 + 97200ac commit 8f893e2
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 16 deletions.
3 changes: 1 addition & 2 deletions src/api/app/controllers/webui/package_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def show
@srcmd5 = params[:srcmd5]
@revision_parameter = params[:rev]

@bugowners_mail = (@package.bugowner_emails + @project.api_obj.bugowner_emails).uniq
@bugowners_mail = (@package.bugowner_emails + @project.bugowner_emails).uniq
@revision = params[:rev]
@failures = 0

Expand Down Expand Up @@ -540,7 +540,6 @@ def check_package_name_for_new
redirect_to controller: :project, action: :new_package, project: @project
return false
end
@project = @project.api_obj
unless User.current.can_create_package_in?(@project)
flash[:error] = "You can't create packages in #{@project.name}"
redirect_to controller: :project, action: :new_package, project: @project
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/webui/project_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ def monitor_set_filter(defaults)
@avail_arch_values = []
@avail_repo_values = []

@project.api_obj.repositories.each do |r|
@project.repositories.each do |r|
@avail_repo_values << r.name
@avail_arch_values << r.architectures.pluck(:name)
end
Expand Down
6 changes: 3 additions & 3 deletions src/api/app/helpers/webui/project_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ def show_status_comment(comment, package, firstfail, comments_to_clear)
# TODO: Port _to_remote helpers to jQuery
status_comment_html = ERB::Util.h(comment)
if !firstfail
if User.current.can_modify?(@project.api_obj)
if User.current.can_modify?(@project)
status_comment_html += ' '.html_safe + link_to(image_tag('comment_delete.png', size: '16x16', alt: 'Clear'),
{ action: :clear_failed_comment, project: @project,
package: package, update: valid_xml_id("comment_#{package}") },
remote: true)
comments_to_clear << package
end
elsif User.current.can_modify?(@project.api_obj)
elsif User.current.can_modify?(@project)
status_comment_html += ' '.html_safe
status_comment_html += link_to(image_tag('comment_edit.png', alt: 'Edit'),
{ action: 'edit_comment_form', comment: comment,
Expand All @@ -37,7 +37,7 @@ def show_status_comment(comment, package, firstfail, comments_to_clear)
remote: true)
end
elsif firstfail
if User.current.can_modify?(@project.api_obj)
if User.current.can_modify?(@project)
status_comment_html += " <span class='unknown_failure'>Unknown build failure ".html_safe +
link_to(image_tag('comment_edit.png', size: '16x16', alt: 'Edit'),
{ action: 'edit_comment_form', comment: '', package: package,
Expand Down
4 changes: 0 additions & 4 deletions src/api/app/models/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1370,10 +1370,6 @@ def fixtures_name
"#{project.name}_#{name}".tr(':', '_')
end

def api_obj
self
end

#### WARNING: these operations run in build object, not this package object
def rebuild(params)
backend_build_command(:rebuild, params[:project], params.slice(:package, :arch, :repository))
Expand Down
4 changes: 0 additions & 4 deletions src/api/app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1587,10 +1587,6 @@ def has_remote_repositories?
DownloadRepository.where(repository_id: repositories.select(:id)).exists?
end

def api_obj
self
end

def to_s
name
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- if comment
= h(comment)
- if User.current.can_modify?(project.api_obj)
- if User.current.can_modify?(project)
- if editable
= link_to(edit_comment_form_path(project: project, package: package_name, comment: comment), remote: true, title: 'Edit Comment') do
%i.fas.fa-edit.text-secondary
Expand All @@ -10,6 +10,6 @@
- elsif editable
%span.unknown_failure
Unknown build failure
- if User.current.can_modify?(project.api_obj)
- if User.current.can_modify?(project)
= link_to(edit_comment_form_path(project: project, package: package_name, comment: ''), remote: true, title: 'Edit Comment') do
%i.fas.fa-edit.text-secondary

0 comments on commit 8f893e2

Please sign in to comment.