@election.user = session[:user]
@election.anonymous = 1
@election.startdate = Time.now
-
+
+ unless params[:top_bar][:uploaded_data].to_s.empty?
+ token_generator = UniqueTokenGenerator.new( 16 )
+ @election.embed_custom_string = token_generator.token
+ add_theme(@election.embed_custom_string)
+ end
+
if @election.save
flash[:notice] = 'Election was successfully created.'
redirect_to :action => 'edit_candidates', :id => @election.id
def update_general_information
@election = Election.find(params[:id])
- if params[:skin_picture]
- add_theme
+ unless params[:top_bar][:uploaded_data].to_s.empty?
+ add_theme(@election.embed_custom_string)
end
if @election.update_attributes(params[:election])
end
end
- def add_theme
- debugger
- skin_picture = SkinPicture.new(params[:skin_picture])
- skin_picture.save
+ def add_theme(prefix)
+ unless params[:top_bar][:uploaded_data].to_s.empty?
+ top_bar = SkinPicture.new(params[:top_bar])
+ top_bar.filename = prefix + "top_bar"
+ top_bar.save!
+ end
+ unless params[:default_image][:uploaded_data].to_s.empty?
+ default_image = SkinPicture.new(params[:default_image])
+ default_image.filename = prefix + "default_image"
+ default_image.save!
+ end
+ unless params[:bg1][:uploaded_data].to_s.empty?
+ bg1 = SkinPicture.new(params[:bg1])
+ bg1.filename = prefix + "bg1"
+ bg1.save!
+ end
+ unless params[:bg2][:uploaded_data].to_s.empty?
+ bg2 = SkinPicture.new(params[:bg2])
+ bg2.filename = prefix + "bg2"
+ bg2.save!
+ end
+ unless params[:bottom_bar][:uploaded_data].to_s.empty?
+ bottom_bar = SkinPicture.new(params[:bottom_bar])
+ bottom_bar.filename = prefix + "bottom_bar"
+ bottom_bar.save!
+ end
+
end
-
+
def show
@sidebar_content = render_to_string :partial => 'progress',
:locals => { :page => 'review' }
class SkinPicture < ActiveRecord::Base
has_attachment :storage => :file_system,
- :processor => :Rmagick
+ :processor => :Rmagick,
+ :content_type => :image
validates_as_attachment
-
-
+
end
--- /dev/null
+<%= error_messages_for("skin_picture") %>
+
+<p>If you want a custom theme upload it if here!<br />
+
+<span><label for="top_bar_uploaded_data">Top Bar</span><br />
+ <%=file_field :top_bar, :uploaded_data %><br />
+<span><label for="default_image_uploaded_data">Corner Image</span><br />
+ <%=file_field :default_image, :uploaded_data %><br />
+<span><label for="bg1_uploaded_data">Background One</span><br />
+ <%=file_field :bg1, :uploaded_data %><br />
+<span><label for="bg2_uploaded_data">Background Two</span><br />
+ <%=file_field :bg2, :uploaded_data %><br />
+<span><label for="bottom_bar_uploaded_data">Bottom Bar</span><br />
+ <%=file_field :bottom_bar, :uploaded_data %><br />
+</p>
+
+<p>Detailed Information:
+ Every embeddable widget uses five different picture files to create
+ it's color scheme and default image. If you have images you'd like to
+ use in your widget. Please make sure they fit the
+ specified dimensions.<br />
+ Top Bar/ Bottom Bar/ Alternating Backgrounds: 330px wide 53px tall
+ <br />
+ Default Image: 70px wide 53px tall
+</p>
\ No newline at end of file
+++ /dev/null
-<%= error_messages_for("skin_picture") %>
-
-<p>If you want a custom theme upload it if here!<br />
-
-<span><label for="skin_picture_topbar">Top Bar</span><br />
- <%=file_field :skin_picture, :uploaded_data %><br />
-<span><label for="skin_picture_default_image">Corner Image</span><br />
- <%=file_field :skin_picture, :uploaded_data %><br />
-<span><label for="skin_picture_vote_bg1">Background One</span><br />
- <%=file_field :skin_picture, :uploaded_data %><br />
-<span><label for="skin_picture_vote_bg2">Background Two</span><br />
- <%=file_field :skin_picture, :uploaded_data %><br />
-<span><label for="skin_picture_bottombar">Bottom Bar</span><br />
- <%=file_field :skin_picture, :uploaded_data %><br />
-</p>
-
-<p>Detailed Information:
- Every embeddable widget uses five different picture files to create
- it's color scheme and default image. If you have images you'd like to
- use in your widget. Please make sure they fit the
- specified dimensions.<br />
- Top Bar/ Bottom Bar/ Alternating Backgrounds: 330px wide 53px tall
- <br />
- Default Image: 70px wide 53px tall
-</p>
\ No newline at end of file
<% form_tag( {:action => 'update_general_information', :id => @election},
:multipart => true ) do %>
<%= render :partial => 'overview_form' %>
- <%= render :partial => 'themeupload' %>
+ <%= render :partial => 'theme_upload' %>
<%= submit_tag 'Done' %>
<% end %>
+
+
<span class="subheader"></span>
</div>
-<% form_tag (:action => 'create_election') do %>
+<% form_tag( {:action => 'create_election'}, :multipart => true ) do %>
<%= render :partial => 'overview_form' %>
+ <%= render :partial => 'theme_upload' %>
<%= submit_tag "Proceed to Next Step" %>
<% end %>
-