Class: Debci::SelfService
- Includes:
- HTMLHelpers, TestHandler, Validators::APTSource
- Defined in:
- lib/debci/self_service.rb
Defined Under Namespace
Classes: InvalidRequest
Constant Summary
Constants included from HTMLHelpers
Instance Method Summary collapse
- #get_same_pending_jobs(job) ⇒ Object
- #login_callback(uid, username) ⇒ Object
- #validate_form_submission(package, suite, archs, extra_apt_sources) ⇒ Object
Methods included from Validators::APTSource
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
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 login_callback(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
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 |