beerify 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 (138) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +11 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/fonts/beerify/glyphicons-halflings-regular.eot +0 -0
  6. data/app/assets/fonts/beerify/glyphicons-halflings-regular.svg +228 -0
  7. data/app/assets/fonts/beerify/glyphicons-halflings-regular.ttf +0 -0
  8. data/app/assets/fonts/beerify/glyphicons-halflings-regular.woff +0 -0
  9. data/app/assets/javascripts/beerify/application.js +3 -0
  10. data/app/assets/javascripts/beerify/bootstrap.js +1991 -0
  11. data/app/assets/stylesheets/beerify/application.css +3 -0
  12. data/app/assets/stylesheets/beerify/bootstrap.css +5909 -0
  13. data/app/controllers/application_controller.rb +2 -0
  14. data/app/controllers/contacts_controller.rb +21 -0
  15. data/app/helpers/application_helper.rb +2 -0
  16. data/app/helpers/contacts_helper.rb +2 -0
  17. data/app/models/ability.rb +28 -0
  18. data/app/models/catalog.rb +11 -0
  19. data/app/models/ckeditor/asset.rb +7 -0
  20. data/app/models/ckeditor/attachment_file.rb +7 -0
  21. data/app/models/ckeditor/picture.rb +7 -0
  22. data/app/models/contact.rb +8 -0
  23. data/app/models/news.rb +11 -0
  24. data/app/models/photo.rb +5 -0
  25. data/app/models/product.rb +12 -0
  26. data/app/models/settings.rb +10 -0
  27. data/app/models/user.rb +10 -0
  28. data/app/models/users/admin.rb +4 -0
  29. data/app/models/users/customer.rb +5 -0
  30. data/app/models/users/sudoer.rb +4 -0
  31. data/app/uploaders/ckeditor_attachment_file_uploader.rb +35 -0
  32. data/app/uploaders/ckeditor_picture_uploader.rb +46 -0
  33. data/app/uploaders/photo_uploader.rb +22 -0
  34. data/app/views/contacts/_form.html.slim +5 -0
  35. data/app/views/contacts/new.html.slim +2 -0
  36. data/app/views/devise/confirmations/new.html.erb +14 -0
  37. data/app/views/devise/mailer/confirmation_instructions.html.erb +3 -0
  38. data/app/views/devise/mailer/reset_password_instructions.html.erb +5 -0
  39. data/app/views/devise/mailer/unlock_instructions.html.erb +4 -0
  40. data/app/views/devise/passwords/edit.html.erb +16 -0
  41. data/app/views/devise/passwords/new.html.erb +14 -0
  42. data/app/views/devise/registrations/edit.html.erb +20 -0
  43. data/app/views/devise/registrations/new.html.erb +16 -0
  44. data/app/views/devise/sessions/new.html.erb +14 -0
  45. data/app/views/devise/shared/_links.erb +25 -0
  46. data/app/views/devise/unlocks/new.html.erb +14 -0
  47. data/app/views/layouts/beerify/application.html.erb +14 -0
  48. data/config/initializers/ckeditor.rb +21 -0
  49. data/config/initializers/devise.rb +254 -0
  50. data/config/initializers/kaminari.rb +3 -0
  51. data/config/initializers/rails_admin.rb +5 -0
  52. data/config/initializers/rails_admin/news_admin.rb +19 -0
  53. data/config/initializers/rails_admin/user_admin.rb +71 -0
  54. data/config/initializers/simple_form.rb +142 -0
  55. data/config/initializers/simple_form_bootstrap.rb +76 -0
  56. data/config/locales/attributes.en.yml +57 -0
  57. data/config/locales/attributes.fr.yml +57 -0
  58. data/config/locales/devise.en.yml +59 -0
  59. data/config/locales/devise.fr.yml +78 -0
  60. data/config/locales/devise.views.en.yml +59 -0
  61. data/config/locales/devise.views.fr.yml +51 -0
  62. data/config/locales/fr.yml +220 -0
  63. data/config/locales/main.en.yml +5 -0
  64. data/config/locales/main.fr.yml +5 -0
  65. data/config/locales/models.en.yml +30 -0
  66. data/config/locales/models.fr.yml +30 -0
  67. data/config/locales/rails_admin.fr.yml +129 -0
  68. data/config/locales/simple_form.en.yml +26 -0
  69. data/config/routes.rb +8 -0
  70. data/config/settings/beerify/development.yml +2 -0
  71. data/config/settings/beerify/production.yml +2 -0
  72. data/config/settings/beerify/settings.yml +1 -0
  73. data/db/migrate/20130805210910_create_users.rb +12 -0
  74. data/db/migrate/20130805212414_add_devise_to_users.rb +34 -0
  75. data/db/migrate/20130819142757_create_catalogs.rb +15 -0
  76. data/db/migrate/20130826095103_create_photos.rb +12 -0
  77. data/db/migrate/20130902160901_create_products.rb +16 -0
  78. data/db/migrate/20130902162315_add_photos_to_product.rb +6 -0
  79. data/db/migrate/20130903083519_create_contacts.rb +11 -0
  80. data/db/migrate/20130903130542_create_news.rb +17 -0
  81. data/db/migrate/20130904000525_create_ckeditor_assets.rb +23 -0
  82. data/db/migrate/20130918132647_add_highlight_to_products.rb +5 -0
  83. data/lib/beerify.rb +4 -0
  84. data/lib/beerify/engine.rb +28 -0
  85. data/lib/beerify/version.rb +3 -0
  86. data/lib/tasks/populate.rake +66 -0
  87. data/spec/beerify/models/catalog_spec.rb +9 -0
  88. data/spec/beerify/models/contact_spec.rb +6 -0
  89. data/spec/beerify/models/news_spec.rb +7 -0
  90. data/spec/beerify/models/photo_spec.rb +5 -0
  91. data/spec/beerify/models/product_spec.rb +8 -0
  92. data/spec/beerify/models/user_spec.rb +4 -0
  93. data/spec/beerify/models/users/admin_spec.rb +5 -0
  94. data/spec/beerify/models/users/customer_spec.rb +5 -0
  95. data/spec/dummy/README.rdoc +28 -0
  96. data/spec/dummy/Rakefile +6 -0
  97. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  98. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  99. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  100. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  101. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  102. data/spec/dummy/bin/bundle +3 -0
  103. data/spec/dummy/bin/rails +4 -0
  104. data/spec/dummy/bin/rake +4 -0
  105. data/spec/dummy/config.ru +4 -0
  106. data/spec/dummy/config/application.rb +23 -0
  107. data/spec/dummy/config/boot.rb +5 -0
  108. data/spec/dummy/config/database.yml +11 -0
  109. data/spec/dummy/config/environment.rb +5 -0
  110. data/spec/dummy/config/environments/development.rb +29 -0
  111. data/spec/dummy/config/environments/production.rb +80 -0
  112. data/spec/dummy/config/environments/test.rb +36 -0
  113. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  114. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  115. data/spec/dummy/config/initializers/inflections.rb +16 -0
  116. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  117. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  118. data/spec/dummy/config/initializers/session_store.rb +3 -0
  119. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  120. data/spec/dummy/config/locales/en.yml +23 -0
  121. data/spec/dummy/config/routes.rb +56 -0
  122. data/spec/dummy/db/migrate/20130904085929_create_users.beerify.rb +13 -0
  123. data/spec/dummy/db/migrate/20130904085930_add_devise_to_users.beerify.rb +35 -0
  124. data/spec/dummy/db/migrate/20130904085931_create_catalogs.beerify.rb +16 -0
  125. data/spec/dummy/db/migrate/20130904085932_create_photos.beerify.rb +13 -0
  126. data/spec/dummy/db/migrate/20130904085933_create_products.beerify.rb +17 -0
  127. data/spec/dummy/db/migrate/20130904085934_add_photos_to_product.beerify.rb +7 -0
  128. data/spec/dummy/db/migrate/20130904085935_create_contacts.beerify.rb +12 -0
  129. data/spec/dummy/db/migrate/20130906090417_create_news.beerify.rb +18 -0
  130. data/spec/dummy/db/migrate/20130906090418_create_ckeditor_assets.beerify.rb +24 -0
  131. data/spec/dummy/db/migrate/20130918132952_add_highlight_to_products.beerify.rb +6 -0
  132. data/spec/dummy/db/schema.rb +116 -0
  133. data/spec/dummy/public/404.html +58 -0
  134. data/spec/dummy/public/422.html +58 -0
  135. data/spec/dummy/public/500.html +57 -0
  136. data/spec/dummy/public/favicon.ico +0 -0
  137. data/spec/spec_helper.rb +19 -0
  138. metadata +641 -0
@@ -0,0 +1,14 @@
1
+ <h2><%= t('.resend_unlock_instructions') %></h2>
2
+
3
+ <%= simple_form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <div class="form-inputs">
7
+ <%= f.input :email, required: true, autofocus: true %>
8
+ </div>
9
+ <div class="form-actions">
10
+ <%= f.submit t('.resend_unlock_instructions'), class: 'btn btn-success' %>
11
+ </div>
12
+ <% end %>
13
+
14
+ <%= render 'devise/shared/links' %>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Beerify</title>
5
+ <%= stylesheet_link_tag "beerify/application", media: "all" %>
6
+ <%= javascript_include_tag "beerify/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,21 @@
1
+ # Use this hook to configure ckeditor
2
+ if Object.const_defined?("Ckeditor")
3
+ Ckeditor.setup do |config|
4
+ # ==> ORM configuration
5
+ # Load and configure the ORM. Supports :active_record (default), :mongo_mapper and
6
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
7
+ # available as additional gems.
8
+ require "ckeditor/orm/active_record"
9
+
10
+ # Allowed image file types for upload.
11
+ # Set to nil or [] (empty array) for all file types
12
+ # config.image_file_types = ["jpg", "jpeg", "png", "gif", "tiff"]
13
+
14
+ # Allowed attachment file types for upload.
15
+ # Set to nil or [] (empty array) for all file types
16
+ # config.attachment_file_types = ["doc", "docx", "xls", "odt", "ods", "pdf", "rar", "zip", "tar", "swf"]
17
+
18
+ # Setup authorization to be run as a before filter
19
+ config.authorize_with :cancan
20
+ end
21
+ end
@@ -0,0 +1,254 @@
1
+ # Use this hook to configure devise mailer, warden hooks and so forth.
2
+ # Many of these configuration options can be set straight in your model.
3
+ Devise.setup do |config|
4
+ config.secret_key = 'c504a476bac31e8ba5d7664cb859109a3517b62be72d14f154b43aefe6babc397f6cbaacfee1a2b99ebe48270634136976396af55728739d454fb8fa29012e75'
5
+
6
+ # ==> Mailer Configuration
7
+ # Configure the e-mail address which will be shown in Devise::Mailer,
8
+ # note that it will be overwritten if you use your own mailer class with default "from" parameter.
9
+ config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
10
+
11
+ # Configure the class responsible to send e-mails.
12
+ # config.mailer = "Devise::Mailer"
13
+
14
+ # ==> ORM configuration
15
+ # Load and configure the ORM. Supports :active_record (default) and
16
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
17
+ # available as additional gems.
18
+ require 'devise/orm/active_record'
19
+
20
+ # ==> Configuration for any authentication mechanism
21
+ # Configure which keys are used when authenticating a user. The default is
22
+ # just :email. You can configure it to use [:username, :subdomain], so for
23
+ # authenticating a user, both parameters are required. Remember that those
24
+ # parameters are used only when authenticating and not when retrieving from
25
+ # session. If you need permissions, you should implement that in a before filter.
26
+ # You can also supply a hash where the value is a boolean determining whether
27
+ # or not authentication should be aborted when the value is not present.
28
+ # config.authentication_keys = [ :email ]
29
+
30
+ # Configure parameters from the request object used for authentication. Each entry
31
+ # given should be a request method and it will automatically be passed to the
32
+ # find_for_authentication method and considered in your model lookup. For instance,
33
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
34
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
35
+ # config.request_keys = []
36
+
37
+ # Configure which authentication keys should be case-insensitive.
38
+ # These keys will be downcased upon creating or modifying a user and when used
39
+ # to authenticate or find a user. Default is :email.
40
+ config.case_insensitive_keys = [ :email ]
41
+
42
+ # Configure which authentication keys should have whitespace stripped.
43
+ # These keys will have whitespace before and after removed upon creating or
44
+ # modifying a user and when used to authenticate or find a user. Default is :email.
45
+ config.strip_whitespace_keys = [ :email ]
46
+
47
+ # Tell if authentication through request.params is enabled. True by default.
48
+ # It can be set to an array that will enable params authentication only for the
49
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
50
+ # enable it only for database (email + password) authentication.
51
+ # config.params_authenticatable = true
52
+
53
+ # Tell if authentication through HTTP Auth is enabled. False by default.
54
+ # It can be set to an array that will enable http authentication only for the
55
+ # given strategies, for example, `config.http_authenticatable = [:token]` will
56
+ # enable it only for token authentication. The supported strategies are:
57
+ # :database = Support basic authentication with authentication key + password
58
+ # :token = Support basic authentication with token authentication key
59
+ # :token_options = Support token authentication with options as defined in
60
+ # http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Token.html
61
+ # config.http_authenticatable = false
62
+
63
+ # If http headers should be returned for AJAX requests. True by default.
64
+ # config.http_authenticatable_on_xhr = true
65
+
66
+ # The realm used in Http Basic Authentication. "Application" by default.
67
+ # config.http_authentication_realm = "Application"
68
+
69
+ # It will change confirmation, password recovery and other workflows
70
+ # to behave the same regardless if the e-mail provided was right or wrong.
71
+ # Does not affect registerable.
72
+ # config.paranoid = true
73
+
74
+ # By default Devise will store the user in session. You can skip storage for
75
+ # :http_auth and :token_auth by adding those symbols to the array below.
76
+ # Notice that if you are skipping storage for all authentication paths, you
77
+ # may want to disable generating routes to Devise's sessions controller by
78
+ # passing :skip => :sessions to `devise_for` in your config/routes.rb
79
+ config.skip_session_storage = [:http_auth]
80
+
81
+ # By default, Devise cleans up the CSRF token on authentication to
82
+ # avoid CSRF token fixation attacks. This means that, when using AJAX
83
+ # requests for sign in and sign up, you need to get a new CSRF token
84
+ # from the server. You can disable this option at your own risk.
85
+ # config.clean_up_csrf_token_on_authentication = true
86
+
87
+ # ==> Configuration for :database_authenticatable
88
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
89
+ # using other encryptors, it sets how many times you want the password re-encrypted.
90
+ #
91
+ # Limiting the stretches to just one in testing will increase the performance of
92
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
93
+ # a value less than 10 in other environments.
94
+ config.stretches = Rails.env.test? ? 1 : 10
95
+
96
+ # Setup a pepper to generate the encrypted password.
97
+ # config.pepper = "544c307f4e8704424e6fd50cd356018e59ec5114e6a102ff560eb97f878a50cdde8a9d302ac2f5193eefb3f8000d67d34d2443ca87299a36201a2b4b49832854"
98
+
99
+ # ==> Configuration for :confirmable
100
+ # A period that the user is allowed to access the website even without
101
+ # confirming his account. For instance, if set to 2.days, the user will be
102
+ # able to access the website for two days without confirming his account,
103
+ # access will be blocked just in the third day. Default is 0.days, meaning
104
+ # the user cannot access the website without confirming his account.
105
+ # config.allow_unconfirmed_access_for = 2.days
106
+
107
+ # A period that the user is allowed to confirm their account before their
108
+ # token becomes invalid. For example, if set to 3.days, the user can confirm
109
+ # their account within 3 days after the mail was sent, but on the fourth day
110
+ # their account can't be confirmed with the token any more.
111
+ # Default is nil, meaning there is no restriction on how long a user can take
112
+ # before confirming their account.
113
+ # config.confirm_within = 3.days
114
+
115
+ # If true, requires any email changes to be confirmed (exactly the same way as
116
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
117
+ # db field (see migrations). Until confirmed new email is stored in
118
+ # unconfirmed email column, and copied to email column on successful confirmation.
119
+ config.reconfirmable = true
120
+
121
+ # Defines which key will be used when confirming an account
122
+ # config.confirmation_keys = [ :email ]
123
+
124
+ # ==> Configuration for :rememberable
125
+ # The time the user will be remembered without asking for credentials again.
126
+ # config.remember_for = 2.weeks
127
+
128
+ # If true, extends the user's remember period when remembered via cookie.
129
+ # config.extend_remember_period = false
130
+
131
+ # Options to be passed to the created cookie. For instance, you can set
132
+ # :secure => true in order to force SSL only cookies.
133
+ # config.rememberable_options = {}
134
+
135
+ # ==> Configuration for :validatable
136
+ # Range for password length. Default is 8..128.
137
+ config.password_length = 8..128
138
+
139
+ # Email regex used to validate email formats. It simply asserts that
140
+ # one (and only one) @ exists in the given string. This is mainly
141
+ # to give user feedback and not to assert the e-mail validity.
142
+ # config.email_regexp = /\A[^@]+@[^@]+\z/
143
+
144
+ # ==> Configuration for :timeoutable
145
+ # The time you want to timeout the user session without activity. After this
146
+ # time the user will be asked for credentials again. Default is 30 minutes.
147
+ # config.timeout_in = 30.minutes
148
+
149
+ # If true, expires auth token on session timeout.
150
+ # config.expire_auth_token_on_timeout = false
151
+
152
+ # ==> Configuration for :lockable
153
+ # Defines which strategy will be used to lock an account.
154
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
155
+ # :none = No lock strategy. You should handle locking by yourself.
156
+ # config.lock_strategy = :failed_attempts
157
+
158
+ # Defines which key will be used when locking and unlocking an account
159
+ # config.unlock_keys = [ :email ]
160
+
161
+ # Defines which strategy will be used to unlock an account.
162
+ # :email = Sends an unlock link to the user email
163
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
164
+ # :both = Enables both strategies
165
+ # :none = No unlock strategy. You should handle unlocking by yourself.
166
+ # config.unlock_strategy = :both
167
+
168
+ # Number of authentication tries before locking an account if lock_strategy
169
+ # is failed attempts.
170
+ # config.maximum_attempts = 20
171
+
172
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
173
+ # config.unlock_in = 1.hour
174
+
175
+ # ==> Configuration for :recoverable
176
+ #
177
+ # Defines which key will be used when recovering the password for an account
178
+ # config.reset_password_keys = [ :email ]
179
+
180
+ # Time interval you can reset your password with a reset password key.
181
+ # Don't put a too small interval or your users won't have the time to
182
+ # change their passwords.
183
+ config.reset_password_within = 6.hours
184
+
185
+ # ==> Configuration for :encryptable
186
+ # Allow you to use another encryption algorithm besides bcrypt (default). You can use
187
+ # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
188
+ # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
189
+ # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
190
+ # REST_AUTH_SITE_KEY to pepper).
191
+ #
192
+ # Require the `devise-encryptable` gem when using anything other than bcrypt
193
+ # config.encryptor = :sha512
194
+
195
+ # ==> Configuration for :token_authenticatable
196
+ # Defines name of the authentication token params key
197
+ # config.token_authentication_key = :auth_token
198
+
199
+ # ==> Scopes configuration
200
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
201
+ # "users/sessions/new". It's turned off by default because it's slower if you
202
+ # are using only default views.
203
+ # config.scoped_views = false
204
+
205
+ # Configure the default scope given to Warden. By default it's the first
206
+ # devise role declared in your routes (usually :user).
207
+ # config.default_scope = :user
208
+
209
+ # Set this configuration to false if you want /users/sign_out to sign out
210
+ # only the current scope. By default, Devise signs out all scopes.
211
+ # config.sign_out_all_scopes = true
212
+
213
+ # ==> Navigation configuration
214
+ # Lists the formats that should be treated as navigational. Formats like
215
+ # :html, should redirect to the sign in page when the user does not have
216
+ # access, but formats like :xml or :json, should return 401.
217
+ #
218
+ # If you have any extra navigational formats, like :iphone or :mobile, you
219
+ # should add them to the navigational formats lists.
220
+ #
221
+ # The "*/*" below is required to match Internet Explorer requests.
222
+ # config.navigational_formats = ["*/*", :html]
223
+
224
+ # The default HTTP method used to sign out a resource. Default is :delete.
225
+ config.sign_out_via = :delete
226
+
227
+ # ==> OmniAuth
228
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
229
+ # up on your models and hooks.
230
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
231
+
232
+ # ==> Warden configuration
233
+ # If you want to use other strategies, that are not supported by Devise, or
234
+ # change the failure app, you can configure them inside the config.warden block.
235
+ #
236
+ # config.warden do |manager|
237
+ # manager.intercept_401 = false
238
+ # manager.default_strategies(:scope => :user).unshift :some_external_strategy
239
+ # end
240
+
241
+ # ==> Mountable engine configurations
242
+ # When using Devise inside an engine, let's call it `MyEngine`, and this engine
243
+ # is mountable, there are some extra configurations to be taken into account.
244
+ # The following options are available, assuming the engine is mounted as:
245
+ #
246
+ # mount MyEngine, at: "/my_engine"
247
+ #
248
+ # The router that invoked `devise_for`, in the example above, would be:
249
+ # config.router_name = :my_engine
250
+ #
251
+ # When using omniauth, Devise cannot automatically set Omniauth path,
252
+ # so you need to do it manually. For the users scope, it would be:
253
+ # config.omniauth_path_prefix = "/my_engine/users/auth"
254
+ end
@@ -0,0 +1,3 @@
1
+ Kaminari.configure do |config|
2
+ config.page_method_name = :per_page_kaminari
3
+ end
@@ -0,0 +1,5 @@
1
+ RailsAdmin.config do |config|
2
+ config.authorize_with :cancan
3
+
4
+ config.included_models = [Catalog, Contact, News, Photo, Product, Users::Admin, Users::Customer]
5
+ end
@@ -0,0 +1,19 @@
1
+ RailsAdmin.config do |config|
2
+ config.model News do
3
+ edit do
4
+ field :title
5
+ field :photo
6
+ field :content, :ck_editor
7
+ field :published_on do
8
+ default_value do
9
+ Time.now.in_time_zone('Europe/Paris')
10
+ end
11
+ end
12
+ field :user do
13
+ default_value do
14
+ bindings[:view]._current_user.id
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,71 @@
1
+ RailsAdmin.config do |config|
2
+ config.model Users::Admin do
3
+ navigation_label do
4
+ I18n.t('activerecord.models.user.other')
5
+ end
6
+
7
+ object_label_method do
8
+ :user_label_method
9
+ end
10
+
11
+ list do
12
+ field :firstname
13
+ field :lastname
14
+ field :email
15
+ field :password do
16
+ visible false
17
+ end
18
+ field :password_confirmation do
19
+ visible false
20
+ end
21
+ end
22
+ end
23
+
24
+ config.model Users::Customer do
25
+ navigation_label do
26
+ I18n.t('activerecord.models.user.other')
27
+ end
28
+
29
+ object_label_method do
30
+ :user_label_method
31
+ end
32
+
33
+ list do
34
+ field :firstname
35
+ field :lastname
36
+ field :email
37
+ field :password do
38
+ visible false
39
+ end
40
+ field :password_confirmation do
41
+ visible false
42
+ end
43
+ end
44
+ end
45
+
46
+ config.model Users::Sudoer do
47
+ navigation_label do
48
+ I18n.t('activerecord.models.user.other')
49
+ end
50
+
51
+ object_label_method do
52
+ :user_label_method
53
+ end
54
+
55
+ list do
56
+ field :firstname
57
+ field :lastname
58
+ field :email
59
+ field :password do
60
+ visible false
61
+ end
62
+ field :password_confirmation do
63
+ visible false
64
+ end
65
+ end
66
+ end
67
+
68
+ def user_label_method
69
+ "#{self.firstname} #{self.lastname}"
70
+ end
71
+ end
@@ -0,0 +1,142 @@
1
+ # Use this setup block to configure all options available in SimpleForm.
2
+ SimpleForm.setup do |config|
3
+ # Wrappers are used by the form builder to generate a
4
+ # complete input. You can remove any component from the
5
+ # wrapper, change the order or even add your own to the
6
+ # stack. The options given below are used to wrap the
7
+ # whole input.
8
+ config.wrappers :default, class: :input,
9
+ hint_class: :field_with_hint, error_class: :field_with_errors do |b|
10
+ ## Extensions enabled by default
11
+ # Any of these extensions can be disabled for a
12
+ # given input by passing: `f.input EXTENSION_NAME => false`.
13
+ # You can make any of these extensions optional by
14
+ # renaming `b.use` to `b.optional`.
15
+
16
+ # Determines whether to use HTML5 (:email, :url, ...)
17
+ # and required attributes
18
+ b.use :html5
19
+
20
+ # Calculates placeholders automatically from I18n
21
+ # You can also pass a string as f.input placeholder: "Placeholder"
22
+ b.use :placeholder
23
+
24
+ ## Optional extensions
25
+ # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
26
+ # to the input. If so, they will retrieve the values from the model
27
+ # if any exists. If you want to enable the lookup for any of those
28
+ # extensions by default, you can change `b.optional` to `b.use`.
29
+
30
+ # Calculates maxlength from length validations for string inputs
31
+ b.optional :maxlength
32
+
33
+ # Calculates pattern from format validations for string inputs
34
+ b.optional :pattern
35
+
36
+ # Calculates min and max from length validations for numeric inputs
37
+ b.optional :min_max
38
+
39
+ # Calculates readonly automatically from readonly attributes
40
+ b.optional :readonly
41
+
42
+ ## Inputs
43
+ b.use :label_input
44
+ b.use :hint, wrap_with: { tag: :span, class: :hint }
45
+ b.use :error, wrap_with: { tag: :span, class: :error }
46
+ end
47
+
48
+ # The default wrapper to be used by the FormBuilder.
49
+ config.default_wrapper = :default
50
+
51
+ # Define the way to render check boxes / radio buttons with labels.
52
+ # Defaults to :nested for bootstrap config.
53
+ # inline: input + label
54
+ # nested: label > input
55
+ config.boolean_style = :nested
56
+
57
+ # Default class for buttons
58
+ config.button_class = 'btn'
59
+
60
+ # Method used to tidy up errors. Specify any Rails Array method.
61
+ # :first lists the first message for each field.
62
+ # Use :to_sentence to list all errors for each field.
63
+ # config.error_method = :first
64
+
65
+ # Default tag used for error notification helper.
66
+ config.error_notification_tag = :div
67
+
68
+ # CSS class to add for error notification helper.
69
+ config.error_notification_class = 'alert alert-error'
70
+
71
+ # ID to add for error notification helper.
72
+ # config.error_notification_id = nil
73
+
74
+ # Series of attempts to detect a default label method for collection.
75
+ # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
76
+
77
+ # Series of attempts to detect a default value method for collection.
78
+ # config.collection_value_methods = [ :id, :to_s ]
79
+
80
+ # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
81
+ # config.collection_wrapper_tag = nil
82
+
83
+ # You can define the class to use on all collection wrappers. Defaulting to none.
84
+ # config.collection_wrapper_class = nil
85
+
86
+ # You can wrap each item in a collection of radio/check boxes with a tag,
87
+ # defaulting to :span. Please note that when using :boolean_style = :nested,
88
+ # SimpleForm will force this option to be a label.
89
+ # config.item_wrapper_tag = :span
90
+
91
+ # You can define a class to use in all item wrappers. Defaulting to none.
92
+ # config.item_wrapper_class = nil
93
+
94
+ # How the label text should be generated altogether with the required text.
95
+ # config.label_text = lambda { |label, required| "#{required} #{label}" }
96
+
97
+ # You can define the class to use on all labels. Default is nil.
98
+ config.label_class = 'control-label'
99
+
100
+ # You can define the class to use on all forms. Default is simple_form.
101
+ # config.form_class = :simple_form
102
+
103
+ # You can define which elements should obtain additional classes
104
+ # config.generate_additional_classes_for = [:wrapper, :label, :input]
105
+
106
+ # Whether attributes are required by default (or not). Default is true.
107
+ # config.required_by_default = true
108
+
109
+ # Tell browsers whether to use the native HTML5 validations (novalidate form option).
110
+ # These validations are enabled in SimpleForm's internal config but disabled by default
111
+ # in this configuration, which is recommended due to some quirks from different browsers.
112
+ # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
113
+ # change this configuration to true.
114
+ config.browser_validations = false
115
+
116
+ # Collection of methods to detect if a file type was given.
117
+ # config.file_methods = [ :mounted_as, :file?, :public_filename ]
118
+
119
+ # Custom mappings for input types. This should be a hash containing a regexp
120
+ # to match as key, and the input type that will be used when the field name
121
+ # matches the regexp as value.
122
+ # config.input_mappings = { /count/ => :integer }
123
+
124
+ # Custom wrappers for input types. This should be a hash containing an input
125
+ # type as key and the wrapper that will be used for all inputs with specified type.
126
+ # config.wrapper_mappings = { string: :prepend }
127
+
128
+ # Default priority for time_zone inputs.
129
+ # config.time_zone_priority = nil
130
+
131
+ # Default priority for country inputs.
132
+ # config.country_priority = nil
133
+
134
+ # When false, do not use translations for labels.
135
+ # config.translate_labels = true
136
+
137
+ # Automatically discover new inputs in Rails' autoload path.
138
+ # config.inputs_discovery = true
139
+
140
+ # Cache SimpleForm inputs discovery
141
+ # config.cache_discovery = !Rails.env.development?
142
+ end