From 7339e9e382ee2398983499e119e0699f91fa6471 Mon Sep 17 00:00:00 2001 From: Alexander Meindl Date: Thu, 25 Jan 2018 17:05:28 +0100 Subject: [PATCH] Add is_private support for db and contacts --- CHANGELOG.md | 1 + app/models/messenger_setting.rb | 2 ++ app/views/messenger_settings/_show.html.slim | 2 ++ app/views/settings/_messenger_settings.html.slim | 6 ++++++ config/locales/de.yml | 6 ++++-- config/locales/en.yml | 2 ++ config/locales/ja.yml | 2 ++ db/migrate/003_add_private_settings.rb | 8 ++++++++ init.rb | 6 ++++-- lib/redmine_messenger/patches/contact_patch.rb | 2 ++ lib/redmine_messenger/patches/db_entry_patch.rb | 3 +++ 11 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 db/migrate/003_add_private_settings.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 065a966..6ce7607 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Changelog - Bug fixed with issue urls, if Redmine is in subdirectory - slim is used as template engine +- add private contacts, db and passwords support (if plugins are installed) 1.0.1 ----- diff --git a/app/models/messenger_setting.rb b/app/models/messenger_setting.rb index d5eef72..393d252 100644 --- a/app/models/messenger_setting.rb +++ b/app/models/messenger_setting.rb @@ -23,8 +23,10 @@ class MessengerSetting < ActiveRecord::Base 'post_wiki_updates', 'post_db', 'post_db_updates', + 'post_private_db', 'post_contact', 'post_contact_updates', + 'post_private_contacts', 'post_password', 'post_password_updates' diff --git a/app/views/messenger_settings/_show.html.slim b/app/views/messenger_settings/_show.html.slim index acb09a1..81caa31 100644 --- a/app/views/messenger_settings/_show.html.slim +++ b/app/views/messenger_settings/_show.html.slim @@ -49,6 +49,7 @@ br = render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_db } = render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_db_updates } + = render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_private_db } - if RedmineMessenger::REDMINE_CONTACTS_SUPPORT && User.current.allowed_to?(:view_contacts, @project) br @@ -57,6 +58,7 @@ br = render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_contact } = render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_contact_updates } + = render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_private_contacts } - if Redmine::Plugin.installed?('redmine_passwords') && User.current.allowed_to?(:view_passwords, @project) br diff --git a/app/views/settings/_messenger_settings.html.slim b/app/views/settings/_messenger_settings.html.slim index db7d4c0..9a70d7f 100644 --- a/app/views/settings/_messenger_settings.html.slim +++ b/app/views/settings/_messenger_settings.html.slim @@ -72,6 +72,9 @@ p p = content_tag(:label, l(:label_settings_post_db_updates)) = check_box_tag 'settings[post_db_updates]', 1, @settings[:post_db_updates].to_i == 1 + p + = content_tag(:label, l(:label_settings_post_private_db)) + = check_box_tag 'settings[post_private_db]', 1, @settings[:post_private_db].to_i == 1 - if RedmineMessenger::REDMINE_CONTACTS_SUPPORT br @@ -84,6 +87,9 @@ p p = content_tag(:label, l(:label_settings_post_contact_updates)) = check_box_tag 'settings[post_contact_updates]', 1, @settings[:post_contact_updates].to_i == 1 + p + = content_tag(:label, l(:label_settings_post_private_contacts)) + = check_box_tag 'settings[post_private_contacts]', 1, @settings[:post_private_contacts].to_i == 1 - if Redmine::Plugin.installed?('redmine_passwords') br diff --git a/config/locales/de.yml b/config/locales/de.yml index 586ab4d..afcd30e 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -28,10 +28,12 @@ de: label_settings_new_include_description: Neue Ticketeschreibung? label_settings_post_contact_updates: Kontakt Updates? label_settings_post_contact: Neue Kontakte? - label_settings_post_db_updates: DB entry Updates? - label_settings_post_db: Neue DB entries? + label_settings_post_db_updates: DB Einträge Updates? + label_settings_post_db: Neue DB Einträge? label_settings_post_password_updates: Passwort Updates? label_settings_post_password: Neue Passwörter? + label_settings_post_private_db: Private DB Einträge? + label_settings_post_private_contacts: Private Kontakte? label_settings_post_private_issues: Private Ticket Updates? label_settings_post_private_notes: Private Notizen? label_settings_post_updates: Ticket Updates? diff --git a/config/locales/en.yml b/config/locales/en.yml index 8e287aa..333fc27 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -32,6 +32,8 @@ en: label_settings_post_db: DB entry added? label_settings_post_password_updates: Password updates? label_settings_post_password: Password added? + label_settings_post_private_db: Private DB entries? + label_settings_post_private_contacts: Private contacts? label_settings_post_private_issues: Private issue updates? label_settings_post_private_notes: Private notes updates? label_settings_post_updates: Issue updates? diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 632e463..3e953af 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -32,6 +32,8 @@ ja: label_settings_post_db: DB entry added? label_settings_post_password_updates: Password updates? label_settings_post_password: Password added? + label_settings_post_private_db: Private DB entries? + label_settings_post_private_contacts: Private contacts? label_settings_post_private_issues: プライベートチケットの更新 label_settings_post_private_notes: プライベート注記の更新 label_settings_post_updates: チケットの更新 diff --git a/db/migrate/003_add_private_settings.rb b/db/migrate/003_add_private_settings.rb new file mode 100644 index 0000000..d9b0f68 --- /dev/null +++ b/db/migrate/003_add_private_settings.rb @@ -0,0 +1,8 @@ +# Redmine Messenger plugin for Redmine + +class AddPrivateSettings < ActiveRecord::Migration + def change + add_column :messenger_settings, :post_private_contacts, :integer, default: 0, null: false + add_column :messenger_settings, :post_private_db, :integer, default: 0, null: false + end +end diff --git a/init.rb b/init.rb index a3ecc41..457a6b9 100644 --- a/init.rb +++ b/init.rb @@ -27,8 +27,10 @@ Redmine::Plugin.register :redmine_messenger do post_updates: '1', new_include_description: '1', updated_include_description: '1', - post_private_issues: '1', - post_private_notes: '1', + post_private_contacts: '0', + post_private_db: '0', + post_private_issues: '0', + post_private_notes: '0', post_wiki: '0', post_wiki_updates: '0', post_db: '0', diff --git a/lib/redmine_messenger/patches/contact_patch.rb b/lib/redmine_messenger/patches/contact_patch.rb index 429b8bc..daf88a8 100644 --- a/lib/redmine_messenger/patches/contact_patch.rb +++ b/lib/redmine_messenger/patches/contact_patch.rb @@ -14,6 +14,7 @@ module RedmineMessenger module InstanceMethods def send_messenger_create return unless Messenger.setting_for_project(project, :post_contact) + return if is_private? && !Messenger.setting_for_project(project, :post_private_contacts) set_language_if_valid Setting.default_language channels = Messenger.channels_for_project project @@ -29,6 +30,7 @@ module RedmineMessenger def send_messenger_update return unless Messenger.setting_for_project(project, :post_contact_updates) + return if is_private? && !Messenger.setting_for_project(project, :post_private_contacts) set_language_if_valid Setting.default_language channels = Messenger.channels_for_project project diff --git a/lib/redmine_messenger/patches/db_entry_patch.rb b/lib/redmine_messenger/patches/db_entry_patch.rb index 7a114b6..ea4d910 100644 --- a/lib/redmine_messenger/patches/db_entry_patch.rb +++ b/lib/redmine_messenger/patches/db_entry_patch.rb @@ -14,6 +14,8 @@ module RedmineMessenger module InstanceMethods def send_messenger_create return unless Messenger.setting_for_project(project, :post_db) + return if is_private? && !Messenger.setting_for_project(project, :post_private_db) + set_language_if_valid Setting.default_language channels = Messenger.channels_for_project project @@ -29,6 +31,7 @@ module RedmineMessenger def send_messenger_update return unless Messenger.setting_for_project(project, :post_db_updates) + return if is_private? && !Messenger.setting_for_project(project, :post_private_db) set_language_if_valid Setting.default_language channels = Messenger.channels_for_project project