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