populate-me 0.0.28 → 0.0.33

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
- SHA1:
3
- metadata.gz: ed06edf0120a1daf291849f203063ec826302f8e
4
- data.tar.gz: a3fcd26ccae3347c8ecac05afcd6030967e434b7
2
+ SHA256:
3
+ metadata.gz: 8164c457284a0daa762745f768ba56acead4592eab6fca62547dfff4d56ad7da
4
+ data.tar.gz: f8fa01c9478a8be7fe04c4628f0c3785d4f089203c6eb8961565defbae6e0b66
5
5
  SHA512:
6
- metadata.gz: 53dcf1737422f6c1fa10bfdd32d13650ee8dad526ac9561b5d77ca50cd97ebb7bab6c91a4e9d58ad0919220a6b797762075db1939bd135f85c9a66f0a437711c
7
- data.tar.gz: a1b50ab8e0ea8ebd9647695420296f10cc912cb6a3c5cac306c45bca0bb6b1867fa264ea7a2f93fe3352894a2d1c6aa90c331cc408cf3ea46e90b2ce56422246
6
+ metadata.gz: 66160cda7918beb24097e28de0189a381c7c72eaea16c184ca8a2e0e2dbb848df73a7af41feb9f195e5942090e483622961386000597a7a625becea4a3208e9b
7
+ data.tar.gz: cb4972cd6d06fc192ece77899110fc33533e5f2b02116562d55b60b6f7a6c62e8c4f854e654ebd047828a9ecf9cb0104278aab7cae252f8030d7d5994d1bef54
@@ -76,7 +76,7 @@ module PopulateMe
76
76
  end,
77
77
  :attachment => proc do |m,c,o|
78
78
  deleter = "<input type='checkbox' name='#{o[:input_name]}' class='deleter' value='nil' /> Delete this file<br />" unless m.doc[c].nil?
79
- "%s%s<input type='file' name='%s' id='%s' class='%s' />%s\n" % [m.to_thumb(c), deleter, o[:input_name], m.field_id_for(c), o[:input_class], o[:required]]
79
+ "%s<input type='file' name='%s' id='%s' class='%s' />%s %s\n" % [m.to_thumb(c), o[:input_name], m.field_id_for(c), o[:input_class], o[:required], deleter]
80
80
  end,
81
81
  :select => proc do |m,c,o|
82
82
  # starter ensures it sends something when multiple is empty
@@ -100,13 +100,13 @@ module PopulateMe
100
100
  select_options.each do |op|
101
101
  key,val = op.kind_of?(Array) ? [op[0],op[1]] : [op,op]
102
102
  if key==:optgroup
103
- out << "<optgroup label='%s'>\n" % [val]
103
+ out << "<optgroup label=\"%s\">\n" % [val]
104
104
  elsif key==:closegroup
105
105
  out << "</optgroup>\n"
106
106
  else
107
107
  # Array case is for multiple select
108
108
  selected = 'selected' if (val==o[:input_value] || (o[:input_value].kind_of?(Array)&&o[:input_value].include?(val)))
109
- out << "<option value='%s' %s>%s</option>\n" % [val,selected,key]
109
+ out << "<option value=\"%s\" %s>%s</option>\n" % [val,selected,key]
110
110
  end
111
111
  end
112
112
  end
@@ -188,7 +188,7 @@ module PopulateMe
188
188
  end
189
189
  def dropdown_cache
190
190
  @dropdown_cache ||= self.find({},:fields=>['_id',label_column]).inject([]) do |out,row|
191
- out.push([row.to_label, row.id.to_s, "<option value='#{row.id}' ", ">#{row.to_label}</option>\n"])
191
+ out.push([row.to_label, row.id.to_s, "<option value=\"#{row.id}\" ", ">#{row.to_label}</option>\n"])
192
192
  end
193
193
  end
194
194
  def reset_dropdown_cache; @dropdown_cache = nil; end
@@ -38,6 +38,13 @@ module PopulateMe
38
38
  def find(selector={},opts={})
39
39
  selector.update(opts.delete(:selector)||{})
40
40
  opts = {:sort=>self.sorting_order}.update(opts)
41
+ if opts.key?(:fields)
42
+ opts[:projection] = opts[:fields].inject({}) do |h, f|
43
+ h[f.to_sym] = 1
44
+ h
45
+ end
46
+ opts.delete(:fields)
47
+ end
41
48
  cur = collection.find(selector,opts)
42
49
  cur.instance_variable_set('@mutant_class', self)
43
50
  cur.extend(CursorMutation)
@@ -175,7 +182,7 @@ module PopulateMe
175
182
  def children_count(k,sel={})
176
183
  k = resolve_class(k)
177
184
  slot_name = sel.delete(:slot_name) || model.foreign_key_name
178
- k.collection.count(:query => {slot_name=>@doc['_id'].to_s}.update(sel))
185
+ k.collection.count({slot_name=>@doc['_id'].to_s}.update(sel))
179
186
  end
180
187
 
181
188
  # CRUD
@@ -187,7 +194,12 @@ module PopulateMe
187
194
 
188
195
  # saving and hooks
189
196
  def new?; @is_new ||= !@doc.key?('_id'); end
190
- def update_doc(fields); @old_doc = @doc.dup; @doc.update(fields); @is_new = false; self; end
197
+ def update_doc(fields)
198
+ @old_doc = @doc.dup
199
+ @doc.update(fields)
200
+ @is_new = false
201
+ self
202
+ end
191
203
  # Getter and setter in one
192
204
  def errors_on(col,message=nil)
193
205
  message.nil? ? @errors[col] : @errors[col] = (@errors[col]||[]) << message
@@ -212,7 +224,7 @@ module PopulateMe
212
224
  next unless model.schema.key?(k)
213
225
  type = k=='_id' ? :primary_key : model.schema[k][:type]
214
226
  fix_method = "fix_type_#{type}"
215
- if v==''
227
+ if v=='' and type!=:attachment
216
228
  default = model.schema[k][:default]
217
229
  @doc[k] = default.is_a?(Proc) ? default.call : default
218
230
  else
@@ -51,6 +51,8 @@ module PopulateMe
51
51
  :content_type=>v[:type]
52
52
  })
53
53
  @doc[k] = {'original'=>attachment_id}
54
+ else # Untouched
55
+ @doc[k] = @old_doc[k]
54
56
  end
55
57
  end
56
58
 
@@ -58,7 +60,8 @@ module PopulateMe
58
60
  obj = (@old_doc||@doc)[col]
59
61
  if obj.respond_to?(:each)
60
62
  obj.each do |k,v|
61
- model.gridfs.delete(v)
63
+ gridfile = model.gridfs.find(_id: v).first
64
+ model.gridfs.delete(v) unless gridfile.nil?
62
65
  end
63
66
  end
64
67
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'populate-me'
3
- s.version = "0.0.28"
3
+ s.version = '0.0.33'
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.summary = "ALPHA !!! Populate Me is relatively complete but simple CMS"
6
6
  s.description = "ALPHA !!! Populate Me is relatively complete but simple CMS. It includes a Rack middleware for putting in your Rack stack, and a bespoke MongoDB ODM. But Populate Me is not really finished yet."
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: populate-me
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.28
4
+ version: 0.0.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mickael Riga
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-11 00:00:00.000000000 Z
11
+ date: 2020-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack-golem
@@ -169,7 +169,7 @@ homepage: https://github.com/mig-hub/populate-me
169
169
  licenses:
170
170
  - MIT
171
171
  metadata: {}
172
- post_install_message:
172
+ post_install_message:
173
173
  rdoc_options: []
174
174
  require_paths:
175
175
  - "./lib"
@@ -184,9 +184,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  - !ruby/object:Gem::Version
185
185
  version: '0'
186
186
  requirements: []
187
- rubyforge_project:
188
- rubygems_version: 2.4.5.1
189
- signing_key:
187
+ rubygems_version: 3.0.3
188
+ signing_key:
190
189
  specification_version: 4
191
190
  summary: ALPHA !!! Populate Me is relatively complete but simple CMS
192
191
  test_files: []