Commit a5b182941a53437b3849089a727987c9644fe49a

Authored by AntonioTerceiro
1 parent c86e4879

ActionItem8: adding infrastructure for custom routes to be used

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@48 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing 2 changed files with 19 additions and 0 deletions   Show diff stats
app/models/profile.rb
@@ -3,11 +3,21 @@ @@ -3,11 +3,21 @@
3 # which by default is the one returned by VirtualCommunity:default. 3 # which by default is the one returned by VirtualCommunity:default.
4 class Profile < ActiveRecord::Base 4 class Profile < ActiveRecord::Base
5 5
  6 + # These names cannot be used as identifiers for Profiles
  7 + RESERVED_IDENTIFIERS = %w[
  8 + admin
  9 + customize
  10 + cms
  11 + system
  12 + community
  13 + ]
  14 +
6 has_many :domains, :as => :owner 15 has_many :domains, :as => :owner
7 belongs_to :virtual_community 16 belongs_to :virtual_community
8 17
9 validates_presence_of :identifier 18 validates_presence_of :identifier
10 validates_format_of :identifier, :with => /^[a-z][a-z0-9_]+[a-z0-9]$/ 19 validates_format_of :identifier, :with => /^[a-z][a-z0-9_]+[a-z0-9]$/
  20 + validates_exclusion_of :identifier, :in => RESERVED_IDENTIFIERS
11 21
12 # creates a new Profile. By default, it is attached to the default 22 # creates a new Profile. By default, it is attached to the default
13 # VirtualCommunity (see VirtualCommunity#default), unless you tell it 23 # VirtualCommunity (see VirtualCommunity#default), unless you tell it
config/routes.rb
@@ -9,6 +9,12 @@ ActionController::Routing::Routes.draw do |map| @@ -9,6 +9,12 @@ ActionController::Routing::Routes.draw do |map|
9 # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase' 9 # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
10 # This route can be invoked with purchase_url(:id => product.id) 10 # This route can be invoked with purchase_url(:id => product.id)
11 11
  12 + # administrative tasks for a virtual community
  13 + map.connect 'admin/:controller/:action/:id'
  14 +
  15 + # profile customization for profiles
  16 + map.connect 'customize/:profile/:controller/:action/:id'
  17 +
12 # You can have the root of your site routed by hooking up '' 18 # You can have the root of your site routed by hooking up ''
13 # -- just remember to delete public/index.html. 19 # -- just remember to delete public/index.html.
14 map.connect '', :controller => "home" 20 map.connect '', :controller => "home"
@@ -19,4 +25,7 @@ ActionController::Routing::Routes.draw do |map| @@ -19,4 +25,7 @@ ActionController::Routing::Routes.draw do |map|
19 25
20 # Install the default route as the lowest priority. 26 # Install the default route as the lowest priority.
21 map.connect ':controller/:action/:id' 27 map.connect ':controller/:action/:id'
  28 +
  29 + # TODO: comatose here
  30 +
22 end 31 end