# GET /comptes
# GET /comptes.json
def index
- @comptes = Compte.all
+ @comptes = current_user.organisation.comptes
end
# GET /comptes/1
has_many :structures, inverse_of: :organisation
accepts_nested_attributes_for :structures, reject_if: proc { |attributes| attributes[:nom].blank? }, allow_destroy: true
+ has_many :users
has_many :prestation_types
has_many :tarif_types
-
has_many :tarifs, through: :tarif_types
+ has_many :comptes, through: :structures
validates :nom, :email, presence: true
has_many :classrooms, inverse_of: :structure
accepts_nested_attributes_for :classrooms, reject_if: proc { |attributes| attributes[:nom].blank? }, allow_destroy: true
+ has_many :comptes
+
def nom_avec_organisation
self.organisation.nom + "/" + self.nom
end
audited
+ belongs_to :organisation
+
end
-<p id="notice"><%= notice %></p>
-
-<h1>Comptes</h1>
+<h1><i class="fas fa-users"></i> Comptes</h1>
<table class="table table-striped">
<thead>
-<p id="notice"><%= notice %></p>
-
-<h1>Enfants</h1>
+<h1><i class="fas fa-child"></i> Enfants</h1>
<table class="table table-striped">
<thead>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
+
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= javascript_include_tag 'application' %>
</head>
- <body class="container">
- <% if notice.present? %>
- <aside class="alert alert-info">
- <%= notice %>
- </aside>
- <% end %>
+ <body>
+ <nav class="navbar navbar-expand-sm bg-primary navbar-dark fixed-top">
+ <div class="container">
+ <ul class="navbar-nav">
+ <li class="nav-item <%= (params[:controller]=='comptes' ? 'active' : '') %>">
+ <%= link_to root_url, class: "nav-link" do %><i class="fas fa-users"></i></span> Comptes<% end %>
+ </li>
+ <li class="nav-item <%= (params[:controller]=='enfants' ? 'active' : '') %>">
+ <%= link_to enfants_url, class: "nav-link" do %><i class="fas fa-child"></i></span> Enfants<% end %>
+ </li>
+ <li class="nav-item">
+ <a class="nav-link disabled" href="#">Disabled</a>
+ </li>
+ </ul>
+ <ul class="navbar-nav navbar-right">
+ <li class="nav-item <%= (params[:controller]=='organisations' ? 'active' : '') %>">
+ <%= link_to organisations_url, class: "nav-link" do %><i class="fas fa-sitemap"></i></span> Organisation<% end %>
+ </li>
+ <li class="nav-item">
+ <a class="nav-link disabled" href="#">Disabled</a>
+ </li>
+ </ul>
+ </div>
+ </nav>
+
+ <div class="container">
+ <% if notice.present? %>
+ <aside class="alert alert-info">
+ <%= notice %>
+ </aside>
+ <% end %>
- <% if alert.present? %>
- <aside class="alert alert-danger">
- <%= alert %>
- </aside>
- <% end %>
+ <% if alert.present? %>
+ <aside class="alert alert-danger">
+ <%= alert %>
+ </aside>
+ <% end %>
+ <br /><br /><br />
- <%= yield %>
+ <%= yield %>
+ </div>
</body>
+
</html>
-<h1>Organisations</h1>
+<h1><i class="fas fa-sitemap"></i> Organisations</h1>
<table class="table table-striped">
<thead>
<%= @organisation.email %>
</p>
-
<p>
<h3>Structures</h3>
<% @organisation.structures.each do |structure| %>
<%= link_to 'Edit', edit_organisation_path(@organisation) %> |
<%= link_to 'Back', organisations_path %>
-<p>
- <h3>Types de prestations</h3>
- <% @organisation.prestation_types.each do |prestation| %>
- <%= link_to prestation.nom, prestation %><br />
- <% end %>
-</p>
-
-<%= link_to "Ajouter un type de prestation", new_prestation_type_path(organisation_id: @organisation) %>
-
<p>
<h3>Types de tarifs</h3>
<% @organisation.tarif_types.each do |tarif| %>
<%= link_to "Ajouter un type de tarif", new_tarif_type_path(organisation_id: @organisation) %>
+<p>
+ <h3>Types de prestations</h3>
+ <% @organisation.prestation_types.each do |prestation| %>
+ <%= link_to prestation.nom, prestation %><br />
+ <% end %>
+</p>
+
+<%= link_to "Ajouter un type de prestation", new_prestation_type_path(organisation_id: @organisation) %>
<p>
<h3>Tarifs</h3>
devise_for :users
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
- root 'dashboard#index'
+ root 'comptes#index'
end
--- /dev/null
+class AddOrganisationToUser < ActiveRecord::Migration[5.2]
+ def change
+ add_reference :users, :organisation, foreign_key: true
+ end
+end
--- /dev/null
+class AddAdminToUser < ActiveRecord::Migration[5.2]
+ def change
+ add_column :users, :admin, :boolean, default: false
+ end
+end
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2019_08_28_110922) do
+ActiveRecord::Schema.define(version: 2019_08_28_123426) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
t.datetime "remember_created_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.bigint "organisation_id"
+ t.boolean "admin", default: false
t.index ["email"], name: "index_users_on_email", unique: true
+ t.index ["organisation_id"], name: "index_users_on_organisation_id"
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end
add_foreign_key "tarif_types", "organisations"
add_foreign_key "tarifs", "prestation_types"
add_foreign_key "tarifs", "tarif_types"
+ add_foreign_key "users", "organisations"
end