mirror of
https://github.com/oonyeje/Pearlception_Website_RoR.git
synced 2025-12-25 03:37:40 +00:00
Config basic stats view
This commit is contained in:
parent
2c15b6290e
commit
e7bee7002c
@ -1,96 +0,0 @@
|
|||||||
# You can have Apartment route to the appropriate Tenant by adding some Rack middleware.
|
|
||||||
# Apartment can support many different "Elevators" that can take care of this routing to your data.
|
|
||||||
# Require whichever Elevator you're using below or none if you have a custom one.
|
|
||||||
#
|
|
||||||
# require 'apartment/elevators/generic'
|
|
||||||
# require 'apartment/elevators/domain'
|
|
||||||
require 'apartment/elevators/subdomain'
|
|
||||||
# require 'apartment/elevators/first_subdomain'
|
|
||||||
|
|
||||||
#
|
|
||||||
# Apartment Configuration
|
|
||||||
#
|
|
||||||
Apartment.configure do |config|
|
|
||||||
|
|
||||||
# Add any models that you do not want to be multi-tenanted, but remain in the global (public) namespace.
|
|
||||||
# A typical example would be a Customer or Tenant model that stores each Tenant's information.
|
|
||||||
#
|
|
||||||
config.excluded_models = [ "User", "Company" ]
|
|
||||||
|
|
||||||
# In order to migrate all of your Tenants you need to provide a list of Tenant names to Apartment.
|
|
||||||
# You can make this dynamic by providing a Proc object to be called on migrations.
|
|
||||||
# This object should yield either:
|
|
||||||
# - an array of strings representing each Tenant name.
|
|
||||||
# - a hash which keys are tenant names, and values custom db config (must contain all key/values required in database.yml)
|
|
||||||
#
|
|
||||||
# config.tenant_names = lambda{ Customer.pluck(:tenant_name) }
|
|
||||||
# config.tenant_names = ['tenant1', 'tenant2']
|
|
||||||
# config.tenant_names = {
|
|
||||||
# 'tenant1' => {
|
|
||||||
# adapter: 'postgresql',
|
|
||||||
# host: 'some_server',
|
|
||||||
# port: 5555,
|
|
||||||
# database: 'postgres' # this is not the name of the tenant's db
|
|
||||||
# # but the name of the database to connect to before creating the tenant's db
|
|
||||||
# # mandatory in postgresql
|
|
||||||
# },
|
|
||||||
# 'tenant2' => {
|
|
||||||
# adapter: 'postgresql',
|
|
||||||
# database: 'postgres' # this is not the name of the tenant's db
|
|
||||||
# # but the name of the database to connect to before creating the tenant's db
|
|
||||||
# # mandatory in postgresql
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# config.tenant_names = lambda do
|
|
||||||
# Tenant.all.each_with_object({}) do |tenant, hash|
|
|
||||||
# hash[tenant.name] = tenant.db_configuration
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
|
|
||||||
names = (Company.pluck :company_name) - ["IVA"]
|
|
||||||
|
|
||||||
names.map!{|tenant| tenant.gsub(/'/,'').gsub(/\s/,'')}
|
|
||||||
|
|
||||||
config.tenant_names = names
|
|
||||||
|
|
||||||
# ==> PostgreSQL only options
|
|
||||||
|
|
||||||
# Specifies whether to use PostgreSQL schemas or create a new database per Tenant.
|
|
||||||
# The default behaviour is true.
|
|
||||||
#
|
|
||||||
config.use_schemas = false
|
|
||||||
|
|
||||||
# Apartment can be forced to use raw SQL dumps instead of schema.rb for creating new schemas.
|
|
||||||
# Use this when you are using some extra features in PostgreSQL that can't be respresented in
|
|
||||||
# schema.rb, like materialized views etc. (only applies with use_schemas set to true).
|
|
||||||
# (Note: this option doesn't use db/structure.sql, it creates SQL dump by executing pg_dump)
|
|
||||||
#
|
|
||||||
# config.use_sql = false
|
|
||||||
|
|
||||||
# There are cases where you might want some schemas to always be in your search_path
|
|
||||||
# e.g when using a PostgreSQL extension like hstore.
|
|
||||||
# Any schemas added here will be available along with your selected Tenant.
|
|
||||||
#
|
|
||||||
# config.persistent_schemas = %w{ hstore }
|
|
||||||
|
|
||||||
# <== PostgreSQL only options
|
|
||||||
#
|
|
||||||
|
|
||||||
# By default, and only when not using PostgreSQL schemas, Apartment will prepend the environment
|
|
||||||
# to the tenant name to ensure there is no conflict between your environments.
|
|
||||||
# This is mainly for the benefit of your development and test environments.
|
|
||||||
# Uncomment the line below if you want to disable this behaviour in production.
|
|
||||||
#
|
|
||||||
config.prepend_environment = !Rails.env.production?
|
|
||||||
end
|
|
||||||
|
|
||||||
# Setup a custom Tenant switching middleware. The Proc should return the name of the Tenant that
|
|
||||||
# you want to switch to.
|
|
||||||
# Rails.application.config.middleware.use 'Apartment::Elevators::Generic', lambda { |request|
|
|
||||||
# request.host.split('.').first
|
|
||||||
# }
|
|
||||||
|
|
||||||
# Rails.application.config.middleware.use 'Apartment::Elevators::Domain'
|
|
||||||
Rails.application.config.middleware.use 'Apartment::Elevators::Subdomain'
|
|
||||||
# Rails.application.config.middleware.use 'Apartment::Elevators::FirstSubdomain'
|
|
||||||
3
Pearlception/app/assets/javascripts/statistics.coffee
Normal file
3
Pearlception/app/assets/javascripts/statistics.coffee
Normal file
@ -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/
|
||||||
3
Pearlception/app/assets/stylesheets/statistics.scss
Normal file
3
Pearlception/app/assets/stylesheets/statistics.scss
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
// Place all the styles related to the statistics controller here.
|
||||||
|
// They will automatically be included in application.css.
|
||||||
|
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||||
2
Pearlception/app/controllers/statistics_controller.rb
Normal file
2
Pearlception/app/controllers/statistics_controller.rb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
class StatisticsController < ApplicationController
|
||||||
|
end
|
||||||
2
Pearlception/app/helpers/statistics_helper.rb
Normal file
2
Pearlception/app/helpers/statistics_helper.rb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
module StatisticsHelper
|
||||||
|
end
|
||||||
@ -40,7 +40,7 @@
|
|||||||
<% if current_user.admin? %>
|
<% if current_user.admin? %>
|
||||||
<li><a href="companies#index">Companies</a></li>
|
<li><a href="companies#index">Companies</a></li>
|
||||||
<% else %>
|
<% else %>
|
||||||
<li><a href="dashboard#statistics">Statistics</a></li>
|
<li><a href="statistics#index">Statistics</a></li>
|
||||||
<li><a href="grades#index">Grades</a></li>
|
<li><a href="grades#index">Grades</a></li>
|
||||||
<!-- <li><a>Reports</a></li>
|
<!-- <li><a>Reports</a></li>
|
||||||
<li><a>Analytics</a></li>
|
<li><a>Analytics</a></li>
|
||||||
|
|||||||
@ -40,10 +40,8 @@
|
|||||||
<% if current_user.admin? %>
|
<% if current_user.admin? %>
|
||||||
<li><a href="companies#index">Companies</a></li>
|
<li><a href="companies#index">Companies</a></li>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
<li><a href="statistics#index">Statistics</a></li>
|
||||||
<li class="active"><a href="grades#index">Grades <span class="sr-only">(current)</span></a></li>
|
<li class="active"><a href="grades#index">Grades <span class="sr-only">(current)</span></a></li>
|
||||||
<!-- <li><a>Reports</a></li>
|
|
||||||
<li><a>Analytics</a></li>
|
|
||||||
<li><a>Export</a></li> -->
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
<!-- <ul class="nav nav-sidebar">
|
<!-- <ul class="nav nav-sidebar">
|
||||||
|
|||||||
51
Pearlception/app/views/statistics/index.html.erb
Normal file
51
Pearlception/app/views/statistics/index.html.erb
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<%= stylesheet_link_tag "dashboard" %>_
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<nav class="navbar navbar-inverse navbar-fixed-top">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="navbar-header">
|
||||||
|
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||||
|
<span class="sr-only">Toggle navigation</span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
</button>
|
||||||
|
<a class="navbar-brand" href="/">Pearlception</a>
|
||||||
|
</div>
|
||||||
|
<div id="navbar" class="navbar-collapse collapse">
|
||||||
|
<ul class="nav navbar-nav navbar-right">
|
||||||
|
<!-- <li><a href="#">Dashboard</a></li> -->
|
||||||
|
<!-- <li><a href="#">Settings</a></li>
|
||||||
|
<li><a href="#">Profile</a></li>
|
||||||
|
<li><a href="#">Help</a></li> -->
|
||||||
|
<li>
|
||||||
|
<%= link_to(destroy_user_session_path, class: 'logout-link', :method => :delete) do %>
|
||||||
|
<i class="fa fa-external-link"></i> Logout
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<!-- <form class="navbar-form navbar-right">
|
||||||
|
<input type="text" class="form-control" placeholder="Search...">
|
||||||
|
</form> -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-3 col-md-2 sidebar">
|
||||||
|
<ul class="nav nav-sidebar">
|
||||||
|
<li><a href="/">Overview</a></li>
|
||||||
|
<!-- This will be removed and placed with correct logic in corresponding controller -->
|
||||||
|
<% if current_user.admin? %>
|
||||||
|
<li><a href="companies#index">Companies</a></li>
|
||||||
|
<% else %>
|
||||||
|
<li class"active"><a href="statistics#index">Statistics</a></li>
|
||||||
|
<li><a href="grades#index">Grades <span class="sr-only">(current)</span></a></li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<%= javascript_include_tag "bootstrap.min" %>_
|
||||||
|
</body>
|
||||||
@ -7,6 +7,7 @@ Rails.application.routes.draw do
|
|||||||
resources :runs
|
resources :runs
|
||||||
resources :companies
|
resources :companies
|
||||||
resources :grades
|
resources :grades
|
||||||
|
resources :statistics
|
||||||
|
|
||||||
devise_for :users, :controllers => {:registrations => 'registrations'}
|
devise_for :users, :controllers => {:registrations => 'registrations'}
|
||||||
devise_scope :users do
|
devise_scope :users do
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class StatisticsControllerTest < ActionDispatch::IntegrationTest
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
||||||
11
setup.rb
11
setup.rb
@ -46,6 +46,7 @@ def initial_migration
|
|||||||
FileUtils.rm(apartment_path) #Remove the original file
|
FileUtils.rm(apartment_path) #Remove the original file
|
||||||
FileUtils.cp(apartment_copy_path,apartment_path) #Copy the blank copy into init
|
FileUtils.cp(apartment_copy_path,apartment_path) #Copy the blank copy into init
|
||||||
Dir.chdir('Pearlception') do
|
Dir.chdir('Pearlception') do
|
||||||
|
puts `rake db:setup`
|
||||||
puts `rake db:migrate` #Run the migration
|
puts `rake db:migrate` #Run the migration
|
||||||
end
|
end
|
||||||
FileUtils.rm(apartment_path) #Remove the blank copy
|
FileUtils.rm(apartment_path) #Remove the blank copy
|
||||||
@ -86,9 +87,17 @@ def migrate_grades
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#This will remvoe hoopers island DB
|
||||||
|
def drop_hoopers
|
||||||
|
client = Mysql2::Client.new(host:'localhost' ,username:"bmv", password:"1156244terps!", database: "Pearlception_development")
|
||||||
|
client.query("DROP DATABASE development_HoopersIsland;")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
########## MAIN METHOD #####################
|
########## MAIN METHOD #####################
|
||||||
#bundle #bundle install
|
#bundle #bundle install
|
||||||
#initial_migration #Setup db
|
#initial_migration #Setup db
|
||||||
setup_initial_admin #Insert the initial admin
|
initial_migration if ARGV.include? "init"
|
||||||
|
#setup_initial_admin #Insert the initial admin
|
||||||
migrate_runs
|
migrate_runs
|
||||||
#migrate_grades #Migrate all the runs over
|
#migrate_grades #Migrate all the runs over
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user