enjoy_cms 0.4.0.4 → 0.4.0.5

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
  SHA1:
3
- metadata.gz: d38e3d832559619dac7803f4d62c582ee29fa2b6
4
- data.tar.gz: 6531465366ee1e683901de9bce7f99c24920780d
3
+ metadata.gz: e7a875f96cd3f0979334375b90a822d6da795fd8
4
+ data.tar.gz: 61b29499b40cb6da3fb76d986071437d6ef3820a
5
5
  SHA512:
6
- metadata.gz: 67f012ab8602b16dbff85d6e62d08c9059d1bb2d06fb39d6b0054bdd907f75d1e9145471cd6e7d6f2705c9b509eab79b638b3a991d540eac6532ad34b94c4739
7
- data.tar.gz: 27ded3c13d239cad28af3b3858caeef1cbb52e9f3d3a3e7ce1aac210f6a8a0aa86c067625976d35cb91eda962bea913995a099941f9f740e399358cbbf61698c
6
+ metadata.gz: 691effa0962a688b062e4234d99c34d6f1628421c86d5faebbbd9c900d069357488f36a911e9e9758e44ff44f859a39b8c0724797d78ce9f6e640e2158987ca3
7
+ data.tar.gz: ee13c9219748151350df6bc8c0d46062a8d7f5497a9fc97978096f17371b22c9315a0dfb8ac9380ecbc0af980f852b50bff45f436180af10e1c736b3e37d5e25
@@ -1,3 +1,4 @@
1
+ require 'rails_admin'
1
2
  module Enjoy::RailsAdminGroupPatch
2
3
  class << self
3
4
  def enjoy_cms_group(config, fields = {})
@@ -5,8 +6,11 @@ module Enjoy::RailsAdminGroupPatch
5
6
 
6
7
  if fields.is_a?(Array)
7
8
  fields.each do |_group|
8
- config.group (_group[:name] || "") do
9
+ config.group (_group[:name] || :default) do
9
10
  active (_group[:active] || false)
11
+ label _group[:label] if _group[:label].present?
12
+ help _group[:help] if _group[:help].present?
13
+ weight _group[:weight] if _group[:weight].present?
10
14
  (_group[:fields] || {}).each_pair do |name, type|
11
15
  if type.blank?
12
16
  field name
@@ -0,0 +1,14 @@
1
+ require 'rails_admin'
2
+ module RailsAdmin
3
+ module Config
4
+ module Fields
5
+
6
+ class Base
7
+ register_instance_option :weight do
8
+ name.to_sym == :default ? -1_000_000 : 0
9
+ end
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,41 @@
1
+ require 'rails_admin'
2
+ module RailsAdmin
3
+ module Config
4
+ module Fields
5
+
6
+ class Group
7
+ register_instance_option :weight do
8
+ name.to_sym == :default ? -1_000_000 : 0
9
+ end
10
+
11
+ def visible_fields
12
+ section.with(bindings).visible_fields.select { |f|
13
+ f.group == self
14
+ }.sort do |a, b|
15
+ a.weight <=> b.weight
16
+ end
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+
24
+ module RailsAdmin
25
+ module Config
26
+ module HasGroups
27
+
28
+ def visible_groups
29
+ parent.groups.collect { |f|
30
+ f.section = self
31
+ f.with(bindings)
32
+ }.select(&:visible?).select { |g|
33
+ g.visible_fields.present?
34
+ }.sort do |a, b|
35
+ a.weight <=> b.weight
36
+ end
37
+ end
38
+
39
+ end
40
+ end
41
+ end
data/lib/enjoy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Enjoy
2
- VERSION = "0.4.0.4"
2
+ VERSION = "0.4.0.5"
3
3
  end
data/lib/enjoy_cms.rb CHANGED
@@ -17,13 +17,19 @@ require 'geocoder'
17
17
  # require 'validates_email_format_of'
18
18
  require 'filename_to_slug'
19
19
 
20
+
20
21
  require 'rails_admin'
21
22
  require 'enjoy/rails_admin_ext/config'
22
23
 
23
24
  # require 'enjoy/rails_admin_ext/enjoy_hash'
24
25
  require 'enjoy/rails_admin_ext/enjoy_html'
25
26
  require 'enjoy/rails_admin_ext/enjoy_slugs'
26
- require 'enjoy/rails_admin_ext/group_patch'
27
+
28
+ require 'enjoy/rails_admin_ext/patches/field_patch'
29
+ require 'enjoy/rails_admin_ext/patches/field_patch'
30
+ require 'enjoy/rails_admin_ext/patches/group_patch'
31
+ require 'enjoy/rails_admin_ext/patches/enjoy_cms_group'
32
+
27
33
 
28
34
  require 'rails_admin_nested_set'
29
35
  require 'rails_admin_toggleable'
data/template.rb CHANGED
@@ -327,15 +327,28 @@ inject_into_file 'app/models/user.rb', before: /^end/ do <<-TEXT
327
327
  end
328
328
 
329
329
  def self.generate_first_admin_user
330
- if User.all.count == 0
330
+ if User.admins.all.count == 0
331
331
  _email_pass = 'admin@#{app_name.dasherize.downcase}.ru'
332
332
  if User.new(roles: ["admin"], email: _email_pass, password: _email_pass, password_confirmation: _email_pass).save
333
- puts "User with email and password '\#{_email_pass}' was created!"
333
+ puts "AdminUser with email and password '\#{_email_pass}' was created!"
334
334
  else
335
- puts 'Creating User error'
335
+ puts 'Creating AdminUser error'
336
336
  end
337
337
  else
338
- puts 'Users are here already'
338
+ puts 'AdminUsers are here already'
339
+ end
340
+ end
341
+
342
+ def self.generate_first_manager_user
343
+ if User.managers.all.count == 0
344
+ _email_pass = 'manager@#{app_name.dasherize.downcase}.ru'
345
+ if User.create(roles: ["manager"], email: _email_pass, password: _email_pass, password_confirmation: _email_pass)
346
+ puts "ManagerUser with email and password '\#{_email_pass}' was created!"
347
+ else
348
+ puts 'Creating ManagerUser error'
349
+ end
350
+ else
351
+ puts 'ManagerUsers are here already'
339
352
  end
340
353
  end
341
354
 
@@ -483,12 +496,8 @@ generate "enjoy:cms:assets", app_name
483
496
  remove_file 'public/robots.txt'
484
497
  generate "enjoy:cms:robots"
485
498
 
486
-
487
499
  #god+unicorn
488
500
  generate "enjoy:cms:unicorn_god", app_name
489
-
490
-
491
-
492
501
  #scripts
493
502
  generate "enjoy:cms:scripts", app_name
494
503
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enjoy_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.4
4
+ version: 0.4.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Kiseliev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-28 00:00:00.000000000 Z
11
+ date: 2016-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -320,7 +320,9 @@ files:
320
320
  - lib/enjoy/rails_admin_ext/enjoy_hash.rb
321
321
  - lib/enjoy/rails_admin_ext/enjoy_html.rb
322
322
  - lib/enjoy/rails_admin_ext/enjoy_slugs.rb
323
- - lib/enjoy/rails_admin_ext/group_patch.rb
323
+ - lib/enjoy/rails_admin_ext/patches/enjoy_cms_group.rb
324
+ - lib/enjoy/rails_admin_ext/patches/field_patch.rb
325
+ - lib/enjoy/rails_admin_ext/patches/group_patch.rb
324
326
  - lib/enjoy/rails_admin_settings_patch.rb
325
327
  - lib/enjoy/routes.rb
326
328
  - lib/enjoy/simple_form_patch.rb