Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/views/settings/_view_customize_settings.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<p>
<label for="settings_create_api_access_key"><%= l(:option_create_api_access_key) %></label>
<%= check_box_tag 'settings[create_api_access_key]', 1, @settings[:create_api_access_key] %>
</p>
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ en:
field_author: "Author"
text_path_pattern_info: "Path pattern is specified with a regular expression. (ex. /issues/[0-9]+)"
text_path_pattern_match_info: "If there is a match with the path of the page, insert the following code and execute it."
option_create_api_access_key: "Automatically create API access key"
1 change: 1 addition & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ ja:
field_author: "作成者"
text_path_pattern_info: "パスのパターンは正規表現で指定します。 (例 /issues/[0-9]+)"
text_path_pattern_match_info: "ページのパスが一致した場合、以下のコードを挿入し、実行します。"
option_create_api_access_key: "APIアクセスキーを自動的に作成する"
4 changes: 3 additions & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
:caption => :label_view_customize,
:html => { :class => 'icon icon-view_customize'},
:if => Proc.new { User.current.admin? }


settings :default => { 'create_api_access_key' => '' }, :partial => 'settings/view_customize_settings'

should_be_disabled false if Redmine::Plugin.installed?(:easy_extensions)
end

Expand Down
6 changes: 6 additions & 0 deletions lib/view_customize/view_hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ def to_html(view_customize)
def create_view_customize_context(view_hook_context)

user = User.current

if Setting.plugin_view_customize[:create_api_access_key] == "1" and user.api_token.nil?
# Create API access key
user.api_key
end

context = {
"user" => {
"id" => user.id,
Expand Down