From: Date: Wed, 28 May 2008 17:24:40 +0000 (-0400) Subject: In the middle of adding custom theme supports. Skin_pictures table added to store... X-Git-Url: https://projects.mako.cc/source/selectricity-live/commitdiff_plain/947bdc28cd01bc025ffde2af3472b38e5d30f9d1?ds=inline;hp=6ab290219a55a24ff6047d02cf6c9a03dc096195 In the middle of adding custom theme supports. Skin_pictures table added to store metadata but final method of upload not yet complete. --- diff --git a/.bzrignore b/.bzrignore index 5304d54..42f2b24 100644 --- a/.bzrignore +++ b/.bzrignore @@ -8,3 +8,7 @@ public/engine_files .DS_Store vendor/plugins/sitealizer/lib/last_update public/pictures +public/skin_pictures +public/pictures +help +public/pictures/0000 diff --git a/app/controllers/election_controller.rb b/app/controllers/election_controller.rb index 571b936..becba6b 100644 --- a/app/controllers/election_controller.rb +++ b/app/controllers/election_controller.rb @@ -62,6 +62,11 @@ class ElectionController < ApplicationController def update_general_information @election = Election.find(params[:id]) + + if params[:skin_picture] + add_theme + end + if @election.update_attributes(params[:election]) flash[:notice] = 'Election was successfully updated.' redirect_to :action => 'show', :id => @election @@ -69,7 +74,12 @@ class ElectionController < ApplicationController render :action => 'edit' end end - + + def add_theme + debugger + skin_picture = SkinPicture.new(params[:skin_picture]) + skin_picture.save + end def show @sidebar_content = render_to_string :partial => 'progress', diff --git a/app/models/skin_picture.rb b/app/models/skin_picture.rb new file mode 100644 index 0000000..c369eae --- /dev/null +++ b/app/models/skin_picture.rb @@ -0,0 +1,9 @@ +class SkinPicture < ActiveRecord::Base + + has_attachment :storage => :file_system, + :processor => :Rmagick + + validates_as_attachment + + +end diff --git a/app/views/election/_themeupload.rhtml b/app/views/election/_themeupload.rhtml new file mode 100644 index 0000000..20d7e29 --- /dev/null +++ b/app/views/election/_themeupload.rhtml @@ -0,0 +1,25 @@ +<%= error_messages_for("skin_picture") %> + +

If you want a custom theme upload it if here!
+ +
+ <%=file_field :skin_picture, :uploaded_data %>
+
+ <%=file_field :skin_picture, :uploaded_data %>
+
+ <%=file_field :skin_picture, :uploaded_data %>
+
+ <%=file_field :skin_picture, :uploaded_data %>
+
+ <%=file_field :skin_picture, :uploaded_data %>
+

+ +

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.
+ Top Bar/ Bottom Bar/ Alternating Backgrounds: 330px wide 53px tall +
+ Default Image: 70px wide 53px tall +

\ No newline at end of file diff --git a/app/views/election/edit_general_information.rhtml b/app/views/election/edit_general_information.rhtml index c2f1cf5..c3b0052 100644 --- a/app/views/election/edit_general_information.rhtml +++ b/app/views/election/edit_general_information.rhtml @@ -3,7 +3,9 @@ -<% form_tag(:action => 'update_general_information', :id => @election) do %> +<% form_tag( {:action => 'update_general_information', :id => @election}, + :multipart => true ) do %> <%= render :partial => 'overview_form' %> + <%= render :partial => 'themeupload' %> <%= submit_tag 'Done' %> <% end %> diff --git a/db/migrate/003_add_custom_widget_support.rb b/db/migrate/003_add_custom_widget_support.rb new file mode 100644 index 0000000..07c69e0 --- /dev/null +++ b/db/migrate/003_add_custom_widget_support.rb @@ -0,0 +1,24 @@ +class AddCustomWidgetSupport < ActiveRecord::Migration + + def self.up + create_table :skin_pictures, :force => true do |t| + t.column :filename, :string + t.column :content_type, :string + t.column :size, :integer + t.column :width, :integer + t.column :height, :integer + t.column :created_at, :datetime + t.column :user_id, :integer + end + + add_column :elections, :embed_custom_string, :string, :default => nil + + end + + def self.down + drop_table :skin_pictures + + remove_column :elections, :embed_custom_string + end + +end diff --git a/db/schema.rb b/db/schema.rb index aa46f6f..e3f8d16 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2,7 +2,7 @@ # migrations feature of ActiveRecord to incrementally modify your database, and # then regenerate this schema definition. -ActiveRecord::Schema.define(:version => 2) do +ActiveRecord::Schema.define(:version => 3) do create_table "candidates", :force => true do |t| t.column "election_id", :integer, :null => false @@ -11,21 +11,22 @@ ActiveRecord::Schema.define(:version => 2) do end create_table "elections", :force => true do |t| - t.column "name", :string, :limit => 100, :default => "", :null => false - t.column "description", :text, :default => "", :null => false - t.column "anonymous", :integer, :limit => 4, :default => 1, :null => false - t.column "startdate", :datetime - t.column "enddate", :datetime, :null => false - t.column "active", :integer, :limit => 4, :default => 0, :null => false - t.column "viewable", :integer, :limit => 4, :default => 1, :null => false - t.column "notices", :integer, :limit => 4, :default => 0, :null => false - t.column "user_id", :integer - t.column "quickuser", :string - t.column "election_method", :string, :limit => 100, :default => "ssd" - t.column "type", :string, :limit => 100, :default => "", :null => false - t.column "embeddable", :boolean, :default => false, :null => false - t.column "authenticated", :boolean, :default => true, :null => false - t.column "early_results", :boolean, :default => false, :null => false + t.column "name", :string, :limit => 100, :default => "", :null => false + t.column "description", :text, :default => "", :null => false + t.column "anonymous", :integer, :limit => 4, :default => 1, :null => false + t.column "startdate", :datetime + t.column "enddate", :datetime, :null => false + t.column "active", :integer, :limit => 4, :default => 0, :null => false + t.column "viewable", :integer, :limit => 4, :default => 1, :null => false + t.column "notices", :integer, :limit => 4, :default => 0, :null => false + t.column "user_id", :integer + t.column "quickuser", :string + t.column "election_method", :string, :limit => 100, :default => "ssd" + t.column "type", :string, :limit => 100, :default => "", :null => false + t.column "embeddable", :boolean, :default => false, :null => false + t.column "authenticated", :boolean, :default => true, :null => false + t.column "early_results", :boolean, :default => false, :null => false + t.column "embed_custom_string", :string end add_index "elections", ["user_id"], :name => "fk_user_election" @@ -66,6 +67,16 @@ ActiveRecord::Schema.define(:version => 2) do t.column "created_on", :date end + create_table "skin_pictures", :force => true do |t| + t.column "filename", :string + t.column "content_type", :string + t.column "size", :integer + t.column "width", :integer + t.column "height", :integer + t.column "created_at", :datetime + t.column "user_id", :integer + end + create_table "tokens", :force => true do |t| t.column "token", :string, :limit => 100, :default => "", :null => false t.column "vote_id", :integer, :null => false diff --git a/test/fixtures/skin_pictures.yml b/test/fixtures/skin_pictures.yml new file mode 100644 index 0000000..b49c4eb --- /dev/null +++ b/test/fixtures/skin_pictures.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +one: + id: 1 +two: + id: 2 diff --git a/test/unit/skin_picture_test.rb b/test/unit/skin_picture_test.rb new file mode 100644 index 0000000..ec95ba4 --- /dev/null +++ b/test/unit/skin_picture_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class SkinPictureTest < Test::Unit::TestCase + fixtures :skin_pictures + + # Replace this with your real tests. + def test_truth + assert true + end +end