From 9d17166e8f92ed69e1cb53b5f23d5bb44073ebe4 Mon Sep 17 00:00:00 2001 From: Okechi Onyeje Date: Thu, 19 Jan 2017 15:42:49 -0500 Subject: [PATCH 1/6] Dashboard integrated but with errors - authentication routes are glitchy - custom devise views are not being displayed properly - routing issues and custom fields for devise routes and models --- Pearlception/.pryrc | 4 +++ Pearlception/Gemfile | 14 +++++++++ Pearlception/Gemfile.lock | 31 +++++++++++++++++++ .../app/assets/stylesheets/custom.scss | 22 +++++++++++++ .../app/controllers/dashboard_controller.rb | 7 ++++- .../controllers/registrations_controller.rb | 8 ++++- .../app/helpers/application_helper.rb | 11 +++++++ Pearlception/app/models/oyster.rb | 11 +++++-- Pearlception/app/models/result.rb | 9 +++++- Pearlception/app/models/run.rb | 10 +++++- Pearlception/app/models/user.rb | 2 ++ .../app/views/dashboard/index.html.erb | 15 ++++++--- .../app/views/layouts/application.html.erb | 14 ++++----- .../app/views/users/sessions/new.html.erb | 2 +- Pearlception/config/database.yml | 18 +++++++++-- Pearlception/config/routes.rb | 9 ++++-- ...9161737_change_company_id_type_in_users.rb | 5 +++ Pearlception/db/schema.rb | 19 +++++------- 18 files changed, 175 insertions(+), 36 deletions(-) create mode 100644 Pearlception/.pryrc create mode 100644 Pearlception/app/assets/stylesheets/custom.scss create mode 100644 Pearlception/db/migrate/20170119161737_change_company_id_type_in_users.rb diff --git a/Pearlception/.pryrc b/Pearlception/.pryrc new file mode 100644 index 0000000..a95f43e --- /dev/null +++ b/Pearlception/.pryrc @@ -0,0 +1,4 @@ +if Rails.env.development? || Rails.env.test? + # This introduces the `table` statement + extend Hirb::Console +end diff --git a/Pearlception/Gemfile b/Pearlception/Gemfile index 9a447a8..e334ea2 100644 --- a/Pearlception/Gemfile +++ b/Pearlception/Gemfile @@ -49,7 +49,21 @@ group :development do # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' + gem 'awesome_rails_console' + gem 'hirb' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] + +# Please clean up duplicated gems if any. +# Feel free to remove gems that you don't want to use or if they conflict with other gem dependencies. (you might need to update .pryrc also) +group :development, :test do + gem 'hirb' + gem 'hirb-unicode' + gem 'pry-byebug' + gem 'pry-stack_explorer' +end + +group :development, :test do +end diff --git a/Pearlception/Gemfile.lock b/Pearlception/Gemfile.lock index 7b37024..47ab8e3 100644 --- a/Pearlception/Gemfile.lock +++ b/Pearlception/Gemfile.lock @@ -39,9 +39,17 @@ GEM minitest (~> 5.1) tzinfo (~> 1.1) arel (7.1.4) + awesome_print (1.7.0) + awesome_rails_console (0.4.0) + awesome_print + pry-rails + railties bcrypt (3.1.11) + binding_of_caller (0.7.2) + debug_inspector (>= 0.0.1) builder (3.2.2) byebug (9.0.6) + coderay (1.1.1) coffee-rails (4.2.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.2.x) @@ -62,6 +70,10 @@ GEM ffi (1.9.14) globalid (0.3.7) activesupport (>= 4.1.0) + hirb (0.7.3) + hirb-unicode (0.0.5) + hirb (~> 0.5) + unicode-display_width (~> 0.1.1) i18n (0.7.0) jbuilder (2.6.1) activesupport (>= 3.0.0, < 5.1) @@ -89,6 +101,18 @@ GEM nokogiri (1.7.0) mini_portile2 (~> 2.1.0) orm_adapter (0.5.0) + pry (0.10.4) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + pry-byebug (3.4.2) + byebug (~> 9.0) + pry (~> 0.10) + pry-rails (0.3.4) + pry (>= 0.9.10) + pry-stack_explorer (0.4.9.2) + binding_of_caller (>= 0.7) + pry (>= 0.9.11) puma (3.6.2) rack (2.0.1) rack-test (0.6.3) @@ -129,6 +153,7 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) + slop (3.6.0) spring (2.0.0) activesupport (>= 4.2) spring-watcher-listen (2.0.1) @@ -151,6 +176,7 @@ GEM thread_safe (~> 0.1) uglifier (3.0.4) execjs (>= 0.3.0, < 3) + unicode-display_width (0.1.1) warden (1.2.6) rack (>= 1.0) web-console (3.4.0) @@ -166,14 +192,19 @@ PLATFORMS ruby DEPENDENCIES + awesome_rails_console bcrypt (~> 3.1.7) byebug coffee-rails (~> 4.2) devise + hirb + hirb-unicode jbuilder (~> 2.5) jquery-rails listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) + pry-byebug + pry-stack_explorer puma (~> 3.0) rails (~> 5.0.1) sass-rails (~> 5.0) diff --git a/Pearlception/app/assets/stylesheets/custom.scss b/Pearlception/app/assets/stylesheets/custom.scss new file mode 100644 index 0000000..0f37419 --- /dev/null +++ b/Pearlception/app/assets/stylesheets/custom.scss @@ -0,0 +1,22 @@ +//@import "bootstrap-sprockets"; +@import "bootstrap"; + +/* mixins, variables, etc. */ + +$gray-medium-light: #eaeaea; + +@mixin box_sizing { + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; +} + +/* miscellaneous */ + +.debug_dump { + clear: both; + float: left; + width: 100%; + margin-top: 45px; + @include box_sizing; +} diff --git a/Pearlception/app/controllers/dashboard_controller.rb b/Pearlception/app/controllers/dashboard_controller.rb index 573a03c..bc5e667 100644 --- a/Pearlception/app/controllers/dashboard_controller.rb +++ b/Pearlception/app/controllers/dashboard_controller.rb @@ -1,7 +1,12 @@ class DashboardController < ApplicationController + before_filter :deny_to_visitors def index - + + end + + def deny_to_visitors + redirect_to "/signin" unless user_signed_in? end end diff --git a/Pearlception/app/controllers/registrations_controller.rb b/Pearlception/app/controllers/registrations_controller.rb index b97cbdf..48c6d01 100644 --- a/Pearlception/app/controllers/registrations_controller.rb +++ b/Pearlception/app/controllers/registrations_controller.rb @@ -1,5 +1,11 @@ class RegistrationsController < Devise::RegistrationsController - private + include ApplicationHelper + protected + + def create + super + binding.pry + end def sign_up_params params.require(:user).permit(:company_id, :email, :password, :password_confirmation) diff --git a/Pearlception/app/helpers/application_helper.rb b/Pearlception/app/helpers/application_helper.rb index de6be79..2768dce 100644 --- a/Pearlception/app/helpers/application_helper.rb +++ b/Pearlception/app/helpers/application_helper.rb @@ -1,2 +1,13 @@ module ApplicationHelper + def resource_name + :user + end + + def resource + @resource ||= User.new + end + + def devise_mapping + @devise_mapping ||= Devise.mappings[:user] + end end diff --git a/Pearlception/app/models/oyster.rb b/Pearlception/app/models/oyster.rb index 0a7cdb6..3514394 100644 --- a/Pearlception/app/models/oyster.rb +++ b/Pearlception/app/models/oyster.rb @@ -1,6 +1,11 @@ class Oyster < ApplicationRecord belongs_to :run - Oyster.establish_connection(:"stats_#{Rails.env}") - - + #Oyster.establish_connection(:"stats_#{Rails.env}") + Oyster.establish_connection( + :adapter => "mysql2", + :host => ENV['STATS_DB_URL'], + :username => ENV['STATS_DB_USER'], + :password => ENV['STATS_DB_PASS'], + :database => "main" + ) end diff --git a/Pearlception/app/models/result.rb b/Pearlception/app/models/result.rb index f03b554..cbd0ed2 100644 --- a/Pearlception/app/models/result.rb +++ b/Pearlception/app/models/result.rb @@ -1,3 +1,10 @@ class Result < ApplicationRecord - establish_connection(:"stats_#{Rails.env}") + #establish_connection(:"stats_#{Rails.env}") + Result.establish_connection( + :adapter => "mysql2", + :host => ENV['STATS_DB_URL'], + :username => ENV['STATS_DB_USER'], + :password => ENV['STATS_DB_PASS'], + :database => "main" + ) end diff --git a/Pearlception/app/models/run.rb b/Pearlception/app/models/run.rb index 18c81f6..1dd5a5e 100644 --- a/Pearlception/app/models/run.rb +++ b/Pearlception/app/models/run.rb @@ -1,4 +1,12 @@ class Run < ApplicationRecord has_many :oysters - establish_connection(:"stats_#{Rails.env}") + belongs_to :companies + # establish_connection(:"stats_#{Rails.env}") + Run.establish_connection( + :adapter => "mysql2", + :host => ENV['STATS_DB_URL'], + :username => ENV['STATS_DB_USER'], + :password => ENV['STATS_DB_PASS'], + :database => "main" + ) end diff --git a/Pearlception/app/models/user.rb b/Pearlception/app/models/user.rb index b2091f9..0a39c7f 100644 --- a/Pearlception/app/models/user.rb +++ b/Pearlception/app/models/user.rb @@ -1,4 +1,6 @@ class User < ApplicationRecord + has_one :company + has_many :runs # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, diff --git a/Pearlception/app/views/dashboard/index.html.erb b/Pearlception/app/views/dashboard/index.html.erb index 50c91ed..be38ebf 100644 --- a/Pearlception/app/views/dashboard/index.html.erb +++ b/Pearlception/app/views/dashboard/index.html.erb @@ -14,10 +14,15 @@

Pearlception Dashboard

-
+

Recent Results

diff --git a/Pearlception/app/views/layouts/application.html.erb b/Pearlception/app/views/layouts/application.html.erb index 368cf4a..5978e7f 100644 --- a/Pearlception/app/views/layouts/application.html.erb +++ b/Pearlception/app/views/layouts/application.html.erb @@ -6,17 +6,17 @@ <%= javascript_include_tag "application", "data-turbolinks-track" => false %> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> - <%= yield %> + <% if notice %> +

<%= notice %>

+ <% end %> + <% if alert %> +

<%= alert %>

+ <% end %> - <% if notice %> -

<%= notice %>

- <% end %> - <% if alert %> -

<%= alert %>

- <% end %> <%= yield %> + <%= debug(params) if Rails.env.development? %> diff --git a/Pearlception/app/views/users/sessions/new.html.erb b/Pearlception/app/views/users/sessions/new.html.erb index f28053e..d6fde2b 100644 --- a/Pearlception/app/views/users/sessions/new.html.erb +++ b/Pearlception/app/views/users/sessions/new.html.erb @@ -1,4 +1,4 @@ -

Log in

+

Log

<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
diff --git a/Pearlception/config/database.yml b/Pearlception/config/database.yml index 04d2385..5c38342 100644 --- a/Pearlception/config/database.yml +++ b/Pearlception/config/database.yml @@ -15,13 +15,13 @@ default: &default pool: 5 username: <%= ENV['TEST_USER'] %> password: <%= ENV['TEST_PASS'] %> - socket: <%= ENV['TEST_SOCKET'] %> + socket: <%= ENV['TEST_SOCKET'] %> -stats_development: &stats +stats_development: &stats adapter: mysql2 encoding: utf8 pool: 5 - username: <%= ENV['STATS_DB_USER'] %> + username: <%= ENV['STATS_DB_USER'] %> password: <%= ENV['STATS_DB_PASS'] %> host: <%= ENV['STATS_DB_URL'] %> port: 3306 @@ -34,6 +34,12 @@ stats_test: development: <<: *default database: Pearlception_development + username: <%= ENV['DEV_DB_USER'] %> + password: <%= ENV['DEV_DB_PASS'] %> + #host: <%= ENV['DEV_DB_URL'] %> + host: localhost + port: 3306 + #database: main # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". @@ -41,6 +47,12 @@ development: test: <<: *default database: Pearlception_test + username: <%= ENV['DEV_DB_USER'] %> + password: <%= ENV['DEV_DB_PASS'] %> + #host: <%= ENV['DEV_DB_URL'] %> + host: localhost + port: 3306 + #database: main # As with config/secrets.yml, you never want to store sensitive information, # like your database password, in your source code. If your source code is diff --git a/Pearlception/config/routes.rb b/Pearlception/config/routes.rb index 38cd3e6..625aa85 100644 --- a/Pearlception/config/routes.rb +++ b/Pearlception/config/routes.rb @@ -1,7 +1,12 @@ Rails.application.routes.draw do - devise_for :users, :controllers => { registrations: 'registrations' } root "dashboard#index" resources :runs + + devise_for :users, :controllers => {:registrations => 'registrations'} + devise_scope :users do + get 'signin' => 'registrations#new' + post 'signin' => 'registrations#create' + end # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html -end \ No newline at end of file +end diff --git a/Pearlception/db/migrate/20170119161737_change_company_id_type_in_users.rb b/Pearlception/db/migrate/20170119161737_change_company_id_type_in_users.rb new file mode 100644 index 0000000..8fb396d --- /dev/null +++ b/Pearlception/db/migrate/20170119161737_change_company_id_type_in_users.rb @@ -0,0 +1,5 @@ +class ChangeCompanyIdTypeInUsers < ActiveRecord::Migration[5.0] + def change + change_column :users, :company_id, :integer, default: -1 + end +end diff --git a/Pearlception/db/schema.rb b/Pearlception/db/schema.rb index 11318a1..bb71542 100644 --- a/Pearlception/db/schema.rb +++ b/Pearlception/db/schema.rb @@ -10,8 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -<<<<<<< HEAD -ActiveRecord::Schema.define(version: 20170109174008) do +ActiveRecord::Schema.define(version: 20170119161737) do create_table "companies", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| t.string "company_name" @@ -21,24 +20,22 @@ ActiveRecord::Schema.define(version: 20170109174008) do end create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| - t.string "email", default: "", null: false - t.string "encrypted_password", default: "", null: false - t.integer "company_id", null: false + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false + t.integer "company_id", null: false + t.boolean "admin", default: false, null: false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false + t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.index ["email"], name: "index_users_on_email", unique: true, using: :btree t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree end -======= -ActiveRecord::Schema.define(version: 0) do ->>>>>>> master end From c0564fff147272020b363d5b7dcefc563af49f18 Mon Sep 17 00:00:00 2001 From: Okechi Onyeje Date: Fri, 20 Jan 2017 00:51:06 -0500 Subject: [PATCH 2/6] Added Dashboard Integration and Authentication - Signin and Signup views still not being shown and defaulting to default --- .../controllers/registrations_controller.rb | 16 +- .../app/views/dashboard/index.html.erb | 189 ++++++------------ .../views/users/registrations/new.html.erb | 2 +- 3 files changed, 77 insertions(+), 130 deletions(-) diff --git a/Pearlception/app/controllers/registrations_controller.rb b/Pearlception/app/controllers/registrations_controller.rb index 48c6d01..8ce31be 100644 --- a/Pearlception/app/controllers/registrations_controller.rb +++ b/Pearlception/app/controllers/registrations_controller.rb @@ -1,13 +1,23 @@ class RegistrationsController < Devise::RegistrationsController include ApplicationHelper - protected + #protected def create - super binding.pry + @user = User.new(sign_up_params) + if !@user.admin? + #search by company token given by one of pearlception admins to the company + #and look up comany_id # + @user.company_id = 0 + else + @user.company_id = -1 + end + @user.save + sign_in @user + redirect_to "/" end def sign_up_params - params.require(:user).permit(:company_id, :email, :password, :password_confirmation) + params.require(:user).permit(:email, :password, :password_confirmation, :company_id) end end diff --git a/Pearlception/app/views/dashboard/index.html.erb b/Pearlception/app/views/dashboard/index.html.erb index be38ebf..0c6abd8 100644 --- a/Pearlception/app/views/dashboard/index.html.erb +++ b/Pearlception/app/views/dashboard/index.html.erb @@ -10,23 +10,23 @@ - Pearlception + Pearlception
@@ -35,10 +35,15 @@
diff --git a/Pearlception/app/views/users/registrations/new.html.erb b/Pearlception/app/views/users/registrations/new.html.erb index 06ef1ad..64d7da6 100644 --- a/Pearlception/app/views/users/registrations/new.html.erb +++ b/Pearlception/app/views/users/registrations/new.html.erb @@ -1,4 +1,4 @@ -

Sign up

+

Sign up!

<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> <%= devise_error_messages! %> From f2d8ca033825cc6a651b5d0ecc0eb7b96e7a438d Mon Sep 17 00:00:00 2001 From: Okechi Onyeje Date: Fri, 20 Jan 2017 01:03:06 -0500 Subject: [PATCH 3/6] Companies Views and Controllers somewhat implemented - Company index route & new route implemented with views - Company create route has issues - Company route only accessible to admins --- .../app/assets/javascripts/companies.coffee | 3 + .../app/assets/stylesheets/companies.scss | 3 + .../app/controllers/companies_controller.rb | 32 +++++++ Pearlception/app/helpers/companies_helper.rb | 2 + Pearlception/app/models/company.rb | 1 + .../app/views/companies/index.html.erb | 91 +++++++++++++++++++ Pearlception/app/views/companies/new.html.erb | 83 +++++++++++++++++ Pearlception/config/routes.rb | 1 + .../controllers/companies_controller_test.rb | 7 ++ 9 files changed, 223 insertions(+) create mode 100644 Pearlception/app/assets/javascripts/companies.coffee create mode 100644 Pearlception/app/assets/stylesheets/companies.scss create mode 100644 Pearlception/app/controllers/companies_controller.rb create mode 100644 Pearlception/app/helpers/companies_helper.rb create mode 100644 Pearlception/app/views/companies/index.html.erb create mode 100644 Pearlception/app/views/companies/new.html.erb create mode 100644 Pearlception/test/controllers/companies_controller_test.rb diff --git a/Pearlception/app/assets/javascripts/companies.coffee b/Pearlception/app/assets/javascripts/companies.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/Pearlception/app/assets/javascripts/companies.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/Pearlception/app/assets/stylesheets/companies.scss b/Pearlception/app/assets/stylesheets/companies.scss new file mode 100644 index 0000000..412c0f5 --- /dev/null +++ b/Pearlception/app/assets/stylesheets/companies.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Companies controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/Pearlception/app/controllers/companies_controller.rb b/Pearlception/app/controllers/companies_controller.rb new file mode 100644 index 0000000..f50f318 --- /dev/null +++ b/Pearlception/app/controllers/companies_controller.rb @@ -0,0 +1,32 @@ +class CompaniesController < ApplicationController + require 'securerandom' + before_filter :deny_to_visitors + + def new + @company = Company.new + end + + def create + @company = Company.new(company_params) + @company.company_token = SecureRandom.uuid + + if @company.save + redirect_to :action => 'index' + else + flash[:alert] = @company.errors.full_messages.to_sentence + redirect_to :action => 'new' + end + end + + def index + @companies = Company.all + end + + def deny_to_visitors + redirect_to "/signin" unless user_signed_in? && current_user.admin? + end + + def company_params + params.require(:company).permit(:company_name, :company_token) + end +end diff --git a/Pearlception/app/helpers/companies_helper.rb b/Pearlception/app/helpers/companies_helper.rb new file mode 100644 index 0000000..099b151 --- /dev/null +++ b/Pearlception/app/helpers/companies_helper.rb @@ -0,0 +1,2 @@ +module CompaniesHelper +end diff --git a/Pearlception/app/models/company.rb b/Pearlception/app/models/company.rb index c2737b5..3a4fb41 100644 --- a/Pearlception/app/models/company.rb +++ b/Pearlception/app/models/company.rb @@ -1,3 +1,4 @@ class Company < ApplicationRecord belongs_to :user + has_many :runs end diff --git a/Pearlception/app/views/companies/index.html.erb b/Pearlception/app/views/companies/index.html.erb new file mode 100644 index 0000000..8a195dd --- /dev/null +++ b/Pearlception/app/views/companies/index.html.erb @@ -0,0 +1,91 @@ +<%= stylesheet_link_tag "dashboard" %>_ + + + + +
+
+ +
+

Companies

+

Registered Companies

+
+ <%= link_to(new_company_path, :method => :get) do %> + Register a Company + <% end %> + + + + + + + + + + <% if @companies.empty? %> +
#Company IDCompany NameRegistration Serial Key
+
+

No Companies Registered

+
+ <% else %> + + + + <% end %> +
+
+
+
+ <%= javascript_include_tag "bootstrap.min" %>_ + diff --git a/Pearlception/app/views/companies/new.html.erb b/Pearlception/app/views/companies/new.html.erb new file mode 100644 index 0000000..e68b7d4 --- /dev/null +++ b/Pearlception/app/views/companies/new.html.erb @@ -0,0 +1,83 @@ +<%= stylesheet_link_tag "dashboard" %>_ + + + + +
+
+ +
+

Companies

+

Register a New Company

+
+ <%= link_to(companies_path, :method => :get) do %> + Back + <% end %> + <%= form_for @company, url: {action: "create"}, html: {class: "company_form"} do |f| %> +
+ <%= f.text_field :company_name, class: 'form-control', placeholder: 'Company Name' %> +
+
+ <%= f.submit "Create" %> +
+
+ + <% end %> + +
+
+
+
+ <%= javascript_include_tag "bootstrap.min" %>_ + diff --git a/Pearlception/config/routes.rb b/Pearlception/config/routes.rb index 625aa85..1a1ae89 100644 --- a/Pearlception/config/routes.rb +++ b/Pearlception/config/routes.rb @@ -2,6 +2,7 @@ Rails.application.routes.draw do root "dashboard#index" resources :runs + resources :companies devise_for :users, :controllers => {:registrations => 'registrations'} devise_scope :users do diff --git a/Pearlception/test/controllers/companies_controller_test.rb b/Pearlception/test/controllers/companies_controller_test.rb new file mode 100644 index 0000000..c3c7d1a --- /dev/null +++ b/Pearlception/test/controllers/companies_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CompaniesControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end From 2b6452716bf1e750028377b5ae68848e44745c22 Mon Sep 17 00:00:00 2001 From: Okechi Onyeje Date: Fri, 20 Jan 2017 01:51:13 -0500 Subject: [PATCH 4/6] Results Index route implemented - Dashboard overview is the results index - No filtering based on companies yet --- Pearlception/Gemfile | 2 ++ Pearlception/Gemfile.lock | 13 +++++++++++++ Pearlception/app/assets/images/ajax-loader.gif | Bin 0 -> 10819 bytes .../app/controllers/dashboard_controller.rb | 1 + Pearlception/app/views/dashboard/index.html.erb | 6 ++++++ 5 files changed, 22 insertions(+) create mode 100644 Pearlception/app/assets/images/ajax-loader.gif diff --git a/Pearlception/Gemfile b/Pearlception/Gemfile index e334ea2..882f710 100644 --- a/Pearlception/Gemfile +++ b/Pearlception/Gemfile @@ -36,6 +36,8 @@ gem 'bcrypt', '~> 3.1.7' # gem 'capistrano-rails', group: :development # for sign in sign up gem 'devise' +#for pagination +gem 'kaminari' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console diff --git a/Pearlception/Gemfile.lock b/Pearlception/Gemfile.lock index 47ab8e3..e375e40 100644 --- a/Pearlception/Gemfile.lock +++ b/Pearlception/Gemfile.lock @@ -82,6 +82,18 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) + kaminari (1.0.1) + activesupport (>= 4.1.0) + kaminari-actionview (= 1.0.1) + kaminari-activerecord (= 1.0.1) + kaminari-core (= 1.0.1) + kaminari-actionview (1.0.1) + actionview + kaminari-core (= 1.0.1) + kaminari-activerecord (1.0.1) + activerecord + kaminari-core (= 1.0.1) + kaminari-core (1.0.1) listen (3.0.8) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -201,6 +213,7 @@ DEPENDENCIES hirb-unicode jbuilder (~> 2.5) jquery-rails + kaminari listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) pry-byebug diff --git a/Pearlception/app/assets/images/ajax-loader.gif b/Pearlception/app/assets/images/ajax-loader.gif new file mode 100644 index 0000000000000000000000000000000000000000..3eaeeca5467a8ccb592bc5c16fdef9ba97cd2d38 GIT binary patch literal 10819 zcmb`NXHZjX->;L91QJksCyNau7QnL%fqT*WV9|EZn{zQuC5vz{IlgGEzA8II` zRbT=F007b7g11~OP2DUlL_BTXY(z}$OmPkvQ;V~}{{R z>7C8(4ZZK^RXx2QTE^QZJEpq^D_i-CSeWF%P#Bz*?F0uagt_QD7a#j)j-NljeB0Yu z+Zc@`6yTX)^sBgYqUt07=ax@be|j5{7oziyzkmLAfWQ|&BmSy6tzaSUBO`JU0e=O! z#WJC<5gUhxaJ#JcD8$Bn&{gqV-aOzg?9W;WnNht$SpATvnRZB)c~ab)`84)=d&6My z$3lYwm*KTIyJrcqEGRvI`ii^(_OX8A-O*N}2iCf~?CPGANfYn>_x2RebI;!foEX(G zQmI6DI18PUMCn%=)2n#~15@>P&3f?ivl=Bg`8qmE3cORo?Lg|91k$= zY;Gcalbdd|+{-`VtGxB5-RnoWkkS6`Vr67o;8tqgr`0ys=g+27+~9+S@?^(e+V1}B z5+q|Z3cWe??Ne_?WQD)Kck|A4XzjU-y5B#4EqOdQUcm){a6H(KkV&h`^MGU!n+GEk z!>Q9{5Xf$(l?CqAP81F5)z^DL;Un^=2H%KQ$)+~y+c01ZbwDg;=;G7C#{zDNrs3n# zapta9f7=*Es;uJ{p4^ntG>;h*vgM8)uIk8%<-gZW50zwl$O_)?-=77VKnsTwOh=wc z`lIh?=O>#v4d?4&On6tG*&M#;gQG9>!{eBPZ!Z%4u78&z6LdPP?I`iVtJXpA37c%$ zvkl{!`&w7Va>8WR3-9MKsP7P&l;gj-@pdx2#ynZ;#icdt>m`*PG8?7UBX%2QQsm>+ z@Nd2Eot>Z0uwGgPcA8=@%>?e-?r;>d#8(5JW;D>>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bCSUHS67{oiz>WqkJaOmOTCd6W6YYmE2P$HU|Q)+K-1lm92?{AbAXZ?-4LnzD0- zT_vJg^wSQ{rJeodo^l^y>Kp%vOZ!JmI2h84jPeWcCy)Y3LGBI&ayTr~0Z)7p8DI_# z4a36R5<-$<%My9qz#cma=y<2eTOTqSBuJ;Tuppu2kL1SQ z;ocA4Nkb#OZ?j?>KvUCD((K#<%gg|*Ypwlb7=(Ro?DMBD+e@=v2Mgafe>xlT!B1VY z=NI1;q!9rM5LSMXKa=A2P%hyM|4ew8nYoO5YO2IKBf0)M%CE+$=V(W;shPc5-Ibun z!MLpCY!&mnGGKM27v`D~PzeNV(b zhdHI#YO#5hYn=#2%0|e|ZO_s}&(~^%d2d<1&eZUX@X>D_;{~6T!z;9mH^RB)z@M-E z8zMLjbIVHt5ydaxy`<}sTF-3A9+hN?%Bo}g%_hV0r4}XiAi<6!x{>A1{2TR( zlrUB3&2{=!$FS2TDp}$7h0`4rzsMxa2xTT$%C zg%&H*yRS5b5=j1-i@20UGW2wthOyD}zLZgyw>4~fmV@#k`lQqon#MP`>4=#OW-Xhu z2_Y{_lWmFm+NgNVjN2Ew?=cxk3|%S-v>2dw2etrpF&+JIG#UKToN=N+c3|A`s?l4v z9{zkSp4@~%yVj20=_xlcPyFM2E$shj%73r|69oXS{@IfG H&+q>LrIalH literal 0 HcmV?d00001 diff --git a/Pearlception/app/controllers/dashboard_controller.rb b/Pearlception/app/controllers/dashboard_controller.rb index bc5e667..10a757e 100644 --- a/Pearlception/app/controllers/dashboard_controller.rb +++ b/Pearlception/app/controllers/dashboard_controller.rb @@ -2,6 +2,7 @@ class DashboardController < ApplicationController before_filter :deny_to_visitors def index + @results = Result.page(params[:page]).per(5) end diff --git a/Pearlception/app/views/dashboard/index.html.erb b/Pearlception/app/views/dashboard/index.html.erb index 0c6abd8..fdaf05d 100644 --- a/Pearlception/app/views/dashboard/index.html.erb +++ b/Pearlception/app/views/dashboard/index.html.erb @@ -143,6 +143,12 @@ <% end %> +
+
+ <%= paginate @results %>
+ <%= page_entries_info @results %> +
+
From ace1290a76920916d01eb08776380d1e42c3e6d9 Mon Sep 17 00:00:00 2001 From: Okechi Onyeje Date: Fri, 20 Jan 2017 02:16:45 -0500 Subject: [PATCH 5/6] Changed Index title of dashboard for admins --- .../app/views/dashboard/index.html.erb | 63 ++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/Pearlception/app/views/dashboard/index.html.erb b/Pearlception/app/views/dashboard/index.html.erb index fdaf05d..6d231d2 100644 --- a/Pearlception/app/views/dashboard/index.html.erb +++ b/Pearlception/app/views/dashboard/index.html.erb @@ -84,11 +84,18 @@ --> -

Recent Results

+ <% if current_user.admin? %> +

Recent Results From All Companies

+ <% else %> +

Recent Results

+ <% end %>
+ <% if current_user.admin? %> + + <% end %> @@ -99,6 +106,59 @@ + <% if current_user.admin? %> + <% @results.each_slice(1) do |row| %> + + <% row.each do |result| + run = Run.find(result.id) + #company = Company.find(run.company_id) + %> + + + + + + + + + + + + + + + + + + + + + + + + + <% end %> + + <% end %> + <% else %> <% @results.each_slice(1) do |row| %> <% row.each do |result| @@ -141,6 +201,7 @@ <% end %> <% end %> + <% end %>
CompanyRun Date Location Harvest Time
+ <%= #company.company_name + "Fake Industries" %> + + <%= run.runDate %> + + <%= run.location ? run.location : "" %> + + <%= "" %> + + + <%= run.supplier ? run.supplier : "" %> + + <%= run.distributor ? run.distributor : "" %> + + <%= result.total %> + + <%= run.other ? run.other : "" %> +
From 7c6cf0f38d9fe39dffb3675758523c6e8d4ec0f9 Mon Sep 17 00:00:00 2001 From: Okechi Onyeje Date: Fri, 20 Jan 2017 02:40:43 -0500 Subject: [PATCH 6/6] Create implemented Company - Create route and view implemented with minimal info - index implemented and shows number of registered companies --- Pearlception/app/models/company.rb | 2 +- Pearlception/app/models/user.rb | 2 +- .../app/views/companies/index.html.erb | 26 ++++++- .../app/views/dashboard/index.html.erb | 70 +++++++++---------- 4 files changed, 60 insertions(+), 40 deletions(-) diff --git a/Pearlception/app/models/company.rb b/Pearlception/app/models/company.rb index 3a4fb41..fdc526f 100644 --- a/Pearlception/app/models/company.rb +++ b/Pearlception/app/models/company.rb @@ -1,4 +1,4 @@ class Company < ApplicationRecord - belongs_to :user + has_many :users has_many :runs end diff --git a/Pearlception/app/models/user.rb b/Pearlception/app/models/user.rb index 0a39c7f..a44f648 100644 --- a/Pearlception/app/models/user.rb +++ b/Pearlception/app/models/user.rb @@ -1,5 +1,5 @@ class User < ApplicationRecord - has_one :company + belongs_to :company has_many :runs # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable diff --git a/Pearlception/app/views/companies/index.html.erb b/Pearlception/app/views/companies/index.html.erb index 8a195dd..b505cdf 100644 --- a/Pearlception/app/views/companies/index.html.erb +++ b/Pearlception/app/views/companies/index.html.erb @@ -59,15 +59,14 @@

Companies

-

Registered Companies

-
+

Registered Companies: <%= @companies.count %>

+
<%= link_to(new_company_path, :method => :get) do %> Register a Company <% end %> - @@ -80,6 +79,27 @@ <% else %> + <% @companies.each_slice(1) do |row| %> + + <% row.each do |company|%> + + + + + + + + + + <% end %> + + <% end %>
# Company ID Company Name Registration Serial Key
+ <%= company.id %> + + <%= company.company_name %> + + <%= company.company_token %> +
<% end %> diff --git a/Pearlception/app/views/dashboard/index.html.erb b/Pearlception/app/views/dashboard/index.html.erb index 6d231d2..accc7ef 100644 --- a/Pearlception/app/views/dashboard/index.html.erb +++ b/Pearlception/app/views/dashboard/index.html.erb @@ -159,48 +159,48 @@ <% end %> <% else %> - <% @results.each_slice(1) do |row| %> - - <% row.each do |result| - run = Run.find(result.id) %> - - - <%= run.runDate %> - + <% @results.each_slice(1) do |row| %> + + <% row.each do |result| + run = Run.find(result.id) %> + + + <%= run.runDate %> + - - - <%= run.location ? run.location : "" %> - + + + <%= run.location ? run.location : "" %> + - - - <%= "" %> - + + + <%= "" %> + - - + + - <%= run.supplier ? run.supplier : "" %> - + <%= run.supplier ? run.supplier : "" %> + - - - <%= run.distributor ? run.distributor : "" %> - + + + <%= run.distributor ? run.distributor : "" %> + - - - <%= result.total %> - + + + <%= result.total %> + - - - <%= run.other ? run.other : "" %> - - <% end %> - - <% end %> + + + <%= run.other ? run.other : "" %> + + <% end %> + + <% end %> <% end %>