largentinas 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 (42) hide show
  1. data/.document +5 -0
  2. data/Gemfile +13 -0
  3. data/Gemfile.lock +20 -0
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +19 -0
  6. data/Rakefile +53 -0
  7. data/VERSION +1 -0
  8. data/app/controllers/departamentos_controller.rb +83 -0
  9. data/app/controllers/localidads_controller.rb +83 -0
  10. data/app/controllers/provincias_controller.rb +83 -0
  11. data/app/helpers/localidads_helper.rb +8 -0
  12. data/app/models/departamento.rb +12 -0
  13. data/app/models/localidad.rb +27 -0
  14. data/app/models/provincia.rb +3 -0
  15. data/app/views/departamentos/_form.html.erb +25 -0
  16. data/app/views/departamentos/edit.html.erb +6 -0
  17. data/app/views/departamentos/index.html.erb +25 -0
  18. data/app/views/departamentos/new.html.erb +5 -0
  19. data/app/views/departamentos/show.html.erb +30 -0
  20. data/app/views/localidads/_form.html.erb +25 -0
  21. data/app/views/localidads/edit.html.erb +6 -0
  22. data/app/views/localidads/index.html.erb +41 -0
  23. data/app/views/localidads/index.xml.builder +9 -0
  24. data/app/views/localidads/new.html.erb +5 -0
  25. data/app/views/localidads/show.html.erb +20 -0
  26. data/app/views/provincias/_form.html.erb +21 -0
  27. data/app/views/provincias/edit.html.erb +6 -0
  28. data/app/views/provincias/index.html.erb +23 -0
  29. data/app/views/provincias/new.html.erb +5 -0
  30. data/app/views/provincias/show.html.erb +26 -0
  31. data/config/routes.rb +15 -0
  32. data/lib/generators/largentinas/largentinas_generator.rb +77 -0
  33. data/lib/generators/largentinas/templates/db/migrate/create_departamentos.rb +14 -0
  34. data/lib/generators/largentinas/templates/db/migrate/create_localidads.rb +14 -0
  35. data/lib/generators/largentinas/templates/db/migrate/create_provincias.rb +13 -0
  36. data/lib/generators/largentinas/templates/db/migrate/departamento_data.rb +585 -0
  37. data/lib/generators/largentinas/templates/db/migrate/localidad_data.rb +5449 -0
  38. data/lib/generators/largentinas/templates/db/migrate/provincia_data.rb +11 -0
  39. data/lib/largentinas.rb +5 -0
  40. data/test/helper.rb +18 -0
  41. data/test/test_largentinas.rb +7 -0
  42. metadata +162 -0
@@ -0,0 +1,3 @@
1
+ class Provincia < ActiveRecord::Base
2
+ has_many :departamentos
3
+ end
@@ -0,0 +1,25 @@
1
+ <%= form_for(@departamento) do |f| %>
2
+ <% if @departamento.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@departamento.errors.count, "error") %> prohibited this departamento from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @departamento.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br />
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :provincia_id %><br />
20
+ <%= f.text_field :provincia_id %>
21
+ </div>
22
+ <div class="actions">
23
+ <%= f.submit %>
24
+ </div>
25
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing departamento</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @departamento %> |
6
+ <%= link_to 'Back', departamentos_path %>
@@ -0,0 +1,25 @@
1
+ <h1>Listing departamentos</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ <th>Provincia</th>
7
+ <th></th>
8
+ <th></th>
9
+ <th></th>
10
+ </tr>
11
+
12
+ <% @departamentos.each do |departamento| %>
13
+ <tr>
14
+ <td><%= departamento.name %></td>
15
+ <td><%= departamento.pname %></td>
16
+ <td><%= link_to 'Show', departamento %></td>
17
+ <td><%= link_to 'Edit', edit_departamento_path(departamento) %></td>
18
+ <td><%= link_to 'Destroy', departamento, :confirm => 'Are you sure?', :method => :delete %></td>
19
+ </tr>
20
+ <% end %>
21
+ </table>
22
+
23
+ <br />
24
+
25
+ <%= link_to 'New Departamento', new_departamento_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New departamento</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', departamentos_path %>
@@ -0,0 +1,30 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Name:</b>
5
+ <%= @departamento.name %>
6
+ </p>
7
+
8
+ <p>
9
+ <b>Provincia:</b>
10
+ <%= @departamento.pname %>
11
+ </p>
12
+
13
+ <%= link_to 'Edit', edit_departamento_path(@departamento) %> |
14
+ <%= link_to 'Back', departamentos_path %>
15
+
16
+ <br>
17
+ <b>Localidades de este depatamento</b>
18
+ <table>
19
+ <tr>
20
+ <th>Localidad</th>
21
+
22
+ <% @departamento.localidads.each do |localidad|%>
23
+ <tr>
24
+ <td>
25
+ <%= link_to localidad.name, localidad %>
26
+ </td>
27
+ </tr>
28
+ <% end %>
29
+
30
+ </table>
@@ -0,0 +1,25 @@
1
+ <%= form_for(@localidad) do |f| %>
2
+ <% if @localidad.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@localidad.errors.count, "error") %> prohibited this localidad from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @localidad.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br />
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :departamento_id %><br />
20
+ <%= f.text_field :departamento_id %>
21
+ </div>
22
+ <div class="actions">
23
+ <%= f.submit %>
24
+ </div>
25
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing localidad</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @localidad %> |
6
+ <%= link_to 'Back', localidads_path %>
@@ -0,0 +1,41 @@
1
+ <%= form_for @search do |f| %>
2
+
3
+ <%= f.label :provincia %><br />
4
+ <%= f.text_field :departamento_provincia_name_contains %><br />
5
+
6
+ <%= f.label :departamento %><br />
7
+ <%= f.text_field :departamento_name_contains %><br />
8
+
9
+ <%= f.label :localidad %><br />
10
+ <%= f.text_field :name_contains %><br />
11
+ <%= f.submit('Buscar') %>
12
+ <% end %>
13
+
14
+ <h1>Localidades</h1>
15
+
16
+ <%= will_paginate @localidads %>
17
+
18
+ <table>
19
+ <tr>
20
+ <th>Name</th>
21
+ <th>Departamneto</th>
22
+ <th>Provincia</th>
23
+ <th></th>
24
+ <th></th>
25
+ <th></th>
26
+ </tr>
27
+
28
+ <% @localidads.each do |localidad| %>
29
+ <tr>
30
+ <td><%= link_to localidad.name,localidad %></td>
31
+ <td><%= link_to localidad.dname,localidad.d %></td>
32
+ <td><%= link_to localidad.pname,localidad.p %></td>
33
+ <td><%= link_to 'Edit', edit_localidad_path(localidad) %></td>
34
+ <td><%= link_to 'Destroy', localidad, :confirm => 'Are you sure?', :method => :delete %></td>
35
+ </tr>
36
+ <% end %>
37
+ </table>
38
+
39
+ <br />
40
+
41
+ <%= link_to 'New Localidad', new_localidad_path %>
@@ -0,0 +1,9 @@
1
+ xml.instruct!
2
+ xml.localidads do
3
+ @localidads.each do |localidad|
4
+ xml.localidad do
5
+ xml.id localidad.id
6
+ xml.name "#{localidad.name} #{localidad.dname}"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ <h1>New localidad</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', localidads_path %>
@@ -0,0 +1,20 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Name:</b>
5
+ <%= @localidad.name %>
6
+ </p>
7
+
8
+ <p>
9
+ <b>Departamneto:</b>
10
+ <%= link_to @localidad.dname, @localidad.d %>
11
+ </p>
12
+
13
+ <p>
14
+ <b>Provincia:</b>
15
+ <%= link_to @localidad.pname,@localidad.p %>
16
+ </p>
17
+
18
+
19
+ <%= link_to 'Edit', edit_localidad_path(@localidad) %> |
20
+ <%= link_to 'Back', localidads_path %>
@@ -0,0 +1,21 @@
1
+ <%= form_for(@provincia) do |f| %>
2
+ <% if @provincia.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@provincia.errors.count, "error") %> prohibited this provincia from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @provincia.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br />
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="actions">
19
+ <%= f.submit %>
20
+ </div>
21
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing provincia</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @provincia %> |
6
+ <%= link_to 'Back', provincias_path %>
@@ -0,0 +1,23 @@
1
+ <h1>Listing provincias</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ <th></th>
7
+ <th></th>
8
+ <th></th>
9
+ </tr>
10
+
11
+ <% @provincias.each do |provincia| %>
12
+ <tr>
13
+ <td><%= provincia.name %></td>
14
+ <td><%= link_to 'Show', provincia %></td>
15
+ <td><%= link_to 'Edit', edit_provincia_path(provincia) %></td>
16
+ <td><%= link_to 'Destroy', provincia, :confirm => 'Are you sure?', :method => :delete %></td>
17
+ </tr>
18
+ <% end %>
19
+ </table>
20
+
21
+ <br />
22
+
23
+ <%= link_to 'New Provincia', new_provincia_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New provincia</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', provincias_path %>
@@ -0,0 +1,26 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Name:</b>
5
+ <%= @provincia.name %>
6
+ </p>
7
+
8
+
9
+ <%= link_to 'Edit', edit_provincia_path(@provincia) %> |
10
+ <%= link_to 'Back', provincias_path %>
11
+
12
+ <br>
13
+ <b>Departamentos de esta Provincia</b>
14
+ <table>
15
+ <tr>
16
+ <th>Localidad</th>
17
+
18
+ <% @provincia.departamentos.each do |departamento|%>
19
+ <tr>
20
+ <td>
21
+ <%= link_to departamento.name, departamento %>
22
+ </td>
23
+ </tr>
24
+ <% end %>
25
+
26
+ </table>
data/config/routes.rb ADDED
@@ -0,0 +1,15 @@
1
+ Rails.application.routes.draw do |map|
2
+
3
+ resources :departamentos
4
+
5
+ resources :localidads
6
+
7
+ resources :provincias do
8
+ resources :departamentos do
9
+ resources :localidads
10
+ end
11
+ end
12
+
13
+
14
+
15
+ end
@@ -0,0 +1,77 @@
1
+ require 'rails/generators/resource_helpers'
2
+ require 'rails/generators/rails/model/model_generator'
3
+ require 'active_support/core_ext/object/blank'
4
+
5
+ class LargentinasGenerator < Rails::Generators::Base
6
+ include Rails::Generators::Migration
7
+
8
+ source_root File.expand_path('../templates', __FILE__)
9
+
10
+ def self.next_migration_number(dirname)
11
+ if ActiveRecord::Base.timestamped_migrations
12
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
13
+ else
14
+ "%.3d" % (current_migration_number(dirname) + 1 )
15
+ end
16
+ end
17
+
18
+ def install
19
+ gem "will_paginate", "~> 3.0.pre2"
20
+ puts "paginacion"
21
+ gem "cancan"
22
+ puts "permisos para roles"
23
+ gem "meta_search"
24
+ puts "hace las busquedas mas faciles"
25
+ gem "builder"
26
+ puts "para hacer los xml"
27
+
28
+ generate('bundle install')
29
+ #generate('nifty:layout')
30
+ #generate('devise:views')
31
+
32
+ #models
33
+
34
+ #vistas
35
+ migrations
36
+
37
+ end
38
+
39
+ private
40
+
41
+ def migrations
42
+ #migraciones
43
+ cf_mig("create_localidads")
44
+ cf_mig("create_departamentos")
45
+ cf_mig("create_provincias")
46
+ cf_mig("localidad_data")
47
+ cf_mig("departamento_data")
48
+ cf_mig("provincia_data")
49
+
50
+ end
51
+
52
+ def cf_mig(dir)
53
+ migration_template "db/migrate/#{dir}.rb", "db/migrate/#{dir}"
54
+ sleep 1
55
+ end
56
+
57
+ def cf_js(dir)
58
+ copy_file("public/javascripts/#{dir}","public/javascripts/#{dir}")
59
+ end
60
+
61
+ def cf_h(dir)
62
+ copy_file("app/helpers/#{dir}","app/helpers/#{dir}")
63
+ end
64
+
65
+ def cf_v(dir)
66
+ copy_file("app/views/#{dir}","app/views/#{dir}")
67
+ end
68
+
69
+ def cf_m(dir)
70
+ copy_file("app/models/#{dir}","app/models/#{dir}")
71
+ end
72
+
73
+ def cf_c(dir)
74
+ copy_file("app/controllers/#{dir}","app/controllers/#{dir}")
75
+ end
76
+
77
+ end
@@ -0,0 +1,14 @@
1
+ class CreateDepartamentos < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :departamentos do |t|
4
+ t.string :name
5
+ t.integer :provincia_id
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :departamentos
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ class CreateLocalidads < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :localidads do |t|
4
+ t.string :name
5
+ t.integer :departamento_id
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :localidads
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ class CreateProvincias < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :provincias do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ drop_table :provincias
12
+ end
13
+ end