adminpanel 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. data/.rspec +2 -2
  2. data/.ruby-version +1 -0
  3. data/.travis.yml +8 -8
  4. data/Gemfile +26 -24
  5. data/README.md +57 -57
  6. data/adminpanel.gemspec +41 -39
  7. data/app/assets/fonts/fontawesome-webfont.svg +254 -254
  8. data/app/assets/javascripts/adminpanel/bootstrap-datepicker.js +1159 -1159
  9. data/app/assets/javascripts/adminpanel/bootstrap-timepicker.js +803 -803
  10. data/app/assets/javascripts/adminpanel/bootstrap.js +2170 -2170
  11. data/app/assets/javascripts/adminpanel/{products.js → images_form.js} +13 -13
  12. data/app/assets/javascripts/adminpanel/imagesloaded.js +12 -12
  13. data/app/assets/javascripts/adminpanel/jquery.dataTables.min.js +155 -155
  14. data/app/assets/javascripts/adminpanel/jquery.facybox.js +395 -395
  15. data/app/assets/javascripts/adminpanel/jquery.masonry.min.js +9 -9
  16. data/app/assets/javascripts/adminpanel/jquery.slimscroll.min.js +13 -13
  17. data/app/assets/javascripts/adminpanel/medium-editor.js +702 -702
  18. data/app/assets/javascripts/adminpanel/realm.js +87 -87
  19. data/app/assets/javascripts/adminpanel/tables.js +126 -126
  20. data/app/assets/javascripts/application-admin.js +15 -15
  21. data/app/assets/stylesheets/adminpanel/_clearfix.css.scss +7 -7
  22. data/app/assets/stylesheets/adminpanel/alertify.css +241 -241
  23. data/app/assets/stylesheets/adminpanel/bootstrap.css +6103 -6103
  24. data/app/assets/stylesheets/adminpanel/colorpicker.css +6 -6
  25. data/app/assets/stylesheets/adminpanel/datepicker.css +9 -9
  26. data/app/assets/stylesheets/adminpanel/elfinder.min.css +59 -59
  27. data/app/assets/stylesheets/adminpanel/facybox.css +146 -146
  28. data/app/assets/stylesheets/adminpanel/font-awesome.min.css +33 -33
  29. data/app/assets/stylesheets/adminpanel/fullcalendar.css +618 -618
  30. data/app/assets/stylesheets/adminpanel/fullcalendar.print.css +61 -61
  31. data/app/assets/stylesheets/adminpanel/select2.css +524 -524
  32. data/app/assets/stylesheets/adminpanel/theme.css +1571 -1571
  33. data/app/assets/stylesheets/adminpanel/timepicker.css +82 -82
  34. data/app/assets/stylesheets/application-admin.css +13 -13
  35. data/app/controllers/adminpanel/application_controller.rb +32 -17
  36. data/app/controllers/adminpanel/galleries_controller.rb +80 -80
  37. data/app/controllers/adminpanel/sections_controller.rb +45 -45
  38. data/app/controllers/adminpanel/sessions_controller.rb +26 -26
  39. data/app/controllers/adminpanel/users_controller.rb +84 -84
  40. data/app/helpers/adminpanel/application_helper.rb +41 -51
  41. data/app/helpers/adminpanel/breadcrumbs_helper.rb +16 -0
  42. data/app/helpers/adminpanel/custom_form_builder.rb +248 -0
  43. data/app/helpers/adminpanel/images_helper.rb +9 -9
  44. data/app/helpers/adminpanel/rest_actions_helper.rb +47 -0
  45. data/app/helpers/adminpanel/router_helper.rb +33 -0
  46. data/app/helpers/adminpanel/sessions_helper.rb +25 -25
  47. data/app/models/adminpanel/gallery.rb +60 -60
  48. data/app/models/adminpanel/image.rb +14 -14
  49. data/app/models/adminpanel/section.rb +22 -22
  50. data/app/models/adminpanel/user.rb +35 -35
  51. data/app/uploaders/adminpanel/gallery_uploader.rb +55 -55
  52. data/app/uploaders/adminpanel/image_uploader.rb +57 -57
  53. data/app/views/adminpanel/galleries/_galleries_table.html.erb +14 -14
  54. data/app/views/adminpanel/galleries/create.html.erb +2 -2
  55. data/app/views/adminpanel/galleries/delete.html.erb +2 -2
  56. data/app/views/adminpanel/galleries/edit.html.erb +25 -25
  57. data/app/views/adminpanel/galleries/index.html.erb +51 -51
  58. data/app/views/adminpanel/galleries/new.html.erb +17 -17
  59. data/app/views/adminpanel/galleries/show.html.erb +17 -17
  60. data/app/views/adminpanel/galleries/update.html.erb +2 -2
  61. data/app/views/adminpanel/sections/_image_fields.html.erb +23 -23
  62. data/app/views/adminpanel/sections/_sections_table.html.erb +16 -16
  63. data/app/views/adminpanel/sections/create.html.erb +2 -2
  64. data/app/views/adminpanel/sections/destroy.html.erb +2 -2
  65. data/app/views/adminpanel/sections/edit.html.erb +41 -41
  66. data/app/views/adminpanel/sections/index.html.erb +44 -44
  67. data/app/views/adminpanel/sections/new.html.erb +26 -26
  68. data/app/views/adminpanel/sections/show.html.erb +30 -30
  69. data/app/views/adminpanel/sections/update.html.erb +2 -2
  70. data/app/views/adminpanel/sessions/new.html.erb +25 -25
  71. data/app/views/adminpanel/users/_user_form.html.erb +20 -20
  72. data/app/views/adminpanel/users/edit.html.erb +5 -5
  73. data/app/views/adminpanel/users/index.html.erb +49 -49
  74. data/app/views/adminpanel/users/new.html.erb +5 -5
  75. data/app/views/adminpanel/users/show.html.erb +20 -20
  76. data/app/views/layouts/_shim.html.erb +3 -3
  77. data/app/views/layouts/_side_menu.html.erb +49 -43
  78. data/app/views/layouts/_top_bar.html.erb +43 -43
  79. data/app/views/layouts/admin-login.html.erb +28 -28
  80. data/app/views/layouts/admin.html.erb +41 -39
  81. data/app/views/shared/_breadcrumb.html.erb +6 -6
  82. data/app/views/shared/_error_messages.html.erb +16 -16
  83. data/app/views/shared/_form_fields.html.erb +25 -0
  84. data/app/views/{adminpanel/products → shared}/_image_fields.html.erb +23 -23
  85. data/app/views/shared/_init_editor.html.erb +24 -0
  86. data/app/views/shared/edit.html.erb +28 -0
  87. data/app/views/shared/index.html.erb +94 -0
  88. data/app/views/shared/new.html.erb +28 -0
  89. data/app/views/shared/show.html.erb +63 -0
  90. data/config/locales/en.yml +5 -5
  91. data/config/locales/es.yml +127 -129
  92. data/config/routes.rb +24 -16
  93. data/lib/adminpanel.rb +9 -7
  94. data/lib/adminpanel/active_record_extension.rb +38 -0
  95. data/lib/adminpanel/engine.rb +5 -5
  96. data/lib/adminpanel/version.rb +3 -3
  97. data/lib/generators/adminpanel/initialize/initialize_generator.rb +17 -0
  98. data/lib/generators/adminpanel/{install/templates/migrations → initialize/templates}/create_adminpanel_tables.rb +45 -64
  99. data/lib/generators/adminpanel/resource/resource_generator.rb +105 -0
  100. data/lib/generators/adminpanel/resource/templates/controller.rb +4 -0
  101. data/lib/generators/adminpanel/resource/templates/migration.rb +9 -0
  102. data/lib/generators/adminpanel/resource/templates/resource.rb +19 -0
  103. data/spec/dummy/.gitignore +17 -17
  104. data/spec/dummy/README.rdoc +261 -261
  105. data/spec/dummy/Rakefile +7 -7
  106. data/{app/views/adminpanel/categories/show.html.erb → spec/dummy/app/adminpanel/products.rb} +0 -0
  107. data/spec/dummy/app/assets/javascripts/application.js +13 -13
  108. data/spec/dummy/app/assets/stylesheets/application.css +13 -13
  109. data/spec/dummy/app/controllers/adminpanel/.gitkeep +0 -0
  110. data/spec/dummy/app/controllers/application_controller.rb +3 -11
  111. data/spec/dummy/app/helpers/application_helper.rb +2 -2
  112. data/spec/dummy/app/views/layouts/application.html.erb +14 -14
  113. data/spec/dummy/config.ru +4 -4
  114. data/spec/dummy/config/application.rb +62 -62
  115. data/spec/dummy/config/boot.rb +9 -9
  116. data/spec/dummy/config/carrierwve.rb +5 -5
  117. data/spec/dummy/config/database.yml +24 -24
  118. data/spec/dummy/config/environment.rb +5 -5
  119. data/spec/dummy/config/environments/development.rb +41 -41
  120. data/spec/dummy/config/environments/production.rb +72 -72
  121. data/spec/dummy/config/environments/test.rb +41 -41
  122. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
  123. data/spec/dummy/config/initializers/inflections.rb +15 -15
  124. data/spec/dummy/config/initializers/mime_types.rb +5 -5
  125. data/spec/dummy/config/initializers/secret_token.rb +8 -8
  126. data/spec/dummy/config/initializers/session_store.rb +8 -8
  127. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
  128. data/spec/dummy/config/locales/en.yml +5 -5
  129. data/spec/dummy/config/routes.rb +4 -4
  130. data/spec/dummy/db/schema.rb +15 -15
  131. data/spec/dummy/public/404.html +26 -26
  132. data/spec/dummy/public/422.html +26 -26
  133. data/spec/dummy/public/500.html +25 -25
  134. data/spec/dummy/public/uploads/gallery/file/1/hipster.jpg +0 -0
  135. data/spec/dummy/public/uploads/gallery/file/1/thumb_hipster.jpg +0 -0
  136. data/spec/dummy/script/rails +6 -6
  137. data/spec/features/authentication_pages_spec.rb +43 -43
  138. data/spec/features/galleries_pages_spec.rb +124 -124
  139. data/spec/features/section_pages_spec.rb +37 -37
  140. data/spec/features/user_pages_spec.rb +48 -48
  141. data/spec/generators/initialize_spec.rb +9 -0
  142. data/spec/generators/resource_spec.rb +122 -0
  143. data/spec/models/gallery_spec.rb +21 -21
  144. data/spec/models/section_spec.rb +66 -66
  145. data/spec/models/user_spec.rb +105 -105
  146. data/spec/spec_helper.rb +32 -31
  147. data/spec/support/define_factory_models.rb +25 -36
  148. data/spec/support/helper_methods.rb +26 -26
  149. data/spec/support/submit_forms_without_button.rb +16 -16
  150. data/spec/support/test_database.rb +45 -58
  151. data/spec/uploaders/gallery_uploader_spec.rb +36 -30
  152. data/spec/uploaders/image_uploader_spec.rb +30 -29
  153. metadata +208 -64
  154. checksums.yaml +0 -7
  155. data/app/assets/javascripts/adminpanel/init_editor.js +0 -28
  156. data/app/controllers/adminpanel/categories_controller.rb +0 -41
  157. data/app/controllers/adminpanel/products_controller.rb +0 -88
  158. data/app/helpers/custom_form_builder.rb +0 -219
  159. data/app/models/adminpanel/category.rb +0 -7
  160. data/app/models/adminpanel/product.rb +0 -24
  161. data/app/views/adminpanel/categories/edit.html.erb +0 -18
  162. data/app/views/adminpanel/categories/index.html.erb +0 -55
  163. data/app/views/adminpanel/categories/new.html.erb +0 -18
  164. data/app/views/adminpanel/products/.DS_Store +0 -0
  165. data/app/views/adminpanel/products/_product_form.html.erb +0 -31
  166. data/app/views/adminpanel/products/edit.html.erb +0 -10
  167. data/app/views/adminpanel/products/index.html.erb +0 -51
  168. data/app/views/adminpanel/products/new.html.erb +0 -10
  169. data/app/views/adminpanel/products/show.html.erb +0 -61
  170. data/config/database.yml +0 -24
  171. data/lib/generators/adminpanel/install/install_generator.rb +0 -12
  172. data/spec/features/categories_pages_spec.rb +0 -44
  173. data/spec/features/product_pages_spec.rb +0 -64
  174. data/spec/models/category_spec.rb +0 -58
  175. data/spec/models/product_spec.rb +0 -51
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 435b2e9a0b1762665f46f09b0139867b12b4309e
4
- data.tar.gz: 2ada99e5776704ba5872ffa3345673fb7d2b6626
5
- SHA512:
6
- metadata.gz: c956d64b07c304bdf6f650bc78b0ad4c455f59d4195219985c6ae8c344fa059c2e46cd8c2949cf8eaa5955e7ceba8a11d910f311be29bcb41a911aed775c0475
7
- data.tar.gz: cdfe59993943b62d09aed0dca24177d10cce055041b8a47e0b640b495eaf2c107f9c256dd538f820f34833c21baf32c5cb7005b03d42403e73a20ab67c2e65a1
@@ -1,28 +0,0 @@
1
- $(document).ready(function(){
2
- if($(".editable")){
3
-
4
- var editor = new MediumEditor('.editable',{
5
- buttons: [
6
- 'bold',
7
- 'italic',
8
- 'underline',
9
- 'anchor',
10
- 'header1',
11
- 'header2',
12
- 'quote',
13
- 'unorderedlist'
14
- ]
15
- });
16
-
17
- $("#save-button").on("click", function(e){
18
- if(editor.serialize()["element-0"].value.length <= 10){
19
- e.preventDefault();
20
- return false;
21
- } else {
22
- $("#description-field").val(editor.serialize()["element-0"].value);
23
- // e.preventDefault();
24
- // return false;
25
- }
26
- });
27
- }
28
- })
@@ -1,41 +0,0 @@
1
- module Adminpanel
2
- class CategoriesController < Adminpanel::ApplicationController
3
- def index
4
- @categories = Category.all
5
- end
6
-
7
- def new
8
- @category = Category.new
9
- end
10
-
11
- def create
12
- @category = Category.new(params[:category])
13
- if @category.save
14
- redirect_to categories_path, :notice => t("category.success")
15
- else
16
- render "new"
17
- end
18
- end
19
-
20
- def edit
21
- @category = Category.find(params[:id])
22
- end
23
-
24
- def update
25
- @category = Category.find(params[:id])
26
-
27
- if @category.update_attributes(params[:category])
28
- redirect_to categories_path, :notice => "#{@category.name} ha sido actualizado con exito"
29
- else
30
- render "edit"
31
- end
32
- end
33
-
34
- def destroy
35
- @category = Category.find(params[:id])
36
- @category.destroy
37
-
38
- redirect_to categories_path
39
- end
40
- end
41
- end
@@ -1,88 +0,0 @@
1
- module Adminpanel
2
- class ProductsController < Adminpanel::ApplicationController
3
- # GET /admin/products
4
- # GET /admin/products.json
5
- def index
6
- @products = Product.all
7
-
8
- respond_to do |format|
9
- format.html # index.html.erb
10
- format.json { render :json => @products }
11
- end
12
- end
13
-
14
- # GET /admin/products/1
15
- # GET /admin/products/1.json
16
- def show
17
- @product = Product.find(params[:id])
18
-
19
- respond_to do |format|
20
- format.html # show.html.erb
21
- format.json { render :json => @product }
22
- end
23
- end
24
-
25
- # GET /admin/products/new
26
- # GET /admin/products/new.json
27
- def new
28
- @product = Product.new
29
- @categories = Category.all.collect{|c| [ c.name, c.id ] }
30
-
31
- respond_to do |format|
32
- format.html # new.html.erb
33
- format.json { render :json => @product }
34
- end
35
- end
36
-
37
- # GET /admin/products/1/edit
38
- def edit
39
- @product = Product.find(params[:id])
40
- @categories = Category.all.collect{|c| [ c.name, c.id ] }
41
- end
42
-
43
- # POST /admin/products
44
- # POST /admin/products.json
45
- def create
46
- @product = Product.new(params[:product])
47
-
48
- respond_to do |format|
49
- if @product.save
50
- format.html { redirect_to product_path(@product), :notice => t("product.success") }
51
- format.json { render :json => product_path(@product), :status => :created, :location => @product }
52
- else
53
- @categories = Category.all.collect{|c| [ c.name, c.id ] }
54
- format.html { render :action => "new" }
55
- format.json { render :json => @product.errors, :status => :unprocessable_entity }
56
- end
57
- end
58
- end
59
-
60
- # PUT /admin/products/1
61
- # PUT /admin/products/1.json
62
- def update
63
- @product = Product.find(params[:id])
64
-
65
- respond_to do |format|
66
- if @product.update_attributes(params[:product])
67
- format.html { redirect_to product_path(@product), :notice => 'Product was successfully updated.' }
68
- format.json { head :no_content }
69
- else
70
- format.html { render :action => "edit" }
71
- format.json { render :json => @product.errors, :status => :unprocessable_entity }
72
- end
73
- end
74
- end
75
-
76
- # DELETE /admin/products/1
77
- # DELETE /admin/products/1.json
78
- def destroy
79
- @product = Product.find(params[:id])
80
- @product.destroy
81
-
82
- respond_to do |format|
83
- format.html { redirect_to products_url }
84
- format.json { head :no_content }
85
- end
86
- end
87
- end
88
- end
@@ -1,219 +0,0 @@
1
- class CustomFormBuilder < ActionView::Helpers::FormBuilder
2
-
3
- alias_method :text_field_original, :text_field
4
- alias_method :radio_button_original, :radio_button
5
- alias_method :checkbox_original, :check_box
6
-
7
- def text_field(name, *args)
8
- options = args.extract_options!
9
-
10
- options.reverse_merge! :class => "span7"
11
- options.reverse_merge! :label => name
12
- label = options[:label]
13
- options.delete(:label)
14
-
15
- @template.content_tag :div, :class => "control-group" do
16
- @template.content_tag(:label, label, :class => "control-label") +
17
- @template.content_tag(:div, super(name, *args << options), :class => "controls")
18
- end
19
- end
20
-
21
- def custom_file_field(name, *args)
22
- options = args.extract_options!
23
-
24
- options.reverse_merge! :class => "span7"
25
- options.reverse_merge! :label => name
26
- label = options[:label]
27
- options.delete(:label)
28
-
29
- @template.content_tag :div, :class => "control-group" do
30
- @template.content_tag(:label, label, :class => "control-label") +
31
- @template.content_tag(:div, file_field(name, *args << options), :class => "controls")
32
- end
33
- end
34
-
35
- def radio_button_group(name, buttons, options)
36
-
37
- options.reverse_merge! :label => name
38
- options.reverse_merge! :html => {}
39
- output = ""
40
-
41
- buttons.each do |b|
42
- output += @template.content_tag(:label, radio_button_original(name, b, options[:html]) + b.capitalize, :class => "radio")
43
- end
44
-
45
- @template.content_tag :div, :class => "control-group" do
46
- @template.content_tag(:label, options[:label], :class => "control-label") +
47
- @template.content_tag(:div, output, { :class => "controls"}, false)
48
- end
49
- end
50
-
51
- def check_box(name, *args)
52
- options = args.extract_options!
53
-
54
- options.reverse_merge! :class => "span7"
55
- options.reverse_merge! :label => name
56
- options.reverse_merge! :include_blank => "(Seleccione por favor)";
57
- label = options[:label]
58
- options.delete(:label)
59
-
60
- @template.content_tag(:label, super(name, *args) + label, :class => "checkbox")
61
- end
62
-
63
- def select(name, select_options, *args)
64
- options = args.extract_options!
65
-
66
- options.reverse_merge! :class => "span7"
67
- options.reverse_merge! :label => name
68
- options.reverse_merge! :include_blank => "(Seleccione por favor)";
69
- label = options[:label]
70
- options.delete(:label)
71
-
72
- @template.content_tag :div, :class => "control-group" do
73
- @template.content_tag(:label, label, :class => "control-label") +
74
- @template.content_tag(:div, super(name, select_options, *args << options), :class => "controls")
75
- end
76
- end
77
-
78
- def number_field(name, *args)
79
- options = args.extract_options!
80
-
81
- options.reverse_merge! :class => "span5"
82
- options.reverse_merge! :label => name
83
- label = options[:label]
84
- options.delete(:label)
85
-
86
- @template.content_tag :div, :class => "control-group" do
87
- @template.content_tag(:label, label, :class => "control-label") +
88
- @template.content_tag(:div, super(name, *args << options), :class => "controls")
89
- end
90
- end
91
-
92
- def password_field(name, *args)
93
- options = args.extract_options!
94
-
95
- options.reverse_merge! :class => "span7"
96
- options.reverse_merge! :label => name
97
- label = options[:label]
98
- options.delete(:label)
99
-
100
- @template.content_tag :div, :class => "control-group" do
101
- @template.content_tag(:label, label, :class => "control-label") +
102
- @template.content_tag(:div, super(name, *args << options), :class => "controls")
103
- end
104
- end
105
-
106
- def text_area(name, *args)
107
- options = args.extract_options!
108
-
109
- options.reverse_merge! :class => "span7"
110
- options.reverse_merge! :rows => "10"
111
- options.reverse_merge! :label => name
112
- label = options[:label]
113
- options.delete(:label)
114
-
115
- @template.content_tag :div, :class => "control-group" do
116
- @template.content_tag(:label, label, :class => "control-label") +
117
- @template.content_tag(:div, super(name, *args << options), :class => "controls")
118
- end
119
- end
120
-
121
- def submit(name, *args)
122
- options = args.extract_options!
123
-
124
- options.reverse_merge! :class => "btn btn-primary"
125
- super(name, *args << options)
126
- end
127
-
128
- def date_picker(name, *args)
129
-
130
- options = args.extract_options!
131
-
132
- options.reverse_merge! :value => Time.now.strftime("%d-%m-%Y")
133
- options.reverse_merge! :label => name
134
- label = options[:label]
135
- options.delete(:label)
136
-
137
- @template.content_tag :div, :class => "control-group" do
138
- @template.content_tag(:label, label, :class => "control-label") +
139
- @template.content_tag(
140
- :div,
141
- @template.content_tag(
142
- :div,
143
- text_field_original(name, *args << options) +
144
- @template.content_tag(
145
- :span,
146
- @template.content_tag(
147
- :i,
148
- nil,
149
- :class => "icon-th"
150
- ),
151
- :class => "add-on"
152
- ),
153
- {
154
- :class => "input-append date span5 datepicker datepicker-basic",
155
- :data => {
156
- :date_format => "dd-mm-yyyy",
157
- :date => options[:value]
158
- }
159
- }
160
- ),
161
- :class => "controls"
162
- )
163
- end
164
- end
165
-
166
- def prepend_field(name, *args)
167
-
168
- options = args.extract_options!
169
-
170
- options.reverse_merge! :label => name
171
- label = options[:label]
172
- options.delete(:label)
173
-
174
- options.reverse_merge! :symbol => "#"
175
- symbol = options[:symbol]
176
- options.delete(:symbol)
177
-
178
- @template.content_tag :div, :class => "control-group" do
179
- @template.content_tag(:label, label, :class => "control-label") +
180
- @template.content_tag(
181
- :div,
182
- @template.content_tag(
183
- :div,
184
- @template.content_tag(:span, symbol, :class => "add-on") +
185
- text_field_original(name, *args << options),
186
- :class => "input-prepend"
187
- ),
188
- :class => "controls"
189
- )
190
- end
191
- end
192
-
193
- def append_field(name, *args)
194
-
195
- options = args.extract_options!
196
-
197
- options.reverse_merge! :label => name
198
- label = options[:label]
199
- options.delete(:label)
200
-
201
- options.reverse_merge! :symbol => "#"
202
- symbol = options[:symbol]
203
- options.delete(:symbol)
204
-
205
- @template.content_tag :div, :class => "control-group" do
206
- @template.content_tag(:label, label, :class => "control-label") +
207
- @template.content_tag(
208
- :div,
209
- @template.content_tag(
210
- :div,
211
- text_field_original(name, *args << options) +
212
- @template.content_tag(:span, symbol, :class => "add-on"),
213
- :class => "input-append"
214
- ),
215
- :class => "controls"
216
- )
217
- end
218
- end
219
- end
@@ -1,7 +0,0 @@
1
- module Adminpanel
2
- class Category < ActiveRecord::Base
3
- attr_accessible :name
4
-
5
- validates_presence_of :name
6
- end
7
- end
@@ -1,24 +0,0 @@
1
- require "carrierwave"
2
- require "carrierwave/orm/activerecord"
3
-
4
- module Adminpanel
5
- class Product < ActiveRecord::Base
6
- attr_accessible :description, :name, :images_attributes, :category_id, :brief
7
- has_many :images, :foreign_key => "foreign_key", :conditions => { :model => "Product" }
8
- belongs_to :category
9
- accepts_nested_attributes_for :images, :allow_destroy => true
10
-
11
- validates_presence_of :name
12
- validates_presence_of :description
13
- validates_presence_of :category_id
14
- validates_presence_of :brief
15
-
16
- def to_param
17
- "#{id} #{name}".parameterize
18
- end
19
-
20
- def simple_name
21
- "Product"
22
- end
23
- end
24
- end
@@ -1,18 +0,0 @@
1
- <% provide(:page_title, @category.name) %>
2
- <% breadcrumb_add('Categorias', products_path) %>
3
- <div class="row-fluid">
4
- <div class = "widget widget-padding span12">
5
- <div class = "widget-header"><i class = "icon-truck"></i><h5>Categoría</h5></div>
6
- <div class = "widget-body">
7
- <div class = "widget-forms clearfix">
8
- <%= custom_form_for(@category, :url => category_path(@category), :html => {:class => "form-horizontal"}) do |f| %>
9
- <%= render 'shared/error_messages', :object => @category %>
10
- <%= f.text_field :name, :label => "Nombre", :placeholder => "Nombre de la categoria" %>
11
- </div>
12
- </div>
13
- <div class = "widget-footer">
14
- <%= f.submit "Agregar", :disable_with => 'Submiting...' %>
15
- </div>
16
- <% end -%>
17
- </div>
18
- </div>
@@ -1,55 +0,0 @@
1
- <%= provide(:page_title, "Categorias") %>
2
- <% #if can? :create, Client %>
3
- <div class="row-fluid">
4
- <%=
5
- link_to(
6
- content_tag(:div,
7
- content_tag(:i, nil, :class => 'icon-plus-sign icon-2x') + content_tag(:span, t("category.new"), nil),
8
- :class => "btn btn-box span2"),
9
- new_category_path,
10
- :id => "new-category-button"
11
- )
12
- %>
13
- </div>
14
- <% #end %>
15
-
16
- <div class="row-fluid">
17
- <div class="widget widget-padding span12">
18
- <div class="widget-header">
19
- <i class="icon-truck"></i>
20
- <h5>Categorías</h5>
21
- </div>
22
- <div class="widget-body">
23
- <div class="dataTables_wrapper form-inline">
24
- <table id="information-table" class="table table-striped table-bordered dataTable">
25
- <thead>
26
- <tr>
27
- <th>Nombre</th>
28
- <th>Acción</th>
29
- </tr>
30
- </thead>
31
- <tbody>
32
- <% @categories.each do |category| %>
33
- <tr>
34
- <td><%= category.name %></td>
35
- <td>
36
- <%= link_to content_tag(:i, nil, :class => 'icon-pencil'), edit_category_path(category), :title => t("action.edit") %>
37
- <%= link_to content_tag(:i, nil, :class => 'icon-remove'), category_path(category),
38
- :title => t("action.delete"),
39
- :id => "category-delete",
40
- :method => :delete,
41
- :data => { :confirm => "Seguro?" }
42
- %>
43
- </td>
44
- </tr>
45
- <% end %>
46
- </tbody>
47
- </table>
48
- <div class="row-fluid">
49
- <div class="span6"></div>
50
- <div class="span6"></div>
51
- </div>
52
- </div>
53
- </div>
54
- </div>
55
- </div>