Skip to content

Commit

Permalink
Merge pull request #20 from frywer/fix_api
Browse files Browse the repository at this point in the history
api improvements
  • Loading branch information
frywer authored May 18, 2020
2 parents 4923fd1 + fbae222 commit e425c2a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/custom_entities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CustomEntitiesController < ApplicationController
include SortHelper
helper :custom_tables_pdf

accept_api_auth :show
accept_api_auth :show, :create, :update, :destroy

before_action :authorize_global
before_action :find_custom_entity, only: [:show, :edit, :update, :add_belongs_to, :new_note]
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/custom_entities_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ def render_api_custom_entity(custom_entity, api)
next unless external_name.present?
api.__send__(external_name, value)
end
api.issue_id custom_entity.issue_id
api.custom_table_id custom_entity.custom_table_id
end
end
3 changes: 2 additions & 1 deletion app/models/custom_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class CustomEntity < ActiveRecord::Base
has_one :project, through: :issue
has_many :custom_fields, through: :custom_table

safe_attributes 'custom_table_id', 'author_id', 'custom_field_values', 'custom_fields', 'parent_entity_ids', 'sub_entity_ids', 'issue_id'
safe_attributes 'custom_table_id', 'author_id', 'custom_field_values', 'custom_fields', 'parent_entity_ids',
'sub_entity_ids', 'issue_id', 'external_values'

acts_as_customizable

Expand Down
4 changes: 1 addition & 3 deletions app/views/custom_entities/show.api.rsb
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
api.__send__(@custom_entity.custom_table.name.downcase.singularize.gsub(/[^0-9A-Za-z]/, '_')) do
render_api_custom_entity @custom_entity, api
end
render_api_custom_entity @custom_entity, api
2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name 'Custom Tables plugin'
author 'Ivan Marangoz'
description 'This is a plugin for Redmine'
version '1.0.5'
version '1.0.6'
requires_redmine :version_or_higher => '3.4.0'
url 'https://github.com/frywer/custom_tables'
author_url 'https://github.com/frywer'
Expand Down

0 comments on commit e425c2a

Please sign in to comment.