rorchado 0.0.5
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.
- checksums.yaml +7 -0
- data/lib/rails/generators/rorchado/USAGE +16 -0
- data/lib/rails/generators/rorchado/rorchado_generator.rb +259 -0
- data/lib/rails/generators/rorchado/templates/controllers/contact_controller.rb +83 -0
- data/lib/rails/generators/rorchado/templates/controllers/contact_controller.rb~ +83 -0
- data/lib/rails/generators/rorchado/templates/controllers/cv_controller.rb +83 -0
- data/lib/rails/generators/rorchado/templates/controllers/cv_controller.rb~ +83 -0
- data/lib/rails/generators/rorchado/templates/controllers/cvterm_controller.rb +83 -0
- data/lib/rails/generators/rorchado/templates/controllers/cvterm_controller.rb~ +83 -0
- data/lib/rails/generators/rorchado/templates/controllers/stock_controller.rb +83 -0
- data/lib/rails/generators/rorchado/templates/db_schemas/chado_schema.xml +697 -0
- data/lib/rails/generators/rorchado/templates/migrations/generic_migration_create.erb +18 -0
- data/lib/rails/generators/rorchado/templates/models/generic_model.erb +5 -0
- data/lib/rails/generators/rorchado/templates/views/contact/_form.html.erb +29 -0
- data/lib/rails/generators/rorchado/templates/views/contact/edit.html.erb +6 -0
- data/lib/rails/generators/rorchado/templates/views/contact/index.html.erb +27 -0
- data/lib/rails/generators/rorchado/templates/views/contact/new.html.erb +5 -0
- data/lib/rails/generators/rorchado/templates/views/contact/show.html.erb +20 -0
- data/lib/rails/generators/rorchado/templates/views/cv/_form.html.erb +25 -0
- data/lib/rails/generators/rorchado/templates/views/cv/edit.html.erb +6 -0
- data/lib/rails/generators/rorchado/templates/views/cv/index.html.erb +25 -0
- data/lib/rails/generators/rorchado/templates/views/cv/new.html.erb +5 -0
- data/lib/rails/generators/rorchado/templates/views/cv/show.html.erb +15 -0
- data/lib/rails/generators/rorchado/templates/views/cvterm/_form.html.erb +41 -0
- data/lib/rails/generators/rorchado/templates/views/cvterm/edit.html.erb +6 -0
- data/lib/rails/generators/rorchado/templates/views/cvterm/index.html.erb +33 -0
- data/lib/rails/generators/rorchado/templates/views/cvterm/new.html.erb +5 -0
- data/lib/rails/generators/rorchado/templates/views/cvterm/show.html.erb +35 -0
- data/lib/rails/generators/rorchado/templates/views/stock/_form.html.erb +45 -0
- data/lib/rails/generators/rorchado/templates/views/stock/edit.html.erb +6 -0
- data/lib/rails/generators/rorchado/templates/views/stock/index.html.erb +35 -0
- data/lib/rails/generators/rorchado/templates/views/stock/new.html.erb +5 -0
- data/lib/rails/generators/rorchado/templates/views/stock/show.html.erb +40 -0
- metadata +105 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 74ca265d8406c125d26a78f7b9283db74adbc06f
|
|
4
|
+
data.tar.gz: b75eaf4af8592097f813266744bb1ec7c07af760
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 8ce4f9898e3d2cace8b02dac2475b08ef5c44efae19ffba6bd038f7f3349bfc234003a657dc90fc8aef6eecdfcd008629bd5b71643d9bc897116988b38a3394f
|
|
7
|
+
data.tar.gz: 6fac5c0c0462b318958adbe6f6e8ed75780b5405817177f60182cc0ca1129db5f8d7ceca2511e852f246943211f004be887eab234e49d059ddd4a64ce4065455
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
It provides the ability to install/unistall the modules of Chado.
|
|
3
|
+
It will create the Model,the Controller and the Views to manage via your RoR app
|
|
4
|
+
all the data that Chado can store.
|
|
5
|
+
|
|
6
|
+
Example:
|
|
7
|
+
rails generate rorchado install --all
|
|
8
|
+
|
|
9
|
+
This will create:
|
|
10
|
+
all the models,controllers and views for all the modules of Chado
|
|
11
|
+
|
|
12
|
+
Example:
|
|
13
|
+
rails generate rorchado uninstall --all
|
|
14
|
+
|
|
15
|
+
This will remove:
|
|
16
|
+
all the models,controllers and views for all the modules of Chado
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require "rails/generators"
|
|
3
|
+
require 'active_support/core_ext/object/inclusion'
|
|
4
|
+
require 'hpricot'
|
|
5
|
+
|
|
6
|
+
class RorchadoGenerator < Rails::Generators::Base
|
|
7
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
8
|
+
argument :command_name, :type => :string, :default => "install"
|
|
9
|
+
class_option :module, :type => :string, :default => "all", :description => "Define which module to install/uninstall. Default value is 'all'."
|
|
10
|
+
|
|
11
|
+
def init
|
|
12
|
+
# Read the available modules from the XML file
|
|
13
|
+
xml = File.read(self.class.source_root + '/db_schemas/chado_schema.xml')
|
|
14
|
+
@docxml = Hpricot::XML(xml)
|
|
15
|
+
|
|
16
|
+
@valid_modules = []
|
|
17
|
+
|
|
18
|
+
(@docxml/:modules/:module).each do |module_item|
|
|
19
|
+
@valid_modules << (module_item.get_attribute :id)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
@valid_commands = [ "help" , "list" , "install" , "uninstall" ]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def GeneratorHandler
|
|
27
|
+
command = "#{command_name}".downcase
|
|
28
|
+
module_name = "#{options.module}".downcase
|
|
29
|
+
|
|
30
|
+
#Debug
|
|
31
|
+
#puts "Command: #{command}"
|
|
32
|
+
#puts "Modules: #{module_name}"
|
|
33
|
+
|
|
34
|
+
# Check if the command is valid
|
|
35
|
+
if !@valid_commands.include?( command ) then
|
|
36
|
+
puts "The command '#{command}' is not supported by RoRChado gem."
|
|
37
|
+
elsif command=="help" then
|
|
38
|
+
puts "List of available commands:"
|
|
39
|
+
@valid_commands.each do |command|
|
|
40
|
+
puts " - #{command} , e.g. rails g rorchado #{command} [OPTIONS]"
|
|
41
|
+
end
|
|
42
|
+
elsif command=="list" then
|
|
43
|
+
puts "List of available Chado modules:"
|
|
44
|
+
@valid_modules.each do |module_tmp|
|
|
45
|
+
puts " - #{module_tmp}"
|
|
46
|
+
end
|
|
47
|
+
else
|
|
48
|
+
# Check which module to handle
|
|
49
|
+
if module_name == "all" then
|
|
50
|
+
# create an array with all the modules
|
|
51
|
+
@valid_modules.each do |module_tmp|
|
|
52
|
+
send("#{command.capitalize}Module" , module_tmp )
|
|
53
|
+
end
|
|
54
|
+
else
|
|
55
|
+
# handle the requested and valid module
|
|
56
|
+
found = false
|
|
57
|
+
@valid_modules.each do |module_tmp|
|
|
58
|
+
if module_tmp == module_name then
|
|
59
|
+
found = true
|
|
60
|
+
break
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
if found then
|
|
65
|
+
send("#{command.capitalize}Module" , module_name )
|
|
66
|
+
else
|
|
67
|
+
# Check if requested to install/unistall the admin
|
|
68
|
+
if module_name == "admin" then
|
|
69
|
+
send("#{command.capitalize}Admin")
|
|
70
|
+
else
|
|
71
|
+
puts "The module '#{module_name}' is not supported by RoRChado gem."
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
private
|
|
80
|
+
def InstallModule(module_name)
|
|
81
|
+
puts "Installing the #{module_name.capitalize} Module"
|
|
82
|
+
|
|
83
|
+
# Loop through the tables of this module
|
|
84
|
+
(@docxml/:modules/:module/"##{module_name}"/:tables/:table ).each do |table_item|
|
|
85
|
+
@table_name = table_item.get_attribute :id
|
|
86
|
+
@table_key = table_item.get_attribute :primary_key
|
|
87
|
+
@class_name = @table_name.camelize
|
|
88
|
+
|
|
89
|
+
# parse the fields of the table & the ORM relations
|
|
90
|
+
@column_items = ""
|
|
91
|
+
@field_items = ""
|
|
92
|
+
@orm_items = ""
|
|
93
|
+
(table_item/:fields/:field ).each do |field_item|
|
|
94
|
+
field_item_id = (field_item.get_attribute :id)
|
|
95
|
+
if @column_items == "" then
|
|
96
|
+
@column_items = ":#{field_item_id}"
|
|
97
|
+
else
|
|
98
|
+
@column_items = @column_items + ", :#{field_item_id}"
|
|
99
|
+
end
|
|
100
|
+
@field_items = @field_items + "\t\tt." + (field_item.get_attribute :type) + " :" + field_item_id
|
|
101
|
+
if (field_item.get_attribute :not_null) == "1" then
|
|
102
|
+
@field_items = @field_items + ",\t :null=> false"
|
|
103
|
+
end
|
|
104
|
+
if (field_item.get_attribute :default) != "" then
|
|
105
|
+
@field_items = @field_items + ",\t :default=> " + (field_item.get_attribute :default)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
@field_items = @field_items + "\n"
|
|
109
|
+
|
|
110
|
+
foreign_key = (field_item.get_attribute :foreign_key)
|
|
111
|
+
if foreign_key != nil && !foreign_key.empty? then
|
|
112
|
+
foreign_key_class = foreign_key.camelize
|
|
113
|
+
@orm_items = @orm_items + "\t\tbelongs_to :#{foreign_key}, :class_name => \'#{foreign_key_class}\', :foreign_key => :#{field_item_id}\n"
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
end
|
|
117
|
+
#--------------
|
|
118
|
+
|
|
119
|
+
#parse the indexes
|
|
120
|
+
@index_items = ""
|
|
121
|
+
@constraint_items = ""
|
|
122
|
+
# counters for auto naming
|
|
123
|
+
@unique_id = 1
|
|
124
|
+
@index_id = 1
|
|
125
|
+
|
|
126
|
+
(table_item/:indexes/:index ).each do |index_item|
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
#grab the columns from the XML
|
|
130
|
+
@columns = (index_item.get_attribute :columns).split(",")
|
|
131
|
+
@comun_names = ""
|
|
132
|
+
@columns.each do |column|
|
|
133
|
+
if @comun_names == "" then
|
|
134
|
+
@comun_names = "\"#{column}\""
|
|
135
|
+
else
|
|
136
|
+
@comun_names = @comun_names + ", \"#{column}\""
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
#+ (index_item.get_attribute :type) + " :" + (index_item.get_attribute :id)
|
|
141
|
+
if (index_item.get_attribute :unique) == "1" then
|
|
142
|
+
@constraint_items = @constraint_items + "\t\tsuppress_messages {execute \'alter table #{@table_name} add constraint #{@table_name}_c#{@unique_id} unique("
|
|
143
|
+
@constraint_items = @constraint_items + @comun_names
|
|
144
|
+
@constraint_items = @constraint_items + ")\'"
|
|
145
|
+
@constraint_items = @constraint_items + "}\n"
|
|
146
|
+
@constraint_items = @constraint_items + "\t\tsay \"Constraint for columns \'"+ (index_item.get_attribute :columns) + "\' created!\"\n"
|
|
147
|
+
|
|
148
|
+
@unique_id = @unique_id + 1
|
|
149
|
+
else
|
|
150
|
+
@index_items = @index_items + "\t\tsuppress_messages {add_index \"#{@table_name}\", ["
|
|
151
|
+
@index_items = @index_items + @comun_names
|
|
152
|
+
@index_items = @index_items + "], :name=> \"#{@table_name}_idx#{@index_id}\""
|
|
153
|
+
@index_items = @index_items + "}\n"
|
|
154
|
+
@index_items = @index_items + "\t\tsay \"Index for columns \'"+ (index_item.get_attribute :columns) + "\' created!\"\n"
|
|
155
|
+
|
|
156
|
+
@index_id = @index_id + 1
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
end
|
|
160
|
+
#--------------
|
|
161
|
+
|
|
162
|
+
template "models/generic_model.erb", "app/models/#{@table_name}.rb"
|
|
163
|
+
template "migrations/generic_migration_create.erb", "db/migrate/" + ((Time.now.to_f * 10000).round).to_s + "_create_#{@table_name}.rb"
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
private
|
|
169
|
+
def UninstallModule(module_name)
|
|
170
|
+
puts "Uninstalling the #{module_name.capitalize} Module"
|
|
171
|
+
|
|
172
|
+
# Loop through the tables of this module
|
|
173
|
+
(@docxml/:modules/:module/"##{module_name}"/:tables/:table ).each do |table_item|
|
|
174
|
+
table_name = (table_item.get_attribute :id).camelize
|
|
175
|
+
|
|
176
|
+
Rails::Generators.invoke "model", ["#{table_name}"], :behavior => :revoke, :destination_root => Rails.root
|
|
177
|
+
Rails::Generators.invoke "migration", ["Create#{table_name}"], :behavior => :revoke, :destination_root => Rails.root
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
private
|
|
183
|
+
def InstallAdmin()
|
|
184
|
+
puts "Installing Basic Admin for Chado"
|
|
185
|
+
# Copy Cv Admin
|
|
186
|
+
copy_file "controllers/cv_controller.rb", "app/controllers/cv_controller.rb"
|
|
187
|
+
copy_file "views/cv/index.html.erb", "app/views/cv/index.html.erb"
|
|
188
|
+
copy_file "views/cv/new.html.erb", "app/views/cv/new.html.erb"
|
|
189
|
+
copy_file "views/cv/edit.html.erb", "app/views/cv/edit.html.erb"
|
|
190
|
+
copy_file "views/cv/show.html.erb", "app/views/cv/show.html.erb"
|
|
191
|
+
copy_file "views/cv/_form.html.erb", "app/views/cv/_form.html.erb"
|
|
192
|
+
copy_file "controllers/cvterm_controller.rb", "app/controllers/cvterm_controller.rb"
|
|
193
|
+
copy_file "views/cvterm/index.html.erb", "app/views/cvterm/index.html.erb"
|
|
194
|
+
copy_file "views/cvterm/new.html.erb", "app/views/cvterm/new.html.erb"
|
|
195
|
+
copy_file "views/cvterm/edit.html.erb", "app/views/cvterm/edit.html.erb"
|
|
196
|
+
copy_file "views/cvterm/show.html.erb", "app/views/cvterm/show.html.erb"
|
|
197
|
+
copy_file "views/cvterm/_form.html.erb", "app/views/cvterm/_form.html.erb"
|
|
198
|
+
|
|
199
|
+
# Copy Contact Admin
|
|
200
|
+
copy_file "controllers/contact_controller.rb", "app/controllers/contact_controller.rb"
|
|
201
|
+
copy_file "views/contact/index.html.erb", "app/views/contact/index.html.erb"
|
|
202
|
+
copy_file "views/contact/new.html.erb", "app/views/contact/new.html.erb"
|
|
203
|
+
copy_file "views/contact/edit.html.erb", "app/views/contact/edit.html.erb"
|
|
204
|
+
copy_file "views/contact/show.html.erb", "app/views/contact/show.html.erb"
|
|
205
|
+
copy_file "views/contact/_form.html.erb", "app/views/contact/_form.html.erb"
|
|
206
|
+
|
|
207
|
+
# Copy Stock Admin
|
|
208
|
+
copy_file "controllers/stock_controller.rb", "app/controllers/stock_controller.rb"
|
|
209
|
+
copy_file "views/stock/index.html.erb", "app/views/stock/index.html.erb"
|
|
210
|
+
copy_file "views/stock/new.html.erb", "app/views/stock/new.html.erb"
|
|
211
|
+
copy_file "views/stock/edit.html.erb", "app/views/stock/edit.html.erb"
|
|
212
|
+
copy_file "views/stock/show.html.erb", "app/views/stock/show.html.erb"
|
|
213
|
+
copy_file "views/stock/_form.html.erb", "app/views/stock/_form.html.erb"
|
|
214
|
+
|
|
215
|
+
# Add Route
|
|
216
|
+
route "resources :contact"
|
|
217
|
+
route "resources :cv"
|
|
218
|
+
route "resources :cvterm"
|
|
219
|
+
route "resources :stock"
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
private
|
|
223
|
+
def UninstallAdmin()
|
|
224
|
+
puts "Uninstalling Basic Admin for Chado"
|
|
225
|
+
|
|
226
|
+
remove_file("app/controllers/cvterm_controller.rb")
|
|
227
|
+
remove_file("app/views/cvterm/index.html.erb")
|
|
228
|
+
remove_file("app/views/cvterm/new.html.erb")
|
|
229
|
+
remove_file("app/views/cvterm/edit.html.erb")
|
|
230
|
+
remove_file("app/views/cvterm/show.html.erb")
|
|
231
|
+
remove_file("app/views/cvterm/_form.html.erb")
|
|
232
|
+
gsub_file "config/routes.rb" , "resources :cvterm" , ""
|
|
233
|
+
|
|
234
|
+
remove_file("app/controllers/cv_controller.rb")
|
|
235
|
+
remove_file("app/views/cv/index.html.erb")
|
|
236
|
+
remove_file("app/views/cv/new.html.erb")
|
|
237
|
+
remove_file("app/views/cv/edit.html.erb")
|
|
238
|
+
remove_file("app/views/cv/show.html.erb")
|
|
239
|
+
remove_file("app/views/cv/_form.html.erb")
|
|
240
|
+
gsub_file "config/routes.rb" , "resources :cv" , ""
|
|
241
|
+
|
|
242
|
+
remove_file("app/controllers/contact_controller.rb")
|
|
243
|
+
remove_file("app/views/contact/index.html.erb")
|
|
244
|
+
remove_file("app/views/contact/new.html.erb")
|
|
245
|
+
remove_file("app/views/contact/edit.html.erb")
|
|
246
|
+
remove_file("app/views/contact/show.html.erb")
|
|
247
|
+
remove_file("app/views/contact/_form.html.erb")
|
|
248
|
+
gsub_file "config/routes.rb" , "resources :contact" , ""
|
|
249
|
+
|
|
250
|
+
remove_file("app/controllers/stock_controller.rb")
|
|
251
|
+
remove_file("app/views/stock/index.html.erb")
|
|
252
|
+
remove_file("app/views/stock/new.html.erb")
|
|
253
|
+
remove_file("app/views/stock/edit.html.erb")
|
|
254
|
+
remove_file("app/views/stock/show.html.erb")
|
|
255
|
+
remove_file("app/views/stock/_form.html.erb")
|
|
256
|
+
gsub_file "config/routes.rb" , "resources :stock" , ""
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
class ContactController < ApplicationController
|
|
2
|
+
# GET /contacts
|
|
3
|
+
# GET /contacts.json
|
|
4
|
+
def index
|
|
5
|
+
@contacts = Contact.all
|
|
6
|
+
|
|
7
|
+
respond_to do |format|
|
|
8
|
+
format.html # index.html.erb
|
|
9
|
+
format.json { render :json => @contacts }
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# GET /contacts/1
|
|
14
|
+
# GET /contacts/1.json
|
|
15
|
+
def show
|
|
16
|
+
@contact = Contact.find(params[:id])
|
|
17
|
+
|
|
18
|
+
respond_to do |format|
|
|
19
|
+
format.html # show.html.erb
|
|
20
|
+
format.json { render :json => @contact }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# GET /contacts/new
|
|
25
|
+
# GET /contacts/new.json
|
|
26
|
+
def new
|
|
27
|
+
@contact = Contact.new
|
|
28
|
+
|
|
29
|
+
respond_to do |format|
|
|
30
|
+
format.html # new.html.erb
|
|
31
|
+
format.json { render :json => @contact }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# GET /contacts/1/edit
|
|
36
|
+
def edit
|
|
37
|
+
@contact = Contact.find(params[:id])
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# POST /contacts
|
|
41
|
+
# POST /contacts.json
|
|
42
|
+
def create
|
|
43
|
+
@contact = Contact.new(params[:contact])
|
|
44
|
+
|
|
45
|
+
respond_to do |format|
|
|
46
|
+
if @contact.save
|
|
47
|
+
format.html { redirect_to "/contact/", :notice => 'Contact was successfully created.' }
|
|
48
|
+
format.json { render :json => @contact, :status => :created, :location => @contact }
|
|
49
|
+
else
|
|
50
|
+
format.html { render :action => "new" }
|
|
51
|
+
format.json { render :json => @contact.errors, :status => :unprocessable_entity }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# PUT /contacts/1
|
|
57
|
+
# PUT /contacts/1.json
|
|
58
|
+
def update
|
|
59
|
+
@contact = Contact.find(params[:id])
|
|
60
|
+
|
|
61
|
+
respond_to do |format|
|
|
62
|
+
if @contact.update_attributes(params[:contact])
|
|
63
|
+
format.html { redirect_to "/contact/", :notice => 'Contact was successfully updated.' }
|
|
64
|
+
format.json { head :no_content }
|
|
65
|
+
else
|
|
66
|
+
format.html { render :action => "edit" }
|
|
67
|
+
format.json { render :json => @contact.errors, :status => :unprocessable_entity }
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# DELETE /contacts/1
|
|
73
|
+
# DELETE /contacts/1.json
|
|
74
|
+
def destroy
|
|
75
|
+
@contact = Contact.find(params[:id])
|
|
76
|
+
@contact.destroy
|
|
77
|
+
|
|
78
|
+
respond_to do |format|
|
|
79
|
+
format.html { redirect_to "/contact/" }
|
|
80
|
+
format.json { head :no_content }
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
class ContactsController < ApplicationController
|
|
2
|
+
# GET /contacts
|
|
3
|
+
# GET /contacts.json
|
|
4
|
+
def index
|
|
5
|
+
@contacts = Contact.all
|
|
6
|
+
|
|
7
|
+
respond_to do |format|
|
|
8
|
+
format.html # index.html.erb
|
|
9
|
+
format.json { render :json => @contacts }
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# GET /contacts/1
|
|
14
|
+
# GET /contacts/1.json
|
|
15
|
+
def show
|
|
16
|
+
@contact = Contact.find(params[:id])
|
|
17
|
+
|
|
18
|
+
respond_to do |format|
|
|
19
|
+
format.html # show.html.erb
|
|
20
|
+
format.json { render :json => @contact }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# GET /contacts/new
|
|
25
|
+
# GET /contacts/new.json
|
|
26
|
+
def new
|
|
27
|
+
@contact = Contact.new
|
|
28
|
+
|
|
29
|
+
respond_to do |format|
|
|
30
|
+
format.html # new.html.erb
|
|
31
|
+
format.json { render :json => @contact }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# GET /contacts/1/edit
|
|
36
|
+
def edit
|
|
37
|
+
@contact = Contact.find(params[:id])
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# POST /contacts
|
|
41
|
+
# POST /contacts.json
|
|
42
|
+
def create
|
|
43
|
+
@contact = Contact.new(params[:contact])
|
|
44
|
+
|
|
45
|
+
respond_to do |format|
|
|
46
|
+
if @contact.save
|
|
47
|
+
format.html { redirect_to @contact, :notice => 'Contact was successfully created.' }
|
|
48
|
+
format.json { render :json => @contact, :status => :created, :location => @contact }
|
|
49
|
+
else
|
|
50
|
+
format.html { render :action => "new" }
|
|
51
|
+
format.json { render :json => @contact.errors, :status => :unprocessable_entity }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# PUT /contacts/1
|
|
57
|
+
# PUT /contacts/1.json
|
|
58
|
+
def update
|
|
59
|
+
@contact = Contact.find(params[:id])
|
|
60
|
+
|
|
61
|
+
respond_to do |format|
|
|
62
|
+
if @contact.update_attributes(params[:contact])
|
|
63
|
+
format.html { redirect_to @contact, :notice => 'Contact was successfully updated.' }
|
|
64
|
+
format.json { head :no_content }
|
|
65
|
+
else
|
|
66
|
+
format.html { render :action => "edit" }
|
|
67
|
+
format.json { render :json => @contact.errors, :status => :unprocessable_entity }
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# DELETE /contacts/1
|
|
73
|
+
# DELETE /contacts/1.json
|
|
74
|
+
def destroy
|
|
75
|
+
@contact = Contact.find(params[:id])
|
|
76
|
+
@contact.destroy
|
|
77
|
+
|
|
78
|
+
respond_to do |format|
|
|
79
|
+
format.html { redirect_to contacts_url }
|
|
80
|
+
format.json { head :no_content }
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
class CvController < ApplicationController
|
|
2
|
+
# GET /cvs
|
|
3
|
+
# GET /cvs.json
|
|
4
|
+
def index
|
|
5
|
+
@cvs = Cv.all
|
|
6
|
+
|
|
7
|
+
respond_to do |format|
|
|
8
|
+
format.html # index.html.erb
|
|
9
|
+
format.json { render :json => @cvs }
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# GET /cvs/1
|
|
14
|
+
# GET /cvs/1.json
|
|
15
|
+
def show
|
|
16
|
+
@cv = Cv.find(params[:id])
|
|
17
|
+
|
|
18
|
+
respond_to do |format|
|
|
19
|
+
format.html # show.html.erb
|
|
20
|
+
format.json { render :json => @cv }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# GET /cvs/new
|
|
25
|
+
# GET /cvs/new.json
|
|
26
|
+
def new
|
|
27
|
+
@cv = Cv.new
|
|
28
|
+
|
|
29
|
+
respond_to do |format|
|
|
30
|
+
format.html # new.html.erb
|
|
31
|
+
format.json { render :json => @cv }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# GET /cvs/1/edit
|
|
36
|
+
def edit
|
|
37
|
+
@cv = Cv.find(params[:id])
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# POST /cvs
|
|
41
|
+
# POST /cvs.json
|
|
42
|
+
def create
|
|
43
|
+
@cv = Cv.new(params[:cv])
|
|
44
|
+
|
|
45
|
+
respond_to do |format|
|
|
46
|
+
if @cv.save
|
|
47
|
+
format.html { redirect_to @cv, :notice => 'Cv was successfully created.' }
|
|
48
|
+
format.json { render :json => @cv, :status => :created, :location => @cv }
|
|
49
|
+
else
|
|
50
|
+
format.html { render :action => "new" }
|
|
51
|
+
format.json { render :json => @cv.errors, :status => :unprocessable_entity }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# PUT /cvs/1
|
|
57
|
+
# PUT /cvs/1.json
|
|
58
|
+
def update
|
|
59
|
+
@cv = Cv.find(params[:id])
|
|
60
|
+
|
|
61
|
+
respond_to do |format|
|
|
62
|
+
if @cv.update_attributes(params[:cv])
|
|
63
|
+
format.html { redirect_to @cv, :notice => 'Cv was successfully updated.' }
|
|
64
|
+
format.json { head :no_content }
|
|
65
|
+
else
|
|
66
|
+
format.html { render :action => "edit" }
|
|
67
|
+
format.json { render :json => @cv.errors, :status => :unprocessable_entity }
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# DELETE /cvs/1
|
|
73
|
+
# DELETE /cvs/1.json
|
|
74
|
+
def destroy
|
|
75
|
+
@cv = Cv.find(params[:id])
|
|
76
|
+
@cv.destroy
|
|
77
|
+
|
|
78
|
+
respond_to do |format|
|
|
79
|
+
format.html { redirect_to cvs_url }
|
|
80
|
+
format.json { head :no_content }
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
class CvsController < ApplicationController
|
|
2
|
+
# GET /cvs
|
|
3
|
+
# GET /cvs.json
|
|
4
|
+
def index
|
|
5
|
+
@cvs = Cv.all
|
|
6
|
+
|
|
7
|
+
respond_to do |format|
|
|
8
|
+
format.html # index.html.erb
|
|
9
|
+
format.json { render :json => @cvs }
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# GET /cvs/1
|
|
14
|
+
# GET /cvs/1.json
|
|
15
|
+
def show
|
|
16
|
+
@cv = Cv.find(params[:id])
|
|
17
|
+
|
|
18
|
+
respond_to do |format|
|
|
19
|
+
format.html # show.html.erb
|
|
20
|
+
format.json { render :json => @cv }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# GET /cvs/new
|
|
25
|
+
# GET /cvs/new.json
|
|
26
|
+
def new
|
|
27
|
+
@cv = Cv.new
|
|
28
|
+
|
|
29
|
+
respond_to do |format|
|
|
30
|
+
format.html # new.html.erb
|
|
31
|
+
format.json { render :json => @cv }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# GET /cvs/1/edit
|
|
36
|
+
def edit
|
|
37
|
+
@cv = Cv.find(params[:id])
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# POST /cvs
|
|
41
|
+
# POST /cvs.json
|
|
42
|
+
def create
|
|
43
|
+
@cv = Cv.new(params[:cv])
|
|
44
|
+
|
|
45
|
+
respond_to do |format|
|
|
46
|
+
if @cv.save
|
|
47
|
+
format.html { redirect_to @cv, :notice => 'Cv was successfully created.' }
|
|
48
|
+
format.json { render :json => @cv, :status => :created, :location => @cv }
|
|
49
|
+
else
|
|
50
|
+
format.html { render :action => "new" }
|
|
51
|
+
format.json { render :json => @cv.errors, :status => :unprocessable_entity }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# PUT /cvs/1
|
|
57
|
+
# PUT /cvs/1.json
|
|
58
|
+
def update
|
|
59
|
+
@cv = Cv.find(params[:id])
|
|
60
|
+
|
|
61
|
+
respond_to do |format|
|
|
62
|
+
if @cv.update_attributes(params[:cv])
|
|
63
|
+
format.html { redirect_to @cv, :notice => 'Cv was successfully updated.' }
|
|
64
|
+
format.json { head :no_content }
|
|
65
|
+
else
|
|
66
|
+
format.html { render :action => "edit" }
|
|
67
|
+
format.json { render :json => @cv.errors, :status => :unprocessable_entity }
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# DELETE /cvs/1
|
|
73
|
+
# DELETE /cvs/1.json
|
|
74
|
+
def destroy
|
|
75
|
+
@cv = Cv.find(params[:id])
|
|
76
|
+
@cv.destroy
|
|
77
|
+
|
|
78
|
+
respond_to do |format|
|
|
79
|
+
format.html { redirect_to cvs_url }
|
|
80
|
+
format.json { head :no_content }
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|