62 lines
1.9 KiB
Ruby
62 lines
1.9 KiB
Ruby
# Redmine Messenger plugin for Redmine
|
|
|
|
class MessengerSetting < ActiveRecord::Base
|
|
include Redmine::SafeAttributes
|
|
belongs_to :project
|
|
|
|
validates :project_id, presence: true
|
|
|
|
safe_attributes 'messenger_url',
|
|
'messenger_icon',
|
|
'messenger_channel',
|
|
'messenger_username',
|
|
'messenger_verify_ssl',
|
|
'auto_mentions',
|
|
'display_watchers',
|
|
'post_updates',
|
|
'new_include_description',
|
|
'updated_include_description',
|
|
'post_private_issues',
|
|
'post_private_notes',
|
|
'post_wiki',
|
|
'post_wiki_updates',
|
|
'post_db',
|
|
'post_db_updates',
|
|
'post_contact',
|
|
'post_contact_updates',
|
|
'post_password',
|
|
'post_password_updates'
|
|
|
|
attr_accessible :messenger_url,
|
|
:messenger_icon,
|
|
:messenger_channel,
|
|
:messenger_username,
|
|
:messenger_verify_ssl,
|
|
:auto_mentions,
|
|
:display_watchers,
|
|
:post_updates,
|
|
:new_include_description,
|
|
:updated_include_description,
|
|
:post_private_issues,
|
|
:post_private_notes,
|
|
:post_wiki,
|
|
:post_wiki_updates,
|
|
:post_db,
|
|
:post_db_updates,
|
|
:post_contact,
|
|
:post_contact_updates,
|
|
:post_password,
|
|
:post_password_updates
|
|
|
|
def self.find_or_create(p_id)
|
|
setting = MessengerSetting.find_by(project_id: p_id)
|
|
unless setting
|
|
setting = MessengerSetting.new
|
|
setting.project_id = p_id
|
|
setting.save!
|
|
end
|
|
|
|
setting
|
|
end
|
|
end
|