Offer model & controller
This commit is contained in:
parent
b3a37cd78f
commit
2e0c9a793f
@ -142,6 +142,15 @@ class Admin::NeedsController < ApplicationController
|
|||||||
redirect_to admin_needs_path
|
redirect_to admin_needs_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def accept
|
||||||
|
@need = Need.find(params[:id])
|
||||||
|
if @need.reject!
|
||||||
|
flash[:notice] = "Le besoin est maintenant négocié"
|
||||||
|
else
|
||||||
|
flash[:error] = "L'état actuel de ce besoin ne permet pas cette action"
|
||||||
|
end
|
||||||
|
redirect_to new_admin_need_offer_path(@need)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
class Admin::NeedsController < ApplicationController
|
class Admin::OffersController < ApplicationController
|
||||||
layout "admin"
|
layout "admin"
|
||||||
before_filter :auth_admin
|
before_filter :auth_admin
|
||||||
before_action :build_category_tree, only:[:new, :update, :create, :edit, :index]
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
@need = Need.find(params[:need_id])
|
||||||
|
@offer = Offer.new
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ class Need < ActiveRecord::Base
|
|||||||
has_many :wishes, dependent: :destroy
|
has_many :wishes, dependent: :destroy
|
||||||
has_many :customers, -> { uniq }, through: :wishes
|
has_many :customers, -> { uniq }, through: :wishes
|
||||||
has_many :messages, dependent: :destroy
|
has_many :messages, dependent: :destroy
|
||||||
|
has_many :offers
|
||||||
belongs_to :category, class_name: "NeedCategory"
|
belongs_to :category, class_name: "NeedCategory"
|
||||||
|
|
||||||
validates :title, :presence => true, length: {within: 4..128}
|
validates :title, :presence => true, length: {within: 4..128}
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
class Offer < ActiveRecord::Base
|
class Offer < ActiveRecord::Base
|
||||||
|
belongs_to :need
|
||||||
|
|
||||||
end
|
end
|
||||||
|
0
app/views/admin/offers/index.html.haml
Normal file
0
app/views/admin/offers/index.html.haml
Normal file
0
app/views/admin/offers/new.html.haml
Normal file
0
app/views/admin/offers/new.html.haml
Normal file
@ -244,6 +244,7 @@ Rails.application.routes.draw do
|
|||||||
resources :needs do
|
resources :needs do
|
||||||
resources :messages
|
resources :messages
|
||||||
resources :wishes
|
resources :wishes
|
||||||
|
resources :offers
|
||||||
member do
|
member do
|
||||||
get :validate
|
get :validate
|
||||||
get :refuse
|
get :refuse
|
||||||
|
Loading…
x
Reference in New Issue
Block a user