Skip to content
Browse files

Added option to enter in to rafflr on checkin as well as after checki…

…n if not already entered.
  • Loading branch information...
1 parent 55f14b5 commit 9aeeed0ed87da90f563cfff94dd3954e9ef1f9e3 @Dishwasha Dishwasha committed May 20, 2012
View
6 app/controllers/checkins_controller.rb
@@ -11,6 +11,10 @@ def index
@checkins = Checkin.unhidden
end
+ if params[:rafflr] == "true"
+ @checkins = @checkins.rafflr
+ end
+
respond_with(@event, @checkins) do |format|
format.html
@@ -61,7 +65,7 @@ def update
if params[:checkin]
if @checkin.update_attributes(params[:checkin])
flash[:notice] = "Successfully updated checkin status for #{@checkin.event.name}"
- redirect_to event_path(@checkin.event)
+ redirect_to event_path(@event)
else
flash[:alert] = "Failed to update checkin status"
redirect_to new_event_path
View
6 app/models/checkin.rb
@@ -5,16 +5,18 @@ class Checkin < ActiveRecord::Base
before_save :set_employer
attr_accessor :current_user, :remember_employer
- attr_accessible :employ, :employer, :employment, :event_id, :remember_employer, :shoutout, :user_id, :as => :default
- attr_accessible :created_at, :employ, :employer, :employment, :event_id, :hidden, :remember_employer, :shoutout, :updated_at, :user_id, :as => :admin
+ attr_accessible :employ, :employer, :employment, :event_id, :rafflr, :remember_employer, :shoutout, :user_id, :as => :default
+ attr_accessible :created_at, :employ, :employer, :employment, :event_id, :hidden, :rafflr, :remember_employer, :shoutout, :updated_at, :user_id, :as => :admin
scope :hidden, :conditions => ["checkins.hidden = ?", true]
scope :unhidden, :conditions => ["checkins.hidden = ?", false]
scope :employ, :conditions => ["checkins.employ = ?", true]
scope :employment, :conditions => ["checkins.employment = ?", true]
+ scope :rafflr, :conditions => ["checkins.rafflr = ?", true]
validates :employ, :inclusion => {:in => [true, false]}
validates :employment, :inclusion => {:in => [true, false]}
+ validates :rafflr, :inclusion => {:in => [true, false]}
validates :remember_employer, :inclusion => {:in => [true, false, "1", "0", 1, 0]}
validates :employer, :format => {:with => /^[\x20-\x7E]*$/}, :length => {:within => 0..254}
validate :is_user
View
5 app/models/event.rb
@@ -41,6 +41,11 @@ def is_checked_in user=nil
!users.find_by_id(user).nil?
end
+ def is_in_rafflr user=nil
+ user ||= current_user
+ Checkin.find_by_user_id(user).try{|user| user.rafflr if user}
+ end
+
def start_date
self.start_datetime.to_date.to_s if self.start_datetime
end
View
5 app/views/checkins/_form.html.slim
@@ -12,4 +12,7 @@ div data-role="fieldcontain"
= f.label :remember_employer, :"data-inline" => true
div data-role="fieldcontain"
= f.label :shoutout, "Shout-out!"
- = f.text_field :shoutout
+ = f.text_field :shoutout
+div data-role="fieldcontain"
+ = f.check_box :rafflr
+ = f.label :rafflr, "Enter in to Rafflr", :"data-inline" => true
View
2 app/views/events/_rafflr.js.erb
@@ -10,7 +10,7 @@ $(document).ready(function() {
if(winners && winners > 0) {
started = true;
var rafflr = $("body").rafflr({
- url: "<%= event_checkins_path(@event, :format => :json) %>",
+ url: "<%= event_checkins_path(@event, :format => :json, :rafflr => true) %>",
winners: winners
});
View
6 app/views/events/show.html.slim
@@ -7,9 +7,13 @@ p
p
| Ends at: #{@event.end_datetime.strftime("%A %B %e, %Y %l:%M %p").squeeze(" ")}
- if @event.is_checked_in(current_user)
- | Checked In
+ | Checked In<br/>
- elsif @event.active?
= link_to "Check In", new_event_checkin_path(@event), :"data-role" => "button", :"data-inline" => "true"
+- if @event.is_in_rafflr(current_user)
+ | Entered in to Rafflr
+- elsif @event.active? && @event.is_checked_in(current_user)
+ = link_to "Enter in to Rafflr", event_checkin_path(@event, @event.checkins.find_by_user_id(current_user.id), :checkin => {:rafflr => true}), :method => :put, :target => "_self", :"data-role" => "button", :"data-inline" => "true"
p
= link_to "Checkin Carousel", event_carousel_path(@event), :method => :get, :"data-role" => "button", :"data-inline" => "true", :target => "_self"
View
5 db/migrate/20120520052247_add_rafflr_to_checkin.rb
@@ -0,0 +1,5 @@
+class AddRafflrToCheckin < ActiveRecord::Migration
+ def change
+ add_column :checkins, :rafflr, :boolean
+ end
+end
View
3 db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120222053740) do
+ActiveRecord::Schema.define(:version => 20120520052247) do
create_table "checkins", :force => true do |t|
t.integer "event_id"
@@ -23,6 +23,7 @@
t.string "shoutout"
t.boolean "hidden", :default => false, :null => false
t.string "employer"
+ t.boolean "rafflr"
end
create_table "events", :force => true do |t|

0 comments on commit 9aeeed0

Please sign in to comment.
Something went wrong with that request. Please try again.