inline_forms 3.0.3 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/bin/inline_forms_installer_core.rb +72 -24
- data/lib/app/views/layouts/devise.html.erb +21 -13
- data/lib/inline_forms/version.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Y2MzNGJhOGUyNzAzZTc2OGMzZDk1YWIyNmJlMDFkNzAxYmY3MjRmMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjY3Nzk2NjE0ZDdmYWE5Zjg0NmJmZGE3Njc0YmIxZWMxN2RkOTA2ZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjYzZjFlN2RmNDRmZWMyNDdlMzQyNDY2MDJlYzlkMTI1MzI0NTNmYzQ2ZjVi
|
10
|
+
OWJkYmVjNTViMzNhODlmYTZiNDBiNWRhMzI2MzVkYWZmNDc2MTM5MDVlZTk5
|
11
|
+
ZmY0YjMwZjRhMzdiOTJmOTUyNWU4NWEyNjg1OGQxM2QzM2RhZTQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTc1NWVlYzYyYmU0ZmRlMDc3NWUzNjhjZDkyYmRjMTMzMzkzNTM5M2VjYjlm
|
14
|
+
MjM3MDM3ZjY0ZDJlOWFmY2M1M2MwNGIyOGFjYzAyY2VlZTMwOTkxNzU3YjQ0
|
15
|
+
NWIxMTI2MjdhN2Q5NDc5MjkyMTVmOGYxMDYxODU4NzE5NWVhZjY=
|
@@ -93,7 +93,7 @@ run "bundle exec rails g devise:install"
|
|
93
93
|
# TODO ROYTJE Devise creates a model. That is a migration, a test, a route and a model. We delete the model, the route, and the test probably too. Is there another way to just create the migration instead of all the stuff that we are going to delete anyway !?
|
94
94
|
|
95
95
|
say "- Devise User model install with added name and locale field..."
|
96
|
-
run "bundle exec rails g devise User name:string
|
96
|
+
run "bundle exec rails g devise User name:string locale_id:integer"
|
97
97
|
|
98
98
|
say "- Replace Devise route and add path_prefix..."
|
99
99
|
gsub_file "config/routes.rb", /devise_for :users/, "devise_for :users, :path_prefix => 'auth'"
|
@@ -129,12 +129,17 @@ create_file "app/models/user.rb", <<-USER_MODEL.strip_heredoc
|
|
129
129
|
# devise :omniauthable
|
130
130
|
|
131
131
|
# Setup accessible (or protected) attributes for your model
|
132
|
-
attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :locale
|
133
132
|
attr_writer :inline_forms_attribute_list
|
133
|
+
attr_accessible :email, :password, :locale, :remember_me
|
134
134
|
|
135
|
+
belongs_to :locale
|
136
|
+
has_and_belongs_to_many :roles
|
137
|
+
|
135
138
|
# validations
|
136
139
|
validates :name, :presence => true
|
137
140
|
|
141
|
+
default_scope order :name
|
142
|
+
|
138
143
|
# pagination
|
139
144
|
attr_reader :per_page
|
140
145
|
@per_page = 7
|
@@ -145,22 +150,31 @@ create_file "app/models/user.rb", <<-USER_MODEL.strip_heredoc
|
|
145
150
|
"\#{name}"
|
146
151
|
end
|
147
152
|
|
153
|
+
def role?(role)
|
154
|
+
return !!self.roles.find_by_name(role)
|
155
|
+
end
|
156
|
+
|
148
157
|
def inline_forms_attribute_list
|
149
158
|
@inline_forms_attribute_list ||= [
|
150
|
-
[ :
|
151
|
-
[ :
|
152
|
-
[ :
|
153
|
-
[ :
|
154
|
-
[ :
|
155
|
-
[ :
|
156
|
-
[ :
|
157
|
-
[ :
|
158
|
-
[ :
|
159
|
-
[ :
|
160
|
-
[ :
|
161
|
-
[ :
|
162
|
-
[ :
|
163
|
-
[ :
|
159
|
+
[ :header_user_login, '', :header ],
|
160
|
+
[ :name, '', :text_field ],
|
161
|
+
[ :email, '', :text_field ],
|
162
|
+
[ :locale , '', :dropdown ],
|
163
|
+
[ :password, '', :devise_password_field ],
|
164
|
+
[ :header_user_roles, '', :header ],
|
165
|
+
[ :roles, '', :check_list ],
|
166
|
+
[ :header_user_other_stuff, '', :header ],
|
167
|
+
[ :encrypted_password, '', :info ],
|
168
|
+
[ :reset_password_token, '', :info ],
|
169
|
+
[ :reset_password_sent_at, '', :info],
|
170
|
+
[ :remember_created_at, '', :info ],
|
171
|
+
[ :sign_in_count, '', :info ],
|
172
|
+
[ :current_sign_in_at, '', :info ],
|
173
|
+
[ :last_sign_in_at, '', :info ],
|
174
|
+
[ :current_sign_in_ip, '', :info ],
|
175
|
+
[ :last_sign_in_ip, '', :info ],
|
176
|
+
[ :created_at, '', :info ],
|
177
|
+
[ :updated_at, '', :info ],
|
164
178
|
]
|
165
179
|
end
|
166
180
|
|
@@ -169,14 +183,46 @@ create_file "app/models/user.rb", <<-USER_MODEL.strip_heredoc
|
|
169
183
|
end
|
170
184
|
|
171
185
|
def self.order_by_clause
|
172
|
-
|
186
|
+
nil
|
173
187
|
end
|
174
188
|
|
175
189
|
end
|
176
190
|
USER_MODEL
|
177
191
|
|
178
|
-
|
192
|
+
say "- Adding admin user with email: #{ENV['email']}, password: #{ENV['password']} to seeds.rb"
|
193
|
+
append_to_file "db/seeds.rb", "User.create({ id: 1, email: '#{ENV['email']}', locale_id: 1, name: 'Admin', password: '#{ENV['password']}', password_confirmation: '#{ENV['password']}' }, without_protection: true)\n"
|
194
|
+
|
195
|
+
# Create Locales
|
196
|
+
say "- Create locales"
|
197
|
+
generate "inline_forms", "Locale name:string title:string users:has_many _enabled:yes _presentation:\#{title}"
|
198
|
+
append_to_file "db/seeds.rb", "Locale.create({ id: 1, name: 'en', title: 'English' }, without_protection: true)\n"
|
199
|
+
|
200
|
+
# Create Roles
|
201
|
+
say "- Create roles"
|
202
|
+
generate "inline_forms", "Role name:string description:text users:has_and_belongs_to_many _enabled:yes _presentation:\#{name}"
|
203
|
+
sleep 1 # to get unique migration number
|
204
|
+
create_file "db/migrate/" +
|
205
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S") +
|
206
|
+
"_" +
|
207
|
+
"inline_forms_create_join_table_user_role.rb", <<-ROLES_MIGRATION.strip_heredoc
|
208
|
+
class InlineFormsCreateJoinTableUserRole < ActiveRecord::Migration
|
209
|
+
def self.up
|
210
|
+
create_table :roles_users, :id => false, :force => true do |t|
|
211
|
+
t.integer :role_id
|
212
|
+
t.integer :user_id
|
213
|
+
end
|
214
|
+
execute 'INSERT INTO roles_users VALUES (1,1);'
|
215
|
+
end
|
216
|
+
|
217
|
+
def self.down
|
218
|
+
drop_table roles_users
|
219
|
+
end
|
220
|
+
end
|
221
|
+
ROLES_MIGRATION
|
222
|
+
|
223
|
+
append_to_file "db/seeds.rb", "Role.create({ id: 1, name: 'superadmin', description: 'Super Admin can access all.' }, without_protection: true)\n"
|
179
224
|
|
225
|
+
# TODO ROYTJE This above is all that: Devise creates a model. That is a migration, a test, a route and a model. We delete the model, the route, and the test probably too. Is there another way to just create the migration instead of all the stuff that we are going to delete anyway !?
|
180
226
|
|
181
227
|
say "- Install ckeditor..."
|
182
228
|
generate "ckeditor:install --backend=carrierwave"
|
@@ -190,8 +236,6 @@ route "mount Ckeditor::Engine => '/ckeditor'"
|
|
190
236
|
say "- Add ckeditor autoload_paths to application.rb..."
|
191
237
|
application "config.autoload_paths += %W(\#{config.root}/app/models/ckeditor)" # TODO ROYTJE is this still needed?
|
192
238
|
|
193
|
-
|
194
|
-
|
195
239
|
say "- Add ckeditor/init to application.js..."
|
196
240
|
insert_into_file "app/assets/javascripts/application.js",
|
197
241
|
"//= require ckeditor/init\n",
|
@@ -209,6 +253,7 @@ generate "paper_trail:install" # TODO One day, we need some management tools so
|
|
209
253
|
say "- Installaing ZURB Foundation..."
|
210
254
|
generate "foundation:install", "-f"
|
211
255
|
|
256
|
+
# Create Translations
|
212
257
|
say "- Generate models and tables and views for translations..." # TODO Translations need to be done in inline_forms, and then generate a yml file, perhaps
|
213
258
|
generate "inline_forms", "InlineFormsLocale name:string inline_forms_translations:belongs_to _enabled:yes _presentation:\#{name}"
|
214
259
|
generate "inline_forms", "InlineFormsKey name:string inline_forms_translations:has_many inline_forms_translations:associated _enabled:yes _presentation:\#{name}"
|
@@ -236,11 +281,11 @@ create_file "db/migrate/" +
|
|
236
281
|
end
|
237
282
|
VIEW_MIGRATION
|
238
283
|
|
284
|
+
|
239
285
|
say "- Migrating Database (only when using sqlite)"
|
240
286
|
run "bundle exec rake db:migrate" if ENV['using_sqlite'] == 'true'
|
241
287
|
|
242
|
-
|
243
|
-
append_to_file "db/seeds.rb", "User.create({ :email => '#{ENV['email']}', :name => 'Admin', :password => '#{ENV['password']}', :password_confirmation => '#{ENV['password']}'}, :without_protection => true)"
|
288
|
+
|
244
289
|
|
245
290
|
say "- Seeding the database (only when using sqlite)"
|
246
291
|
run "bundle exec rake db:seed" if ENV['using_sqlite'] == 'true'
|
@@ -313,7 +358,7 @@ create_file "app/controllers/application_controller.rb", <<-END_APPCONTROLLER.st
|
|
313
358
|
end
|
314
359
|
END_APPCONTROLLER
|
315
360
|
|
316
|
-
say "- Creating Ability model so that the
|
361
|
+
say "- Creating Ability model so that the superadmin can access all..."
|
317
362
|
create_file "app/models/ability.rb", <<-END_ABILITY.strip_heredoc
|
318
363
|
class Ability
|
319
364
|
include CanCan::Ability
|
@@ -323,7 +368,10 @@ create_file "app/models/ability.rb", <<-END_ABILITY.strip_heredoc
|
|
323
368
|
|
324
369
|
user ||= user.new # guest user
|
325
370
|
|
326
|
-
|
371
|
+
# use this if you get stuck:
|
372
|
+
# if user.id == 1 #quick hack
|
373
|
+
# can :access, :all
|
374
|
+
if user.role? :superadmin
|
327
375
|
can :access, :all
|
328
376
|
else
|
329
377
|
# put restrictions for other users here
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<meta charset="utf-8" />
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6
6
|
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,400italic' rel='stylesheet' type='text/css' />
|
7
|
-
<title><%=
|
7
|
+
<title><%= application_title + " v" + InlineForms::VERSION -%></title>
|
8
8
|
|
9
9
|
<%= stylesheet_link_tag "application" %>
|
10
10
|
<%= javascript_include_tag "vendor/modernizr" %>
|
@@ -13,21 +13,29 @@
|
|
13
13
|
|
14
14
|
<body>
|
15
15
|
|
16
|
-
<div id="
|
17
|
-
<div class="small-6 small-centered columns">
|
18
|
-
<%= image_tag 'devise_header.png' %>
|
19
|
-
</div>
|
20
|
-
</div>
|
16
|
+
<div id="devise_outer_container">
|
21
17
|
|
18
|
+
<div class="row contain-to-grid">
|
19
|
+
<nav id='devise_top_bar' class="top-bar" data-topbar>
|
20
|
+
<ul class="title-area">
|
21
|
+
<li class="name">
|
22
|
+
<h1><a href="/"><%= application_name %> v<%= inline_forms_version %></a></h1>
|
23
|
+
</li>
|
24
|
+
<li class="toggle-topbar menu-icon">
|
25
|
+
<a href="#"><span></span></a>
|
26
|
+
</li>
|
27
|
+
</ul>
|
28
|
+
<section class="top-bar-section">
|
29
|
+
<ul class="right">
|
30
|
+
</ul>
|
31
|
+
</section>
|
32
|
+
</nav>
|
33
|
+
</div>
|
34
|
+
<% flash.each do |name, msg| %>
|
35
|
+
<%= content_tag :div, msg, :id => "flash_#{name}", :class => "flash row" %>
|
36
|
+
<% end %>
|
22
37
|
<%= yield %>
|
23
38
|
|
24
|
-
<div id="devise-footer" class="row">
|
25
|
-
<div class="small-6 columns">
|
26
|
-
<%= image_tag 'devise_footer_left.png' %>
|
27
|
-
</div>
|
28
|
-
<div class="small-6 columns">
|
29
|
-
<%= image_tag 'devise_footer_right.png' %>
|
30
|
-
</div>
|
31
39
|
</div>
|
32
40
|
|
33
41
|
<%= javascript_include_tag "application" %>
|
data/lib/inline_forms/version.rb
CHANGED