Skip to content

Commit

Permalink
[webui] Remove read_patchinfo from the routes
Browse files Browse the repository at this point in the history
Move read_patchinfo method to private section, and remove it from the
routes as it is not used.
  • Loading branch information
eduardoj committed Jun 5, 2018
1 parent 468a705 commit 1a1814d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 51 deletions.
100 changes: 50 additions & 50 deletions src/api/app/controllers/webui/patchinfo_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,56 +50,6 @@ def show
@packager = User.where(login: @packager).first
end

def read_patchinfo
@binaries = []
@file.each(:binary) do |binaries|
@binaries << binaries.text
end
@binary = []
@packager = @file.value(:packager)
@version = @file.value(:version)

if params[:issueid]
@issues = params[:issue].to_a << params[:issueid]
else
@issues = []
@file.each(:issue) do |a|
if a.text == ''
# old uploaded patchinfos could have broken tracker-names like "bnc "
# instead of "bnc". Catch these.
begin
a.text = get_issue_sum(a.value(:tracker), a.value(:id))
rescue ActiveXML::Transport::NotFoundError
a.text = 'PLEASE CHECK THE FORMAT OF THE ISSUE'
end
end

issueurl = IssueTracker.find_by_name(a.value(:tracker)).
try(:show_url_for, a.value(:id)).to_s

@issues << [
a.value(:tracker),
a.value(:id),
issueurl,
a.text
]
end
end
@category = @file.value(:category)
@rating = @file.value(:rating)
@summary = @file.value(:summary)
@name = @file.value(:name)

@description = @file.value(:description)
@message = @file.value(:message)
@relogin = @file.has_element?('relogin_needed')
@reboot = @file.has_element?('reboot_needed')
@zypp_restart_needed = @file.has_element?('zypp_restart_needed')
return unless @file.has_element?('stopped')
@block = true
@block_reason = @file.value(:stopped)
end

def save
flash[:error] = nil
# Note: At this point a patchinfo already got created by
Expand Down Expand Up @@ -267,6 +217,56 @@ def new_tracker

private

def read_patchinfo
@binaries = []
@file.each(:binary) do |binaries|
@binaries << binaries.text
end
@binary = []
@packager = @file.value(:packager)
@version = @file.value(:version)

if params[:issueid]
@issues = params[:issue].to_a << params[:issueid]
else
@issues = []
@file.each(:issue) do |a|
if a.text == ''
# old uploaded patchinfos could have broken tracker-names like "bnc "
# instead of "bnc". Catch these.
begin
a.text = get_issue_sum(a.value(:tracker), a.value(:id))
rescue ActiveXML::Transport::NotFoundError
a.text = 'PLEASE CHECK THE FORMAT OF THE ISSUE'
end
end

issueurl = IssueTracker.find_by_name(a.value(:tracker)).
try(:show_url_for, a.value(:id)).to_s

@issues << [
a.value(:tracker),
a.value(:id),
issueurl,
a.text
]
end
end
@category = @file.value(:category)
@rating = @file.value(:rating)
@summary = @file.value(:summary)
@name = @file.value(:name)

@description = @file.value(:description)
@message = @file.value(:message)
@relogin = @file.has_element?('relogin_needed')
@reboot = @file.has_element?('reboot_needed')
@zypp_restart_needed = @file.has_element?('zypp_restart_needed')
return unless @file.has_element?('stopped')
@block = true
@block_reason = @file.value(:stopped)
end

def valid_summary?(name)
name && name.length > 10
end
Expand Down
1 change: 0 additions & 1 deletion src/api/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ def self.public_or_about_path?(request)
post 'patchinfo/updatepatchinfo' => :updatepatchinfo
get 'patchinfo/edit_patchinfo' => :edit_patchinfo
get 'patchinfo/show/:project/:package' => :show, as: 'patchinfo_show', constraints: cons, defaults: { format: 'html' }
get 'patchinfo/read_patchinfo' => :read_patchinfo
post 'patchinfo/save/:project/:package' => :save, constraints: cons, as: :patchinfo_save
post 'patchinfo/remove' => :remove
get 'patchinfo/new_tracker' => :new_tracker
Expand Down

0 comments on commit 1a1814d

Please sign in to comment.