suite
This commit is contained in:
parent
03e4fdbfd4
commit
8ce9260471
@ -14,6 +14,11 @@ class Admin::MOdrRepsController < ApplicationController
|
||||
@m_odr_reps = MOdrRep.includes(:particulars)
|
||||
|
||||
|
||||
if !current_admin.has_permission?("odr_rep.view")
|
||||
@m_odr_reps = @m_odr_reps.joins(:m_odr).where(:m_odrs => {:p_customer_id => current_admin.p_customers.ids})
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
if params[:search][:state].to_s != ""
|
||||
|
@ -6,6 +6,8 @@ class Admin < ApplicationRecord
|
||||
has_many :timer_watchers
|
||||
has_many :admin_preferences
|
||||
|
||||
has_many :admin_p_customers
|
||||
has_many :p_customers, :through => :admin_p_customers
|
||||
|
||||
has_secure_password
|
||||
|
||||
@ -59,11 +61,14 @@ class Admin < ApplicationRecord
|
||||
has_many :admin_permissions, :through => :admin_roles
|
||||
|
||||
|
||||
def has_permission?(permission)
|
||||
def has_permission?(permission_slug)
|
||||
permission = AdminPermission.where(:slug => permission_slug).first
|
||||
permission = AdminPermission.create(:slug => permission_slug) if !permission
|
||||
|
||||
if self.super_admin
|
||||
true
|
||||
else
|
||||
permission = AdminPermission.where("code = ? or slug = ?",permission, permission).first
|
||||
|
||||
|
||||
if permission
|
||||
if self.admin_permissions.include?(permission)
|
||||
@ -75,7 +80,6 @@ class Admin < ApplicationRecord
|
||||
false
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
4
app/models/admin_p_customer.rb
Normal file
4
app/models/admin_p_customer.rb
Normal file
@ -0,0 +1,4 @@
|
||||
class AdminPCustomer < ApplicationRecord
|
||||
belongs_to :admin
|
||||
belongs_to :p_customer
|
||||
end
|
@ -1,6 +1,6 @@
|
||||
class AdminPermission < ApplicationRecord
|
||||
|
||||
def member_label
|
||||
self.code.to_s+" "+self.name
|
||||
self.slug.to_s+" "+self.name.to_s
|
||||
end
|
||||
end
|
||||
|
@ -49,7 +49,7 @@ class MOdr < ApplicationRecord
|
||||
has_many :m_odr_reps, :dependent => :destroy
|
||||
|
||||
|
||||
|
||||
has_many :m_odr_coupons
|
||||
|
||||
|
||||
|
||||
|
3
app/models/m_odr_coupon.rb
Normal file
3
app/models/m_odr_coupon.rb
Normal file
@ -0,0 +1,3 @@
|
||||
class MOdrCoupon < ApplicationRecord
|
||||
belongs_to :m_odr
|
||||
end
|
@ -104,6 +104,15 @@ file_admin_ok remise particular_civilite particular_name particular_firstname pa
|
||||
end
|
||||
|
||||
before_validation do
|
||||
|
||||
if self.m_odr.reduc_code_needed and self.m_odr.m_odr_coupons.count > 0 and !self.m_odr.m_odr_coupons.where("name LIKE ?", self.reduc_code).first
|
||||
|
||||
errors.add(:reduc_code, 'doit être différent de la page actuelle')
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
self.particular = self.particulars.first
|
||||
|
||||
if !self.state
|
||||
|
@ -3,6 +3,6 @@
|
||||
|
||||
%li= link_to "Participations ODR", admin_m_odr_reps_path
|
||||
|
||||
|
||||
%li= link_to "ODR", admin_m_odrs_path
|
||||
%li= link_to "Historique mail", admin_mail_hists_path
|
||||
-if current_admin.has_permission?("odr.view")
|
||||
%li= link_to "ODR", admin_m_odrs_path
|
||||
%li= link_to "Historique mail", admin_mail_hists_path
|
||||
|
@ -36,5 +36,8 @@
|
||||
|
||||
=f.input :admin_roles, :label => "Rôles :", :collection => AdminRole.all, :as => :check_boxes
|
||||
|
||||
|
||||
=f.input :p_customers, :label => "Vue autorisée pour les clinets suivant :", :collection => PCustomer.all, :as => :check_boxes
|
||||
|
||||
.actions= f.submit "Sauvegarder", :class => "btn btn-primary"
|
||||
|
||||
|
@ -21,9 +21,11 @@
|
||||
|
||||
-tr[:actions] = capture do
|
||||
%td.actions
|
||||
= link_to i(:"trash-o"), [:admin, m_odr_rep], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
|
||||
= link_to i(:pencil), edit_admin_m_odr_rep_path(m_odr_rep), :remote => true
|
||||
= link_to i(:eye), admin_m_odr_rep_path(m_odr_rep)
|
||||
-if current_admin.has_permission?("odr_rep.delete")
|
||||
= link_to i(:"trash-o"), [:admin, m_odr_rep], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
|
||||
-if current_admin.has_permission?("odr_rep.update")
|
||||
= link_to i(:pencil), edit_admin_m_odr_rep_path(m_odr_rep), :remote => true
|
||||
= link_to i(:eye), admin_m_odr_rep_path(m_odr_rep)
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
.qi_header
|
||||
.right= link_to 'Ajouter ', new_admin_m_odr_rep_path(), :class => "btn btn-primary", :remote => true
|
||||
-if current_admin.has_permission?("odr_rep.create")
|
||||
.right= link_to 'Ajouter ', new_admin_m_odr_rep_path(), :class => "btn btn-primary", :remote => true
|
||||
%h1
|
||||
ODR
|
||||
%span
|
||||
@ -20,7 +21,15 @@
|
||||
|
||||
%td
|
||||
Opération :
|
||||
=select_tag "search[m_odr_id]", options_for_select([["",""]]+MOdr.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:m_odr_id])
|
||||
|
||||
-if !current_admin.has_permission?("odr_rep.view")
|
||||
-m_odrs = MOdr.where(:p_customer_id => current_admin.p_customers.ids)
|
||||
-else
|
||||
-m_odrs = MOdr
|
||||
|
||||
|
||||
|
||||
=select_tag "search[m_odr_id]", options_for_select([["",""]]+m_odrs.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:m_odr_id])
|
||||
|
||||
|
||||
%td=text_field_tag :name, params[:name],:class => "form-control", :placeholder => "Nom"
|
||||
|
@ -31,17 +31,19 @@
|
||||
|
||||
|
||||
-if true
|
||||
.element
|
||||
=link_to admin_p_customers_path do
|
||||
.cat#big_cat_clients
|
||||
=ic :"address-book-o"
|
||||
Clients
|
||||
-if current_admin.has_permission?("customer.view")
|
||||
.element
|
||||
=link_to admin_p_customers_path do
|
||||
.cat#big_cat_clients
|
||||
=ic :"address-book-o"
|
||||
Clients
|
||||
|
||||
.element
|
||||
=link_to admin_m_odr_reps_path do
|
||||
.cat#big_cat_stocks
|
||||
=ic :"cubes"
|
||||
Opérations ODR
|
||||
-if current_admin.has_permission?("odr_rep.view_for_my") or current_admin.has_permission?("odr_rep.view")
|
||||
.element
|
||||
=link_to admin_m_odr_reps_path do
|
||||
.cat#big_cat_stocks
|
||||
=ic :"cubes"
|
||||
Opérations ODR
|
||||
|
||||
|
||||
|
||||
@ -58,18 +60,19 @@
|
||||
=ic :"file-text-o"
|
||||
Documents
|
||||
|
||||
-if current_admin.has_permission?("virements.view")
|
||||
.element
|
||||
=link_to admin_m_odr_virements_path do
|
||||
.cat#big_cat_payments
|
||||
=ic :"eur"
|
||||
Virements
|
||||
|
||||
.element
|
||||
=link_to admin_m_odr_virements_path do
|
||||
.cat#big_cat_payments
|
||||
=ic :"eur"
|
||||
Virements
|
||||
|
||||
.element
|
||||
=link_to admin_file_tunels_path do
|
||||
.cat#big_cat_tournees
|
||||
=ic :"lock"
|
||||
Tunnels fichier sécurisés
|
||||
-if current_admin.has_permission?("file_tunels.view")
|
||||
.element
|
||||
=link_to admin_file_tunels_path do
|
||||
.cat#big_cat_tournees
|
||||
=ic :"lock"
|
||||
Tunnels fichier sécurisés
|
||||
|
||||
|
||||
-if false
|
||||
|
@ -115,15 +115,15 @@ Rails.application.configure do
|
||||
|
||||
config.action_mailer.default_url_options = { :host => HOSTNAME }
|
||||
|
||||
config.action_mailer.delivery_method = :mailjet
|
||||
#config.action_mailer.delivery_method = :mailjet
|
||||
|
||||
|
||||
#config.action_mailer.delivery_method = :smtp
|
||||
#config.action_mailer.smtp_settings = {
|
||||
# :address => "localhost",
|
||||
# :port => 25,
|
||||
# :openssl_verify_mode => 'none'
|
||||
#}
|
||||
config.action_mailer.delivery_method = :smtp
|
||||
config.action_mailer.smtp_settings = {
|
||||
:address => "localhost",
|
||||
:port => 25,
|
||||
:openssl_verify_mode => 'none'
|
||||
}
|
||||
|
||||
Rails.application.routes.default_url_options = config.action_mailer.default_url_options = { :host => HOSTNAME, :protocol => 'https' }
|
||||
|
||||
|
10
db/migrate/20200401115523_create_admin_p_customers.rb
Normal file
10
db/migrate/20200401115523_create_admin_p_customers.rb
Normal file
@ -0,0 +1,10 @@
|
||||
class CreateAdminPCustomers < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
create_table :admin_p_customers do |t|
|
||||
t.references :admin, foreign_key: true
|
||||
t.references :p_customer, foreign_key: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
10
db/migrate/20200401121041_create_m_odr_coupons.rb
Normal file
10
db/migrate/20200401121041_create_m_odr_coupons.rb
Normal file
@ -0,0 +1,10 @@
|
||||
class CreateMOdrCoupons < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
create_table :m_odr_coupons do |t|
|
||||
t.string :name
|
||||
t.references :m_odr, foreign_key: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
15
db/schema.rb
15
db/schema.rb
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2020_03_09_142522) do
|
||||
ActiveRecord::Schema.define(version: 2020_04_01_115523) do
|
||||
|
||||
create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
t.string "name"
|
||||
@ -29,6 +29,15 @@ ActiveRecord::Schema.define(version: 2020_03_09_142522) do
|
||||
t.index ["admin_role_id"], name: "index_admin_admin_roles_on_admin_role_id"
|
||||
end
|
||||
|
||||
create_table "admin_p_customers", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
t.bigint "admin_id"
|
||||
t.bigint "p_customer_id"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.index ["admin_id"], name: "index_admin_p_customers_on_admin_id"
|
||||
t.index ["p_customer_id"], name: "index_admin_p_customers_on_p_customer_id"
|
||||
end
|
||||
|
||||
create_table "admin_permission_admin_roles", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
t.bigint "admin_permission_id"
|
||||
t.bigint "admin_role_id"
|
||||
@ -634,7 +643,7 @@ ActiveRecord::Schema.define(version: 2020_03_09_142522) do
|
||||
t.index ["m_odr_id"], name: "index_m_odr_places_on_m_odr_id"
|
||||
end
|
||||
|
||||
create_table "m_odr_product_cats", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
create_table "m_odr_product_cats", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t|
|
||||
t.bigint "m_odr_id"
|
||||
t.string "name"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
@ -2560,6 +2569,8 @@ ActiveRecord::Schema.define(version: 2020_03_09_142522) do
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
end
|
||||
|
||||
add_foreign_key "admin_p_customers", "admins"
|
||||
add_foreign_key "admin_p_customers", "p_customers"
|
||||
add_foreign_key "admin_preferences", "admins"
|
||||
add_foreign_key "file_tunel_downloads", "file_tunel_sends"
|
||||
add_foreign_key "file_tunel_downloads", "file_tunels"
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 1.8 MiB |
9
test/fixtures/admin_p_customers.yml
vendored
Normal file
9
test/fixtures/admin_p_customers.yml
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
admin: one
|
||||
p_customer: one
|
||||
|
||||
two:
|
||||
admin: two
|
||||
p_customer: two
|
9
test/fixtures/m_odr_coupons.yml
vendored
Normal file
9
test/fixtures/m_odr_coupons.yml
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
m_odr: one
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
m_odr: two
|
7
test/models/admin_p_customer_test.rb
Normal file
7
test/models/admin_p_customer_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class AdminPCustomerTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
7
test/models/m_odr_coupon_test.rb
Normal file
7
test/models/m_odr_coupon_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class MOdrCouponTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user