qm-acts-as-generic-controller 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ begin
10
10
  gemspec.email = "marcin@saepia.net"
11
11
  gemspec.homepage = "http://q.saepia.net"
12
12
  gemspec.authors = ["Marcin Lewandowski"]
13
- gemspec.version = "0.2.1"
13
+ gemspec.version = "0.2.2"
14
14
  gemspec.files = Rake::FileList.new [ "MIT-LICENSE", "Rakefile", "lib/*", "app/views/generic_controller/*" ]
15
15
  gemspec.add_dependency "qui-common-helpers", ">= 0.0.8"
16
16
  gemspec.add_dependency "qui-index-table", ">= 0.0.9"
@@ -49,7 +49,7 @@
49
49
  <%- end -%>
50
50
 
51
51
 
52
- <%- if is_accessible and (not current_user.respond_to? "has_privileges?" or (current_user.respond_to? "has_privileges?" and current_user.has_privileges?(:class_name => klass, :attribute => field[:name]))) -%>
52
+ <%- if is_accessible and (not current_user.respond_to? "has_privileges?" or field[:options][:skip_privileges_check] == true or (current_user.respond_to? "has_privileges?" and current_user.has_privileges?(:class_name => klass, :attribute => field[:name]))) -%>
53
53
  <li>
54
54
  <%= f.label field[:name] %>
55
55
 
@@ -93,20 +93,9 @@ module QM
93
93
 
94
94
  def create
95
95
  model.transaction do
96
- if model.respond_to? "document?" and model.document? and params[:scan_original_id]
97
- document = Document.find(params[:scan_original_id])
98
- logger.info document.inspect
99
- end
100
-
101
96
  remove_unprivileged_keys_from_params
102
97
 
103
98
  instance_variable_set(singular_variable, model.new(params[singular_variable(true)])) unless instance_variable_defined?(singular_variable)
104
-
105
- if document
106
- document.send("#{model.to_s.tableize.singularize}=", instance_variable_get(singular_variable))
107
- logger.info document.inspect
108
- document.save
109
- end
110
99
 
111
100
  save_creator
112
101
  save_updator
@@ -322,6 +311,19 @@ module QM
322
311
  end
323
312
 
324
313
  def remove_unprivileged_keys_from_params
314
+ =begin
315
+ if model.respond_to? "document?" and model.document? and params[:document_scan]
316
+ document = Document.find(params[:scan_original_id])
317
+ logger.info document.inspect
318
+ end
319
+
320
+ if document
321
+ document.send("#{model.to_s.tableize.singularize}=", instance_variable_get(singular_variable))
322
+ logger.info document.inspect
323
+ document.save
324
+ end
325
+ =end
326
+
325
327
  if defined?(current_user) and current_user.respond_to? :privileged_attributes
326
328
  params[singular_variable(true)].keys.each do |key|
327
329
  if not current_user.privileged_attributes(model, :write).include?(key) and (model.generic_field_associations.has_key?(key.to_sym) and not current_user.privileged_attributes(model, :write).include?(model.generic_field_associations[key.to_sym][:foreign_key]))
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qm-acts-as-generic-controller
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marcin Lewandowski
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-07 00:00:00 +01:00
18
+ date: 2011-04-18 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency