Skip to content

Commit

Permalink
Hotfix: rollback roles permission for enabled module
Browse files Browse the repository at this point in the history
Project settings: admin can select who can create Telegram group
Add journal entry with link to chat after it created
  • Loading branch information
arturtr committed Mar 26, 2016
1 parent 06f29ca commit 6717904
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 12 deletions.
3 changes: 3 additions & 0 deletions app/controllers/telegram_group_chats_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def create
retry
end

@issue.init_journal(User.current, "По ссылке #{telegram_chat_url} создан чат по этой задаче.")
@issue.save

respond_to do |format|
format.html { redirect_to @issue }
format.js
Expand Down
14 changes: 8 additions & 6 deletions app/views/projects/settings/_redmine_chat_telegram.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
method: :put, class: 'tabular', multipart: true, id: 'chat_telegram_settings') do %>

<fieldset class="box tabular">
<legend><%= t 'redmine_chat_telegram.settings.creator_telegram_group_ids' %></legend>
<% @project.groups.each do |group| %>
<label class="floating">
<%= check_box_tag 'chat_telegram_settings[creator_telegram_group_ids][]', group.id, @project.creator_telegram_group_ids.try(:include?, group.id.to_s), :id => nil %>
<%= group %>
<legend><%= t 'redmine_chat_telegram.settings.telegram_group_creator_role.title' %></legend>
<% %w(all selected).each do |role| %>
<label class="floating" style="width: 350px">
<%= radio_button_tag 'chat_telegram_settings[telegram_group_creator_role]', role,
(@project.telegram_group_creator_role == role or (!@project.telegram_group_creator_role.present? and role == 'all')),
:id => nil %>
<%= t "redmine_chat_telegram.settings.telegram_group_creator_role.#{role}" %>
</label>
<br>
<% end %>
<%= hidden_field_tag 'chat_telegram_settings[creator_telegram_group_ids][]', '' %>
</fieldset>


Expand Down
4 changes: 2 additions & 2 deletions app/views/telegram_group_chats/_link_or_button.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<% if @issue.telegram_chat_url.present? %>
<%= render 'telegram_group_chats/links' %>
<% else %>
<% if @project.creator_telegram_group_ids.present? and User.current.group_ids.present? and
(User.current.group_ids.map(&:to_s) & @project.creator_telegram_group_ids).present? %>
<% if User.current.logged? and
(@project.everybody_can_create_telegram_group? or User.current.allowed_to?(:create_telegram_chat, @project)) %>
<%= link_to telegram_group_chats_path(issue_id: @issue.id), method: :post, remote: true do %>
<%= image_tag '/plugin_assets/redmine_chat_telegram/images/telegram-icon.png' %>
Создать чат Telegram
Expand Down
3 changes: 1 addition & 2 deletions app/views/telegram_group_chats/_links.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<%= image_tag '/plugin_assets/redmine_chat_telegram/images/telegram-icon.png' %>
Войти в чат Telegram
<% end %>
|
<% if @issue.telegram_messages.present? %>
<%= link_to 'Архив', issue_telegram_messages_path(@issue.id) %>
| <%= link_to 'Архив', issue_telegram_messages_path(@issue.id) %>
<% end %>
6 changes: 6 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# English strings go here for Rails i18n
en:
permission_create_telegram_chat: Create Telegram Chat
permission_manage_redmine_chat_telegram_settings: Manage plugin settings in project
redmine_chat_telegram:
tab_title: Chat Telegram
settings:
creator_telegram_group_ids: "This groups users can create Telegram Group Chat"
telegram_group_creator_role:
title: Who can create Telegram groups?
all: All
selected: Holders of the relevant rights (by role)

6 changes: 6 additions & 0 deletions config/locales/ru.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# English strings go here for Rails i18n
ru:
permission_create_telegram_chat: Создание чата Telegram
permission_manage_redmine_chat_telegram_settings: Редактировать настройки плагина в проекте
redmine_chat_telegram:
tab_title: Chat Telegram
settings:
creator_telegram_group_ids: "Пользователи из этих групп могут создавать групповые чаты Telegram"
telegram_group_creator_role:
title: Кто может создавать группы Telegram?
all: Все
selected: Те, чьей роли разрешено создавать группы
3 changes: 2 additions & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
name 'Redmine Chat Telegram plugin'
url 'https://github.com/centosadmin/redmine_chat_telegram'
description 'This is a plugin for Redmine which adds Telegram Group Chat to Redmine Issue'
version '0.6.1'
version '0.6.2'
author 'Centos-admin.ru'
author_url 'http://centos-admin.ru'

settings(default: { 'bot_name' => 'BotName', 'bot_token' => 'bot_token' },
partial: 'settings/chat_telegram')

project_module :chat_telegram do
permission :create_telegram_chat, :telegram_group_chats => :create
permission :manage_redmine_chat_telegram_settings, {
projects: :settings,
redmine_chat_telegram_settings: :update,
Expand Down
5 changes: 4 additions & 1 deletion lib/redmine_chat_telegram/patches/project_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ def self.included(base) # :nodoc:
base.class_eval do
unloadable

store :chat_telegram_settings, accessors: %w(creator_telegram_group_ids)
store :chat_telegram_settings, accessors: %w(telegram_group_creator_role)

def everybody_can_create_telegram_group?
telegram_group_creator_role == 'all' or !telegram_group_creator_role.present?
end
end
end

Expand Down

0 comments on commit 6717904

Please sign in to comment.