tramway-core 1.18.1.1 → 1.18.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff863d7c75ba76a10d1f9c751b9710474a16b0cd126a6974224d8cbcb26d9dd4
4
- data.tar.gz: b890fdbb1e3a33e6dc9cac04ca8cc3d91a5c240a9337c4313b576faf44f47c7b
3
+ metadata.gz: 2eca2bd589fed76d9385bbed1319fbd061e418521966d81561bf8ffeaa3648c9
4
+ data.tar.gz: 67488c6b5304f9941220b9bcb97d6ca5271e414e323d7c64806805e5aea5deb5
5
5
  SHA512:
6
- metadata.gz: 2ae3500906ffdc568ce881fad3c6581958bfcb32d5f145242f93eac7d6710a05a0d549e734ae3542040366cc75e584846f5100bdcada8e29e9529975f6e194af
7
- data.tar.gz: f6be135129633829f2585831fc2576a566618f023f1bc4ab15f7b96e35437c9fddc668c6fa14a02d273d3c46e8c5ee5be4149946f6df8a679fe5628c8a26d398
6
+ metadata.gz: 3f8da95bb6038a4e3bb956fcf0a7851cb2e81a82392a92fd00a1d1337eaad0a13f5a852a2a8701bcead04eb1250ac17335d5bf44deb18c4dbcf3df980026e275
7
+ data.tar.gz: be00745caa58c4703b5dca9eb53ef6dc8d16917d39c510f0d95efac655c165fa5eec00e6813424eba5edd0f78377c60bbdb77688a3f7895b4ab8d9910f051617
@@ -15,4 +15,8 @@ class Tramway::Core::ApplicationController < ActionController::Base
15
15
  def model_class
16
16
  params[:model].constantize
17
17
  end
18
+
19
+ def authenticated_user
20
+ (defined?(current_user) && current_user.try(:model)) || (defined?(current_admin) && current_admin.model)
21
+ end
18
22
  end
@@ -2,9 +2,10 @@
2
2
 
3
3
  module Tramway::Core::Inputs::AssociationsHelper
4
4
  def build_collection_for_association(form_object, property)
5
+ user = defined?(current_user) ? current_user : current_admin
5
6
  full_class_name_association = form_object.class.full_class_name_association(property)
6
7
  check_valid_association full_class_name_association
7
- full_class_name_association.active.send("#{current_user.role}_scope", current_user.id).map do |obj|
8
+ full_class_name_association.active.send("#{user.role}_scope", user.id).map do |obj|
8
9
  decorator_class(full_class_name_association).decorate obj
9
10
  end.sort_by(&:name)
10
11
  end
@@ -2,8 +2,9 @@
2
2
 
3
3
  module Tramway::Core::Inputs::PolymorphicAssociationsHelper
4
4
  def build_collection_for_polymorphic_association(form_object, property)
5
+ user = defined?(current_user) ? current_user : current_admin
5
6
  object_names = full_class_names(form_object, property).map do |class_name|
6
- class_name.active.send("#{current_user.role}_scope", current_user.id).map do |obj|
7
+ class_name.active.send("#{user.role}_scope", user.id).map do |obj|
7
8
  decorator_class(class_name).decorate obj
8
9
  end
9
10
  end.flatten
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Core
5
- VERSION = '1.18.1.1'
5
+ VERSION = '1.18.1.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.1.1
4
+ version: 1.18.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-04-30 00:00:00.000000000 Z
12
+ date: 2020-05-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: audited