ava_rails_generator 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -19,6 +19,7 @@ class AvaRailsGenerator < Rails::Generator::NamedBase
19
19
  m.directory('app/helpers')
20
20
  m.directory('app/views/top')
21
21
  m.directory('app/views/auth')
22
+ m.directory('app/views/databases')
22
23
  m.directory('app/views/layouts')
23
24
  m.directory('public/stylesheets')
24
25
  m.directory('public/javascripts')
@@ -28,11 +29,18 @@ class AvaRailsGenerator < Rails::Generator::NamedBase
28
29
  m.file('application_controller.rb', 'app/controllers/application_controller.rb')
29
30
  m.file('auth_controller.rb', 'app/controllers/auth_controller.rb')
30
31
  m.file('top_controller.rb', 'app/controllers/top_controller.rb')
32
+ m.file('databases_controller.rb', 'app/controllers/databases_controller.rb')
31
33
  m.file('application_search.rb', 'app/models/application_search.rb')
34
+ m.file('application_upload.rb', 'app/models/application_upload.rb')
32
35
  m.file('user.rb', 'app/models/user.rb')
36
+ m.file('log.rb', 'app/models/log.rb')
33
37
  m.template('index.html.erb', 'app/views/top/index.html.erb')
34
38
  m.template('login.html.erb', 'app/views/auth/login.html.erb')
35
39
  m.template('password.html.erb', 'app/views/auth/password.html.erb')
40
+ m.file('databases_list.html.erb', 'app/views/databases/list.html.erb')
41
+ m.file('databases_index.html.erb', 'app/views/databases/index.html.erb')
42
+ m.file('databases_new.html.erb', 'app/views/databases/new.html.erb')
43
+ m.file('databases_edit.html.erb', 'app/views/databases/edit.html.erb')
36
44
  m.template('application.html.erb', 'app/views/layouts/application.html.erb')
37
45
 
38
46
  m.file('application_helper.rb', 'app/helpers/application_helper.rb')
@@ -48,6 +56,7 @@ class AvaRailsGenerator < Rails::Generator::NamedBase
48
56
 
49
57
  m.file('001_create_sessions.rb', 'db/migrate/001_create_sessions.rb')
50
58
  m.file('002_create_users.rb', 'db/migrate/002_create_users.rb')
59
+ m.file('003_create_logs.rb', 'db/migrate/003_create_logs.rb')
51
60
 
52
61
  Dir.glob(source_path('*.css')).each {|f|
53
62
  m.file(File.basename(f), File.join('public/stylesheets', File.basename(f)))
@@ -156,6 +165,14 @@ EOS
156
165
  map.root :controller => :auth, :action => :login
157
166
  map.top 'top', :controller => :top, :action => :index
158
167
 
168
+ map.connect '/databases', :controller => :databases, :action => :list
169
+ map.connect '/database/:tablename.:format', :controller => :databases, :action => :index
170
+ map.connect '/database/new/:tablename', :controller => :databases, :action => :new
171
+ map.connect '/database/cre/:tablename', :controller => :databases, :action => :create, :conditions => { :method => :post }
172
+ map.connect '/database/:tablename/:id/edit', :controller => :databases, :action => :edit
173
+ map.connect '/database/:tablename/:id', :controller => :databases, :action => :update, :conditions => { :method => :put }
174
+ map.connect '/database/:tablename/:id', :controller => :databases, :action => :destroy,:conditions => { :method => :delete }
175
+
159
176
  EOS
160
177
  match.gsub("\n\n", s)
161
178
  end
@@ -11,7 +11,7 @@ class CreateUsers < ActiveRecord::Migration
11
11
  end
12
12
  add_index :users, :account, :unique => true
13
13
 
14
- User.create(:account => 'test', :name => '[Built-in]Masaki Ozawa')
14
+ User.create(:account => 'test', :name => 'Built-in User')
15
15
  end
16
16
 
17
17
  def self.down
@@ -0,0 +1,15 @@
1
+ class CreateLogs < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :logs do |t|
4
+ t.integer :user_id, :null => false
5
+ t.string :action
6
+ t.string :error
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+
12
+ def self.down
13
+ drop_table :logs
14
+ end
15
+ end
@@ -3,16 +3,25 @@ module ActiveSupport
3
3
  module Array
4
4
  module Conversions
5
5
 
6
- def to_csv(instance, options = {})
6
+ def to_csv(options = {})
7
7
  require 'csv'
8
8
  require 'kconv'
9
9
 
10
+ instance = options[:instance]
11
+ unless instance.blank?
12
+ columns = instance.columns
13
+ table_name = instance.table_name
14
+ else
15
+ columns = options[:columns]
16
+ table_name = options[:table_name]
17
+ end
18
+
10
19
  o_keys = []
11
20
  o_names = []
12
21
  o_types = []
13
- instance.columns.each{|column|
22
+ columns.each{|column|
14
23
  o_keys << column.name
15
- name = I18n.t(column.name, :scope => [:activerecord, :attributes, instance.table_name.singularize]) #ApplicationController.helpers.hlabel(:order, column.name)
24
+ name = I18n.t(column.name, :scope => [:activerecord, :attributes, table_name.singularize]) #ApplicationController.helpers.hlabel(:order, column.name)
16
25
  name = I18n.t(column.name, :scope => [:activerecord, :attributes, :commons]) if name.index("translation missing") && name.index("translation missing").to_i >= 0
17
26
  name = column.name if name.index("translation missing") && name.index("translation missing").to_i >= 0
18
27
  o_names << name
@@ -43,11 +52,11 @@ module ActiveSupport
43
52
  a1 = []
44
53
  keys.each_with_index{|key,j|
45
54
  begin
46
- s = all.read_attribute(key)
47
- s = s.gsub(/\r\n|\r|\n/, " ")
55
+ s = (instance.blank? ? all[key] : all.read_attribute(key))
56
+ s = s.gsub(/\r\n|\r|\n/, " ") if s.type.to_s == "String"
48
57
  s = Kconv.tosjis(s)
49
- s = '"' + s + '"' unless o_types[j] == ":integer" || s.index(",") > 0
50
- rescue
58
+ s = '"' + s + '"' unless o_types[j].blank? && (o_types[j] == ":integer" || s.index(",") > 0)
59
+ rescue => e
51
60
  end
52
61
  a1 << s
53
62
  }
@@ -126,7 +126,8 @@ EOS
126
126
  login_account = @user.account
127
127
  login_name = @user.name
128
128
  company = APP_COMPANY
129
- link_password = '<li>' + link_to("パスワード変更", "javascript:void(0);", :onclick => "javascript:pop('" + url_for(:controller => :auth, :action => :password) + "', '600', 'passwordsetting');") + '</li>'
129
+ link_database = '<li>' + link_to("データベース設定", "javascript:void(0);", :onclick => "javascript:pop('" + url_for(:controller => :databases, :action => :list) + "', '600', 'databasesetting');") + '</li>'
130
+ link_password = '<li>' + link_to("パスワード変更", "javascript:void(0);", :onclick => "javascript:pop('" + url_for(:controller => :auth, :action => :password ) + "', '600', 'passwordsetting');") + '</li>'
130
131
  link_logout = '<li>' + link_to('ログアウト', :controller => :auth, :action => :logout ) + '</li>'
131
132
 
132
133
  str =<<"EOS"
@@ -136,6 +137,7 @@ EOS
136
137
  <div id="hBox">
137
138
  <h2 id="hCompany">#{company}</h2>
138
139
  <ul id="hNavi">
140
+ #{link_database}
139
141
  #{link_password}
140
142
  #{link_logout}
141
143
  </ul>
@@ -181,7 +183,7 @@ EOS
181
183
 
182
184
  # メッセージ
183
185
  def message(options = {})
184
-
186
+ return ""
185
187
  js = remote_function(:url => {:controller => :auth, :action => :open_close }, :with => "'flag=' + flag" , :update => "msgBtn")
186
188
  jsstr =<<"EOS"
187
189
  function openclose(){
@@ -382,6 +384,11 @@ EOS
382
384
  EOS
383
385
  end
384
386
 
387
+ # 一覧ページネートボタン
388
+ def paginate_tag(obj)
389
+ will_paginate obj, :previous_label => "&nbsp;", :next_label => "&nbsp;"
390
+ end
391
+
385
392
  # 前へ次へボタン
386
393
  def prevnext_tag
387
394
  ids = session[:ids]
@@ -415,8 +422,9 @@ EOS
415
422
  end
416
423
 
417
424
  # 新規作成ボタン
418
- def new_button_tag
419
- link_to image_tag('/images/btn_new.png', :alt => '新規作成', :style => 'vertical-align: middle;'), {:controller => controller_name, :action => :new}
425
+ def new_button_tag(options = {})
426
+ params = options[:params]
427
+ link_to image_tag('/images/btn_new.png', :alt => '新規作成', :style => 'vertical-align: middle;'), {:controller => controller_name, :action => :new, :params => params}
420
428
  end
421
429
 
422
430
  # 最新に更新ボタン
@@ -425,7 +433,7 @@ EOS
425
433
  end
426
434
 
427
435
  # 修正ボタン
428
- def edit_button_tag
436
+ def edit_button_tag(options = {})
429
437
  link_to image_tag('/images/btn_upd.png', :alt => '修正' ), {:controller => controller_name, :action => :edit, :id => params[:id]}
430
438
  end
431
439
 
@@ -0,0 +1,138 @@
1
+ class ApplicationUpload
2
+
3
+ attr_accessor :filename
4
+ attr_accessor :content_type
5
+ attr_accessor :size
6
+ attr_accessor :data
7
+
8
+ def initialize(file)
9
+ unless file.blank?
10
+ begin
11
+ @filename = file.original_filename.gsub(/[^\w!\#$%&()=^~|@`\[\]\{\};+,.-]/u, '')
12
+ @content_type = file.content_type.gsub(/[^\w.+;=_\/-]/n, '')
13
+ @size = file.size
14
+ @data = file.read
15
+ rescue
16
+ end
17
+ end
18
+ end
19
+
20
+
21
+ def to_a
22
+ require 'csv'
23
+
24
+ arrs = []
25
+ CSV.parse(@data){|line|
26
+ row = []
27
+ line.each_with_index{|col,j|
28
+ row << col
29
+ }
30
+ arrs << row
31
+ }
32
+ return arrs
33
+ end
34
+
35
+
36
+ def import(instance)
37
+ upload_msga = []
38
+ upload_cols = instance.columns
39
+ exclude_cols = ["id", "lock_version", "created_at", "updated_at"]
40
+
41
+ self.to_a.each_with_index{|row,i|
42
+ if i > 0
43
+ id = 0
44
+ object = nil
45
+ row.each_with_index{|data,j|
46
+ data = Kconv.toutf8(data.to_s)
47
+ if j == 0
48
+ begin
49
+ id = data.to_i
50
+ object = instance.find(id)
51
+ rescue
52
+ id = 0
53
+ object = instance.new
54
+ upload_cols.each{|col|
55
+ if exclude_cols.index(col.name).blank?
56
+ object[col.name] = ""
57
+ object[col.name] = 0 if col.type.to_s == "integer"
58
+ end
59
+ }
60
+ end
61
+
62
+ else
63
+ begin
64
+ if exclude_cols.index(upload_cols[j].name).blank?
65
+ begin
66
+ object[upload_cols[j].name] = data
67
+ rescue
68
+ object[upload_cols[j].name] = ""
69
+ end
70
+ end
71
+ rescue
72
+ end
73
+
74
+ if j == (upload_cols.size - 1)
75
+ upload_msga << object.errors.full_messages.to_s if object.invalid?
76
+
77
+ if object.save
78
+ id = object.id
79
+ begin
80
+ object_name = object.name_with_id
81
+ rescue
82
+ object_name = sprintf(FORMAT_NAME_WITH_ID, object.id, object.name)
83
+ end
84
+ upload_msga << object_name + (id == 0 ? " create." : " update.")
85
+ end
86
+
87
+ end
88
+ end
89
+ }
90
+ end
91
+ }
92
+
93
+ upload_msgs = upload_msga.join("/")
94
+ return upload_msgs
95
+ end
96
+
97
+ def import_by_sql(table)
98
+ msg = []
99
+ col = []
100
+ sql_header = ""
101
+ sql = ""
102
+ exd = ["id", "lock_version", "created_at", "updated_at"]
103
+
104
+ self.to_a.each_with_index{|row,i|
105
+ if i == 0
106
+ sql_header = "insert into #{table} ("
107
+ row.each_with_index{|data,j|
108
+ if exd.index(data).blank?
109
+ col << data
110
+ sql_header += data + ","
111
+ end
112
+ }
113
+ sql_header = sql_header.slice(0, sql_header.size - 1)
114
+ sql_header += ") values ("
115
+
116
+ elsif i > 0
117
+ sql = sql_header
118
+ row.each_with_index{|data,j|
119
+ if exd.index(data[j]).blank?
120
+ data = Kconv.toutf8(data.to_s)
121
+ sql += "'" + data.gsub("'", " ") + "',"
122
+ end
123
+ }
124
+ sql = sql.slice(0, sql.size - 1)
125
+ sql += ")"
126
+
127
+ begin
128
+ ActiveRecord::Base.connection.execute(sql)
129
+ rescue => e
130
+ p e
131
+ end
132
+
133
+ end
134
+ }
135
+ return msg
136
+ end
137
+
138
+ end
@@ -13,21 +13,21 @@ class AuthController < ApplicationController
13
13
  user = User.authenticate(params[:id], params[:password])
14
14
  raise if user.blank?
15
15
  session_set_user(user)
16
- #Log.create(:user_id => user.id, :action => action_name)
16
+ Log.create(:user_id => user.id, :action => action_name)
17
17
  redirect_to(top_url)
18
18
  rescue => e
19
19
  flash.now[:notice] = t(:error_login)
20
- #Log.create(:user_id => 0, :action => action_name, :error => params[:id] + " " + t(:error_login) + " " + e.message)
20
+ Log.create(:user_id => 0, :action => action_name, :error => params[:id] + " " + t(:error_login) + " " + e.message)
21
21
  end
22
22
  end
23
23
  end
24
24
 
25
25
  def logout
26
- # begin
27
- # user = session[:user_id]
28
- #Log.create(:user_id => user.id, :action => action_name) unless user.blank?
29
- # rescue
30
- # end
26
+ begin
27
+ user = session[:user_id]
28
+ Log.create(:user_id => user.id, :action => action_name) unless user.blank?
29
+ rescue
30
+ end
31
31
  session_reset
32
32
  redirect_to(root_url)
33
33
  end
@@ -0,0 +1,159 @@
1
+ class DatabasesController < ApplicationController
2
+ # GET /databases
3
+ # GET /databases.xml
4
+ def list
5
+ @display_type = DISPLAY_TYPE_SIMPLE
6
+
7
+ @tables = ActiveRecord::Base.connection.tables
8
+
9
+ respond_to do |format|
10
+ format.html # index.html.erb
11
+ format.csv { send_data(@databases.to_csv, :type => "text/csv") }
12
+ # format.xml { send_data(xmls.to_xml, :type => "text/xml; charset=utf8;", :disposition => "attachement") }
13
+ end
14
+ end
15
+
16
+ # POST /database
17
+ # POST /database.xml
18
+ def import
19
+ table = params[:tablename]
20
+ upload_file = ApplicationUpload.new(params[:file])
21
+ ActiveRecord::Base.connection.execute("update sqlite_sequence set seq=0 where name='" + table + "'")
22
+ # ActiveRecord::Base.connection.execute("alter table " + table + " auto_increment=1")
23
+ ActiveRecord::Base.connection.execute("delete from " + table)
24
+ upload_msgs = upload_file.import_by_sql(table)
25
+
26
+ flash[:notice] = t(:success_default) unless upload_msgs.blank?
27
+ redirect_to(:controller => :databases, :action => :index, :tablename=> table)
28
+ end
29
+
30
+ # GET /database/xxx
31
+ # GET /database/xxx.xml
32
+ def index
33
+ @display_type = DISPLAY_TYPE_SIMPLE
34
+
35
+ # @app_search.default 'id', 'desc'
36
+ # @app_search.sort 'name', 'databases.name'
37
+
38
+ @tablename = params[:tablename]
39
+ @columns = ActiveRecord::Base.connection.columns(@tablename)
40
+
41
+ where = ""
42
+ unless params[:keyword].blank?
43
+ where = " where"
44
+ @columns.each{|column|
45
+ where += " #{column.name} like '#{@app_search.keyword}' or"
46
+ }
47
+ where = where.slice(0, where.size - 2)
48
+ end
49
+
50
+ alls = ActiveRecord::Base.connection.execute("select * from " + @tablename + where)
51
+
52
+ session_set_ids(alls)
53
+ session[:prm].delete(:tablename)
54
+ page = alls.paginate(:page => params[:page], :per_page => PAGINATE_PER_PAGE);
55
+ @databases = page
56
+
57
+ xmls = alls
58
+
59
+ respond_to do |format|
60
+ format.html # index.html.erb
61
+ format.csv { send_data(xmls.to_csv(:columns => @columns, :table_name => @tablename), :type => "text/csv") }
62
+ # format.xml { send_data(xmls.to_xml, :type => "text/xml; charset=utf8;", :disposition => "attachement") }
63
+ end
64
+ end
65
+
66
+ # GET /databases/new/xxx
67
+ def new
68
+ @display_type = DISPLAY_TYPE_SIMPLE
69
+
70
+ @database = set_ar(params).new
71
+
72
+ @columns = ActiveRecord::Base.connection.columns(@tablename)
73
+ # @columns.delete_if {|x| ["id","created_at","updated_at"].include?(x.name) }
74
+ end
75
+
76
+ # GET /databases/xxxx/edit/1
77
+ def edit
78
+ @display_type = DISPLAY_TYPE_SIMPLE
79
+
80
+ @database = set_ar(params).find(params[:id])
81
+
82
+ @columns = ActiveRecord::Base.connection.columns(@tablename)
83
+ # @columns.delete_if {|x| ["id","created_at","updated_at"].include?(x.name) }
84
+ end
85
+
86
+ # POST /databases/xxx
87
+ def create
88
+ @display_type = DISPLAY_TYPE_SIMPLE
89
+
90
+ begin
91
+ @database = set_ar(params).new
92
+
93
+ @columns = ActiveRecord::Base.connection.columns(@tablename)
94
+ @columns.delete_if {|x| ["id","created_at","updated_at"].include?(x.name) }
95
+ @columns.each{|column|
96
+ key = column.name
97
+ val = params[column.name]
98
+ @database.update_attributes(key => val)
99
+ }
100
+
101
+ flash[:notice] = t(:success_created, :id => @database.id)
102
+ redirect_to(:controller => :databases, :action => :edit, :tablename => @tablename, :id => @database.id)
103
+ # redirect_to(:controller => :databases, :action => :index, :tablename => @tablename)
104
+ rescue => e
105
+ flash[:error] = t(:error_default, :message => e.message)
106
+ render :action => :new
107
+ end
108
+ end
109
+
110
+ # PUT /databases/1
111
+ def update
112
+ @display_type = DISPLAY_TYPE_SIMPLE
113
+
114
+ begin
115
+ @database = set_ar(params).find(params[:id])
116
+
117
+ @columns = ActiveRecord::Base.connection.columns(@tablename)
118
+ @columns.delete_if {|x| ["id","created_at","updated_at"].include?(x.name) }
119
+ @columns.each{|column|
120
+ key = column.name
121
+ val = params[column.name]
122
+ @database.update_attributes(key => val)
123
+ }
124
+
125
+ flash[:notice] = t(:success_updated, :id => @database.id)
126
+ redirect_to(:controller => :databases, :action => :edit, :tablename => @tablename, :id => @database.id)
127
+ rescue => e
128
+ flash[:error] = t(:error_default, :message => e.message)
129
+ render :action => :edit
130
+ end
131
+ end
132
+
133
+ # DELETE /databases/1
134
+ # DELETE /databases/1.xml
135
+ def destroy
136
+ @display_type = DISPLAY_TYPE_SIMPLE
137
+
138
+ begin
139
+ @database = set_ar(params).find(params[:id])
140
+
141
+ @database.destroy
142
+
143
+ flash[:notice] = t(:success_deleted, :id => @database.id)
144
+ redirect_to(:action => :index)
145
+ rescue => e
146
+ flash[:error] = t(:error_default, :message => e.message)
147
+ render :action => :index
148
+ end
149
+ end
150
+
151
+
152
+ protected
153
+ def set_ar(params)
154
+ @tablename = params[:tablename]
155
+ ar = Class.new(ActiveRecord::Base)
156
+ ar.set_table_name(@tablename)
157
+ return ar
158
+ end
159
+ end
@@ -0,0 +1,61 @@
1
+ <% form_for(@database, :url => { :action => :update, :tablename => @tablename }, :html => { :method => :put }) do |f| %>
2
+
3
+ <%#= menu %>
4
+ <div id="contents">
5
+ <%#= submenu %>
6
+
7
+ <div id="main">
8
+
9
+ <%= message %>
10
+
11
+ <%= pagetitle :title => "database [" + @tablename + "]" %>
12
+
13
+ <div class="sheet">
14
+
15
+ <%= f.error_messages %>
16
+ <%= flash_tag %>
17
+
18
+ <% content_for :button do %>
19
+ <div class="commonBtnArea">
20
+ <div class="centerBox">
21
+ <%#= delete_button_tag(Class.new(ActiveRecord::Base).set_table_name(@tablename)) %>
22
+ <%# obj = Class.new(ActiveRecord::Base).set_table_name(@tablename) %>
23
+ <%= link_to image_tag('/images/btn_delete.png', :alt => '削除', :style => 'float: right;'), {:action => :destroy}, :confirm => '削除してもよろしいですか?', :method => :delete %>
24
+ <%= submit_button_tag(f, :value => '/images/btn_update.png') %>
25
+ <%= index_button_tag %>
26
+ </div>
27
+ <!--/ commonBtnArea--></div>
28
+ <% end %>
29
+
30
+ <%#= yield :button %>
31
+
32
+ <%= pagesubtitle %>
33
+ <%= required_notice_tag %>
34
+
35
+ <table class="commonSheet">
36
+ <% @columns.each do |column| %>
37
+ <tr>
38
+ <th><%= f.label column.name %><%#=hlabel @tablename.singularize, column.name %></th>
39
+ <td>
40
+ <% if ["id","created_at","updated_at"].include?(column.name) -%>
41
+ <% if column.type.to_s == "datetime" -%>
42
+ <%=hdate @database[column.name] -%>
43
+ <% else -%>
44
+ <%=h @database[column.name] -%>
45
+ <% end -%>
46
+ <% else -%>
47
+ <%= f.text_field column.name -%>
48
+ <% end -%>
49
+ </td>
50
+ </tr>
51
+ <% end %>
52
+ </table>
53
+
54
+ </div>
55
+
56
+ <%= yield :button %>
57
+
58
+ <!--/ #main--></div>
59
+ <!--/ #contents--></div>
60
+
61
+ <% end %>
@@ -0,0 +1,67 @@
1
+ <%#= menu %>
2
+
3
+ <div id="contents">
4
+ <%#= submenu %>
5
+
6
+ <div id="main">
7
+
8
+ <%#= message %>
9
+
10
+ <%= pagetitle :title => "database [" + @tablename + "]" %>
11
+
12
+ <%= flash_tag %>
13
+
14
+ <div class="commonBtnArea">
15
+ <div class="leftBox">
16
+ <%= search_tag %>
17
+ </div>
18
+ <div class="rightBox">
19
+ <%= csv_button_tag %>
20
+ <%= new_button_tag :params => {:tablename => @tablename} %>
21
+ </div>
22
+ <!--/ commonBtnArea--></div>
23
+
24
+ <div class="list">
25
+ <%= paginate_tag @databases %>
26
+ <%= counter_tag %>
27
+ <table class="commonList">
28
+ <thead>
29
+ <tr>
30
+ <% @columns.each do |column| %>
31
+ <th><%=h column.name %></th>
32
+ <% end %>
33
+ </tr>
34
+ </thead>
35
+ <tbody>
36
+ <% @databases.each do |database| %>
37
+ <tr>
38
+ <% @columns.each do |column| %>
39
+ <td><%=link_to database[column.name].blank? ? "": database[column.name], :controller => :databases, :action => :edit, :tablename => @tablename, :id => database["id"] %></td>
40
+ <% end %>
41
+ </tr>
42
+ <% end %>
43
+ </tbody>
44
+ </table>
45
+ <!--/ list--></div>
46
+
47
+ <div class="commonBtnArea">
48
+ <div class="leftBox">
49
+ <% form_tag({ :action => :import, :tablename => @tablename }, { :multipart => true, :method => :post }) do %>
50
+ <h3><%= hlabel :import, :file %></h3>
51
+ <%#= note "Let's write an explanatory note later!" %><br>
52
+
53
+ <%= file_field_tag :file %>
54
+ <%= submit_tag hlabel(:import, :button), :confirm => hlabel(:import, :message) %>
55
+ <% end %>
56
+ </div>
57
+ <!--/ commonBtnArea--></div>
58
+
59
+ <div class="commonBtnArea">
60
+ <div class="centerBox">
61
+ <%= index_button_tag :action => :list %>
62
+ </div>
63
+ <!--/ commonBtnArea--></div>
64
+
65
+
66
+ <!--/ #main--></div>
67
+ <!--/ #contents--></div>
@@ -0,0 +1,50 @@
1
+ <%#= menu %>
2
+
3
+ <div id="contents">
4
+ <%#= submenu %>
5
+
6
+ <div id="main">
7
+
8
+ <%#= message %>
9
+
10
+ <%= pagetitle :title => "database tables" %>
11
+
12
+ <%= flash_tag %>
13
+
14
+ <!-- div class="commonBtnArea">
15
+ <div class="leftBox">
16
+ <%#= search_tag %>
17
+ </div>
18
+ <div class="rightBox">
19
+ <%#= csv_button_tag %>
20
+ <%#= new_button_tag %>
21
+ </div>
22
+ <!--/ commonBtnArea--><!--/div-->
23
+
24
+ <div class="list">
25
+ <%#= paginate_tag @tables %>
26
+ <%= counter_tag :size => @tables.size %>
27
+ <table class="commonList">
28
+ <thead>
29
+ <tr>
30
+ <th><%=h "table" %></th>
31
+ </tr>
32
+ </thead>
33
+ <tbody>
34
+ <% @tables.each do |table| %>
35
+ <tr>
36
+ <td><%=link_to table, :controller => :databases, :action => :index, :tablename=> table %></td>
37
+ </tr>
38
+ <% end %>
39
+ </tbody>
40
+ </table>
41
+ <!--/ list--></div>
42
+
43
+ <div class="commonBtnArea">
44
+ <div class="centerBox">
45
+ <%= close_button_tag %>
46
+ </div>
47
+ <!--/ commonBtnArea--></div>
48
+
49
+ <!--/ #main--></div>
50
+ <!--/ #contents--></div>
@@ -0,0 +1,58 @@
1
+ <% form_for(@database, :url => { :action => :create, :tablename => @tablename }, :html => { :method => :post }) do |f| %>
2
+
3
+ <%#= menu %>
4
+ <div id="contents">
5
+ <%#= submenu %>
6
+
7
+ <div id="main">
8
+
9
+ <%= message %>
10
+
11
+ <%= pagetitle :title => "database [" + @tablename + "]" %>
12
+
13
+ <div class="sheet">
14
+
15
+ <%= f.error_messages %>
16
+ <%= flash_tag %>
17
+
18
+ <% content_for :button do %>
19
+ <div class="commonBtnArea">
20
+ <div class="centerBox">
21
+ <%= submit_button_tag(f, :value => '/images/btn_create.png') %>
22
+ <%= index_button_tag %>
23
+ </div>
24
+ <!--/ commonBtnArea--></div>
25
+ <% end %>
26
+
27
+ <%#= yield :button %>
28
+
29
+ <%= pagesubtitle %>
30
+ <%= required_notice_tag %>
31
+
32
+ <table class="commonSheet">
33
+ <% @columns.each do |column| %>
34
+ <tr>
35
+ <th><%= f.label column.name %><%#=hlabel @tablename.singularize, column.name %></th>
36
+ <td>
37
+ <% if ["id","created_at","updated_at"].include?(column.name) -%>
38
+ <% if column.type.to_s == "datetime" -%>
39
+ <%=hdate @database[column.name] -%>
40
+ <% else -%>
41
+ <%=h @database[column.name] -%>
42
+ <% end -%>
43
+ <% else -%>
44
+ <%= f.text_field column.name -%>
45
+ <% end -%>
46
+ </td>
47
+ </tr>
48
+ <% end %>
49
+ </table>
50
+
51
+ </div>
52
+
53
+ <%= yield :button %>
54
+
55
+ <!--/ #main--></div>
56
+ <!--/ #contents--></div>
57
+
58
+ <% end %>
@@ -0,0 +1,3 @@
1
+ class Log < ActiveRecord::Base
2
+ belongs_to :user
3
+ end
@@ -10,9 +10,16 @@ ja:
10
10
 
11
11
  activerecord:
12
12
  models:
13
+ log: "ログ"
13
14
  user: "ユーザー"
14
15
 
15
16
  attributes:
17
+ log:
18
+ id: "ログNO"
19
+ user_id: "ユーザーNO"
20
+ action: "アクション"
21
+ error: "エラー"
22
+
16
23
  user:
17
24
  id: "ユーザーNO"
18
25
  name: "名前"
@@ -21,6 +28,11 @@ ja:
21
28
  password_new: "新しいパスワード"
22
29
  password_confirmation: "新しいパスワードの確認"
23
30
 
31
+ import:
32
+ file: "ファイルの選択"
33
+ button: "インポート"
34
+ message: "インポートしますか?"
35
+
24
36
  commons:
25
37
  id: "NO"
26
38
  name: "名称"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ava_rails_generator
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Masaki Ozawa
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-04 00:00:00 +09:00
18
+ date: 2012-04-12 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -110,6 +110,7 @@ files:
110
110
  - ava_rails_generator.rb
111
111
  - templates/001_create_sessions.rb
112
112
  - templates/002_create_users.rb
113
+ - templates/003_create_logs.rb
113
114
  - templates/action_view_helper.rb
114
115
  - templates/action_view_ja.yml
115
116
  - templates/active_record_ja.yml
@@ -122,6 +123,7 @@ files:
122
123
  - templates/application_csv.rb
123
124
  - templates/application_helper.rb
124
125
  - templates/application_search.rb
126
+ - templates/application_upload.rb
125
127
  - templates/arrow_h.gif
126
128
  - templates/arrow_l.png
127
129
  - templates/arrow_n.gif
@@ -160,6 +162,11 @@ files:
160
162
  - templates/builder.js
161
163
  - templates/calendar.gif
162
164
  - templates/csv.rb
165
+ - templates/databases_controller.rb
166
+ - templates/databases_edit.html.erb
167
+ - templates/databases_index.html.erb
168
+ - templates/databases_list.html.erb
169
+ - templates/databases_new.html.erb
163
170
  - templates/default.css
164
171
  - templates/footer_a_bak.gif
165
172
  - templates/footer_m_bak.gif
@@ -175,6 +182,7 @@ files:
175
182
  - templates/layout.css
176
183
  - templates/link.gif
177
184
  - templates/link_t.gif
185
+ - templates/log.rb
178
186
  - templates/login.html.erb
179
187
  - templates/login_back01.png
180
188
  - templates/logo.png