Compare commits
No commits in common. "855d8171f83f9ddf8ccda0922a858856c531c1d6" and "03e4fdbfd46278a6caf65760cb44473f1dada1d9" have entirely different histories.
855d8171f8
...
03e4fdbfd4
@ -14,11 +14,6 @@ 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,8 +6,6 @@ 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
|
||||
|
||||
@ -61,14 +59,11 @@ class Admin < ApplicationRecord
|
||||
has_many :admin_permissions, :through => :admin_roles
|
||||
|
||||
|
||||
def has_permission?(permission_slug)
|
||||
permission = AdminPermission.where(:slug => permission_slug).first
|
||||
permission = AdminPermission.create(:slug => permission_slug) if !permission
|
||||
|
||||
def has_permission?(permission)
|
||||
if self.super_admin
|
||||
true
|
||||
else
|
||||
|
||||
permission = AdminPermission.where("code = ? or slug = ?",permission, permission).first
|
||||
|
||||
if permission
|
||||
if self.admin_permissions.include?(permission)
|
||||
@ -80,6 +75,7 @@ class Admin < ApplicationRecord
|
||||
false
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -1,4 +0,0 @@
|
||||
class AdminPCustomer < ApplicationRecord
|
||||
belongs_to :admin
|
||||
belongs_to :p_customer
|
||||
end
|
@ -1,6 +1,6 @@
|
||||
class AdminPermission < ApplicationRecord
|
||||
|
||||
def member_label
|
||||
self.slug.to_s+" "+self.name.to_s
|
||||
self.code.to_s+" "+self.name
|
||||
end
|
||||
end
|
||||
|
@ -49,7 +49,7 @@ class MOdr < ApplicationRecord
|
||||
has_many :m_odr_reps, :dependent => :destroy
|
||||
|
||||
|
||||
has_many :m_odr_coupons
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
class MOdrCoupon < ApplicationRecord
|
||||
belongs_to :m_odr
|
||||
end
|
@ -104,15 +104,6 @@ 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, "n'existe pas")
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
self.particular = self.particulars.first
|
||||
|
||||
if !self.state
|
||||
|
@ -3,6 +3,6 @@
|
||||
|
||||
%li= link_to "Participations ODR", admin_m_odr_reps_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,8 +36,5 @@
|
||||
|
||||
=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,7 @@
|
||||
|
||||
-tr[:actions] = capture do
|
||||
%td.actions
|
||||
-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,4 @@
|
||||
.qi_header
|
||||
-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
|
||||
@ -21,15 +20,7 @@
|
||||
|
||||
%td
|
||||
Opération :
|
||||
|
||||
-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])
|
||||
=select_tag "search[m_odr_id]", options_for_select([["",""]]+MOdr.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,14 +31,12 @@
|
||||
|
||||
|
||||
-if true
|
||||
-if current_admin.has_permission?("customer.view")
|
||||
.element
|
||||
=link_to admin_p_customers_path do
|
||||
.cat#big_cat_clients
|
||||
=ic :"address-book-o"
|
||||
Clients
|
||||
|
||||
-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
|
||||
@ -60,14 +58,13 @@
|
||||
=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
|
||||
|
||||
-if current_admin.has_permission?("file_tunels.view")
|
||||
.element
|
||||
=link_to admin_file_tunels_path do
|
||||
.cat#big_cat_tournees
|
||||
|
@ -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' }
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
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
|
@ -1,10 +0,0 @@
|
||||
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_04_01_115523) do
|
||||
ActiveRecord::Schema.define(version: 2020_03_09_142522) do
|
||||
|
||||
create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
t.string "name"
|
||||
@ -29,15 +29,6 @@ ActiveRecord::Schema.define(version: 2020_04_01_115523) 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"
|
||||
@ -643,7 +634,7 @@ ActiveRecord::Schema.define(version: 2020_04_01_115523) 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 ROW_FORMAT=DYNAMIC", force: :cascade do |t|
|
||||
create_table "m_odr_product_cats", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
t.bigint "m_odr_id"
|
||||
t.string "name"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
@ -2569,8 +2560,6 @@ ActiveRecord::Schema.define(version: 2020_04_01_115523) 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.
Before Width: | Height: | Size: 1.8 MiB |
9
test/fixtures/admin_p_customers.yml
vendored
9
test/fixtures/admin_p_customers.yml
vendored
@ -1,9 +0,0 @@
|
||||
# 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
9
test/fixtures/m_odr_coupons.yml
vendored
@ -1,9 +0,0 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
m_odr: one
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
m_odr: two
|
@ -1,7 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class AdminPCustomerTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
@ -1,7 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class MOdrCouponTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user