From e76a13920500f2abcea0837df6834e963d947850 Mon Sep 17 00:00:00 2001 From: Tom Naessens Date: Wed, 10 Dec 2014 21:25:21 +0100 Subject: [PATCH 01/85] Add the migrations, add the category to the form --- app/controllers/products_controller.rb | 2 +- app/models/product.rb | 3 +++ app/models/user.rb | 7 ++++++- app/views/products/_form.html.erb | 2 ++ db/migrate/20141210200008_add_category_to_products.rb | 5 +++++ db/schema.rb | 3 ++- test/fixtures/products.yml | 1 + test/fixtures/users.yml | 7 ++++++- test/models/product_test.rb | 1 + test/models/user_test.rb | 7 ++++++- 10 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20141210200008_add_category_to_products.rb diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index 65b79e7..17f0899 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -39,7 +39,7 @@ class ProductsController < ApplicationController private def product_params - params.require(:product).permit(:name, :price, :avatar) + params.require(:product).permit(:name, :price, :avatar, :category) end end diff --git a/app/models/product.rb b/app/models/product.rb index e7f09dc..5a7542f 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -11,12 +11,15 @@ # avatar_content_type :string(255) # avatar_file_size :integer # avatar_updated_at :datetime +# category :integer default(0) # class Product < ActiveRecord::Base has_many :order_products has_attached_file :avatar, styles: { medium: "100x100>" }, default_style: :medium + enum category: %w(food beverages other) + validates :name, presence: true validates :price, numericality: { only_integer: true, greater_than_or_equal_to: 0 } validates_attachment :avatar, presence: true, content_type: { content_type: ["image/jpeg", "image/gif", "image/png"] }, diff --git a/app/models/user.rb b/app/models/user.rb index 4468325..11f716e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,8 +16,13 @@ # last_sign_in_at :datetime # current_sign_in_ip :string(255) # last_sign_in_ip :string(255) -# dagschotel :reference +# admin :boolean # dagschotel_id :integer +# avatar_file_name :string(255) +# avatar_content_type :string(255) +# avatar_file_size :integer +# avatar_updated_at :datetime +# orders_count :integer default(0) # class User < ActiveRecord::Base diff --git a/app/views/products/_form.html.erb b/app/views/products/_form.html.erb index 8a13796..8ee0799 100644 --- a/app/views/products/_form.html.erb +++ b/app/views/products/_form.html.erb @@ -8,6 +8,8 @@ <%= f.label :price %> <%= f.number_field :price, value: number_with_precision(f.object.price, precision: 2), class: 'form-control', placeholder: "0.00", step: :any %> + <%= form_collection_select f, :category, Product.categories.keys, :to_s, :titlecase %> + <%= f.label :avatar %> <%= f.file_field :avatar %> diff --git a/db/migrate/20141210200008_add_category_to_products.rb b/db/migrate/20141210200008_add_category_to_products.rb new file mode 100644 index 0000000..6cc913b --- /dev/null +++ b/db/migrate/20141210200008_add_category_to_products.rb @@ -0,0 +1,5 @@ +class AddCategoryToProducts < ActiveRecord::Migration + def change + add_column :products, :category, :integer, default: 0 + end +end diff --git a/db/schema.rb b/db/schema.rb index a7496f5..08ab3d3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20141210090544) do +ActiveRecord::Schema.define(version: 20141210200008) do create_table "order_products", force: true do |t| t.integer "order_id" @@ -38,6 +38,7 @@ ActiveRecord::Schema.define(version: 20141210090544) do t.string "avatar_content_type" t.integer "avatar_file_size" t.datetime "avatar_updated_at" + t.integer "category", default: 0 end create_table "users", force: true do |t| diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml index 36b426d..6de2af1 100644 --- a/test/fixtures/products.yml +++ b/test/fixtures/products.yml @@ -11,6 +11,7 @@ # avatar_content_type :string(255) # avatar_file_size :integer # avatar_updated_at :datetime +# category :integer default(0) # # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 4d5b784..640f298 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -16,8 +16,13 @@ # last_sign_in_at :datetime # current_sign_in_ip :string(255) # last_sign_in_ip :string(255) -# dagschotel :reference +# admin :boolean # dagschotel_id :integer +# avatar_file_name :string(255) +# avatar_content_type :string(255) +# avatar_file_size :integer +# avatar_updated_at :datetime +# orders_count :integer default(0) # # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html diff --git a/test/models/product_test.rb b/test/models/product_test.rb index c2ac6dc..e089dca 100644 --- a/test/models/product_test.rb +++ b/test/models/product_test.rb @@ -11,6 +11,7 @@ # avatar_content_type :string(255) # avatar_file_size :integer # avatar_updated_at :datetime +# category :integer default(0) # require 'test_helper' diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 1e0afd3..086c7cf 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -16,8 +16,13 @@ # last_sign_in_at :datetime # current_sign_in_ip :string(255) # last_sign_in_ip :string(255) -# dagschotel :reference +# admin :boolean # dagschotel_id :integer +# avatar_file_name :string(255) +# avatar_content_type :string(255) +# avatar_file_size :integer +# avatar_updated_at :datetime +# orders_count :integer default(0) # require 'test_helper' From 0b0d780e91ed60025bbc22c562373bce2b3c8f0d Mon Sep 17 00:00:00 2001 From: Tom Naessens Date: Wed, 10 Dec 2014 22:06:36 +0100 Subject: [PATCH 02/85] Tabs <3 --- app/controllers/products_controller.rb | 1 + app/views/layouts/_header.html.erb | 2 +- app/views/products/index.html.erb | 21 ++++++++++++++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index 17f0899..ec7b916 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -14,6 +14,7 @@ class ProductsController < ApplicationController def index @products = Product.all + @categories = Product.categories end def edit diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 60f5119..2cd2a64 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -40,7 +40,7 @@
  • <%= link_to "List" , users_path %>
  • -
  • <%= link_to 'Download schulden', admins_schulden_path(format: :csv) %>/li> +
  • <%= link_to 'Download schulden', admins_schulden_path(format: :csv) %>
  • <% end %>
  • <%= link_to "List" , users_path %>
  • -
  • <%= link_to 'Download schulden', admins_schulden_path(format: :csv) %>/li> +
  • <%= link_to 'Download schulden', admins_schulden_path(format: :csv) %>
  • <% end %>
  • class="active"<% end %>><%= o.titleize %>
  • <% end %> +
  • All
  • @@ -17,6 +18,9 @@ <%= render @products.where(category: i) %> <% end %> +
    + <%= render @products %> +
    From b5eab1dce14ee37221cf35bf97cfb3b721479cf3 Mon Sep 17 00:00:00 2001 From: ohsab Date: Fri, 12 Dec 2014 12:50:13 +0100 Subject: [PATCH 05/85] enkele layout fixes --- app/assets/stylesheets/application.css.scss | 6 ++++++ app/assets/stylesheets/users.css.scss | 15 ++++++++++----- app/views/devise/sessions/new.html.erb | 16 +++++++++------- app/views/products/_form.html.erb | 6 +++--- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index f23eb96..8bf2bf8 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -102,3 +102,9 @@ footer ul li { width: 100%; margin-top: 30px; } + +.form-field{ + margin-bottom: 15px; + text-align: bottom; + +} diff --git a/app/assets/stylesheets/users.css.scss b/app/assets/stylesheets/users.css.scss index ddc2ba5..6a2d220 100644 --- a/app/assets/stylesheets/users.css.scss +++ b/app/assets/stylesheets/users.css.scss @@ -3,6 +3,16 @@ // You can use Sass (SCSS) here: http://sass-lang.com/ +//signin +.sign-in{ + .checkbox label{ + padding-left: 0px; + } + #user_remember_me{ + margin-left: 10px; + } +} + .users .thumbnail { padding: 0px; min-height: 280px; @@ -37,11 +47,6 @@ background-color: #f5f5dc; } - - - - - /* sidebar */ aside { diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index bc6674d..3396d7e 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,16 +1,18 @@

    Sign in

    Partners sign in using the link sent by email.
    + - <%= f.submit "Sign in", class: "btn btn-primary" %> -<% end %> <%= render "devise/shared/links" %> diff --git a/app/views/products/_form.html.erb b/app/views/products/_form.html.erb index 8a13796..77706ce 100644 --- a/app/views/products/_form.html.erb +++ b/app/views/products/_form.html.erb @@ -1,15 +1,15 @@
    -
    +