refactoring respond_to

This commit is contained in:
Alexander Machehin 2014-08-29 02:46:42 +06:00
parent 9ba87cd361
commit 4d495aca2e
14 changed files with 30 additions and 90 deletions

View File

@ -7,16 +7,12 @@ class Api::V1::AdvisoriesController < Api::V1::BaseController
def index
@advisories = @advisories.includes(:platforms, :projects).paginate(paginate_params)
respond_to do |format|
format.json
end
respond_to :json
end
def show
@packages_info = @advisory.fetch_packages_info
respond_to do |format|
format.json
end
respond_to :json
end
def create

View File

@ -3,9 +3,7 @@ class Api::V1::ArchesController < Api::V1::BaseController
def index
@arches = Arch.order(:id).paginate(paginate_params)
respond_to do |format|
format.json
end
respond_to :json
end
end

View File

@ -6,9 +6,7 @@ class Api::V1::BuildListsController < Api::V1::BaseController
load_and_authorize_resource :build_list, only: [:show, :create, :cancel, :publish, :reject_publish, :create_container, :publish_into_testing, :rerun_tests]
def show
respond_to do |format|
format.json
end
respond_to :json
end
def index
@ -16,9 +14,7 @@ class Api::V1::BuildListsController < Api::V1::BaseController
filter = BuildList::Filter.new(@project, current_user, current_ability, params[:filter] || {})
@build_lists = filter.find.includes(:save_to_platform, :project, :user, :arch)
@build_lists = @build_lists.recent.paginate(paginate_params)
respond_to do |format|
format.json
end
respond_to :json
end
def create

View File

@ -7,23 +7,17 @@ class Api::V1::GroupsController < Api::V1::BaseController
def index
# accessible_by(current_ability)
@groups = current_user.groups.paginate(paginate_params)
respond_to do |format|
format.json
end
respond_to :json
end
def show
respond_to do |format|
format.json
end
respond_to :json
end
def members
@members = @group.members.where('actor_id != ?', @group.owner_id)
.order('name').paginate(paginate_params)
respond_to do |format|
format.json
end
respond_to :json
end
def update

View File

@ -33,9 +33,7 @@ class Api::V1::IssuesController < Api::V1::BaseController
def show
redirect_to api_v1_project_pull_request_path(@project.id, @issue.serial_id) if @issue.pull_request
respond_to do |format|
format.json
end
respond_to :json
end
def create

View File

@ -7,8 +7,6 @@ class Api::V1::MaintainersController < Api::V1::BaseController
.actual.by_platform(@platform)
.like_name(params[:package_name])
.paginate(paginate_params)
respond_to do |format|
format.json
end
respond_to :json
end
end

View File

@ -18,15 +18,11 @@ class Api::V1::PlatformsController < Api::V1::BaseController
def index
@platforms = @platforms.accessible_by(current_ability, :related)
.by_type(params[:type]).paginate(paginate_params)
respond_to do |format|
format.json
end
respond_to :json
end
def show
respond_to do |format|
format.json
end
respond_to :json
end
def platforms_for_build
@ -52,9 +48,7 @@ class Api::V1::PlatformsController < Api::V1::BaseController
def members
@members = @platform.members.order('name').paginate(paginate_params)
respond_to do |format|
format.json
end
respond_to :json
end
def add_member

View File

@ -13,9 +13,7 @@ class Api::V1::ProductBuildListsController < Api::V1::BaseController
end
@product_build_lists = @product_build_lists.joins(:product, :project, :arch)
@product_build_lists = @product_build_lists.recent.paginate(paginate_params)
respond_to do |format|
format.json
end
respond_to :json
end
def create
@ -27,9 +25,7 @@ class Api::V1::ProductBuildListsController < Api::V1::BaseController
end
def show
respond_to do |format|
format.json
end
respond_to :json
end
def update

View File

@ -13,9 +13,7 @@ class Api::V1::ProductsController < Api::V1::BaseController
end
def show
respond_to do |format|
format.json
end
respond_to :json
end
def destroy

View File

@ -8,9 +8,7 @@ class Api::V1::ProjectsController < Api::V1::BaseController
def index
@projects = Project.accessible_by(current_ability, :membered)
.paginate(paginate_params)
respond_to do |format|
format.json
end
respond_to :json
end
def get_id
@ -19,22 +17,16 @@ class Api::V1::ProjectsController < Api::V1::BaseController
else
raise ActiveRecord::RecordNotFound
end
respond_to do |format|
format.json
end
respond_to :json
end
def show
respond_to do |format|
format.json
end
respond_to :json
end
def refs_list
@refs = @project.repo.branches + @project.repo.tags.select{ |t| t.commit }
respond_to do |format|
format.json
end
respond_to :json
end
def update
@ -60,9 +52,7 @@ class Api::V1::ProjectsController < Api::V1::BaseController
def members
@members = @project.collaborators.order('uname').paginate(paginate_params)
respond_to do |format|
format.json
end
respond_to :json
end
def add_member

View File

@ -39,9 +39,7 @@ class Api::V1::PullRequestsController < Api::V1::BaseController
def show
redirect_to api_v1_project_issue_path(@project.id, @issue.serial_id) if @pull.nil?
respond_to do |format|
format.json
end
respond_to :json
end
def create
@ -98,16 +96,12 @@ class Api::V1::PullRequestsController < Api::V1::BaseController
def commits
@commits = @pull.repo.commits_between(@pull.to_commit, @pull.from_commit).paginate(paginate_params)
respond_to do |format|
format.json
end
respond_to :json
end
def files
@stats = @pull.diff_stats.zip(@pull.diff).paginate(paginate_params)
respond_to do |format|
format.json
end
respond_to :json
end
def merge

View File

@ -7,16 +7,12 @@ class Api::V1::RepositoriesController < Api::V1::BaseController
load_and_authorize_resource :repository, through: :platform, shallow: true
def show
respond_to do |format|
format.json
end
respond_to :json
end
def projects
@projects = @repository.projects.recent.paginate(paginate_params)
respond_to do |format|
format.json
end
respond_to :json
end
def update
@ -36,9 +32,7 @@ class Api::V1::RepositoriesController < Api::V1::BaseController
end
def key_pair
respond_to do |format|
format.json
end
respond_to :json
end
# Only one request per 15 minutes for each platform

View File

@ -7,8 +7,6 @@ class Api::V1::SearchController < Api::V1::BaseController
(params[:type] || 'all'),
paginate_params
)
respond_to do |format|
format.json
end
respond_to :json
end
end

View File

@ -7,9 +7,7 @@ class Api::V1::UsersController < Api::V1::BaseController
def show
@user = User.opened.find params[:id] # dont show system users
respond_to do |format|
format.json
end
respond_to :json
end
def show_current_user
@ -40,9 +38,7 @@ class Api::V1::UsersController < Api::V1::BaseController
render_json_response @user, error_message(@user.notifier, 'User notification settings have not been updated'), 422
end
else
respond_to do |format|
format.json
end
respond_to :json
end
end