adminpanel 2.1.2 → 2.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/adminpanel.gemspec +20 -18
- data/app/assets/javascripts/adminpanel/jquery.knob.js +652 -0
- data/app/assets/javascripts/adminpanel/realm.js +20 -18
- data/app/assets/javascripts/adminpanel/spinner.js.coffee +3 -3
- data/app/controllers/adminpanel/analytics_controller.rb +99 -53
- data/app/controllers/adminpanel/auths_controller.rb +1 -1
- data/app/controllers/adminpanel/sessions_controller.rb +26 -26
- data/app/controllers/concerns/adminpanel/facebook_actions.rb +2 -2
- data/app/helpers/adminpanel/adminpanel_form_builder.rb +257 -298
- data/app/helpers/adminpanel/analytics_helper.rb +46 -0
- data/app/helpers/adminpanel/application_helper.rb +57 -57
- data/app/helpers/adminpanel/breadcrumbs_helper.rb +13 -13
- data/app/helpers/adminpanel/sessions_helper.rb +20 -20
- data/app/helpers/adminpanel/shared_pages_helper.rb +41 -41
- data/app/models/adminpanel/gallery.rb +65 -63
- data/app/models/adminpanel/image.rb +5 -5
- data/app/models/adminpanel/section.rb +61 -53
- data/app/models/adminpanel/user.rb +1 -6
- data/app/models/concerns/adminpanel/facebook.rb +1 -1
- data/app/uploaders/adminpanel/gallery_uploader.rb +1 -1
- data/app/views/adminpanel/analytics/_widget_task_statistics.html.erb +63 -0
- data/app/views/adminpanel/analytics/fb.html.erb +98 -0
- data/app/views/adminpanel/analytics/index.html.erb +8 -8
- data/app/views/adminpanel/galleries/_galleries_table.html.erb +12 -12
- data/app/views/adminpanel/galleries/move_better.js.erb +1 -1
- data/app/views/adminpanel/galleries/move_worst.js.erb +1 -1
- data/app/views/adminpanel/sections/_sections_table.html.erb +7 -7
- data/app/views/adminpanel/sections/show.html.erb +25 -25
- data/app/views/adminpanel/sessions/new.html.erb +22 -22
- data/app/views/layouts/_shim.html.erb +1 -1
- data/app/views/layouts/_side_menu.html.erb +35 -35
- data/app/views/layouts/admin-login.html.erb +22 -22
- data/app/views/layouts/admin.html.erb +35 -35
- data/app/views/shared/_breadcrumb.html.erb +4 -4
- data/app/views/shared/_error_messages.html.erb +15 -15
- data/app/views/shared/_form_fields.html.erb +48 -47
- data/app/views/shared/_image_fields.html.erb +1 -1
- data/config/initializers/pluralization_es.rb +1 -1
- data/config/locales/es.yml +38 -2
- data/config/routes.rb +5 -4
- data/lib/adminpanel/version.rb +1 -1
- data/lib/generators/adminpanel/gallery/templates/gallery_migration.rb +5 -5
- data/lib/generators/adminpanel/gallery/templates/uploader.rb +1 -1
- data/lib/generators/adminpanel/initialize/initialize_generator.rb +54 -54
- data/lib/generators/adminpanel/initialize/templates/category_template.rb +1 -1
- data/lib/generators/adminpanel/initialize/templates/create_adminpanel_categories_table.rb +5 -5
- data/lib/generators/adminpanel/initialize/templates/create_adminpanel_tables.rb +57 -57
- data/lib/generators/adminpanel/initialize/templates/section_uploader.rb +1 -1
- data/lib/generators/adminpanel/migration/migration_generator.rb +44 -0
- data/lib/generators/adminpanel/migration/migration_generator_helper.rb +19 -0
- data/lib/generators/adminpanel/resource/resource_generator.rb +60 -245
- data/lib/generators/adminpanel/resource/resource_generator_helper.rb +189 -0
- data/lib/generators/adminpanel/resource/templates/{controller.rb → adminpanel_controller_template.rb} +2 -2
- data/lib/generators/adminpanel/resource/templates/{resource.rb → adminpanel_resource_template.rb} +0 -0
- data/test/dummy/app/models/adminpanel/categorization.rb +2 -2
- data/test/dummy/app/models/adminpanel/category.rb +3 -3
- data/test/dummy/app/models/adminpanel/department.rb +2 -2
- data/test/dummy/app/models/adminpanel/item.rb +3 -3
- data/test/dummy/app/models/adminpanel/mug.rb +14 -14
- data/test/dummy/app/models/adminpanel/product.rb +19 -19
- data/test/dummy/app/models/adminpanel/salesman.rb +15 -15
- data/test/dummy/app/uploader/adminpanel/photo_uploader.rb +1 -1
- data/test/dummy/app/views/layouts/application.html.erb +9 -9
- data/test/dummy/config/boot.rb +1 -1
- data/test/features/shared/{belongs_to_category_modal_test.rb → form/belongs_to_category_modal_test.rb} +0 -0
- data/test/features/shared/{belongs_to_non_category_modal_test.rb → form/belongs_to_non_category_modal_test.rb} +0 -0
- data/test/features/shared/{has_many_through_category_modal_test.rb → form/has_many_through_category_modal_test.rb} +0 -0
- data/test/features/shared/{has_many_through_non_category_modal_test.rb → form/has_many_through_non_category_modal_test.rb} +0 -0
- data/test/features/shared/{edit_test.rb → resource/edit_test.rb} +0 -0
- data/test/features/shared/{index_test.rb → resource/index_test.rb} +0 -0
- data/test/features/shared/{new_test.rb → resource/new_test.rb} +0 -0
- data/test/features/shared/{show_test.rb → resource/show_test.rb} +0 -0
- data/test/features/shared/{action_exclution_test.rb → ui/action_exclution_test.rb} +0 -0
- data/test/test_helper.rb +1 -1
- metadata +44 -32
- data/test/dummy/app/controllers/adminpanel/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
module Adminpanel
|
2
|
+
module AnalyticsHelper
|
3
|
+
def first_fb_value(metric)
|
4
|
+
total = 0.0
|
5
|
+
# metric.first['values'].each do |value|
|
6
|
+
# if value['value'] != []
|
7
|
+
# total = total + value['value'].to_f
|
8
|
+
# end
|
9
|
+
# end
|
10
|
+
# return total
|
11
|
+
metric.first['values'].first['value'].to_f
|
12
|
+
end
|
13
|
+
|
14
|
+
def days_to_substract
|
15
|
+
if params[:insight] == 'day'
|
16
|
+
1
|
17
|
+
elsif params[:insight] == 'week'
|
18
|
+
7
|
19
|
+
elsif params[:insight] == 'days_28'
|
20
|
+
28
|
21
|
+
else
|
22
|
+
0
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def divide_metrics(metric_1, metric_2)
|
27
|
+
debugger
|
28
|
+
if first_fb_value(metric_2) != 0.0
|
29
|
+
return first_fb_value(metric_1) / first_fb_value(metric_2)
|
30
|
+
else
|
31
|
+
return 0
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def insight
|
36
|
+
return 'day' if !params[:insight].present?
|
37
|
+
return 'day' if params[:insight] == 'day'
|
38
|
+
return 'week' if params[:insight] == 'week'
|
39
|
+
return 'month' if params[:insight] == 'days_28'
|
40
|
+
end
|
41
|
+
|
42
|
+
def metric(metric)
|
43
|
+
metric.first['name']
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -1,59 +1,59 @@
|
|
1
1
|
module Adminpanel
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
2
|
+
module ApplicationHelper
|
3
|
+
include SessionsHelper
|
4
|
+
include BreadcrumbsHelper
|
5
|
+
include SharedPagesHelper
|
6
|
+
|
7
|
+
def adminpanel_form_for(name, *args, &block)
|
8
|
+
options = args.extract_options!
|
9
|
+
options.reverse_merge! :builder => Adminpanel::AdminpanelFormBuilder, :html => { :class => "form-horizontal" }
|
10
|
+
|
11
|
+
form_for(name, *(args << options), &block)
|
12
|
+
end
|
13
|
+
|
14
|
+
def full_title(page_title)
|
15
|
+
base_title = t("Panel title")
|
16
|
+
if page_title.empty?
|
17
|
+
base_title
|
18
|
+
else
|
19
|
+
"#{page_title} | #{base_title}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def is_current_section?(display_name)
|
24
|
+
display_name == params[:controller].classify.constantize.display_name ? 'active' : nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def section_is_login(section_name)
|
28
|
+
section_name.downcase == 'login'
|
29
|
+
end
|
30
|
+
|
31
|
+
def link_to_add_fields(name, f, association)
|
32
|
+
new_object = f.object.send(association).klass.new
|
33
|
+
id = new_object.object_id
|
34
|
+
fields = f.fields_for(association, new_object, :child_index => id) do |builder|
|
35
|
+
render("shared/image_fields", :f => builder)
|
36
|
+
end
|
37
|
+
link_to(content_tag(:div, content_tag(:button,
|
38
|
+
content_tag(:h6, name, :id => "add-image-button"),
|
39
|
+
:class => "btn btn-success btn-mini"), :class => "mws-form-row"),
|
40
|
+
'#', :class => "add_fields", :data => {:id => id, :fields => fields.gsub("\n", "")})
|
41
|
+
end
|
42
|
+
|
43
|
+
def route_symbol(model_name)
|
44
|
+
model_name.pluralize.downcase
|
45
|
+
end
|
46
|
+
|
47
|
+
def symbol_class(symbol)
|
48
|
+
"adminpanel/#{symbol.to_s}".classify.constantize
|
49
|
+
end
|
50
|
+
|
51
|
+
def main_root_path
|
52
|
+
if main_app.respond_to?(root_path)
|
53
|
+
main_app.root_path
|
54
|
+
else
|
55
|
+
"/"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
59
|
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
module Adminpanel
|
2
|
-
|
3
|
-
|
4
|
-
def initialize_breadcrumb
|
5
|
-
@breadcrumb ||= [:title => 'Inicio', :url => root_url]
|
6
|
-
end
|
2
|
+
module BreadcrumbsHelper
|
7
3
|
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
def initialize_breadcrumb
|
5
|
+
@breadcrumb ||= [:title => 'Inicio', :url => root_url]
|
6
|
+
end
|
11
7
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
8
|
+
def breadcrumb_add(title, url)
|
9
|
+
initialize_breadcrumb << { :title => title, :url => url }
|
10
|
+
end
|
11
|
+
|
12
|
+
def render_breadcrumb(divider)
|
13
|
+
render :partial => 'shared/breadcrumb', :locals => { :nav => initialize_breadcrumb, :divider => divider }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,26 +1,26 @@
|
|
1
1
|
module Adminpanel
|
2
|
-
|
2
|
+
module SessionsHelper
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
def sign_in(user)
|
5
|
+
cookies.permanent[:remember_token] = user.remember_token
|
6
|
+
self.current_user = user
|
7
|
+
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
def signed_in?
|
10
|
+
!current_user.nil?
|
11
|
+
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
def current_user=(user)
|
14
|
+
@current_user = user
|
15
|
+
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
def current_user
|
18
|
+
@current_user ||= User.find_by_remember_token(cookies[:remember_token])
|
19
|
+
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
21
|
+
def sign_out
|
22
|
+
self.current_user = nil
|
23
|
+
cookies.delete(:remember_token)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,53 +1,53 @@
|
|
1
1
|
module Adminpanel
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
module SharedPagesHelper
|
3
|
+
def parent_object_name(resource, parent_model)
|
4
|
+
@model.reflect_on_all_associations.each do |association|
|
5
5
|
if association.klass.to_s == parent_model
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
if !resource.send(association.name).nil?
|
7
|
+
return resource.send(association.name).name
|
8
|
+
else
|
9
|
+
return "N/A #{association.klass.to_s}"
|
10
|
+
end
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
13
|
+
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
def pluralize_model(class_name)
|
16
|
+
"#{demodulize_class(class_name).pluralize}"
|
17
|
+
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
def relationship_ids(class_string)
|
20
|
+
"#{demodulize_class(class_string)}_ids"
|
21
|
+
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
def class_name_downcase(object)
|
24
|
+
demodulize_class(object.class)
|
25
|
+
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
def demodulize_class(class_name)
|
28
|
+
class_name.to_s.demodulize.downcase
|
29
|
+
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
def active_tab(index)
|
32
|
+
if index == 0
|
33
|
+
return "active"
|
34
|
+
else
|
35
|
+
return ""
|
36
|
+
end
|
37
|
+
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
39
|
+
def get_oauth_link(resource)
|
40
|
+
Koala::Facebook::OAuth.new(
|
41
|
+
Adminpanel.fb_app_id,
|
42
|
+
Adminpanel.fb_app_secret,
|
43
|
+
url_for({
|
44
|
+
controller: params[:controller],
|
45
|
+
action: 'fb_choose_page',
|
46
|
+
id: resource,
|
47
|
+
host: request.host
|
48
|
+
})
|
49
|
+
).url_for_oauth_code
|
50
|
+
end
|
51
51
|
|
52
|
-
|
52
|
+
end
|
53
53
|
end
|
@@ -1,80 +1,82 @@
|
|
1
1
|
require "carrierwave"
|
2
2
|
require "carrierwave/orm/activerecord"
|
3
3
|
module Adminpanel
|
4
|
-
|
5
|
-
|
4
|
+
class Gallery < ActiveRecord::Base
|
5
|
+
include Adminpanel::Base
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
mount_uploader :file, Adminpanel::GalleryUploader
|
8
|
+
validates_presence_of :file
|
9
9
|
|
10
|
-
|
10
|
+
include Adminpanel::Galleryzation
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
12
|
+
def move_to_better_position
|
13
|
+
if self.position > 1
|
14
|
+
conflicting_gallery = Gallery.find_by_position(position - 1)
|
15
|
+
self.update_attribute(:position, self.position - 1)
|
16
|
+
conflicting_gallery.update_attribute(
|
17
|
+
:position, conflicting_gallery.position + 1
|
18
|
+
)
|
19
|
+
true
|
20
|
+
else
|
21
|
+
false
|
22
|
+
end
|
23
|
+
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
25
|
+
def move_to_worst_position
|
26
|
+
records = self.class.count
|
27
|
+
if self.position < records
|
28
|
+
conflicting_gallery = Gallery.find_by_position(position + 1)
|
29
|
+
update_attribute(:position, self.position + 1)
|
30
|
+
conflicting_gallery.update_attribute(
|
31
|
+
:position, conflicting_gallery.position - 1
|
32
|
+
)
|
33
|
+
true
|
34
|
+
else
|
35
|
+
false
|
36
|
+
end
|
37
|
+
end
|
38
38
|
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
40
|
+
def self.form_attributes
|
41
|
+
[
|
42
|
+
{
|
43
|
+
'file' => {
|
44
|
+
'type' => 'file_field',
|
45
|
+
'label' => I18n.t('model.attributes.file'),
|
46
|
+
}
|
47
|
+
}
|
48
|
+
]
|
49
|
+
end
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
-
|
51
|
+
def self.display_name
|
52
|
+
I18n.t('model.Gallery')
|
53
|
+
end
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
55
|
+
def self.icon
|
56
|
+
'picture-o'
|
57
|
+
end
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
-
|
59
|
+
def name
|
60
|
+
File.basename(file.path)
|
61
|
+
end
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
63
|
+
private
|
64
|
+
def rearrange_positions
|
65
|
+
unarranged_galleries = Gallery.where("position > ?", self.position)
|
66
|
+
unarranged_galleries.each do |gallery|
|
67
|
+
gallery.update_attribute(:position, gallery.position - 1)
|
68
|
+
end
|
67
69
|
|
68
|
-
|
70
|
+
end
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
72
|
+
def set_position
|
73
|
+
last_record = Gallery.last
|
74
|
+
if last_record.nil?
|
75
|
+
self.position = 1
|
76
|
+
else
|
77
|
+
self.position = last_record.position + 1
|
78
|
+
end
|
79
|
+
end
|
78
80
|
|
79
|
-
|
81
|
+
end
|
80
82
|
end
|