Skip to content

Commit

Permalink
Let the BsRequest have a proper title
Browse files Browse the repository at this point in the history
  • Loading branch information
ncounter committed Jul 18, 2024
1 parent db55813 commit 898f6e8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def bs_request_params
# This is for target_package which might be empty since it's not required
params[:bs_request][:bs_request_actions_attributes]['0'].compact_blank!

params.require(:bs_request).permit(:description,
params.require(:bs_request).permit(:title, :description,
bs_request_actions_attributes: %i[target_package target_project
source_project source_package
source_rev sourceupdate
Expand Down
8 changes: 8 additions & 0 deletions src/api/app/models/bs_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class BsRequest < ApplicationRecord
before_validation :sanitize!, if: :sanitize?, on: :create
before_save :accept_staged_request
before_save :assign_number
before_save :assign_title
after_create :notify
before_update :send_state_change
after_save :update_cache
Expand Down Expand Up @@ -312,6 +313,12 @@ def assign_number
end
end

def assign_title
return if title.present?

self.title = "Request #{number}"
end

def check_supersede_state
errors.add(:superseded_by, 'Superseded_by should be set') if state == :superseded && (!superseded_by.is_a?(Numeric) || superseded_by <= 0)

Expand Down Expand Up @@ -1265,6 +1272,7 @@ def create_new_review(opts)
# priority :string default("moderate")
# state :string(255) indexed
# superseded_by :integer indexed
# title :string(255)
# updated_when :datetime
# created_at :datetime not null
# updated_at :datetime not null
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/views/webui/request/_request_header.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

.card-title.d-flex.justify-content-between.mb-2.pt-4.px-4
%h3
Request #{bs_request.number}
#{bs_request.title}
-# state badge
%small
= render badge_state
Expand Down
3 changes: 3 additions & 0 deletions src/api/app/views/webui/requests/submissions/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
= bs_request_action.label(:target_package, 'To target package:')
= bs_request_action.text_field(:target_package, class: 'form-control',
placeholder: "Leave empty to keep the package's name")
.mb-3
= f.label(:target_package, 'Title:')
= f.text_field(:title, class: 'form-control', placeholder: "Request title")
.mb-3
= f.label(:description, 'Please describe your reasons to submit this package:')
%abbr.text-danger{ title: 'required' } *
Expand Down
5 changes: 5 additions & 0 deletions src/api/db/migrate/20240717094427_add_title_to_bs_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddTitleToBsRequest < ActiveRecord::Migration[7.0]
def change
add_column :bs_requests, :title, :string
end
end
3 changes: 2 additions & 1 deletion src/api/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_07_10_083919) do
ActiveRecord::Schema[7.0].define(version: 2024_07_17_094427) do
create_table "active_storage_attachments", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
Expand Down Expand Up @@ -262,6 +262,7 @@
t.datetime "updated_when", precision: nil
t.string "approver"
t.integer "staging_project_id"
t.string "title"
t.index ["creator"], name: "index_bs_requests_on_creator"
t.index ["number"], name: "index_bs_requests_on_number", unique: true
t.index ["staging_project_id"], name: "index_bs_requests_on_staging_project_id"
Expand Down

0 comments on commit 898f6e8

Please sign in to comment.