adminpanel 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/app/assets/stylesheets/adminpanel/theme.css +46 -41
  2. data/app/controllers/adminpanel/categories_controller.rb +71 -0
  3. data/app/controllers/adminpanel/users_controller.rb +69 -69
  4. data/app/helpers/adminpanel/application_helper.rb +2 -1
  5. data/app/helpers/adminpanel/class_definitions_helper.rb +10 -0
  6. data/app/helpers/adminpanel/custom_form_builder.rb +23 -24
  7. data/app/helpers/adminpanel/pluralizations_helper.rb +21 -0
  8. data/app/helpers/adminpanel/rest_actions_helper.rb +42 -34
  9. data/app/helpers/adminpanel/router_helper.rb +30 -26
  10. data/app/models/adminpanel/gallery.rb +6 -2
  11. data/app/models/adminpanel/image.rb +1 -1
  12. data/app/models/adminpanel/user.rb +15 -1
  13. data/app/views/adminpanel/categories/_categories_table.html.erb +48 -0
  14. data/app/views/adminpanel/categories/_category_form.html.erb +14 -0
  15. data/app/views/adminpanel/categories/index.html.erb +55 -0
  16. data/app/views/adminpanel/categories/new.js.erb +1 -0
  17. data/app/views/layouts/_side_menu.html.erb +91 -22
  18. data/app/views/shared/_error_messages.html.erb +3 -3
  19. data/app/views/shared/_form_fields.html.erb +14 -13
  20. data/app/views/shared/index.html.erb +1 -1
  21. data/config/locales/es.yml +5 -10
  22. data/config/routes.rb +20 -9
  23. data/lib/adminpanel/active_record_extension.rb +52 -8
  24. data/lib/adminpanel/engine.rb +4 -2
  25. data/lib/adminpanel/version.rb +1 -1
  26. data/lib/generators/adminpanel/initialize/initialize_generator.rb +20 -6
  27. data/lib/generators/adminpanel/initialize/templates/adminpanel_setup.rb +16 -0
  28. data/lib/generators/adminpanel/initialize/templates/category_template.rb +32 -0
  29. data/lib/generators/adminpanel/initialize/templates/create_adminpanel_categories_table.rb +11 -0
  30. data/lib/generators/adminpanel/resource/resource_generator.rb +1 -1
  31. data/lib/tasks/adminpanel/adminpanel.rake +4 -4
  32. data/spec/dummy/app/controllers/adminpanel/categories_controller.rb +1 -1
  33. data/spec/dummy/app/models/adminpanel/categorization.rb +5 -5
  34. data/spec/dummy/app/models/adminpanel/category.rb +9 -9
  35. data/spec/generators/initialize_generator_spec.rb +34 -0
  36. data/spec/generators/{resource_spec.rb → resource_generator_spec.rb} +0 -0
  37. data/spec/models/user_spec.rb +3 -3
  38. metadata +18 -19
  39. data/app/helpers/adminpanel/images_helper.rb +0 -10
  40. data/app/views/adminpanel/users/_user_form.html.erb +0 -21
  41. data/app/views/adminpanel/users/edit.html.erb +0 -6
  42. data/app/views/adminpanel/users/index.html.erb +0 -49
  43. data/app/views/adminpanel/users/new.html.erb +0 -6
  44. data/app/views/adminpanel/users/show.html.erb +0 -21
  45. data/config/locales/en.yml +0 -5
  46. data/spec/dummy/config/initializers/inflections.rb +0 -15
  47. data/spec/features/user_pages_spec.rb +0 -48
  48. data/spec/generators/initialize_spec.rb +0 -9
@@ -4,13 +4,15 @@ module Adminpanel
4
4
  end
5
5
 
6
6
  class << self
7
- mattr_accessor :analytics_profile_id, :analytics_key_path, :analytics_key_filename
7
+ mattr_accessor :analytics_profile_id, :analytics_key_path, :analytics_key_filename,
8
+ :unincluded_modules
8
9
  self.analytics_profile_id = nil
9
10
  self.analytics_key_path = "config/analytics"
10
11
  self.analytics_key_filename = nil
12
+ self.unincluded_modules = []
11
13
  end
12
14
 
13
15
  def self.setup(&block)
14
- yield self
16
+ yield self
15
17
  end
16
18
  end
@@ -1,3 +1,3 @@
1
1
  module Adminpanel
2
- VERSION = "1.2.4"
2
+ VERSION = "1.2.5"
3
3
  end
@@ -3,15 +3,29 @@ module Adminpanel
3
3
  module Generators
4
4
  class InitializeGenerator < Rails::Generators::Base
5
5
  desc "Generate the migrations necessary to start the gem"
6
- source_root File.expand_path("../templates", __FILE__)
6
+ source_root File.expand_path("../templates", __FILE__)
7
+ class_option :include_category, :type => :boolean, :aliases => "-c", :default => true, :desc => "Include category skeleton and migration for it"
7
8
 
8
- def self.next_migration_number(path)
9
- Time.now.utc.strftime("%Y%m%d%H%M%S")
10
- end
9
+ def self.next_migration_number(path)
10
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
11
+ end
12
+
13
+ def create_initializers
14
+ copy_file 'adminpanel_setup.rb', 'config/initializers/adminpanel_setup.rb'
15
+ end
16
+
17
+ def create_categories
18
+ if options[:include_category]
19
+ puts "including category files"
20
+ copy_file "category_template.rb", 'app/models/adminpanel/category.rb'
21
+ migration_template 'create_adminpanel_categories_table.rb', 'db/migrate/create_adminpanel_categories_tables.rb'
22
+ end
23
+ end
11
24
 
12
25
  def create_migration
13
- migration_template 'create_adminpanel_tables.rb', 'db/migrate/create_adminpanel_tables.rb'
26
+ migration_template 'create_adminpanel_tables.rb', 'db/migrate/create_adminpanel_tables.rb'
14
27
  end
28
+
15
29
  end
16
30
  end
17
- end
31
+ end
@@ -0,0 +1,16 @@
1
+ Adminpanel.setup do |config|
2
+ # # You get this from the Google Analytics Dashboard, this configuration is required.
3
+ # config.analytics_profile_id = '12341234'
4
+
5
+ # # The next configuration is the file used to establish server to server authentication/authorization
6
+ # # you need to download this file from the Google Developers Console
7
+ # # and place it inside your application, this configuration is required.
8
+ # config.analytics_key_filename = '12345ABCDE.p12'
9
+
10
+ # # Path to the key file, defaults to config/analytics
11
+ # config.analytics_key_path = "config/analytics"
12
+
13
+ # # Configure the default modules that you don't need
14
+ # # the supported options are :categories, :gallery, :sections and :categories
15
+ # config.unincluded_modules = [:categories, :gallery, :sections, :categories]
16
+ end
@@ -0,0 +1,32 @@
1
+ module Adminpanel
2
+ class Category < ActiveRecord::Base
3
+ attr_accessible :name, :model
4
+
5
+ validates_presence_of :model
6
+ validates_presence_of :name
7
+ validates_uniqueness_of :name
8
+
9
+
10
+ has_many :categorizations
11
+ has_many :products, :through => :categorizations, :dependent => :destroy
12
+
13
+
14
+ def self.form_attributes
15
+ [
16
+ {"product_ids" => {"type" => "has_many", "model" => "Adminpanel::Product", "name" => "product_ids"}},
17
+ {"name" => {"type" => "text_field", "name" => "name", "label" => "name", "placeholder" => "name"}},
18
+ ]
19
+ end
20
+
21
+ def self.display_name
22
+ "Categoría"
23
+ end
24
+
25
+ # def self.icon
26
+ # "icon-truck"
27
+ # end
28
+
29
+ default_scope { order("model ASC")}
30
+ scope :of_model, lambda{|model| where(:model => model)}
31
+ end
32
+ end
@@ -0,0 +1,11 @@
1
+ class CreateCategoriesTable < ActiveRecord::Migration
2
+ def change
3
+ create_table :adminpanel_categories do |t|
4
+
5
+
6
+ t.string :name
7
+ t.string :model
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -5,7 +5,7 @@ module Adminpanel
5
5
  class ResourceGenerator < Rails::Generators::Base
6
6
 
7
7
  source_root File.expand_path("../templates", __FILE__)
8
- argument :resource_name, :type => :string
8
+ argument :resource_name, :type => :string, :required => true
9
9
  argument :fields, :type => :array, :default => "name:string"
10
10
  desc "Generate the resource files necessary to use a model"
11
11
 
@@ -9,7 +9,7 @@ namespace :adminpanel do
9
9
  :name => args[:name].titleize,
10
10
  :has_description => false,
11
11
  :description => "",
12
- :key => args[:name].underscore,
12
+ :key => (args[:name].tr(' ','_')),
13
13
  :page => args[:section],
14
14
  :has_image => false
15
15
  )
@@ -129,7 +129,7 @@ private
129
129
  end
130
130
 
131
131
  def generate_lorem
132
- value = ""
132
+ value = "#{@lorem.sample}"
133
133
  [*60..80].sample.times do
134
134
  value = "#{value} #{@lorem.sample}"
135
135
  end
@@ -137,8 +137,8 @@ private
137
137
  end
138
138
 
139
139
  def generate_lorem_name
140
- value = ""
141
- [*1..4].sample.times do
140
+ value = "#{@lorem.sample}"
141
+ [*0..3].sample.times do
142
142
  value = "#{value} #{@lorem.sample}"
143
143
  end
144
144
  "#{value.titleize}."
@@ -1,4 +1,4 @@
1
1
  module Adminpanel
2
2
  class CategoriesController < Adminpanel::ApplicationController
3
3
  end
4
- end
4
+ end
@@ -3,9 +3,9 @@ module Adminpanel
3
3
  attr_accessible :product_id, :category_id
4
4
 
5
5
  belongs_to :product
6
- belongs_to :category
7
-
8
-
6
+ belongs_to :category
7
+
8
+
9
9
  def self.form_attributes
10
10
  [
11
11
  {"product_id" => {"type" => "belongs_to", "model" => "Adminpanel::Product", "name" => "product_id"}},
@@ -18,7 +18,7 @@ module Adminpanel
18
18
  end
19
19
 
20
20
  # def self.icon
21
- # "icon-truck"
21
+ # "icon-truck"
22
22
  # end
23
23
  end
24
- end
24
+ end
@@ -3,14 +3,14 @@ module Adminpanel
3
3
  attr_accessible :product_ids, :name
4
4
 
5
5
  has_many :categorizations
6
- has_many :products, :through => :categorizations, :dependent => :destroy
7
-
8
-
6
+ has_many :products, :through => :categorizations, :dependent => :destroy
7
+
8
+
9
9
  def self.form_attributes
10
- [
11
- {"product_ids" => {"type" => "has_many", "model" => "Adminpanel::Product", "name" => "product_ids"}},
12
- {"name" => {"type" => "text_field", "name" => "name", "label" => "name", "placeholder" => "name"}},
13
- ]
10
+ [
11
+ {"name" => {"type" => "text_field", "name" => "name", "label" => "name", "placeholder" => "name"}},
12
+ {"product_ids" => {"type" => "has_many", "model" => "Adminpanel::Product", "name" => "product_ids"}},
13
+ ]
14
14
  end
15
15
 
16
16
  def self.display_name
@@ -18,7 +18,7 @@ module Adminpanel
18
18
  end
19
19
 
20
20
  # def self.icon
21
- # "icon-truck"
21
+ # "icon-truck"
22
22
  # end
23
23
  end
24
- end
24
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe "adminpanel:initialize" do
4
+ context "with no arguments or options" do
5
+ it "should generate a migration" do
6
+ subject.should generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_adminpanel_tables.rb")
7
+ end
8
+
9
+ it "should generate the default category and migration" do
10
+ subject.should generate("app/models/adminpanel/category.rb")
11
+ end
12
+
13
+ it 'should generate the categories migration' do
14
+ subject.should generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_adminpanel_categories_tables.rb")
15
+ end
16
+ end
17
+
18
+ with_args :'-c', :false do
19
+ it "shouldn't generate the default category and migration" do
20
+ subject.should_not generate("app/models/adminpanel/category.rb")
21
+ end
22
+
23
+ it "shouldn't generate the categories migration" do
24
+ subject.should_not generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_adminpanel_categories_tables.rb")
25
+ end
26
+
27
+ end
28
+
29
+ it 'should generate the configuration initializer' do
30
+ subject.should generate('config/initializers/adminpanel_setup.rb'){ |content|
31
+ content.should =~ /Adminpanel.setup do |config|/
32
+ }
33
+ end
34
+ end
@@ -4,9 +4,9 @@ describe Adminpanel::User do
4
4
 
5
5
  before do
6
6
  @user = Adminpanel::User.new(
7
- :name => "Example User",
7
+ :name => "Example User",
8
8
  :email => "user@example.com",
9
- :password => "foobar",
9
+ :password => "foobar",
10
10
  :password_confirmation => "foobar"
11
11
  )
12
12
  end
@@ -103,4 +103,4 @@ describe Adminpanel::User do
103
103
  specify { user_for_invalid_password.should be_false }
104
104
  end
105
105
  end
106
- end
106
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adminpanel
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 4
10
- version: 1.2.4
9
+ - 5
10
+ version: 1.2.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jose Ramon Camacho
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2014-03-11 00:00:00 -06:00
19
+ date: 2014-03-19 00:00:00 -06:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -412,6 +412,7 @@ files:
412
412
  - app/assets/stylesheets/adminpanel/timepicker.css
413
413
  - app/assets/stylesheets/application-admin.css
414
414
  - app/controllers/adminpanel/application_controller.rb
415
+ - app/controllers/adminpanel/categories_controller.rb
415
416
  - app/controllers/adminpanel/galleries_controller.rb
416
417
  - app/controllers/adminpanel/pages_controller.rb
417
418
  - app/controllers/adminpanel/sections_controller.rb
@@ -419,8 +420,9 @@ files:
419
420
  - app/controllers/adminpanel/users_controller.rb
420
421
  - app/helpers/adminpanel/application_helper.rb
421
422
  - app/helpers/adminpanel/breadcrumbs_helper.rb
423
+ - app/helpers/adminpanel/class_definitions_helper.rb
422
424
  - app/helpers/adminpanel/custom_form_builder.rb
423
- - app/helpers/adminpanel/images_helper.rb
425
+ - app/helpers/adminpanel/pluralizations_helper.rb
424
426
  - app/helpers/adminpanel/rest_actions_helper.rb
425
427
  - app/helpers/adminpanel/router_helper.rb
426
428
  - app/helpers/adminpanel/sessions_helper.rb
@@ -433,6 +435,10 @@ files:
433
435
  - app/uploaders/adminpanel/gallery_uploader.rb
434
436
  - app/uploaders/adminpanel/image_uploader.rb
435
437
  - app/views/adminpanel/.DS_Store
438
+ - app/views/adminpanel/categories/_categories_table.html.erb
439
+ - app/views/adminpanel/categories/_category_form.html.erb
440
+ - app/views/adminpanel/categories/index.html.erb
441
+ - app/views/adminpanel/categories/new.js.erb
436
442
  - app/views/adminpanel/galleries/_galleries_table.html.erb
437
443
  - app/views/adminpanel/galleries/create.html.erb
438
444
  - app/views/adminpanel/galleries/delete.html.erb
@@ -450,11 +456,6 @@ files:
450
456
  - app/views/adminpanel/sections/index.html.erb
451
457
  - app/views/adminpanel/sections/show.html.erb
452
458
  - app/views/adminpanel/sessions/new.html.erb
453
- - app/views/adminpanel/users/_user_form.html.erb
454
- - app/views/adminpanel/users/edit.html.erb
455
- - app/views/adminpanel/users/index.html.erb
456
- - app/views/adminpanel/users/new.html.erb
457
- - app/views/adminpanel/users/show.html.erb
458
459
  - app/views/layouts/_shim.html.erb
459
460
  - app/views/layouts/_side_menu.html.erb
460
461
  - app/views/layouts/_top_bar.html.erb
@@ -469,7 +470,6 @@ files:
469
470
  - app/views/shared/index.html.erb
470
471
  - app/views/shared/new.html.erb
471
472
  - app/views/shared/show.html.erb
472
- - config/locales/en.yml
473
473
  - config/locales/es.yml
474
474
  - config/routes.rb
475
475
  - lib/adminpanel.rb
@@ -477,6 +477,9 @@ files:
477
477
  - lib/adminpanel/engine.rb
478
478
  - lib/adminpanel/version.rb
479
479
  - lib/generators/adminpanel/initialize/initialize_generator.rb
480
+ - lib/generators/adminpanel/initialize/templates/adminpanel_setup.rb
481
+ - lib/generators/adminpanel/initialize/templates/category_template.rb
482
+ - lib/generators/adminpanel/initialize/templates/create_adminpanel_categories_table.rb
480
483
  - lib/generators/adminpanel/initialize/templates/create_adminpanel_tables.rb
481
484
  - lib/generators/adminpanel/resource/resource_generator.rb
482
485
  - lib/generators/adminpanel/resource/templates/controller.rb
@@ -511,7 +514,6 @@ files:
511
514
  - spec/dummy/config/environments/production.rb
512
515
  - spec/dummy/config/environments/test.rb
513
516
  - spec/dummy/config/initializers/backtrace_silencers.rb
514
- - spec/dummy/config/initializers/inflections.rb
515
517
  - spec/dummy/config/initializers/mime_types.rb
516
518
  - spec/dummy/config/initializers/secret_token.rb
517
519
  - spec/dummy/config/initializers/session_store.rb
@@ -533,9 +535,8 @@ files:
533
535
  - spec/features/galleries_pages_spec.rb
534
536
  - spec/features/section_pages_spec.rb
535
537
  - spec/features/shared_pages_spec.rb
536
- - spec/features/user_pages_spec.rb
537
- - spec/generators/initialize_spec.rb
538
- - spec/generators/resource_spec.rb
538
+ - spec/generators/initialize_generator_spec.rb
539
+ - spec/generators/resource_generator_spec.rb
539
540
  - spec/models/gallery_spec.rb
540
541
  - spec/models/product_spec.rb
541
542
  - spec/models/section_spec.rb
@@ -612,7 +613,6 @@ test_files:
612
613
  - spec/dummy/config/environments/production.rb
613
614
  - spec/dummy/config/environments/test.rb
614
615
  - spec/dummy/config/initializers/backtrace_silencers.rb
615
- - spec/dummy/config/initializers/inflections.rb
616
616
  - spec/dummy/config/initializers/mime_types.rb
617
617
  - spec/dummy/config/initializers/secret_token.rb
618
618
  - spec/dummy/config/initializers/session_store.rb
@@ -634,9 +634,8 @@ test_files:
634
634
  - spec/features/galleries_pages_spec.rb
635
635
  - spec/features/section_pages_spec.rb
636
636
  - spec/features/shared_pages_spec.rb
637
- - spec/features/user_pages_spec.rb
638
- - spec/generators/initialize_spec.rb
639
- - spec/generators/resource_spec.rb
637
+ - spec/generators/initialize_generator_spec.rb
638
+ - spec/generators/resource_generator_spec.rb
640
639
  - spec/models/gallery_spec.rb
641
640
  - spec/models/product_spec.rb
642
641
  - spec/models/section_spec.rb
@@ -1,10 +0,0 @@
1
- module Adminpanel
2
- module ImagesHelper
3
-
4
- def is_class?(name)
5
- Module.const_get(name).is_a?(Class)
6
- rescue NameError
7
- return false
8
- end
9
- end
10
- end
@@ -1,21 +0,0 @@
1
- <div class = "widget widget-padding span12">
2
- <div class = "widget-header"><i class = "icon-user"></i><h5>Usuario</h5></div>
3
- <div class = "widget-body">
4
- <div class = "widget-forms clearfix">
5
- <%= custom_form_for(@user) do |f| %>
6
- <%= render 'shared/error_messages', :object => @user %>
7
-
8
- <%= f.text_field :name, :label => "Nombre", :placeholder => "Nombre del usuario" %>
9
-
10
- <%= f.text_field :email, :label => t("model.attributes.Adminpanel::User.email"), :placeholder => t("model.attributes.Adminpanel::User.email") %>
11
-
12
- <%= f.password_field :password, :label => t("model.attributes.Adminpanel::User.password"), :placeholder => t("model.attributes.Adminpanel::User.password") %>
13
-
14
- <%= f.password_field :password_confirmation, :label => t("model.attributes.Adminpanel::User.password_confirmation"), :placeholder => t("model.attributes.Adminpanel::User.password_confirmation") %>
15
- </div>
16
- </div>
17
- <div class = "widget-footer">
18
- <%= f.submit "Agregar", :disable_with => 'Submiting...' %>
19
- </div>
20
- <% end -%>
21
- </div>
@@ -1,6 +0,0 @@
1
- <% provide(:page_title, "Editar") %>
2
- <% breadcrumb_add('Usuarios', users_path) %>
3
- <% breadcrumb_add(@user.name, user_path(@user)) %>
4
- <div class="row-fluid">
5
- <%= render 'user_form' %>
6
- </div>