membership_editor_controller.rb
1.17 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
class MembershipEditorController < MyProfileController
before_filter :login_required
def target
environment
end
protect 'edit_profile', :profile, :only => [:index, :new_enterprise, :create_enterprise ]
def index
@memberships = current_user.person.enterprise_memberships
end
def new_enterprise
@enterprise = Enterprise.new()
@validation_entities = Organization.find(:all)
end
def create_enterprise
@enterprise = Enterprise.new(params[:enterprise])
@enterprise.organization_info = OrganizationInfo.new(params[:organization])
if @enterprise.save
@enterprise.affiliate(current_user.person, Role.find(:all, :conditions => {:name => ['owner', 'member', 'moderator']}))
flash[:notice] = _('The enterprise was successfully created, the validation entity will cotact you as soon as your enterprise is approved')
redirect_to :action => 'index'
else
flash[:notice] = _('Enterprise was not created')
@validation_entities = Organization.find(:all)
render :action => 'register_form'
end
end
# Search enterprises by name or tags
def search
@tagged_enterprises = Enterprise.search(params[:query])
end
end