adminpanel 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/adminpanel.gemspec +20 -18
  3. data/app/assets/javascripts/adminpanel/jquery.knob.js +652 -0
  4. data/app/assets/javascripts/adminpanel/realm.js +20 -18
  5. data/app/assets/javascripts/adminpanel/spinner.js.coffee +3 -3
  6. data/app/controllers/adminpanel/analytics_controller.rb +99 -53
  7. data/app/controllers/adminpanel/auths_controller.rb +1 -1
  8. data/app/controllers/adminpanel/sessions_controller.rb +26 -26
  9. data/app/controllers/concerns/adminpanel/facebook_actions.rb +2 -2
  10. data/app/helpers/adminpanel/adminpanel_form_builder.rb +257 -298
  11. data/app/helpers/adminpanel/analytics_helper.rb +46 -0
  12. data/app/helpers/adminpanel/application_helper.rb +57 -57
  13. data/app/helpers/adminpanel/breadcrumbs_helper.rb +13 -13
  14. data/app/helpers/adminpanel/sessions_helper.rb +20 -20
  15. data/app/helpers/adminpanel/shared_pages_helper.rb +41 -41
  16. data/app/models/adminpanel/gallery.rb +65 -63
  17. data/app/models/adminpanel/image.rb +5 -5
  18. data/app/models/adminpanel/section.rb +61 -53
  19. data/app/models/adminpanel/user.rb +1 -6
  20. data/app/models/concerns/adminpanel/facebook.rb +1 -1
  21. data/app/uploaders/adminpanel/gallery_uploader.rb +1 -1
  22. data/app/views/adminpanel/analytics/_widget_task_statistics.html.erb +63 -0
  23. data/app/views/adminpanel/analytics/fb.html.erb +98 -0
  24. data/app/views/adminpanel/analytics/index.html.erb +8 -8
  25. data/app/views/adminpanel/galleries/_galleries_table.html.erb +12 -12
  26. data/app/views/adminpanel/galleries/move_better.js.erb +1 -1
  27. data/app/views/adminpanel/galleries/move_worst.js.erb +1 -1
  28. data/app/views/adminpanel/sections/_sections_table.html.erb +7 -7
  29. data/app/views/adminpanel/sections/show.html.erb +25 -25
  30. data/app/views/adminpanel/sessions/new.html.erb +22 -22
  31. data/app/views/layouts/_shim.html.erb +1 -1
  32. data/app/views/layouts/_side_menu.html.erb +35 -35
  33. data/app/views/layouts/admin-login.html.erb +22 -22
  34. data/app/views/layouts/admin.html.erb +35 -35
  35. data/app/views/shared/_breadcrumb.html.erb +4 -4
  36. data/app/views/shared/_error_messages.html.erb +15 -15
  37. data/app/views/shared/_form_fields.html.erb +48 -47
  38. data/app/views/shared/_image_fields.html.erb +1 -1
  39. data/config/initializers/pluralization_es.rb +1 -1
  40. data/config/locales/es.yml +38 -2
  41. data/config/routes.rb +5 -4
  42. data/lib/adminpanel/version.rb +1 -1
  43. data/lib/generators/adminpanel/gallery/templates/gallery_migration.rb +5 -5
  44. data/lib/generators/adminpanel/gallery/templates/uploader.rb +1 -1
  45. data/lib/generators/adminpanel/initialize/initialize_generator.rb +54 -54
  46. data/lib/generators/adminpanel/initialize/templates/category_template.rb +1 -1
  47. data/lib/generators/adminpanel/initialize/templates/create_adminpanel_categories_table.rb +5 -5
  48. data/lib/generators/adminpanel/initialize/templates/create_adminpanel_tables.rb +57 -57
  49. data/lib/generators/adminpanel/initialize/templates/section_uploader.rb +1 -1
  50. data/lib/generators/adminpanel/migration/migration_generator.rb +44 -0
  51. data/lib/generators/adminpanel/migration/migration_generator_helper.rb +19 -0
  52. data/lib/generators/adminpanel/resource/resource_generator.rb +60 -245
  53. data/lib/generators/adminpanel/resource/resource_generator_helper.rb +189 -0
  54. data/lib/generators/adminpanel/resource/templates/{controller.rb → adminpanel_controller_template.rb} +2 -2
  55. data/lib/generators/adminpanel/resource/templates/{resource.rb → adminpanel_resource_template.rb} +0 -0
  56. data/test/dummy/app/models/adminpanel/categorization.rb +2 -2
  57. data/test/dummy/app/models/adminpanel/category.rb +3 -3
  58. data/test/dummy/app/models/adminpanel/department.rb +2 -2
  59. data/test/dummy/app/models/adminpanel/item.rb +3 -3
  60. data/test/dummy/app/models/adminpanel/mug.rb +14 -14
  61. data/test/dummy/app/models/adminpanel/product.rb +19 -19
  62. data/test/dummy/app/models/adminpanel/salesman.rb +15 -15
  63. data/test/dummy/app/uploader/adminpanel/photo_uploader.rb +1 -1
  64. data/test/dummy/app/views/layouts/application.html.erb +9 -9
  65. data/test/dummy/config/boot.rb +1 -1
  66. data/test/features/shared/{belongs_to_category_modal_test.rb → form/belongs_to_category_modal_test.rb} +0 -0
  67. data/test/features/shared/{belongs_to_non_category_modal_test.rb → form/belongs_to_non_category_modal_test.rb} +0 -0
  68. data/test/features/shared/{has_many_through_category_modal_test.rb → form/has_many_through_category_modal_test.rb} +0 -0
  69. data/test/features/shared/{has_many_through_non_category_modal_test.rb → form/has_many_through_non_category_modal_test.rb} +0 -0
  70. data/test/features/shared/{edit_test.rb → resource/edit_test.rb} +0 -0
  71. data/test/features/shared/{index_test.rb → resource/index_test.rb} +0 -0
  72. data/test/features/shared/{new_test.rb → resource/new_test.rb} +0 -0
  73. data/test/features/shared/{show_test.rb → resource/show_test.rb} +0 -0
  74. data/test/features/shared/{action_exclution_test.rb → ui/action_exclution_test.rb} +0 -0
  75. data/test/test_helper.rb +1 -1
  76. metadata +44 -32
  77. data/test/dummy/app/controllers/adminpanel/.gitkeep +0 -0
  78. data/test/dummy/app/models/.gitkeep +0 -0
@@ -1,9 +1,9 @@
1
1
  module Adminpanel
2
- class Image < ActiveRecord::Base
3
- include Adminpanel::Base
2
+ class Image < ActiveRecord::Base
3
+ include Adminpanel::Base
4
4
 
5
- validates_presence_of :file
5
+ validates_presence_of :file
6
6
 
7
- mount_uploader :file, Adminpanel::SectionUploader
8
- end
7
+ mount_uploader :file, Adminpanel::SectionUploader
8
+ end
9
9
  end
@@ -1,69 +1,77 @@
1
1
  require 'carrierwave'
2
2
  require 'carrierwave/orm/activerecord'
3
3
  module Adminpanel
4
- class Section < ActiveRecord::Base
5
- include Adminpanel::Base
4
+ class Section < ActiveRecord::Base
5
+ include Adminpanel::Base
6
6
 
7
- mount_images :images
7
+ mount_images :images
8
8
 
9
- validates_length_of :description,
10
- minimum: 10,
11
- maximum: 10,
12
- on: :update,
13
- if: :is_a_phone?,
14
- message: I18n.t('activerecord.errors.messages.not_phone')
15
- validates_presence_of :description,
16
- minimum: 9,
17
- on: :update,
18
- if: lambda{|section| section.has_description == true }
19
- validates :description,
20
- numericality: { only_integer: true },
21
- on: :update,
22
- if: :is_a_phone?
23
- validates_presence_of :key
24
- validates_presence_of :name
25
- validates_presence_of :page
9
+ validates_length_of :description,
10
+ minimum: 10,
11
+ maximum: 10,
12
+ on: :update,
13
+ if: :is_a_phone?,
14
+ message: I18n.t('activerecord.errors.messages.not_phone')
15
+ validates_presence_of :description,
16
+ minimum: 9,
17
+ on: :update,
18
+ if: :has_description
19
+ validates :description,
20
+ numericality: { only_integer: true },
21
+ on: :update,
22
+ if: :is_a_phone?
23
+ validates_presence_of :key
24
+ validates_presence_of :name
25
+ validates_presence_of :page
26
26
 
27
- VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
28
- validates_format_of :description, with: VALID_EMAIL_REGEX, if: lambda{|section| section.key == 'email'}
27
+ VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
28
+ validates_format_of :description, with: VALID_EMAIL_REGEX, if: :is_email?
29
29
 
30
- default_scope { order("page ASC") }
30
+ default_scope { order("page ASC") }
31
31
 
32
- scope :of_page, lambda{ |page|
33
- where(page: page)
34
- }
32
+ scope :of_page, lambda{ |page|
33
+ where(page: page)
34
+ }
35
35
 
36
- scope :with_description, -> { where.not( description: '') }
36
+ scope :with_description, -> { where.not( description: '') }
37
37
 
38
- def self.form_attributes
39
- [
40
- {'description' => {'name' => 'Descripcion', 'description' => 'label', 'label' => 'Seccion'}},
41
- {'name' => {'name' => 'name', 'label' => 'Seccion'}},
42
- {'key' => {'name' => 'key', 'label' => 'Llave'}},
43
- {'page' => {'name' => 'page'}},
44
- ]
38
+ def self.form_attributes
39
+ [
40
+ {'description' => {'name' => 'Descripcion', 'description' => 'label', 'label' => 'Seccion'}},
41
+ {'name' => {'name' => 'name', 'label' => 'Seccion'}},
42
+ {'key' => {'name' => 'key', 'label' => 'Llave'}},
43
+ {'page' => {'name' => 'page'}},
44
+ ]
45
45
 
46
- end
46
+ end
47
47
 
48
- def self.icon
49
- 'tasks'
50
- end
48
+ def self.icon
49
+ 'tasks'
50
+ end
51
51
 
52
- def self.display_name
53
- 'Seccion'
54
- end
52
+ def self.display_name
53
+ 'Seccion'
54
+ end
55
55
 
56
- def description
57
- if self.has_description && !self.attributes['description'].nil?
58
- return self.attributes['description'].html_safe
59
- else
60
- return self.attributes['description']
61
- end
62
- end
56
+ def description
57
+ if self.has_description && !self.attributes['description'].nil?
58
+ return self.attributes['description'].html_safe
59
+ else
60
+ return self.attributes['description']
61
+ end
62
+ end
63
63
 
64
- private
65
- def is_a_phone?
66
- key == 'phone' && description != ''
67
- end
68
- end
64
+ protected
65
+ def has_description?
66
+ !self.has_description.nil? || self.has_description
67
+ end
68
+
69
+ def is_email?
70
+ key == 'email' && description != ''
71
+ end
72
+
73
+ def is_a_phone?
74
+ key == 'phone' && description != ''
75
+ end
76
+ end
69
77
  end
@@ -37,15 +37,13 @@ module Adminpanel
37
37
  {
38
38
  'name' => {
39
39
  'type' => 'text_field',
40
- 'name' => 'Nombre',
41
40
  'label' => 'Nombre',
42
41
  'placeholder' => 'Nombre'
43
42
  }
44
43
  },
45
44
  {
46
45
  'email' => {
47
- 'type' => 'text_field',
48
- 'name' => 'Correo',
46
+ 'type' => 'email_field',
49
47
  'label' => 'Correo',
50
48
  'placeholder' => 'Correo'
51
49
  }
@@ -53,7 +51,6 @@ module Adminpanel
53
51
  {
54
52
  'password' => {
55
53
  'type' => 'password_field',
56
- 'name' => 'Contrasena',
57
54
  'label' => I18n.t('model.attributes.password'),
58
55
  'placeholder' => I18n.t('model.attributes.password'),
59
56
  'show' => 'false'
@@ -62,7 +59,6 @@ module Adminpanel
62
59
  {
63
60
  'password_confirmation' => {
64
61
  'type' => 'password_field',
65
- 'name' => 'Confirmacion de contrasena',
66
62
  'placeholder' => I18n.t('model.attributes.password_confirmation'),
67
63
  'label' => I18n.t('model.attributes.password_confirmation'),
68
64
  'show' => 'false'
@@ -71,7 +67,6 @@ module Adminpanel
71
67
  {
72
68
  'group_id' => {
73
69
  'type' => 'belongs_to',
74
- 'name' => 'Group',
75
70
  'model' => 'Adminpanel::Group',
76
71
  'remote_resource' => false,
77
72
  'placeholder' => I18n.t('model.attributes.group_id'),
@@ -13,7 +13,7 @@ module Adminpanel
13
13
  # )
14
14
  # end
15
15
  def fb_link
16
- 'www.overwrite.fb_link.com'
16
+ 'http://www.google.com'
17
17
  end
18
18
 
19
19
  # static(class) methods
@@ -53,4 +53,4 @@ module Adminpanel
53
53
  # end
54
54
 
55
55
  end
56
- end
56
+ end
@@ -0,0 +1,63 @@
1
+ <div class="widget-tasks-statistics">
2
+ <div class="userstats clearfix" style="margin-top: 25px;">
3
+ <%= link_to '#', data: { toggle: 'modal', target: "##{metric(inside)}" } do %>
4
+ <div class="white">
5
+ <i style="color:<%= color %>" class="fa fa-<%= icon %>"></i>
6
+ <p style="color:<%= color %>" >
7
+ <%= "#{first_fb_value(inside).to_i} #{placeholder}" %>
8
+ </p>
9
+ </div>
10
+ <div>
11
+ <input
12
+ class="knob"
13
+ data-width="120"
14
+ data-height="120"
15
+ data-displayInput=false
16
+ data-readOnly=true
17
+ data-thickness=".12"
18
+ value="<%= divide_metrics(inside, outside) * 100 %>"
19
+ >
20
+ </div>
21
+ <p>
22
+ <strong>
23
+ <%= first_fb_value(outside).to_i %>
24
+ </strong>
25
+ <%= label %>
26
+ </p>
27
+ <% end %>
28
+ </div>
29
+ </div>
30
+
31
+ <!-- modal -->
32
+ <%= content_for :modals do %>
33
+ <div id="<%= metric(inside) %>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
34
+ <div class="modal-header" id="modal-header">
35
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
36
+ <h3 id="modal-title">
37
+ <%= I18n.t("analytics.metrics.#{metric(inside)}") %> /
38
+ <%= I18n.t("analytics.metrics.#{metric(outside)}") %>
39
+ </h3>
40
+ </div>
41
+ <div id="modal-container">
42
+ <div class="modal-body">
43
+ <ul>
44
+ <li>
45
+ <%= I18n.t("analytics.metrics.#{metric(inside)}") %>:
46
+ <%= I18n.t("analytics.description.#{metric(inside)}") %>
47
+ </li>
48
+ <br>
49
+ <li>
50
+ <%= I18n.t("analytics.metrics.#{metric(outside)}") %>:
51
+ <%= I18n.t("analytics.description.#{metric(outside)}") %>
52
+ </li>
53
+
54
+ </ul>
55
+ </div>
56
+ <div class="modal-footer">
57
+ <button id="modal-button" class="btn" data-dismiss="modal" aria-hidden="true">
58
+ <%= I18n.t('action.close') %>
59
+ </button>
60
+ </div>
61
+ </div>
62
+ </div>
63
+ <% end %>
@@ -0,0 +1,98 @@
1
+ <% provide(:page_title, I18n.t('analytics.facebook')) -%>
2
+ <%= form_tag fb_analytics_path, method: :get %>
3
+ <%=
4
+ select_tag(
5
+ 'insight',
6
+ options_for_select(
7
+ [
8
+ [I18n.t('analytics.now'), 'day'],
9
+ [I18n.t('analytics.week'), 'week'],
10
+ [I18n.t('analytics.month'), 'days_28']
11
+ ],
12
+ params[:insight]
13
+ )
14
+ )
15
+ %>
16
+ <%= button_tag(I18n.t('analytics.search'), type: 'submit', class: 'btn btn-info') %>
17
+ <h3><%= I18n.t('analytics.for') %> <%= I18n.t("analytics.#{insight}") %></h3>
18
+ <% date = Date.parse @new_likes.first['values'].first['end_time'] %>
19
+ <h5><%= date - days_to_substract %> - <%= date %></h5>
20
+ <div class="overview_boxes">
21
+ <div class="box_row clearfix">
22
+ <%=
23
+ render(
24
+ 'widget_task_statistics',
25
+ inside: @new_likes,
26
+ outside: @total_likes,
27
+ placeholder: '+',
28
+ icon: 'thumbs-up',
29
+ color: '#98AEEA',
30
+ label: 'Likes'
31
+ )
32
+ %>
33
+
34
+ <%=
35
+ render(
36
+ 'widget_task_statistics',
37
+ inside: @impressions_unique,
38
+ outside: @impressions,
39
+ placeholder: I18n.t('analytics.unique'),
40
+ icon: 'ticket',
41
+ color: '#6CD0F7',
42
+ label: I18n.t('analytics.impressions')
43
+ )
44
+ %>
45
+
46
+ <%=
47
+ render(
48
+ 'widget_task_statistics',
49
+ inside: @views_unique,
50
+ outside: @views,
51
+ placeholder: 'únicas',
52
+ icon: 'eye',
53
+ color: '#6CD0F7',
54
+ label: 'Vistas'
55
+ )
56
+ %>
57
+
58
+ <%=
59
+ render(
60
+ 'widget_task_statistics',
61
+ inside: @stories,
62
+ outside: @stories,
63
+ placeholder: '',
64
+ icon: 'bullhorn',
65
+ color: '#6CD0F7',
66
+ label: 'Hablando de ti'
67
+ )
68
+ %>
69
+
70
+ <%=
71
+ render(
72
+ 'widget_task_statistics',
73
+ inside: @consumptions_unique,
74
+ outside: @consumptions,
75
+ placeholder: 'únicas',
76
+ icon: 'crosshairs',
77
+ color: '#6CD0F7',
78
+ label: 'Consumptions'
79
+ )
80
+ %>
81
+
82
+ <%=
83
+ render(
84
+ 'widget_task_statistics',
85
+ inside: @hidden_unique,
86
+ outside: @hidden,
87
+ placeholder: '-',
88
+ icon: 'thumbs-down',
89
+ color: '#E28270',
90
+ label: 'Dislike o Hide'
91
+ )
92
+ %>
93
+
94
+
95
+ </div>
96
+ </div>
97
+
98
+ <%= yield :modals %>
@@ -1,13 +1,13 @@
1
1
  <% provide(:page_title, "Google Analytics") -%>
2
2
  <% content_for :scripts do %>
3
- <%#= javascript_include_tag "adminpanel/analytics/analytics" %>
3
+ <%#= javascript_include_tag "adminpanel/analytics/analytics" %>
4
4
  <% end %>
5
5
  <div class="row-fluid">
6
- <div class="widget widget-padding span12">
7
- <div class="widget-header">
8
- <i class="fa fa-dashboard"></i><h5>Estadísticas del Sitio</h5>
9
- </div>
10
- <%= content_tag "div", :id => "graphic-container", :class => "widget-body", :data => { :visits => @visits, :dates => @visitDates } do %>
11
- <% end %>
12
- </div>
6
+ <div class="widget widget-padding span12">
7
+ <div class="widget-header">
8
+ <i class="fa fa-dashboard"></i><h5>Estadísticas del Sitio</h5>
9
+ </div>
10
+ <%= content_tag "div", :id => "graphic-container", :class => "widget-body", :data => { :visits => @visits, :dates => @visitDates } do %>
11
+ <% end %>
12
+ </div>
13
13
  </div>
@@ -1,15 +1,15 @@
1
1
  <% @galleries.each do |gallery| %>
2
- <tr>
3
- <td><%= link_to image_tag(gallery.file_url(:thumb)), gallery_path(gallery) %></td>
4
- <td>
5
- <%= link_to content_tag(:i, nil, :class => "fa fa-chevron-up"), move_to_better_gallery_path(gallery), :method => :put, :remote => true %>
6
- <%= link_to content_tag(:i, nil, :class => "fa fa-chevron-down"), move_to_worst_gallery_path(gallery), :method => :put, :remote => true %>
7
- </td>
8
- <td>
9
- <%= render 'shared/show_icon_button', resource: gallery %>
10
- <%= render 'shared/edit_icon_button', resource: gallery %>
2
+ <tr>
3
+ <td><%= link_to image_tag(gallery.file_url(:thumb)), gallery_path(gallery) %></td>
4
+ <td>
5
+ <%= link_to content_tag(:i, nil, :class => "fa fa-chevron-up"), move_to_better_gallery_path(gallery), :method => :put, :remote => true %>
6
+ <%= link_to content_tag(:i, nil, :class => "fa fa-chevron-down"), move_to_worst_gallery_path(gallery), :method => :put, :remote => true %>
7
+ </td>
8
+ <td>
9
+ <%= render 'shared/show_icon_button', resource: gallery %>
10
+ <%= render 'shared/edit_icon_button', resource: gallery %>
11
11
 
12
- <%= render 'shared/delete_icon_button', resource: gallery %>
13
- </td>
14
- </tr>
12
+ <%= render 'shared/delete_icon_button', resource: gallery %>
13
+ </td>
14
+ </tr>
15
15
  <% end %>
@@ -1 +1 @@
1
- $("#galleries-content").html("<%= escape_javascript(render 'galleries_table', :locals => { :galleries => @galleries } ) %>");
1
+ $("#galleries-content").html("<%= escape_javascript(render 'galleries_table', :locals => { :galleries => @galleries } ) %>");
@@ -1 +1 @@
1
- $("#galleries-content").html("<%= escape_javascript(render 'galleries_table', :locals => { :galleries => @galleries } ) %>");
1
+ $("#galleries-content").html("<%= escape_javascript(render 'galleries_table', :locals => { :galleries => @galleries } ) %>");
@@ -1,10 +1,10 @@
1
1
  <table class="table table-striped table-bordered">
2
- <tr>
3
- <th><%= t("section.name") %></th>
4
- <th><%= t("section.description") %></th>
5
- <th><%= t("actions") %></th>
6
- </tr>
7
- <% sections.each do |section| %>
2
+ <tr>
3
+ <th><%= t("section.name") %></th>
4
+ <th><%= t("section.description") %></th>
5
+ <th><%= t("actions") %></th>
6
+ </tr>
7
+ <% sections.each do |section| %>
8
8
  <tr>
9
9
  <td><%= link_to section.name, section_path(section) %></td>
10
10
  <td><%= strip_tags section.description %></td>
@@ -12,6 +12,6 @@
12
12
  <%= render 'shared/edit_icon_button', resource: section, resource_name: @model.display_name %>
13
13
  </td>
14
14
  </tr>
15
- <% end %>
15
+ <% end %>
16
16
 
17
17
  </table>