Class: Debci::SelfService

Inherits:
AuthApp
  • Object
show all
Includes:
HTMLHelpers, TestHandler, Validators::APTSource
Defined in:
lib/debci/self_service.rb

Defined Under Namespace

Classes: InvalidRequest

Constant Summary

Constants included from HTMLHelpers

HTMLHelpers::ICONS

Instance Method Summary collapse

Methods included from Validators::APTSource

#invalid_extra_apt_sources

Methods included from HTMLHelpers

#expand_pin_packages, #expand_url, #file_link, #history_url, #icon, #package_url, #title_test_trigger_pin

Methods included from TestHandler

#enqueue, #get_job_to_retry, #request_batch_tests, #request_tests, #valid_package_name?, #validate_batch_test, #validate_priority, #validate_tests

Methods inherited from AuthApp

#authenticate!, #forbidden

Methods inherited from App

#get_page_params, get_page_range, #get_page_range, #pagination_params, #refresh!

Instance Method Details

#get_same_pending_jobs(job) ⇒ Object



259
260
261
262
263
264
265
266
267
268
269
# File 'lib/debci/self_service.rb', line 259

def get_same_pending_jobs(job)
  Debci::Job.pending.where(
    package_id: job.package_id,
    suite: job.suite,
    arch: job.arch,
    requestor: job.requestor,
    trigger: job.trigger,
    is_private: job.is_private
  ).select { |j| Set.new(j.pin_packages) == Set.new(job.pin_packages) }
            .select { |j| Set.new(j.extra_apt_sources) == Set.new(job.extra_apt_sources) }
end

#login_callback(uid, username) ⇒ Object



271
272
273
274
275
276
277
278
279
280
# File 'lib/debci/self_service.rb', line 271

def (uid, username)
  user = Debci::User.find_or_create_by!(uid: uid) do |c|
    c.username = username
  end
  user.update(username: username) if user.username != username
  session[:user_id] = user.id
  original_url = session[:original_url]
  session.delete(:original_url)
  redirect(original_url || "/user/#{user.username}")
end

#validate_form_submission(package, suite, archs, extra_apt_sources) ⇒ Object

Raises:



181
182
183
184
185
186
187
# File 'lib/debci/self_service.rb', line 181

def validate_form_submission(package, suite, archs, extra_apt_sources)
  raise InvalidRequest.new('Please enter a valid package name') unless valid_package_name?(package)
  raise InvalidRequest.new('Please select a suite') if suite == ''
  raise InvalidRequest.new('Please select an architecture') if archs.empty?
  invalid_extra_apt_sources = invalid_extra_apt_sources(extra_apt_sources)
  raise InvalidRequest.new("Please enter valid extra apt sources: Invalid apt sources: #{invalid_extra_apt_sources}") unless invalid_extra_apt_sources.empty?
end