migrate to using aws/paperclip for metacodes. RUN RAKE TASK ON PRODUCTION

This commit is contained in:
Devin Howard 2016-02-23 14:58:20 +08:00
parent cb43ebce92
commit 295534e4ab
7 changed files with 90 additions and 55 deletions

View file

@ -272,6 +272,3 @@ DEPENDENCIES
tunemygc
uglifier
uservoice-ruby
BUNDLED WITH
1.11.2

View file

@ -3,6 +3,15 @@ class Metacode < ActiveRecord::Base
has_many :metacode_sets, :through => :in_metacode_sets
has_many :topics
# This method associates the attribute ":icon" with a file attachment
has_attached_file :icon, :styles => {
:ninetysix => ['96x96#', :png],
},
:default_url => 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_wildcard.png'
# Validate the attached icon is image/jpg, image/png, etc
validates_attachment_content_type :icon, :content_type => /\Aimage\/.*\Z/
def hasSelected(user)
return true if user.settings.metacodes.include? self.id.to_s
return false

View file

@ -18,7 +18,7 @@
</div>
<div class="field">
<%= f.label :icon %>
<%= f.text_field :icon %>
<%= f.file_field :icon %>
<div class="clearfloat"></div>
</div>
<div class="field">

View file

@ -0,0 +1,8 @@
class AddAttachmentIconToMetacodes < ActiveRecord::Migration
def change
change_table :metacodes do |t|
t.rename :icon, :old_icon
t.attachment :icon
end
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160120061513) do
ActiveRecord::Schema.define(version: 20160223061711) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -76,10 +76,14 @@ ActiveRecord::Schema.define(version: 20160120061513) do
create_table "metacodes", force: :cascade do |t|
t.text "name"
t.string "icon"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "old_icon"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "color"
t.string "icon_file_name"
t.string "icon_content_type"
t.integer "icon_file_size"
t.datetime "icon_updated_at"
end
create_table "synapses", force: :cascade do |t|

View file

@ -24,283 +24,283 @@ User.new({
## METACODES
Metacode.create({
name: 'Action',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_action.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_action.png',
color: '#BD6C85'
})
Metacode.create({
name: 'Activity',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_activity.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_activity.png',
color: '#6EBF65'
})
Metacode.create({
name: 'Catalyst',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_catalyst.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_catalyst.png',
color: '#EF8964',
})
Metacode.create({
name: 'Closed',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_closedissue.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_closedissue.png',
color: '#ABB49F',
})
Metacode.create({
name: 'Process',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_process.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_process.png',
color: '#BDB25E',
})
Metacode.create({
name: 'Future',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_futuredev.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_futuredev.png',
color: '#25A17F',
})
Metacode.create({
name: 'Group',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_group.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_group.png',
color: '#7076BC',
})
Metacode.create({
name: 'Implication',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_implication.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_implication.png',
color: '#83DECA',
})
Metacode.create({
name: 'Insight',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_insight.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_insight.png',
color: '#B074AD',
})
Metacode.create({
name: 'Intention',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_intention.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_intention.png',
color: '#BAEAFF',
})
Metacode.create({
name: 'Knowledge',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_knowledge.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_knowledge.png',
color: '#60ACF7',
})
Metacode.create({
name: 'Location',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_location.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_location.png',
color: '#ABD9A7',
})
Metacode.create({
name: 'Need',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_need.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_need.png',
color: '#D2A7D4',
})
Metacode.create({
name: 'Open',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_openissue.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_openissue.png',
color: '#9BBF71',
})
Metacode.create({
name: 'Opportunity',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_opportunity.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_opportunity.png',
color: '#889F64',
})
Metacode.create({
name: 'Person',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_person.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_person.png',
color: '#DE925F',
})
Metacode.create({
name: 'Platform',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_platform.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_platform.png',
color: '#21C8FE',
})
Metacode.create({
name: 'Problem',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_problem.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_problem.png',
color: '#99CFC4',
})
Metacode.create({
name: 'Resource',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_resource.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_resource.png',
color: '#C98C63',
})
Metacode.create({
name: 'Role',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_role.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_role.png',
color: '#A8595D',
})
Metacode.create({
name: 'Task',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_task.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_task.png',
color: '#3397C4',
})
Metacode.create({
name: 'Trajectory',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_trajectory.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_trajectory.png',
color: '#D3AA4C',
})
Metacode.create({
name: 'Argument',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_argument.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_argument.png',
color: '#7FAEFD',
})
Metacode.create({
name: 'Con',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_con.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_con.png',
color: '#CF7C74',
})
Metacode.create({
name: 'Subject',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_subject.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_subject.png',
color: '#8293D8',
})
Metacode.create({
name: 'Decision',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_decision.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_decision.png',
color: '#CCA866',
})
Metacode.create({
name: 'Event',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_event.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_event.png',
color: '#F5854B',
})
Metacode.create({
name: 'Example',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_example.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_example.png',
color: '#618C61',
})
Metacode.create({
name: 'Experience',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_experience.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_experience.png',
color: '#BE995F',
})
Metacode.create({
name: 'Feedback',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_feedback.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_feedback.png',
color: '#54A19D',
})
Metacode.create({
name: 'Aim',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_aim.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_aim.png',
color: '#B0B0B0',
})
Metacode.create({
name: 'Good',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_goodpractice.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_goodpractice.png',
color: '#BD9E86',
})
Metacode.create({
name: 'Idea',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_idea.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_idea.png',
color: '#C4BC5E',
})
Metacode.create({
name: 'List',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_list.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_list.png',
color: '#B7A499',
})
Metacode.create({
name: 'Media',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_media.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_media.png',
color: '#6D94CC',
})
Metacode.create({
name: 'Metamap',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_metamap.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_metamap.png',
color: '#AEA9FD',
})
Metacode.create({
name: 'Model',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_model.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_model.png',
color: '#B385BA',
})
Metacode.create({
name: 'Note',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_note.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_note.png',
color: '#A389A1',
})
Metacode.create({
name: 'Perspective',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_perspective.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_perspective.png',
color: '#2EB6CC',
})
Metacode.create({
name: 'Pro',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_pro.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_pro.png',
color: '#89B879',
})
Metacode.create({
name: 'Project',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_project.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_project.png',
color: '#85A050',
})
Metacode.create({
name: 'Question',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_question.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_question.png',
color: '#5CB3B3',
})
Metacode.create({
name: 'Reference',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_reference.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_reference.png',
color: '#A7A7A7',
})
Metacode.create({
name: 'Research',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_research.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_research.png',
color: '#CD8E89',
})
Metacode.create({
name: 'Status',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_status.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_status.png',
color: '#EFA7C0',
})
Metacode.create({
name: 'Tool',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_tool.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_tool.png',
color: '#828282',
})
Metacode.create({
name: 'Wildcard',
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_wildcard.png',
icon_file_name: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_wildcard.png',
color: '#73C7DE',
})
## END METACODES

17
lib/tasks/aws.rake Normal file
View file

@ -0,0 +1,17 @@
namespace :aws do
desc 'migrate metacodes to aws'
task metacode_icon_migrate: :environment do
def no_aws(msg)
Rails.logger.error msg
end
no_aws 'You need to configure S3_BUCKET' unless ENV['S3_BUCKET'].present?
no_aws 'You need to configure AWS_ACCESS_KEY_ID' unless ENV['AWS_ACCESS_KEY_ID'].present?
no_aws 'You need to configure AWS_SECRET_ACCESS_KEY' unless ENV['AWS_SECRET_ACCESS_KEY'].present?
Metacode.find_each do |metacode|
metacode.icon = metacode.old_icon
metacode.save
end
end
end