Skip to content
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@
/yarn-error.log

.byebug_history

# Ignore application configuration
/config/application.yml
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ gem 'jbuilder', '~> 2.5'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'
gem 'jquery-rails'

gem "paperclip", git: "git://github.com/thoughtbot/paperclip.git"
gem 'aws-sdk', '~> 2'
gem 'figaro'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
Expand Down
36 changes: 34 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
GIT
remote: git://github.com/thoughtbot/paperclip.git
revision: c794f6df0a10b94f377b9efea08dcfa4e73cfc43
specs:
paperclip (5.1.0)
activemodel (>= 4.2.0)
activesupport (>= 4.2.0)
cocaine (~> 0.5.5)
mime-types
mimemagic (~> 0.3.0)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -43,6 +54,14 @@ GEM
arel (8.0.0)
autoprefixer-rails (7.1.6)
execjs
aws-sdk (2.10.80)
aws-sdk-resources (= 2.10.80)
aws-sdk-core (2.10.80)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-resources (2.10.80)
aws-sdk-core (= 2.10.80)
aws-sigv4 (1.0.2)
bcrypt (3.1.11)
bindex (0.5.0)
bootstrap (4.0.0.beta2.1)
Expand All @@ -58,6 +77,9 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
climate_control (0.2.0)
cocaine (0.5.8)
climate_control (>= 0.0.3, < 1.0)
coderay (1.1.2)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
Expand All @@ -78,13 +100,16 @@ GEM
factory_bot (~> 4.8.2)
railties (>= 3.0.0)
ffi (1.9.18)
figaro (1.1.1)
thor (~> 0.14)
globalid (0.4.1)
activesupport (>= 4.2.0)
i18n (0.9.0)
i18n (0.9.1)
concurrent-ruby (~> 1.0)
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
jmespath (1.3.1)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
Expand All @@ -101,6 +126,10 @@ GEM
mail (2.7.0)
mini_mime (>= 0.1.1)
method_source (0.9.0)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mimemagic (0.3.2)
mini_mime (0.1.4)
mini_portile2 (2.3.0)
minitest (5.10.3)
Expand Down Expand Up @@ -205,17 +234,20 @@ PLATFORMS
ruby

DEPENDENCIES
aws-sdk (~> 2)
bcrypt (~> 3.1.7)
bootstrap (~> 4.0.0.alpha6)
byebug
capybara
coffee-rails (~> 4.2)
database_cleaner
factory_bot_rails
figaro
jbuilder (~> 2.5)
jquery-rails
launchy
listen (>= 3.0.5, < 3.2)
paperclip!
pg (~> 0.18)
pry
puma (~> 3.7)
Expand All @@ -228,4 +260,4 @@ DEPENDENCIES
web-console (>= 3.3.0)

BUNDLED WITH
1.16.0.pre.3
1.16.0
Binary file not shown.
Binary file removed app/assets/images/alejandra-higareda-295603.jpg
Binary file not shown.
Empty file.
Empty file.
Binary file removed app/assets/images/brooke-cagle-171800.jpg
Binary file not shown.
Binary file removed app/assets/images/brooke-cagle-224815.jpg
Binary file not shown.
Binary file removed app/assets/images/chelsea-ferenando-201350.jpg
Binary file not shown.
Binary file removed app/assets/images/dami-adebayo-208876.jpg
Binary file not shown.
Binary file removed app/assets/images/domenico-loia-272251.jpg
Binary file not shown.
Empty file removed app/assets/images/favicon.ico
Empty file.
Binary file removed app/assets/images/foto-sushi-128246.jpg
Binary file not shown.
Binary file removed app/assets/images/ilya-pavlov-87438.jpg
Binary file not shown.
Binary file removed app/assets/images/ivana-cajina-322968.jpg
Binary file not shown.
Binary file removed app/assets/images/joseph-gonzalez-399972.jpg
Binary file not shown.
Binary file removed app/assets/images/michael-dam-258165.jpg
Binary file not shown.
Binary file removed app/assets/images/pete-bellis-199853.jpg
Binary file not shown.
Binary file removed app/assets/images/priscilla-du-preez-216787.jpg
Binary file not shown.
Binary file removed app/assets/images/rawpixel-com-196509.jpg
Binary file not shown.
1 change: 0 additions & 1 deletion app/assets/images/robots.txt

This file was deleted.

Binary file removed app/assets/images/tanja-heffner-196114.jpg
Binary file not shown.
Binary file removed app/assets/images/warren-wong-242286.jpg
Binary file not shown.
4 changes: 3 additions & 1 deletion app/controllers/admin/freelancers_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class Admin::FreelancersController < Admin::BaseController


def index
@freelancers = Freelancer.all
end

def new
@freelancer = Freelancer.new
Expand Down
21 changes: 21 additions & 0 deletions app/models/freelancer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,25 @@ class Freelancer < ApplicationRecord
has_many :orders, through: :order_freelancers

enum status: ["active", "retired"]
attr_accessor :avatar_file_name


has_attached_file :avatar, styles: {
thumb: '100x100>',
square: '200x200#',
medium: '300x300>'
}
has_attached_file :image, styles: { medium: "300x300#", thumb: "100x100#" },
default_style: :thumb,
default_url: ":style/defaults/default.jpg"
validates_attachment_content_type :image, :content_type => ["image/jpg", "image/jpeg", "image/png"]

=begin
Additional ImageMagick resizing options can be found here
The has_attached_file method also accepts a styles hash that specifies the resize dimensions of the uploaded image. The > and # symbols will tell ImageMagick how the image will be resized (the > will proportionally reduce the size of the image).
=end

# Validate the attached image is image/jpg, image/png, etc
validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/

end
2 changes: 1 addition & 1 deletion app/views/admin/freelancers/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="row d-flex justify-content-around">
<% group.each do |freelancer| %>
<div class="card col-3 d-flex text-center">
<img class="card-img-top" src="<%=freelancer.image%>" alt="Card image cap">
<div><%=image_tag(freelancer.avatar.url(:thumb), id: "image_#{freelancer.id}")%></div>
<h4 class="card-title">Name: <%=freelancer.name%></h4>
<p class="card-text"><%=freelancer.description%></p>
<p class="card-text"><%=freelancer.price%>/hr</p>
Expand Down
9 changes: 7 additions & 2 deletions app/views/admin/freelancers/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="form-outline">
<%=form_for [:admin, @freelancer] do |f| %>
<%=form_for [:admin, @freelancer, multipart: true] do |f| %>
<div class="new-account-item">
<div class="form-control account-input">
<%= f.label :name, class: 'new-account-label'%>
Expand Down Expand Up @@ -28,10 +28,15 @@
</div>
</div>

<div class="new-account-item">
<div class="form-control account-input">
<%= f.label :avatar, class: 'new-account-label'%>
<%= f.file_field :avatar, class: 'new-account-box'%>
</div>
</div>

<div class="new-account-item">
<%= f.submit "Create Freelancer Profile", class: "btn btn-primary create-button" %>
</div>
<% end %>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/admin/orders/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Cancelled: <%= @orders.total_cancelled %>
<% if order.Paid? %>
<%= link_to "Mark as Completed", admin_dashboard_path(order_id: order.id, status: 'Completed'), method: :patch %>
<% end %>
<%= link_to "View Order #{order.id}", order_path(order) %>
<%= link_to "View Order #{order.id}", admin_order_path(order) %>
</div>
</br>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/cart/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<% @cart.collect_freelancers.each do |freelancer| %>
<ul class="list-group">
<%= image_tag(freelancer.image, size: "100x100", class: "image-fl-index", id: "image_#{freelancer.id}") %>
<%= image_tag(freelancer.avatar.url(:square), class: "image-fl-index", id: "image_#{freelancer.id}") %>
<h3>Name: <%= freelancer.name %></h3>
<li class="list-group-item"><%= freelancer.description %></li>
<li class="list-group-item">Quantity: <%= @cart.count_of(freelancer.id)%></li>
Expand Down
6 changes: 5 additions & 1 deletion app/views/categories/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@

<%@category.freelancers.each do |freelancer| %>

<%= image_tag(freelancer.image, size: "50x50", class: "image-fl-index", id: "image_#{freelancer.id}") %>
<div class="">
<div><%=image_tag(freelancer.avatar.url(:thumb), id: "image_#{freelancer.id}")%></div>
<ul>
<h4>Name: <%= freelancer.name %></h4>
<li class="list-group-item"><%= freelancer.description%></li>
<li class="list-group-item">$<%= freelancer.price %>/hr</li>
<li class="list-group-item"> <%= button_to "Choose Me!", cart_index_path(freelancer_id: freelancer.id), class: "btn btn-danger btn-sm"%></li>
<% end %>
</ul>

</div>
3 changes: 2 additions & 1 deletion app/views/freelancers/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@




<div class="card-deck d-flex justify-content-between">
<% @freelancers.in_groups_of(3, false).each do |group| %>
<div class="row d-flex justify-content-around">
<% group.each do |freelancer| %>
<div class="card col-3 d-flex text-center">
<img class="card-img-top" src="<%=freelancer.image%>" alt="Card image cap">
<div><%=image_tag(freelancer.avatar.url(:thumb), id: "image_#{freelancer.id}")%></div>
<h4 class="card-title">Name: <%=freelancer.name%></h4>
<p class="card-text"><%=freelancer.description%></p>
<p class="card-text"><%=freelancer.price%>/hr</p>
Expand Down
3 changes: 2 additions & 1 deletion app/views/freelancers/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div class="container d-flex justify-content-center">
<div class="card text-center" style="width:600px">
<img class="card-img-top" src="<%=@freelancer.image%>" alt="Card image cap">
<div><%=image_tag(@freelancer.avatar.url(:thumb), id: "image_#{@freelancer.id}")%></div>

<div class="card-block">
<h4 class="card-title"> Name: <%=@freelancer.name%></h4>
<p class="card-text"><%=@freelancer.description%></p>
Expand Down
15 changes: 15 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
Rails.application.configure do

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@s-espinosa @icorson3
I think this might be set up right, but I'm not sure.

config.paperclip_defaults = {
storage: :s3,
s3_credentials: {
bucket: ENV['S3_BUCKET_NAME'],
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
s3_region: ENV['S3_REGION'],
s3_host_name: ENV['S3_HOST_NAME']
}
}

# Settings specified here will take precedence over those in config/application.rb.

# In the development environment your application's code is reloaded on
Expand Down Expand Up @@ -51,4 +63,7 @@
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker



end
15 changes: 14 additions & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
Rails.application.configure do
config.paperclip_defaults = {
storage: :s3,
s3_credentials: {
bucket: ENV['S3_BUCKET_NAME'],
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
s3_region: ENV['S3_REGION'],
s3_host_name: ENV['S3_HOST_NAME']
}
}
# Settings specified here will take precedence over those in config/application.rb.

# Code is not reloaded between requests.
Expand Down Expand Up @@ -28,7 +38,7 @@
# config.assets.css_compressor = :sass

# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
config.assets.compile = true

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@s-espinosa @icorson3 I see a lot of conflicting information about setting this to true or false


# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb

Expand Down Expand Up @@ -88,4 +98,7 @@

# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false



end
14 changes: 14 additions & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
Rails.application.configure do

config.paperclip_defaults = {
storage: :s3,
s3_credentials: {
bucket: ENV['S3_BUCKET_NAME'],
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
s3_region: ENV['S3_REGION'],
s3_host_name: ENV['S3_HOST_NAME']
}
}

# Settings specified here will take precedence over those in config/application.rb.

# The test environment is used exclusively to run your application's
Expand Down Expand Up @@ -39,4 +51,6 @@

# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true


end
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

namespace :admin do
resources :users, only: [:edit, :update, :show]
resources :freelancers, only: [:new, :create]
resources :freelancers, only: [:new, :create, :index]

resources :orders, only: [:show]
get '/dashboard', to: 'orders#index'
patch '/dashboard', to: 'orders#update'
Expand Down
12 changes: 7 additions & 5 deletions config/secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@

# Environmental secrets are only available for that specific environment.

development:

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@s-espinosa @icorson3 I tried to remove this, but for some reason it still got pushed to GH?

secret_key_base: ffa096348fa590e131d67e30b0c3815610b7679a8bbf87e1bebff212e649d965585fccf955165d5999dfb562018d97892c5d217686fec21fee9e07943a8c4c11

test:
secret_key_base: b13aa68d17a60b96bd5ed46033e75f9d2c327c7cc53335d3faef95d7409be140c779efbe367cc4f88cd4221c1d90009be39a5bf6f77da6e0ec33dc06917d489e

# Do not keep production secrets in the unencrypted secrets file.
# Instead, either read values from the environment.
# Or, use `bin/rails secrets:setup` to configure encrypted secrets
# and move the `production:` environment over there.

production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
secret_key_base: <%= Figaro.env.secret_key_base %>

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@s-espinosa @icorson3
I think this is correct, but I'm not sure how to input the AWS variables that heroku needs. Or they might not need to be saved here because I'm also setting them using terminal commands heroku config AWS_THINGY=random5stuff3


development:
secret_key_base: <%= Figaro.env.secret_key_base %>

test:
secret_key_base: <%= Figaro.env.secret_key_base %>
8 changes: 4 additions & 4 deletions data/freelancers.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name,description,price,image,category_id
name,description,price,image,category_id, status
Kelly ,"I am a professional front-end web developer, with more than 5 years experience building beautiful websites. I primarily serve solopreneurs, other freelancers, and small businesses.",100,chelsea-ferenando-201350.jpg,1
Peter,Engineer and creative mind with over 5 years of experience in software development. Very interested in creating appealing web and mobile solutions and developing fun 'out of the box' alternatives to user needs.,125,dami-adebayo-208876.jpg,4
Jacob,"Since 2011, I have focused on building top-notch native iOS apps, embracing new technologies, and developing great client relationships.",200,brooke-cagle-224815.jpg,4
Expand All @@ -7,7 +7,7 @@ Michael,"User Experience Design, User Interface Design, Responsive Web Design, M
Olivia,I have almost 10 years experience working with packaging and I have knowledge in both graphic design and product design. One of my designs was a finalist at the 2012 HBA International Package Design Awards in New York City.,75,priscilla-du-preez-216787.jpg,7
Angela,"In over 20 years of professional writing, I have flexed my style to suit the audience and meet the goals of my clients from across the spectrum of economic sectors: business, journalism, government, education, and non-profits. ",45,pete-bellis-199853.jpg,5
Samantha,"I have worked as a Quality Assurance Engineer for over 10 years. I have tested UI, Data scraping and Websites. Look forward in working with you",30,michael-dam-258165.jpg,8
George," 20+ years experience in Business Applications consulting, desing and development",150,warren-wong-242286.jpg,6
George," 20+ years experience in Business Applications consulting, desing and development",150,warren-wong-242286.jpg,6, 1
Timothy,"Web Developer interested in freelance opportunities. A strong focus on modern web development: multithreaded programming, OOP, operation with huge Databases. Experience of nearly 10 years.",30,ivana-cajina-322968.jpg,2
Francis,"I am a Graphic Designer/Illustrator with over 36 years of experience. I have spent the last nineteen years working digitally but am also able to do illustrations and drawings by hand. I am comfortable doing any design/illustration work by computer as well and have experience doing everything from cartoons, banners, vector art, logos, business card design, brochure design, posters, ebook cover designs, post cards, dvd covers, editorial cartoons, etc.. ",75,brooke-cagle-171800.jpg,7
Janet,I am UI designer with 3 years working experience. Several times per year I am improving my skills and knowledge by passing design courses. ,110,foto-sushi-128246.jpg,3
Francis,"I am a Graphic Designer/Illustrator with over 36 years of experience. I have spent the last nineteen years working digitally but am also able to do illustrations and drawings by hand. I am comfortable doing any design/illustration work by computer as well and have experience doing everything from cartoons, banners, vector art, logos, business card design, brochure design, posters, ebook cover designs, post cards, dvd covers, editorial cartoons, etc.. ",75,brooke-cagle-171800.jpg,7, 1
Janet,I am UI designer with 3 years working experience. Several times per year I am improving my skills and knowledge by passing design courses. ,110,foto-sushi-128246.jpg,3, 1
11 changes: 11 additions & 0 deletions db/migrate/20171107234018_add_avatar_to_freelancers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class AddAvatarToFreelancers < ActiveRecord::Migration[5.1]

def self.up
add_attachment :freelancers, :avatar
end

def self.down
remove_attachment :freelancers, :avatar
end

end
Loading