refinerycms-registrations 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. data/app/assets/images/refinery/race_registrations/admin/chosen-sprite.png +0 -0
  2. data/app/assets/images/refinery/race_registrations/down_arrow.png +0 -0
  3. data/app/assets/images/refinery/race_registrations/up_arrow.png +0 -0
  4. data/app/assets/javascripts/refinery/race_registrations/admin/jquery.chosen.min.js +10 -0
  5. data/app/assets/javascripts/refinery/race_registrations/admin/race_registrations.js +53 -0
  6. data/app/assets/javascripts/refinery/race_registrations/race_registrations.js +41 -0
  7. data/app/assets/stylesheets/refinery/race_registrations/admin/chosen.css.scss +396 -0
  8. data/app/assets/stylesheets/refinery/race_registrations/admin/race_registrations.css.scss +13 -0
  9. data/app/assets/stylesheets/refinery/race_registrations/admin/sortable_table.css.scss +40 -0
  10. data/app/assets/stylesheets/refinery/race_registrations/race_registrations.css.scss +74 -0
  11. data/app/controllers/refinery/race_registrations/admin/categories_controller.rb +33 -0
  12. data/app/controllers/refinery/race_registrations/admin/groups_controller.rb +13 -0
  13. data/app/controllers/refinery/race_registrations/admin/people_controller.rb +89 -0
  14. data/app/controllers/refinery/race_registrations/admin/registrations_controller.rb +13 -0
  15. data/app/controllers/refinery/race_registrations/categories_controller.rb +17 -0
  16. data/app/controllers/refinery/race_registrations/people_controller.rb +36 -0
  17. data/app/controllers/refinery/race_registrations/registrations_controller.rb +40 -0
  18. data/app/helpers/refinery/race_registrations/admin/people_helper.rb +23 -0
  19. data/app/helpers/refinery/race_registrations/registrations_helper.rb +23 -0
  20. data/app/models/refinery/race_registrations/category.rb +17 -0
  21. data/app/models/refinery/race_registrations/group.rb +20 -0
  22. data/app/models/refinery/race_registrations/group_category.rb +8 -0
  23. data/app/models/refinery/race_registrations/person.rb +53 -0
  24. data/app/models/refinery/race_registrations/registration.rb +37 -0
  25. data/app/views/layouts/print.html.erb +14 -0
  26. data/app/views/refinery/pages/registration_list.html.erb +15 -0
  27. data/app/views/refinery/race_registrations/admin/_submenu.html.erb +77 -0
  28. data/app/views/refinery/race_registrations/admin/categories/_categories.html.erb +2 -0
  29. data/app/views/refinery/race_registrations/admin/categories/_category.html.erb +20 -0
  30. data/app/views/refinery/race_registrations/admin/categories/_form.html.erb +17 -0
  31. data/app/views/refinery/race_registrations/admin/categories/_records.html.erb +18 -0
  32. data/app/views/refinery/race_registrations/admin/categories/_sortable_list.html.erb +5 -0
  33. data/app/views/refinery/race_registrations/admin/categories/edit.html.erb +1 -0
  34. data/app/views/refinery/race_registrations/admin/categories/index.html.erb +5 -0
  35. data/app/views/refinery/race_registrations/admin/categories/new.html.erb +1 -0
  36. data/app/views/refinery/race_registrations/admin/groups/_form.html.erb +23 -0
  37. data/app/views/refinery/race_registrations/admin/groups/_group.html.erb +20 -0
  38. data/app/views/refinery/race_registrations/admin/groups/_groups.html.erb +2 -0
  39. data/app/views/refinery/race_registrations/admin/groups/_records.html.erb +18 -0
  40. data/app/views/refinery/race_registrations/admin/groups/_sortable_list.html.erb +5 -0
  41. data/app/views/refinery/race_registrations/admin/groups/edit.html.erb +1 -0
  42. data/app/views/refinery/race_registrations/admin/groups/index.html.erb +5 -0
  43. data/app/views/refinery/race_registrations/admin/groups/new.html.erb +1 -0
  44. data/app/views/refinery/race_registrations/admin/people/_form.html.erb +82 -0
  45. data/app/views/refinery/race_registrations/admin/people/_people.html.erb +14 -0
  46. data/app/views/refinery/race_registrations/admin/people/_person.html.erb +21 -0
  47. data/app/views/refinery/race_registrations/admin/people/_records.html.erb +11 -0
  48. data/app/views/refinery/race_registrations/admin/people/edit.html.erb +1 -0
  49. data/app/views/refinery/race_registrations/admin/people/index.html.erb +27 -0
  50. data/app/views/refinery/race_registrations/admin/people/index.js.erb +3 -0
  51. data/app/views/refinery/race_registrations/admin/people/new.html.erb +1 -0
  52. data/app/views/refinery/race_registrations/admin/registrations/_form.html.erb +54 -0
  53. data/app/views/refinery/race_registrations/admin/registrations/_records.html.erb +18 -0
  54. data/app/views/refinery/race_registrations/admin/registrations/_registration.html.erb +20 -0
  55. data/app/views/refinery/race_registrations/admin/registrations/_registrations.html.erb +2 -0
  56. data/app/views/refinery/race_registrations/admin/registrations/_sortable_list.html.erb +5 -0
  57. data/app/views/refinery/race_registrations/admin/registrations/edit.html.erb +1 -0
  58. data/app/views/refinery/race_registrations/admin/registrations/index.html.erb +5 -0
  59. data/app/views/refinery/race_registrations/admin/registrations/new.html.erb +1 -0
  60. data/app/views/refinery/race_registrations/categories/index.html.erb +11 -0
  61. data/app/views/refinery/race_registrations/categories/show.html.erb +27 -0
  62. data/app/views/refinery/race_registrations/groups/index.html.erb +11 -0
  63. data/app/views/refinery/race_registrations/groups/show.html.erb +27 -0
  64. data/app/views/refinery/race_registrations/people/_form.html.erb +81 -0
  65. data/app/views/refinery/race_registrations/people/_form_header.html.erb +8 -0
  66. data/app/views/refinery/race_registrations/people/new.html.erb +28 -0
  67. data/app/views/refinery/race_registrations/registrations/_registration.html.erb +47 -0
  68. data/app/views/refinery/race_registrations/registrations/_registration_chooser.html.erb +7 -0
  69. data/app/views/refinery/race_registrations/registrations/show.html.erb +21 -0
  70. data/config/initializers/refinery/core.rb +8 -0
  71. data/config/locales/en.yml +136 -0
  72. data/config/locales/es.yml +141 -0
  73. data/config/locales/fr.yml +139 -0
  74. data/config/locales/humanizer.de.yml +43 -0
  75. data/config/locales/humanizer.en.yml +43 -0
  76. data/config/locales/humanizer.es.yml +43 -0
  77. data/config/locales/humanizer.fi.yml +43 -0
  78. data/config/locales/humanizer.fr.yml +43 -0
  79. data/config/locales/humanizer.it.yml +43 -0
  80. data/config/locales/humanizer.nl.yml +43 -0
  81. data/config/locales/humanizer.pl.yml +43 -0
  82. data/config/locales/humanizer.pt-BR.yml +43 -0
  83. data/config/locales/humanizer.pt-PT.yml +43 -0
  84. data/config/locales/humanizer.ru.yml +43 -0
  85. data/config/locales/humanizer.sk.yml +9 -0
  86. data/config/locales/humanizer.zh-CN.yml +43 -0
  87. data/config/locales/nb.yml +141 -0
  88. data/config/locales/nl.yml +141 -0
  89. data/config/locales/sk.yml +138 -0
  90. data/config/routes.rb +44 -0
  91. data/db/migrate/1_create_race_registrations_registrations.rb +31 -0
  92. data/db/migrate/2_create_race_registrations_people.rb +33 -0
  93. data/db/migrate/3_create_race_registrations_categories.rb +26 -0
  94. data/db/migrate/4_create_race_registrations_groups.rb +26 -0
  95. data/db/migrate/5_create_race_registrations_group_categories.rb +18 -0
  96. data/db/migrate/6_add_registration_id_to_people.rb +20 -0
  97. data/db/migrate/7_add_group_id_to_registrations.rb +13 -0
  98. data/db/seeds.rb +51 -0
  99. data/lib/generators/refinery/registrations_generator.rb +18 -0
  100. data/lib/refinery/registrations.rb +22 -0
  101. data/lib/refinery/registrations/configuration.rb +11 -0
  102. data/lib/refinery/registrations/engine.rb +31 -0
  103. data/lib/refinery/registrations/extensions/pages_controller_extension.rb +18 -0
  104. data/lib/refinerycms-registrations.rb +1 -0
  105. data/lib/tasks/refinery/registrations.rake +13 -0
  106. data/readme.md +95 -0
  107. metadata +182 -0
@@ -0,0 +1,13 @@
1
+ @import "sortable_table";
2
+
3
+ #person_registration_ids {
4
+ width: 300px;
5
+ }
6
+
7
+ .filter_field {
8
+ float:left;
9
+ }
10
+
11
+ .search_field {
12
+ float:right;
13
+ }
@@ -0,0 +1,40 @@
1
+ .sortable {
2
+ width: 100%;
3
+
4
+ td,th {
5
+ padding: 4px;
6
+ }
7
+
8
+ td {
9
+ &.action img {
10
+ padding: 2px 4px 4px;
11
+ vertical-align: middle;
12
+ }
13
+
14
+ }
15
+ th {
16
+ background-color: #e2e2e2;
17
+
18
+ .current_th {
19
+ padding-right: 12px;
20
+ background-repeat: no-repeat;
21
+ background-position: right center;
22
+ }
23
+ .asc {
24
+ background-image: image-url('refinery/race_registrations/up_arrow.png');
25
+ }
26
+ .desc {
27
+ background-image: image-url('refinery/race_registrations/down_arrow.png');
28
+ }
29
+
30
+ }
31
+ tr {
32
+ &.on {
33
+ background-color: #f9e3b8;
34
+ }
35
+ &.on-hover {
36
+ }
37
+
38
+
39
+ }
40
+ }
@@ -0,0 +1,74 @@
1
+ .use_diacritics {
2
+ color: red;
3
+ font-weight: bold;
4
+ }
5
+
6
+ form#new_person {
7
+ .field label {
8
+ font-weight: bold;
9
+ display: block;
10
+ float: left;
11
+ width: 160px;
12
+ }
13
+ #label_person_club {
14
+ font-weight: normal;
15
+ }
16
+ }
17
+
18
+
19
+ // From refinerycms-core
20
+ #message, .flash {
21
+ padding: 8px 8px 8px 30px;
22
+ margin-bottom: 15px;
23
+ position: relative;
24
+ }
25
+ .flash_notice, .flash_message {
26
+ border: 1px solid #00A017;
27
+ color: #00A017;
28
+ background: 7px 7px no-repeat image_url('refinery/icons/accept.png') #E0F5E0;
29
+ }
30
+ .flash_notice, .flash_notice * {
31
+ color: #00A017;
32
+ }
33
+ .flash_error, .flash_alert {
34
+ border: 1px solid #A00027;
35
+ color: #A00027;
36
+ background: 7px 7px no-repeat image_url('refinery/icons/cancel.png') #FFB1B1;
37
+ }
38
+ .flash.flash_notice #flash_close, .flash.flash_error #flash_close, .flash.flash_alert #flash_close {
39
+ text-transform: lowercase;
40
+ }
41
+ .flash.flash_message {
42
+ background: #E0F5E0;
43
+ padding: 9px;
44
+ position: relative;
45
+ margin-bottom: 32px;
46
+ h2 {
47
+ margin-top: 12px;
48
+ }
49
+ }
50
+ .flash.flash_message.flash_message, .flash_message * {
51
+ color: #262719;
52
+ font-size: 14px;
53
+ }
54
+ .flash a, .flash a:hover {
55
+ color: #e20003;
56
+ border-bottom-color: #e20003;
57
+ }
58
+ .flash.flash_error a, .flash.flash_error a:hover,
59
+ .flash.flash_alert a, .flash.flash_alert a:hover {
60
+ display: none;
61
+ }
62
+ noscript .flash.flash_error a, noscript .flash.flash_error a:hover,
63
+ noscript .flash.flash_alert a, noscript .flash.flash_alert a:hover {
64
+ display: inline;
65
+ font-weight: bold;
66
+ }
67
+ .flash a#flash_close {
68
+ position: absolute;
69
+ right: 9px;
70
+ top: 7px;
71
+ }
72
+ .flash.flash_message a#flash_close {
73
+ top: 21px;
74
+ }
@@ -0,0 +1,33 @@
1
+ module Refinery
2
+ module RaceRegistrations
3
+ module Admin
4
+ class CategoriesController < ::Refinery::AdminController
5
+
6
+ crudify :'refinery/race_registrations/category',
7
+ :order => "position DESC",
8
+ :xhr_paging => true
9
+
10
+ def index
11
+ if params[:registration_id]
12
+ registration = Refinery::RaceRegistrations::Registration.find(params[:registration_id])
13
+ @categories = registration.categories
14
+
15
+ respond_to do |format|
16
+ format.json { render :json=> @categories }
17
+ end
18
+
19
+ else
20
+ # default crudify action
21
+ search_all_categories if searching?
22
+ paginate_all_categories
23
+
24
+ render_partial_response?
25
+ end
26
+
27
+
28
+ end
29
+
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,13 @@
1
+ module Refinery
2
+ module RaceRegistrations
3
+ module Admin
4
+ class GroupsController < ::Refinery::AdminController
5
+
6
+ crudify :'refinery/race_registrations/group',
7
+ :order => "position DESC",
8
+ :xhr_paging => true
9
+
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,89 @@
1
+ module Refinery
2
+ module RaceRegistrations
3
+ module Admin
4
+ class PeopleController < ::Refinery::AdminController
5
+ include PeopleHelper
6
+ helper :"refinery/race_registrations/admin/people"
7
+
8
+ crudify :'refinery/race_registrations/person',
9
+ :title_attribute => "surname",
10
+ :xhr_paging => false
11
+
12
+ before_filter :initialize_update, :only => :update
13
+
14
+
15
+ def new
16
+ @person = Person.new
17
+ @categories = Category.all
18
+ end
19
+
20
+ def create
21
+ @categories = Category.all
22
+
23
+ @person = Person.new(params[:person])
24
+ @person.bypass_humanizer = true
25
+
26
+
27
+ if @person.save
28
+ flash.notice = t(
29
+ 'refinery.crudify.created',
30
+ :what => @person.surname
31
+ )
32
+
33
+ find_all_people
34
+ render :index
35
+ else
36
+ render :action => 'new'
37
+ end
38
+
39
+ end
40
+
41
+
42
+ def edit
43
+ # @person comes from crud before_filter
44
+ @categories = Registration.find(@person.registration_id).categories
45
+ end
46
+
47
+
48
+ protected
49
+
50
+
51
+ def initialize_update
52
+ # we need to create instance variables for collection_select. Without this method, crudify will call crudify's edit, no edit method in this file
53
+ edit
54
+ end
55
+
56
+ # overriding crudify method
57
+ def find_person
58
+ @person = Person.find(params[:id])
59
+ @person.bypass_humanizer = true
60
+ end
61
+
62
+ # overriding crudify method
63
+ def find_all_people
64
+ @people = Person.search(params[:search], params[:sort], params[:person]).order(sort_column + " " + sort_direction).paginate(:per_page => 20, :page => params[:page])
65
+ end
66
+
67
+ # overriding crudify method
68
+ def search_all_people
69
+ find_all_people
70
+ end
71
+
72
+
73
+ def render_partial_response?
74
+ # this is initialization only for form - form filtering
75
+ @person = Person.new
76
+ if params[:person]
77
+ @person.registration_ids = params[:person][:registration_ids]
78
+ end
79
+
80
+ respond_to do |format|
81
+ format.js { render "index"}
82
+ format.html { render "index"}
83
+ end
84
+ end
85
+
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,13 @@
1
+ module Refinery
2
+ module RaceRegistrations
3
+ module Admin
4
+ class RegistrationsController < ::Refinery::AdminController
5
+
6
+ crudify :'refinery/race_registrations/registration',
7
+ :order => "position DESC",
8
+ :xhr_paging => true
9
+
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ module Refinery
2
+ module RaceRegistrations
3
+ class CategoriesController < ::ApplicationController
4
+
5
+ def index
6
+ if params[:registration_id]
7
+ registration = Refinery::RaceRegistrations::Registration.find(params[:registration_id])
8
+ @categories = registration.categories
9
+
10
+ respond_to do |format|
11
+ format.json { render :json=> @categories }
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,36 @@
1
+ module Refinery
2
+ module RaceRegistrations
3
+ class PeopleController < ::ApplicationController
4
+ before_filter :find_page
5
+
6
+ def new
7
+ @person = Person.new
8
+ @registrations = Registration.published
9
+ @categories = @registrations.first.try(:categories)
10
+
11
+ present(@page)
12
+ end
13
+
14
+ def create
15
+ @person = Person.new(params[:person])
16
+
17
+ if @person.save
18
+ redirect_to refinery.race_registrations_registration_path(:id=> @person.registration_id) , :notice => t('refinery.crudify.created', :what => @person.name + " " + @person.surname )
19
+ else
20
+ @registrations = Registration.published
21
+ @categories = @registrations.first.try(:categories)
22
+
23
+ render :action=> "new"
24
+ end
25
+ end
26
+
27
+
28
+ protected
29
+
30
+ def find_page
31
+ @page = Refinery::Page.where(:link_url => "/race_registrations/people/new").first
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,40 @@
1
+ module Refinery
2
+ module RaceRegistrations
3
+ class RegistrationsController < ::ApplicationController
4
+ before_filter :find_all_registrations
5
+ before_filter :find_page
6
+
7
+
8
+ def redirect
9
+ if params[:registration][:id].present?
10
+ redirect_to refinery.race_registrations_registration_path(params[:registration][:id])
11
+ end
12
+ end
13
+
14
+ def index
15
+ @registration = Registration.first
16
+ redirect_to refinery.race_registrations_registration_path(:id=> @registration)
17
+ end
18
+
19
+ def show
20
+ @registration = Registration.find(params[:id])
21
+
22
+ # you can use meta fields from your model instead (e.g. browser_title)
23
+ # by swapping @page for @registration in the line below:
24
+ present(@page)
25
+ end
26
+
27
+ protected
28
+
29
+ def find_all_registrations
30
+ @registrations = Registration.order('position ASC')
31
+ end
32
+
33
+ def find_page
34
+ @page = Refinery::Page.where(:link_url => "/race_registrations/registrations").first
35
+ end
36
+
37
+
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,23 @@
1
+ module Refinery
2
+ module RaceRegistrations
3
+ module Admin
4
+ module PeopleHelper
5
+ def sortable(column, title = nil)
6
+ title ||= column.titleize
7
+ css_class = column == sort_column ? "current_th #{sort_direction}" : nil
8
+ direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc"
9
+
10
+ link_to title, refinery.race_registrations_admin_people_path(:sort => column, :direction => direction, :page => nil ), {:class => css_class}
11
+ end
12
+
13
+ def sort_column
14
+ %w[name surname country birth_date email club city registration_id category_id created_at].include?(params[:sort]) ? params[:sort] : "id"
15
+ end
16
+
17
+ def sort_direction
18
+ %w[asc desc].include?(params[:direction]) ? params[:direction] : "desc"
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ module Refinery
2
+ module RaceRegistrations
3
+ module RegistrationsHelper
4
+
5
+ def sortable(column, title = nil)
6
+ title ||= column.titleize
7
+ css_class = column == sort_column ? "current_th #{sort_direction}" : nil
8
+ direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc"
9
+
10
+ link_to title, refinery.race_registrations_registration_path(:sort => column, :direction => direction, :page => nil ), {:class => css_class}
11
+ end
12
+
13
+ def sort_column
14
+ %w[name surname country birth_date email club city registration_id category_id created_at].include?(params[:sort]) ? params[:sort] : "surname"
15
+ end
16
+
17
+ def sort_direction
18
+ %w[asc desc].include?(params[:direction]) ? params[:direction] : "asc"
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ module Refinery
2
+ module RaceRegistrations
3
+ class Category < Refinery::Core::BaseModel
4
+ has_many :group_categories
5
+ has_many :groups, :through => :group_categories
6
+ has_many :people , :order => "surname ASC"
7
+
8
+ default_scope order("position DESC")
9
+
10
+ attr_accessible :title, :position
11
+
12
+ acts_as_indexed :fields => [:title]
13
+
14
+ validates :title, :presence => true, :uniqueness => true
15
+ end
16
+ end
17
+ end