multiple swags [wip]
This commit is contained in:
parent
a0e1760ef1
commit
4843021971
4 changed files with 22 additions and 12 deletions
|
|
@ -585,6 +585,7 @@ Style/PredicateName:
|
|||
- 'spec/**/*'
|
||||
- 'app/models/comment.rb'
|
||||
- 'app/models/contact.rb'
|
||||
- 'app/controllers/admin/sponsors_controller'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ module Admin
|
|||
|
||||
def show; end
|
||||
|
||||
def edit
|
||||
end
|
||||
def edit; end
|
||||
|
||||
def new
|
||||
@sponsor = @conference.sponsors.new
|
||||
|
|
@ -52,8 +51,12 @@ module Admin
|
|||
end
|
||||
end
|
||||
|
||||
def add_swag
|
||||
swags_hash = @sponsor.swags_hash
|
||||
end
|
||||
|
||||
def generate_swags_hash(type, quantity)
|
||||
swags_hash = Hash.new
|
||||
swags_hash = {}
|
||||
swags_hash[type.to_s] = quantity.to_i
|
||||
end
|
||||
|
||||
|
|
@ -62,27 +65,27 @@ module Admin
|
|||
def paid
|
||||
@sponsor.paid = !@sponsor.paid
|
||||
if @sponsor.save
|
||||
flash[:notice] = "Sponsor successfully updated."
|
||||
flash[:notice] = 'Sponsor successfully updated.'
|
||||
else
|
||||
flash[:error] = "Sponsor failed to be updated."
|
||||
flash[:error] = 'Sponsor failed to be updated.'
|
||||
end
|
||||
end
|
||||
|
||||
def has_swag
|
||||
@sponsor.has_swag = !@sponsor.has_swag
|
||||
if @sponsor.save
|
||||
flash[:notice] = "Sponsor successfully updated."
|
||||
flash[:notice] = 'Sponsor successfully updated.'
|
||||
else
|
||||
flash[:error] = "Sponsor failed to be updated."
|
||||
flash[:error] = 'Sponsor failed to be updated.'
|
||||
end
|
||||
end
|
||||
|
||||
def swag_received
|
||||
@sponsor.swag_received = !@sponsor.swag_received
|
||||
if @sponsor.save
|
||||
flash[:notice] = "Sponsor successfully updated."
|
||||
flash[:notice] = 'Sponsor successfully updated.'
|
||||
else
|
||||
flash[:error] = "Sponsor failed to be updated."
|
||||
flash[:error] = 'Sponsor failed to be updated.'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,8 @@
|
|||
off_color: 'warning',
|
||||
on_text: 'Yes',
|
||||
off_text: 'No' }
|
||||
= f.input :type, label: 'Swags type'
|
||||
= f.input :quantity, label: 'Swags quantity', as: :number, in: 0..9999
|
||||
- generate_swags_hash(@type, @quantity)
|
||||
|
||||
|
||||
= image_tag f.object.picture.thumb.url if f.object.picture?
|
||||
= f.input :picture
|
||||
%p.text-right
|
||||
|
|
|
|||
7
app/views/admin/sponsors/_swags.erb
Normal file
7
app/views/admin/sponsors/_swags.erb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<div class="swag_fields">
|
||||
<%= f.inputs do %>
|
||||
<%= f.input :type, label: 'Swags type' %>
|
||||
<%= f.input :quantity, label: 'Swags quantity', as: :number, in: 0..9999 %>
|
||||
<%- generate_swags_hash(@type, @quantity) %>
|
||||
<% end %>
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue