新增:修改赞助关系
This commit is contained in:
parent
1ac5498091
commit
cd595646d8
|
@ -1,5 +1,5 @@
|
||||||
class LogController < ApplicationController
|
class LogController < ApplicationController
|
||||||
def file_list
|
def list
|
||||||
path = "#{Rails.root}/log"
|
path = "#{Rails.root}/log"
|
||||||
@file_list = []
|
@file_list = []
|
||||||
Dir.foreach(path) do |file|
|
Dir.foreach(path) do |file|
|
||||||
|
|
|
@ -12,6 +12,7 @@ class SponsorTiersController < ApplicationController
|
||||||
# GET /sponsor_tiers/1
|
# GET /sponsor_tiers/1
|
||||||
# GET /sponsor_tiers/1.json
|
# GET /sponsor_tiers/1.json
|
||||||
def show
|
def show
|
||||||
|
@check_sponsorship = Sponsorship.where("sponsor_id=? AND developer_id=?", current_user.id, @sponsor_tier.user)
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /sponsor_tiers/new
|
# GET /sponsor_tiers/new
|
||||||
|
|
|
@ -73,8 +73,8 @@ class SponsorshipsController < ApplicationController
|
||||||
|
|
||||||
@sponsorship = Sponsorship.new(sponsorship_params.merge({sponsor_id: sponsor_id}))
|
@sponsorship = Sponsorship.new(sponsorship_params.merge({sponsor_id: sponsor_id}))
|
||||||
# print('#######################', params[:single].class)
|
# print('#######################', params[:single].class)
|
||||||
unless check_sponsorship.length.zero? || params[:single]
|
unless check_sponsorship.length.zero?
|
||||||
return render json: {status: -1, message: '您已赞助了TA' }
|
return render json: {status: -1, message: '您已经赞助了TA' }
|
||||||
end
|
end
|
||||||
|
|
||||||
if @sponsorship.pay && @sponsorship.save
|
if @sponsorship.pay && @sponsorship.save
|
||||||
|
@ -113,6 +113,14 @@ class SponsorshipsController < ApplicationController
|
||||||
# format.json { render json: @sponsorship.errors, status: :unprocessable_entity }
|
# format.json { render json: @sponsorship.errors, status: :unprocessable_entity }
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
|
if @sponsorship.sponsor.id != current_user.id
|
||||||
|
return render json: {status: -1, message: '没有权限' }
|
||||||
|
end
|
||||||
|
if @sponsorship.update(sponsorship_params)
|
||||||
|
render json: {status: 1, message: '修改成功' }
|
||||||
|
else
|
||||||
|
render json: {status: -1, message: '修改失败' }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# DELETE /sponsorships/1
|
# DELETE /sponsorships/1
|
||||||
|
|
|
@ -1 +1,9 @@
|
||||||
json.partial! "sponsor_tiers/sponsor_tier", sponsor_tier: @sponsor_tier
|
json.tier do
|
||||||
|
json.partial! "sponsor_tiers/sponsor_tier", sponsor_tier: @sponsor_tier
|
||||||
|
end
|
||||||
|
if @check_sponsorship.length.zero?
|
||||||
|
json.is_sponsoring false
|
||||||
|
else
|
||||||
|
json.is_sponsoring true
|
||||||
|
json.sponsorship_id @check_sponsorship[0].id
|
||||||
|
end
|
||||||
|
|
|
@ -16,5 +16,6 @@ json.sponsorships do
|
||||||
json.user_id sponsor.id
|
json.user_id sponsor.id
|
||||||
json.login sponsor.login
|
json.login sponsor.login
|
||||||
json.accumulate sponsorship.accumulate
|
json.accumulate sponsorship.accumulate
|
||||||
|
json.sponsor_id sponsorship.sponsor.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,5 +16,6 @@ json.sponsorships do
|
||||||
json.user_id sponsor.id
|
json.user_id sponsor.id
|
||||||
json.login sponsor.login
|
json.login sponsor.login
|
||||||
json.accumulate sponsorship.accumulate
|
json.accumulate sponsorship.accumulate
|
||||||
|
json.sponsor_id sponsorship.sponsor.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,5 +16,6 @@ json.sponsorships do
|
||||||
json.user_id sponsor.id
|
json.user_id sponsor.id
|
||||||
json.login sponsor.login
|
json.login sponsor.login
|
||||||
json.accumulate sponsorship.accumulate
|
json.accumulate sponsorship.accumulate
|
||||||
|
json.sponsor_id sponsorship.sponsor.id
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -16,5 +16,6 @@ json.sponsorships do
|
||||||
json.user_id sponsor.id
|
json.user_id sponsor.id
|
||||||
json.login sponsor.login
|
json.login sponsor.login
|
||||||
json.accumulate sponsorship.accumulate
|
json.accumulate sponsorship.accumulate
|
||||||
|
json.sponsor_id sponsorship.sponsor.id
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -19,8 +19,9 @@ Rails.application.routes.draw do
|
||||||
get 'wallets/balance'
|
get 'wallets/balance'
|
||||||
get 'wallets/coin_changes'
|
get 'wallets/coin_changes'
|
||||||
|
|
||||||
get 'log/file_list'
|
get 'log/list', to: 'log#list'
|
||||||
post 'log/download'
|
# post 'log/download', to: 'log#download'
|
||||||
|
match 'log/download/:filename' => 'log#download', :constraints => { filename: /[0-z\.]+/ }, via:[:get]
|
||||||
|
|
||||||
resources :sponsor_tiers
|
resources :sponsor_tiers
|
||||||
resources :sponsorships do
|
resources :sponsorships do
|
||||||
|
@ -230,7 +231,7 @@ Rails.application.routes.draw do
|
||||||
resources :repositories, only: [:index, :show, :edit] do
|
resources :repositories, only: [:index, :show, :edit] do
|
||||||
member do
|
member do
|
||||||
get :entries
|
get :entries
|
||||||
match :sub_entries, :via => [:get, :put]
|
match :sub_entries, via: [:get, :put]
|
||||||
get :commits
|
get :commits
|
||||||
post :files
|
post :files
|
||||||
get :tags
|
get :tags
|
||||||
|
@ -265,7 +266,7 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
resources :courses do
|
resources :courses do
|
||||||
member do
|
member do
|
||||||
get 'settings', :action => 'settings', :as => 'settings'
|
get 'settings', action: 'settings', as: 'settings'
|
||||||
post 'set_invite_code_halt'
|
post 'set_invite_code_halt'
|
||||||
post 'set_public_or_private'
|
post 'set_public_or_private'
|
||||||
post 'search_teacher_candidate'
|
post 'search_teacher_candidate'
|
||||||
|
|
Loading…
Reference in New Issue