mdd 3.0.13 → 3.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/generators/mdwa/sandbox/sandbox_generator.rb +1 -1
- data/lib/generators/mdwa/sandbox/templates/app/controllers/a/administrators_controller.rb +12 -12
- data/lib/generators/mdwa/sandbox/templates/app/models/administrator.rb +1 -1
- data/lib/generators/mdwa/sandbox/templates/app/views/a/administrators/_administrators.html.erb +1 -1
- data/lib/generators/mdwa/sandbox/templates/app/views/a/administrators/_form.html.erb +1 -1
- data/lib/generators/mdwa/sandbox/templates/db/seeds/site.rb +2 -2
- data/lib/generators/mdwa/templates/templates/scaffold/views/_form_fields.html.erb +1 -1
- data/lib/generators/mdwa/templates/templates/scaffold/views/_list.html.erb +2 -2
- data/lib/generators/mdwa/templates/templates/scaffold/views/show.html.erb +1 -1
- data/lib/generators/mdwa/transform/transform_generator.rb +4 -2
- data/lib/mdwa/dsl/entity.rb +6 -2
- data/lib/mdwa/version.rb +1 -1
- metadata +4 -4
@@ -110,7 +110,7 @@ module Mdwa
|
|
110
110
|
if ask_question("Generate models?")
|
111
111
|
copy_file 'app/models/ability.rb', 'app/models/ability.rb'
|
112
112
|
copy_file 'app/models/user.rb', 'app/models/user.rb'
|
113
|
-
copy_file 'app/models/administrator.rb', 'app/models/administrator.rb'
|
113
|
+
copy_file 'app/models/administrator.rb', 'app/models/a/administrator.rb'
|
114
114
|
copy_file 'app/models/permission.rb', 'app/models/permission.rb'
|
115
115
|
end
|
116
116
|
end
|
@@ -4,7 +4,7 @@ class A::AdministratorsController < A::BackendController
|
|
4
4
|
load_and_authorize_resource
|
5
5
|
|
6
6
|
def index
|
7
|
-
@administrators = Administrator.paginate :page => params[:page]
|
7
|
+
@administrators = A::Administrator.paginate :page => params[:page]
|
8
8
|
|
9
9
|
respond_to do |format|
|
10
10
|
format.html # index.html.erb
|
@@ -12,7 +12,7 @@ class A::AdministratorsController < A::BackendController
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def show
|
15
|
-
@administrator = Administrator.find(params[:id])
|
15
|
+
@administrator = A::Administrator.find(params[:id])
|
16
16
|
|
17
17
|
respond_to do |format|
|
18
18
|
format.html # show.html.erb
|
@@ -20,7 +20,7 @@ class A::AdministratorsController < A::BackendController
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def new
|
23
|
-
@administrator = Administrator.new
|
23
|
+
@administrator = A::Administrator.new
|
24
24
|
|
25
25
|
respond_to do |format|
|
26
26
|
format.html # new.html.erb
|
@@ -28,16 +28,16 @@ class A::AdministratorsController < A::BackendController
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def edit
|
31
|
-
@administrator = Administrator.find(params[:id])
|
31
|
+
@administrator = A::Administrator.find(params[:id])
|
32
32
|
end
|
33
33
|
|
34
34
|
def edit_own_account
|
35
|
-
@administrator = Administrator.find(current_user.id)
|
35
|
+
@administrator = A::Administrator.find(current_user.id)
|
36
36
|
render 'edit'
|
37
37
|
end
|
38
38
|
|
39
39
|
def create
|
40
|
-
@administrator = Administrator.new(params[:
|
40
|
+
@administrator = A::Administrator.new(params[:a_administrator])
|
41
41
|
|
42
42
|
respond_to do |format|
|
43
43
|
if @administrator.save
|
@@ -49,15 +49,15 @@ class A::AdministratorsController < A::BackendController
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def update
|
52
|
-
@administrator = Administrator.find(params[:id])
|
52
|
+
@administrator = A::Administrator.find(params[:id])
|
53
53
|
# if password is blank, delete from params
|
54
|
-
if params[:
|
55
|
-
params[:
|
56
|
-
params[:
|
54
|
+
if params[:a_administrator][:password].blank?
|
55
|
+
params[:a_administrator].delete :password
|
56
|
+
params[:a_administrator].delete :password_confirmation
|
57
57
|
end
|
58
58
|
|
59
59
|
respond_to do |format|
|
60
|
-
if @administrator.update_attributes(params[:
|
60
|
+
if @administrator.update_attributes(params[:a_administrator])
|
61
61
|
format.html { redirect_to a_administrators_path, notice: t('administrators.update_success') }
|
62
62
|
else
|
63
63
|
format.html { render action: "edit" }
|
@@ -68,7 +68,7 @@ class A::AdministratorsController < A::BackendController
|
|
68
68
|
# DELETE /administrators/1
|
69
69
|
# DELETE /administrators/1.json
|
70
70
|
def destroy
|
71
|
-
@administrator = Administrator.find(params[:id])
|
71
|
+
@administrator = A::Administrator.find(params[:id])
|
72
72
|
|
73
73
|
if current_user.id == params[:id].to_i
|
74
74
|
redirect_to a_administrators_path, notice: t('administrators.destroy_cant_delete_own_user')
|
data/lib/generators/mdwa/sandbox/templates/app/views/a/administrators/_administrators.html.erb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
<td align="center"><%= link_to administrator.id, edit_a_administrator_path(administrator) %></td>
|
11
11
|
<td><%= link_to administrator.name, edit_a_administrator_path(administrator) %></td>
|
12
12
|
<td><%= administrator.email %></td>
|
13
|
-
<td><%= link_to t('system.index_remove_label'),
|
13
|
+
<td><%= link_to t('system.index_remove_label'), administrator, :method => :delete, :confirm => t('system.index_confirm_deletion') %></td>
|
14
14
|
</tr>
|
15
15
|
<% end %>
|
16
16
|
</table>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
Permission.create( :name => "SuperAdmin" ) if Permission.find_by_name("SuperAdmin").nil?
|
3
3
|
|
4
|
-
if Administrator.count.zero?
|
5
|
-
Administrator.create :name => "Administrator", :email => 'admin@admin.com', :password => 'admin123', :password_confirmation => 'admin123'
|
4
|
+
if A::Administrator.count.zero?
|
5
|
+
A::Administrator.create :name => "Administrator", :email => 'admin@admin.com', :password => 'admin123', :password_confirmation => 'admin123'
|
6
6
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
===entity_code===
|
2
|
-
<%- @model.attributes.each do |attr| -%>
|
2
|
+
<%- @model.attributes.select{|a| a.name != 'id' and a.name != 'created_at' and a.name != 'updated_at'}.each do |attr| -%>
|
3
3
|
<div class="field">
|
4
4
|
<%%= f.label :<%= attr.name %> %>
|
5
5
|
<%- if attr.type.to_sym == :file -%>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<thead>
|
4
4
|
<th class="list_show"><%%= t 'system.index_id' %></th>
|
5
5
|
<th class="list_edit"><%%= t 'system.index_edit' %></th>
|
6
|
-
<%- @model.attributes.each do |attr| -%>
|
6
|
+
<%- @model.attributes.select{|a| a.name != 'id' and a.name != 'created_at' and a.name != 'updated_at'}.each do |attr| -%>
|
7
7
|
<th><%%= t '<%= @model.plural_name %>.index_<%= attr.name %>' %></th>
|
8
8
|
<%- end -%>
|
9
9
|
<%- @model.associations.each do |assoc| -%>
|
@@ -20,7 +20,7 @@
|
|
20
20
|
<td>
|
21
21
|
<%%= link_to t('system.index_edit_label'), edit_<%= @model.object_name %>_path(<%= @model.singular_name %>) <%= ", :class => 'lightbox various fancybox.ajax'" if @entity.ajax %> %>
|
22
22
|
</td>
|
23
|
-
<%- @model.attributes.each do |attr| -%>
|
23
|
+
<%- @model.attributes.select{|a| a.name != 'id' and a.name != 'created_at' and a.name != 'updated_at'}.each do |attr| -%>
|
24
24
|
<td>
|
25
25
|
<%- if attr.type.to_sym == :file -%>
|
26
26
|
<%% unless <%= @model.singular_name %>.<%= attr.name %>_file_name.blank? %>
|
@@ -5,7 +5,7 @@
|
|
5
5
|
</div>
|
6
6
|
|
7
7
|
<div class="inside">
|
8
|
-
<%- @model.attributes.each do |attr| -%>
|
8
|
+
<%- @model.attributes.select{|a| a.name != 'id' and a.name != 'created_at' and a.name != 'updated_at'}.each do |attr| -%>
|
9
9
|
<div class="field">
|
10
10
|
<label><%%= t '<%= @model.plural_name %>.show_<%= attr.name %>' %></label>
|
11
11
|
<%- if attr.type.to_sym == :file -%>
|
@@ -199,7 +199,7 @@ module Mdwa
|
|
199
199
|
model_class.columns.each do |column|
|
200
200
|
|
201
201
|
# ignore rails default columns and attributes used in associations
|
202
|
-
next if column.name
|
202
|
+
next if column.name.end_with? '_id'
|
203
203
|
|
204
204
|
entity_attribute = entity.attributes[column.name]
|
205
205
|
# model attribute exists, but not in entity -> was erased
|
@@ -207,7 +207,8 @@ module Mdwa
|
|
207
207
|
@changes << {:entity => entity, :type => 'remove_column', :column => column.name, :attr_type => column.type}
|
208
208
|
# attribute exists in model and entity, but changed type
|
209
209
|
elsif entity_attribute.type.to_sym != column.type.to_sym
|
210
|
-
|
210
|
+
# ignores files, passwords and float, decimal, integer variations
|
211
|
+
next if entity_attribute.type.to_sym == :file or entity_attribute.type.to_sym == :password or ((column.type.to_sym == :integer or column.type.to_sym == :decimal) and entity_attribute.type.to_sym == :float)
|
211
212
|
@changes << {:entity => entity, :type => 'change_column', :column => column.name, :attr_type => entity_attribute.type, :from => column.type}
|
212
213
|
end
|
213
214
|
end
|
@@ -310,6 +311,7 @@ module Mdwa
|
|
310
311
|
# migration number
|
311
312
|
if ActiveRecord::Base.timestamped_migrations
|
312
313
|
@migration_number = Time.now.utc.strftime("%Y%m%d%H%M%S")
|
314
|
+
sleep 1
|
313
315
|
else
|
314
316
|
@migration_number = "%.3d" % (current_migration_number(Rails.root + 'db/migrate') + 1)
|
315
317
|
end
|
data/lib/mdwa/dsl/entity.rb
CHANGED
@@ -73,6 +73,9 @@ module MDWA
|
|
73
73
|
def after_declaration
|
74
74
|
|
75
75
|
# if it's a user and have no attributes, include "name" to prevent errors
|
76
|
+
self.attribute('id', 'integer')
|
77
|
+
self.attribute('created_at', 'datetime')
|
78
|
+
self.attribute('updated_at', 'datetime')
|
76
79
|
if user?
|
77
80
|
self.attribute('name', 'string')
|
78
81
|
self.attribute('email', 'string')
|
@@ -141,7 +144,8 @@ module MDWA
|
|
141
144
|
# Return an instance of Generators::Model
|
142
145
|
#
|
143
146
|
def generator_model
|
144
|
-
@generator_model = Generators::Model.new(self.
|
147
|
+
@generator_model = Generators::Model.new(self.scaffold_name)
|
148
|
+
@generator_model.specific_model_name = self.model_name if(!self.model_name.blank? and self.model_name != self.scaffold_name)
|
145
149
|
self.attributes.values.each do |attribute|
|
146
150
|
@generator_model.add_attribute Generators::ModelAttribute.new( "#{attribute.name}:#{attribute.type}" )
|
147
151
|
end
|
@@ -168,7 +172,7 @@ module MDWA
|
|
168
172
|
# Selects the default attribute of the entity
|
169
173
|
#
|
170
174
|
def default_attribute
|
171
|
-
default_attr = self.attributes.first
|
175
|
+
default_attr = self.attributes.values.first # first element value
|
172
176
|
self.attributes.each do |key, attr|
|
173
177
|
default_attr = attr if attr.default?
|
174
178
|
end
|
data/lib/mdwa/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mdd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.14
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -482,7 +482,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
482
482
|
version: '0'
|
483
483
|
segments:
|
484
484
|
- 0
|
485
|
-
hash: -
|
485
|
+
hash: -3153241005913851607
|
486
486
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
487
487
|
none: false
|
488
488
|
requirements:
|
@@ -491,7 +491,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
491
491
|
version: '0'
|
492
492
|
segments:
|
493
493
|
- 0
|
494
|
-
hash: -
|
494
|
+
hash: -3153241005913851607
|
495
495
|
requirements: []
|
496
496
|
rubyforge_project: mdd
|
497
497
|
rubygems_version: 1.8.24
|