Commit 0a75de29 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Make Pipeline Triggers to be user aware

- they can have owner,
- they can be edited,
- they have description,
- you can take ownership of them
parent c33f09d2
...@@ -5,10 +5,12 @@ module Ci ...@@ -5,10 +5,12 @@ module Ci
acts_as_paranoid acts_as_paranoid
belongs_to :project, foreign_key: :gl_project_id belongs_to :project, foreign_key: :gl_project_id
belongs_to :owner, class_name: "User"
has_many :trigger_requests, dependent: :destroy has_many :trigger_requests, dependent: :destroy
validates :token, presence: true validates :token, presence: true, uniqueness: true
validates :token, uniqueness: true validates :owner, presence: true
before_validation :set_default_values before_validation :set_default_values
...@@ -25,7 +27,11 @@ module Ci ...@@ -25,7 +27,11 @@ module Ci
end end
def short_token def short_token
token[0...10] token[0...4]
end
def can_show_token?(user)
owner.blank? || owner == user
end end
end end
end end
class AddOwnerIdToTriggers < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :ci_triggers, :owner_id, :integer
add_foreign_key :ci_triggers, :users, column: :owner_id, on_delete: :nullify
end
end
class AddDescriptionToTriggers < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :ci_triggers, :description, :string
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment