Commit 7977e9ea3847c41829276f652969993f41c4943e

Authored by AntonioTerceiro
1 parent 9b050113

ActionItem102: creating Region model class



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@657 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/helpers/categories_helper.rb
@@ -13,6 +13,7 @@ module CategoriesHelper @@ -13,6 +13,7 @@ module CategoriesHelper
13 TYPES = [ 13 TYPES = [
14 [ _('Categoria Geral'), Category.to_s ], 14 [ _('Categoria Geral'), Category.to_s ],
15 [ _('Product Category'), ProductCategory.to_s ], 15 [ _('Product Category'), ProductCategory.to_s ],
  16 + [ _('Region'), Region.to_s ],
16 ] 17 ]
17 18
18 def select_color_for_category 19 def select_color_for_category
app/models/region.rb 0 → 100644
@@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
  1 +# Region is a special type of category that is related to geographical issues.
  2 +class Region < Category
  3 +end
app/views/categories/_form.rhtml
@@ -4,8 +4,10 @@ @@ -4,8 +4,10 @@
4 <% if @category.new_record? %> 4 <% if @category.new_record? %>
5 <% if @category.parent %> 5 <% if @category.parent %>
6 <%= hidden_field_tag('parent_id', @category.parent.id) %> 6 <%= hidden_field_tag('parent_id', @category.parent.id) %>
  7 + <%= hidden_field_tag('type', @category.parent.class.name) %>
  8 + <% else %>
  9 + <%= select_category_type :type %>
7 <% end %> 10 <% end %>
8 - <%= select_category_type :type %>  
9 <% end %> 11 <% end %>
10 12
11 <%= select_color_for_category %> 13 <%= select_color_for_category %>
test/unit/region_test.rb 0 → 100644
@@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
  1 +require File.dirname(__FILE__) + '/../test_helper'
  2 +
  3 +class RegionTest < Test::Unit::TestCase
  4 +
  5 + should 'be a subclass of category' do
  6 + assert_equal Category, Region.superclass
  7 + end
  8 +end