enterprise_controller.rb
1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Manage enterprises by providing an interface to register, activate and manage them
class EnterpriseController < ApplicationController
before_filter :logon, :my_enterprises
def index
@enterprises = Enterprise.find(:all) - @my_enterprises
@pending_enterprises = current_user.person.my_enterprises(false)
end
def register_form
@enterprise = Enterprise.new()
@vitual_communities = VirtualCommunity.find(:all)
end
def register
@enterprise = Enterprise.new(params[:enterprise])
@enterprise.identifier = @enterprise.name
if @enterprise.save
@enterprise.people << current_user.person
flash[:notice] = _('Enterprise was succesfully created')
redirect_to :action => 'index'
else
flash[:notice] = _('Enterprise was not created')
render :action => 'register_form'
end
end
def show
@enterprise = @my_enterprises.find{|e| e.id == params[:id]}
end
protected
def logon
redirect_to :controller => 'account' unless logged_in?
end
def my_enterprises
@my_enterprises = current_user.person.my_enterprises
end
end