Merge e2a9dd1db1 into 301ad1c722
This commit is contained in:
commit
c4a6a170a7
8 changed files with 19 additions and 4 deletions
|
|
@ -48,7 +48,7 @@ module Admin
|
|||
private
|
||||
|
||||
def ticket_params
|
||||
params.require(:ticket).permit(:conference, :title, :url, :description, :conference_id, :price_cents, :price_currency, :price)
|
||||
params.require(:ticket).permit(:conference, :title, :url, :description, :conference_id, :price_cents, :price_currency, :price, :payment_mode)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class Ticket < ActiveRecord::Base
|
|||
# If we would allow different currencies per conference we also have to handle convertions between currencies!
|
||||
validate :tickets_of_conference_have_same_currency
|
||||
|
||||
validates :price_cents, :price_currency, :title, presence: true
|
||||
validates :price_cents, :price_currency, :payment_mode, :title, presence: true
|
||||
|
||||
validates_numericality_of :price_cents, greater_than: 0
|
||||
|
||||
|
|
|
|||
|
|
@ -13,5 +13,6 @@
|
|||
= f.input :description, input_html: { rows: 5, data: { provide: "markdown-editable" } }
|
||||
= f.input :price
|
||||
= f.input :price_currency, as: :select, class: 'form-control', collection: ['USD', 'EUR', 'GBP', 'INR', 'CNY'], include_blank: false
|
||||
= f.input :payment_mode, as: :select, class: 'form-control', collection: ['Online', 'Offline'], include_blank: false
|
||||
%p.text-right
|
||||
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
%th Price
|
||||
%th Sold
|
||||
%th Turnover
|
||||
%th Payment Mode
|
||||
%th Actions
|
||||
%tbody
|
||||
- @conference.tickets.each do |ticket|
|
||||
|
|
@ -26,6 +27,8 @@
|
|||
= ticket.tickets_sold
|
||||
%td
|
||||
= humanized_money_with_symbol ticket.tickets_turnover
|
||||
%td
|
||||
= ticket.payment_mode
|
||||
%td
|
||||
.btn-group
|
||||
= link_to 'Edit', edit_admin_conference_ticket_path(@conference.short_title, ticket.id),
|
||||
|
|
|
|||
5
db/migrate/20160526142456_add_payment_mode_to_tickets.rb
Normal file
5
db/migrate/20160526142456_add_payment_mode_to_tickets.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class AddPaymentModeToTickets < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :tickets, :payment_mode, :string
|
||||
end
|
||||
end
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160427104236) do
|
||||
ActiveRecord::Schema.define(version: 20160526142456) do
|
||||
|
||||
create_table "ahoy_events", force: :cascade do |t|
|
||||
t.uuid "visit_id", limit: 16
|
||||
|
|
@ -411,6 +411,7 @@ ActiveRecord::Schema.define(version: 20160427104236) do
|
|||
t.text "description"
|
||||
t.integer "price_cents", default: 0, null: false
|
||||
t.string "price_currency", default: "USD", null: false
|
||||
t.string "payment_mode"
|
||||
end
|
||||
|
||||
create_table "tracks", force: :cascade do |t|
|
||||
|
|
|
|||
|
|
@ -3,5 +3,6 @@ FactoryGirl.define do
|
|||
title { "#{Faker::Hipster.word} Ticket" }
|
||||
price_cents 1000
|
||||
price_currency 'USD'
|
||||
payment_mode 'Online'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||
|
||||
describe Ticket do
|
||||
let(:conference) { create(:conference) }
|
||||
let(:ticket) { create(:ticket, price: 50, price_currency: 'USD', conference: conference) }
|
||||
let(:ticket) { create(:ticket, price: 50, price_currency: 'USD', payment_mode: 'Online', conference: conference) }
|
||||
let(:user) { create(:user) }
|
||||
|
||||
describe 'validation' do
|
||||
|
|
@ -22,6 +22,10 @@ describe Ticket do
|
|||
should validate_presence_of(:price_currency)
|
||||
end
|
||||
|
||||
it 'is not valid without a payment_mode' do
|
||||
should validate_presence_of(:payment_mode)
|
||||
end
|
||||
|
||||
it 'is not valid with a price_cents equals zero' do
|
||||
should_not allow_value(0).for(:price_cents)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue