biovision-courses 0.0.180221

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +28 -0
  4. data/Rakefile +26 -0
  5. data/app/assets/config/biovision_courses_manifest.js +2 -0
  6. data/app/assets/javascripts/biovision/courses/application.js +13 -0
  7. data/app/assets/stylesheets/biovision/courses/application.css +15 -0
  8. data/app/controllers/admin/course_categories_controller.rb +28 -0
  9. data/app/controllers/admin/course_tags_controller.rb +28 -0
  10. data/app/controllers/admin/courses_controller.rb +29 -0
  11. data/app/controllers/biovision/courses/application_controller.rb +7 -0
  12. data/app/controllers/course_categories_controller.rb +70 -0
  13. data/app/controllers/course_tags_controller.rb +66 -0
  14. data/app/controllers/courses_controller.rb +94 -0
  15. data/app/helpers/biovision/courses/application_helper.rb +6 -0
  16. data/app/helpers/biovision_courses_helper.rb +80 -0
  17. data/app/jobs/biovision/courses/application_job.rb +6 -0
  18. data/app/mailers/biovision/courses/application_mailer.rb +8 -0
  19. data/app/models/application_record.rb +3 -0
  20. data/app/models/biovision/courses/application_record.rb +7 -0
  21. data/app/models/course.rb +109 -0
  22. data/app/models/course_category.rb +137 -0
  23. data/app/models/course_course_tag.rb +13 -0
  24. data/app/models/course_tag.rb +49 -0
  25. data/app/uploaders/course_image_uploader.rb +46 -0
  26. data/app/views/admin/course_categories/_nav_item.html.erb +2 -0
  27. data/app/views/admin/course_categories/entity/_in_list.html.erb +43 -0
  28. data/app/views/admin/course_categories/index.html.erb +17 -0
  29. data/app/views/admin/course_categories/show.html.erb +85 -0
  30. data/app/views/admin/course_tags/_nav_item.html.erb +2 -0
  31. data/app/views/admin/course_tags/entity/_in_list.html.erb +21 -0
  32. data/app/views/admin/course_tags/index.html.erb +19 -0
  33. data/app/views/admin/course_tags/show.html.erb +39 -0
  34. data/app/views/admin/courses/_nav_item.html.erb +2 -0
  35. data/app/views/admin/courses/entity/_in_list.html.erb +40 -0
  36. data/app/views/admin/courses/index.html.erb +17 -0
  37. data/app/views/admin/courses/show.html.erb +117 -0
  38. data/app/views/admin/index/dashboard/_biovision_courses.html.erb +12 -0
  39. data/app/views/course_categories/_form.html.erb +96 -0
  40. data/app/views/course_categories/edit.html.erb +22 -0
  41. data/app/views/course_categories/edit.js.erb +1 -0
  42. data/app/views/course_categories/new.html.erb +15 -0
  43. data/app/views/course_categories/new.js.erb +1 -0
  44. data/app/views/course_tags/_form.html.erb +72 -0
  45. data/app/views/course_tags/edit.html.erb +17 -0
  46. data/app/views/course_tags/edit.js.erb +1 -0
  47. data/app/views/course_tags/new.html.erb +15 -0
  48. data/app/views/course_tags/new.js.erb +1 -0
  49. data/app/views/courses/_form.html.erb +244 -0
  50. data/app/views/courses/edit.html.erb +17 -0
  51. data/app/views/courses/edit.js.erb +1 -0
  52. data/app/views/courses/form/_wysiwyg.html.erb +14 -0
  53. data/app/views/courses/new.html.erb +15 -0
  54. data/app/views/courses/new.js.erb +1 -0
  55. data/app/views/layouts/biovision/courses/application.html.erb +14 -0
  56. data/config/locales/courses-ru.yml +138 -0
  57. data/config/routes.rb +26 -0
  58. data/db/migrate/20180218120000_prepare_course_privileges.rb +19 -0
  59. data/db/migrate/20180218120005_create_course_categories.rb +28 -0
  60. data/db/migrate/20180218120010_create_course_tags.rb +20 -0
  61. data/db/migrate/20180218120015_create_courses.rb +42 -0
  62. data/db/migrate/20180218120020_create_course_course_tags.rb +17 -0
  63. data/lib/biovision/courses.rb +7 -0
  64. data/lib/biovision/courses/engine.rb +18 -0
  65. data/lib/biovision/courses/version.rb +5 -0
  66. data/lib/tasks/biovision/courses_tasks.rake +4 -0
  67. metadata +207 -0
@@ -0,0 +1,22 @@
1
+ <% content_for :meta_title, t('.title') %>
2
+ <% content_for :breadcrumbs do %>
3
+ <%= link_to(t('admin.course_categories.nav_item.text'), admin_course_categories_path) %>
4
+ <% @entity.parents.each do |parent| %>
5
+ <%= admin_course_category_link(parent) %>
6
+ <% end %>
7
+ <%= admin_course_category_link(@entity) %>
8
+ <span><%= t('.heading') %></span>
9
+ <% end %>
10
+
11
+ <article>
12
+ <h1><%= t('.heading') %></h1>
13
+
14
+ <ul class="actions">
15
+ <li><%= return_icon(admin_course_category_path(@entity.id)) %></li>
16
+ <% if @entity.can_be_deleted? %>
17
+ <li class="danger"><%= destroy_icon(@entity) %></li>
18
+ <% end %>
19
+ </ul>
20
+
21
+ <%= render partial: 'form', locals: { entity: @entity } %>
22
+ </article>
@@ -0,0 +1 @@
1
+ <%= render partial: 'shared/forms/list_of_errors', locals: { entity: @entity, form_id: 'course_category-form' } %>
@@ -0,0 +1,15 @@
1
+ <% content_for :meta_title, t('.title') %>
2
+ <% content_for :breadcrumbs do %>
3
+ <%= link_to(t('admin.course_categories.nav_item.text'), admin_course_categories_path) %>
4
+ <span><%= t('.heading') %></span>
5
+ <% end %>
6
+
7
+ <article>
8
+ <h1><%= t('.title') %></h1>
9
+
10
+ <ul class="actions">
11
+ <li><%= back_icon(admin_course_categories_path) %></li>
12
+ </ul>
13
+
14
+ <%= render partial: 'form', locals: { entity: @entity } %>
15
+ </article>
@@ -0,0 +1 @@
1
+ <%= render partial: 'shared/forms/list_of_errors', locals: { entity: @entity, form_id: 'course_category-form' } %>
@@ -0,0 +1,72 @@
1
+ <%= form_with model: entity, html: { id: 'course_tag-form' } do |f| %>
2
+ <%= render partial: 'shared/list_of_errors', locals: { entity: entity } %>
3
+
4
+ <dl>
5
+ <dt><%= f.label :image %></dt>
6
+ <dd>
7
+ <figure role="group" class="preview" id="course_tag-image">
8
+ <% if entity.image.blank? %>
9
+ <%= f.label :image, image_tag('biovision/base/placeholders/image.svg') %>
10
+ <% else %>
11
+ <%= f.label :image, image_tag(entity.image.big.url) %>
12
+ <% end %>
13
+ <figcaption>
14
+ <%=
15
+ f.file_field(
16
+ :image,
17
+ id: :course_tag_image,
18
+ accept: 'image/jpeg,image/png',
19
+ data: { image: 'course_tag-image' }
20
+ )
21
+ %>
22
+ </figcaption>
23
+ </figure>
24
+ <div class="guideline"><%= t('.guidelines.image') %></div>
25
+ </dd>
26
+
27
+ <dt><%= f.label :name %></dt>
28
+ <dd>
29
+ <%=
30
+ f.text_field(
31
+ :name,
32
+ id: :course_tag_name,
33
+ size: nil,
34
+ maxlength: CourseTag::NAME_LIMIT,
35
+ required: true,
36
+ data: { transliterate: 'course_tag_slug' }
37
+ )
38
+ %>
39
+ <div class="guideline"><%= t('.guidelines.name') %></div>
40
+ </dd>
41
+
42
+ <dt><%= f.label :slug %></dt>
43
+ <dd>
44
+ <%=
45
+ f.text_field(
46
+ :slug,
47
+ id: :course_tag_slug,
48
+ size: nil,
49
+ maxlength: CourseTag::SLUG_LIMIT,
50
+ pattern: CourseTag::SLUG_PATTERN_HTML,
51
+ title: t('.guidelines.slug'),
52
+ required: true
53
+ )
54
+ %>
55
+ <div class="guideline"><%= t('.guidelines.slug') %></div>
56
+ </dd>
57
+
58
+ <dt><%= t(:flags) %></dt>
59
+ <dd>
60
+ <ul class="flags">
61
+ <li>
62
+ <%= f.check_box :visible, id: :course_tag_visible %>
63
+ <%= f.label :visible %>
64
+ </li>
65
+ </ul>
66
+ </dd>
67
+ </dl>
68
+
69
+ <div class="buttons">
70
+ <%= f.button t(:save), type: :submit, class: 'button-save' %>
71
+ </div>
72
+ <% end %>
@@ -0,0 +1,17 @@
1
+ <% content_for :meta_title, t('.title') %>
2
+ <% content_for :breadcrumbs do %>
3
+ <%= link_to(t('admin.course_tags.nav_item.text'), admin_course_tags_path) %>
4
+ <%= admin_course_tag_link(@entity) %>
5
+ <span><%= t('.heading') %></span>
6
+ <% end %>
7
+
8
+ <article>
9
+ <h1><%= t('.heading') %></h1>
10
+
11
+ <ul class="actions">
12
+ <li><%= return_icon(admin_course_tag_path(@entity.id)) %></li>
13
+ <li class="danger"><%= destroy_icon(@entity) %></li>
14
+ </ul>
15
+
16
+ <%= render partial: 'form', locals: { entity: @entity } %>
17
+ </article>
@@ -0,0 +1 @@
1
+ <%= render partial: 'shared/forms/list_of_errors', locals: { entity: @entity, form_id: 'course_tag-form' } %>
@@ -0,0 +1,15 @@
1
+ <% content_for :meta_title, t('.title') %>
2
+ <% content_for :breadcrumbs do %>
3
+ <%= link_to(t('admin.course_tags.nav_item.text'), admin_course_tags_path) %>
4
+ <span><%= t('.heading') %></span>
5
+ <% end %>
6
+
7
+ <article>
8
+ <h1><%= t('.title') %></h1>
9
+
10
+ <ul class="actions">
11
+ <li><%= back_icon(admin_course_tags_path) %></li>
12
+ </ul>
13
+
14
+ <%= render partial: 'form', locals: { entity: @entity } %>
15
+ </article>
@@ -0,0 +1 @@
1
+ <%= render partial: 'shared/forms/list_of_errors', locals: { entity: @entity, form_id: 'course_tag-form' } %>
@@ -0,0 +1,244 @@
1
+ <%= form_with model: entity, html: { id: 'course-form' } do |f| %>
2
+ <%= render partial: 'shared/list_of_errors', locals: { entity: entity } %>
3
+
4
+ <dl>
5
+ <dt><%= f.label :priority %></dt>
6
+ <dd>
7
+ <%=
8
+ f.number_field(
9
+ :priority,
10
+ id: :course_priority,
11
+ in: Course::PRIORITY_RANGE,
12
+ required: true
13
+ )
14
+ %>
15
+ </dd>
16
+
17
+ <dt><%= f.label :course_category_id %></dt>
18
+ <dd>
19
+ <%=
20
+ f.select(
21
+ :course_category_id,
22
+ course_categories_for_select,
23
+ id: :course_course_category_id,
24
+ required: true
25
+ )
26
+ %>
27
+ </dd>
28
+
29
+ <dt><%= f.label :title %></dt>
30
+ <dd>
31
+ <%=
32
+ f.text_field(
33
+ :title,
34
+ id: :course_title,
35
+ size: nil,
36
+ maxlength: Course::TITLE_LIMIT,
37
+ required: true,
38
+ data: { transliterate: 'course_slug' }
39
+ )
40
+ %>
41
+ <div class="guideline"><%= t('.guidelines.title') %></div>
42
+ </dd>
43
+
44
+ <dt><%= f.label :subtitle %></dt>
45
+ <dd>
46
+ <%=
47
+ f.text_field(
48
+ :subtitle,
49
+ id: :course_subtitle,
50
+ size: nil,
51
+ maxlength: Course::TITLE_LIMIT
52
+ )
53
+ %>
54
+ <div class="guideline"><%= t('.guidelines.subtitle') %></div>
55
+ </dd>
56
+
57
+ <dt><%= f.label :slug %></dt>
58
+ <dd>
59
+ <%=
60
+ f.text_field(
61
+ :slug,
62
+ id: :course_slug,
63
+ size: nil,
64
+ maxlength: Course::SLUG_LIMIT,
65
+ pattern: Course::SLUG_PATTERN_HTML,
66
+ title: t('.guidelines.slug'),
67
+ required: true
68
+ )
69
+ %>
70
+ <div class="guideline"><%= t('.guidelines.slug') %></div>
71
+ </dd>
72
+
73
+ <dt><%= f.label :duration %></dt>
74
+ <dd>
75
+ <%=
76
+ f.text_field(
77
+ :duration,
78
+ id: :course_duration,
79
+ size: nil,
80
+ maxlength: Course::DURATION_LIMIT
81
+ )
82
+ %>
83
+ <div class="guideline"><%= t('.guidelines.duration') %></div>
84
+ </dd>
85
+
86
+ <dt><%= f.label :price %></dt>
87
+ <dd>
88
+ <%=
89
+ f.number_field(
90
+ :price,
91
+ id: :course_price,
92
+ in: (0..100000000)
93
+ )
94
+ %>
95
+ </dd>
96
+
97
+ <dt><%= f.label :special_price %></dt>
98
+ <dd>
99
+ <%=
100
+ f.number_field(
101
+ :special_price,
102
+ id: :course_special_price,
103
+ in: (0..100000000)
104
+ )
105
+ %>
106
+ </dd>
107
+
108
+ <dt><%= f.label :special_price_end %></dt>
109
+ <dd>
110
+ <%=
111
+ f.date_field(
112
+ :special_price_end,
113
+ id: :course_special_price_end,
114
+ )
115
+ %>
116
+ </dd>
117
+
118
+ <dt><%= f.label :image %></dt>
119
+ <dd>
120
+ <figure role="group" class="preview" id="course-image">
121
+ <% if entity.image.blank? %>
122
+ <%= f.label :image, image_tag('biovision/base/placeholders/image.svg') %>
123
+ <% else %>
124
+ <%= f.label :image, image_tag(entity.image.big.url) %>
125
+ <% end %>
126
+ <figcaption>
127
+ <%=
128
+ f.file_field(
129
+ :image,
130
+ id: :course_image,
131
+ accept: 'image/jpeg,image/png',
132
+ data: { image: 'course-image' }
133
+ )
134
+ %>
135
+ </figcaption>
136
+ </figure>
137
+ <div class="guideline"><%= t('.guidelines.image') %></div>
138
+ </dd>
139
+
140
+ <dt><%= f.label :image_alt_text %></dt>
141
+ <dd>
142
+ <%=
143
+ f.text_field(
144
+ :image_alt_text,
145
+ id: :course_image_alt_text,
146
+ size: nil,
147
+ maxlength: Course::META_LIMIT
148
+ )
149
+ %>
150
+ <div class="guideline"><%= t('.guidelines.image_alt_text') %></div>
151
+ </dd>
152
+
153
+ <dt><%= f.label :lead %></dt>
154
+ <dd>
155
+ <%=
156
+ f.text_area(
157
+ :lead,
158
+ id: :course_lead,
159
+ cols: 80,
160
+ rows: 3,
161
+ maxlength: Course::LEAD_LIMIT
162
+ )
163
+ %>
164
+ <div class="guideline"><%= t('.guidelines.lead') %></div>
165
+ </dd>
166
+
167
+ <dt><%= f.label :description %></dt>
168
+ <dd>
169
+ <%=
170
+ f.text_area(
171
+ :description,
172
+ id: :course_description,
173
+ cols: 20,
174
+ rows: 25,
175
+ required: true
176
+ )
177
+ %>
178
+ </dd>
179
+
180
+
181
+ <dt><%= f.label :meta_title %></dt>
182
+ <dd>
183
+ <%=
184
+ f.text_field(
185
+ :meta_title,
186
+ id: :course_meta_title,
187
+ size: nil,
188
+ maxlength: Course::META_LIMIT
189
+ )
190
+ %>
191
+ <div class="guideline"><%= t('.guidelines.meta_title') %></div>
192
+ </dd>
193
+
194
+ <dt><%= f.label :meta_description %></dt>
195
+ <dd>
196
+ <%=
197
+ f.text_field(
198
+ :meta_description,
199
+ id: :course_meta_description,
200
+ size: nil,
201
+ maxlength: Course::META_LIMIT
202
+ )
203
+ %>
204
+ <div class="guideline"><%= t('.guidelines.meta_description') %></div>
205
+ </dd>
206
+
207
+ <dt><%= f.label :meta_keywords %></dt>
208
+ <dd>
209
+ <%=
210
+ f.text_field(
211
+ :meta_keywords,
212
+ id: :course_meta_keywords,
213
+ size: nil,
214
+ maxlength: Course::META_LIMIT
215
+ )
216
+ %>
217
+ <div class="guideline"><%= t('.guidelines.meta_keywords') %></div>
218
+ </dd>
219
+
220
+ <dt><%= t(:flags) %></dt>
221
+ <dd>
222
+ <ul class="flags">
223
+ <li>
224
+ <%= f.check_box :visible, id: :course_visible %>
225
+ <%= f.label :visible %>
226
+ </li>
227
+ <li>
228
+ <%= f.check_box :highlight, id: :course_highlight %>
229
+ <%= f.label :highlight %>
230
+ </li>
231
+ <li>
232
+ <%= f.check_box :online, id: :course_online %>
233
+ <%= f.label :online %>
234
+ </li>
235
+ </ul>
236
+ </dd>
237
+ </dl>
238
+
239
+ <div class="buttons">
240
+ <%= f.button t(:save), type: :submit, class: 'button-save' %>
241
+ </div>
242
+ <% end %>
243
+
244
+ <%= render 'courses/form/wysiwyg' %>
@@ -0,0 +1,17 @@
1
+ <% content_for :meta_title, t('.title') %>
2
+ <% content_for :breadcrumbs do %>
3
+ <%= link_to(t('admin.courses.nav_item.text'), admin_courses_path) %>
4
+ <%= admin_course_link(@entity) %>
5
+ <span><%= t('.heading') %></span>
6
+ <% end %>
7
+
8
+ <article>
9
+ <h1><%= t('.heading') %></h1>
10
+
11
+ <ul class="actions">
12
+ <li><%= return_icon(admin_course_path(@entity.id)) %></li>
13
+ <li class="danger"><%= destroy_icon(@entity) %></li>
14
+ </ul>
15
+
16
+ <%= render partial: 'form', locals: { entity: @entity } %>
17
+ </article>
@@ -0,0 +1 @@
1
+ <%= render partial: 'shared/forms/list_of_errors', locals: { entity: @entity, form_id: 'course-form' } %>
@@ -0,0 +1,14 @@
1
+ <script src="//cdn.ckeditor.com/4.8.0/full/ckeditor.js"></script>
2
+ <script>
3
+ 'use strict';
4
+
5
+ document.addEventListener('DOMContentLoaded', function () {
6
+ const editor = document.getElementById('course_description');
7
+
8
+ CKEDITOR.replace(editor, {
9
+ filebrowserUploadUrl: '/media_files/ckeditor',
10
+ removePlugins: 'forms,save,preview,flash,bidi,language,print,templates,newpage,iframe,about,scayt,wsc',
11
+ // extraPlugins: 'embed'
12
+ });
13
+ });
14
+ </script>
@@ -0,0 +1,15 @@
1
+ <% content_for :meta_title, t('.title') %>
2
+ <% content_for :breadcrumbs do %>
3
+ <%= link_to(t('admin.courses.nav_item.text'), admin_courses_path) %>
4
+ <span><%= t('.heading') %></span>
5
+ <% end %>
6
+
7
+ <article>
8
+ <h1><%= t('.heading') %></h1>
9
+
10
+ <ul class="actions">
11
+ <li><%= back_icon(admin_courses_path) %></li>
12
+ </ul>
13
+
14
+ <%= render partial: 'form', locals: { entity: @entity } %>
15
+ </article>