实现组织的增、删、改、查功能及相关界面
This commit is contained in:
parent
3c4b502e97
commit
e2307366f6
|
@ -1,5 +1,7 @@
|
||||||
class OrganizationController < ApplicationController
|
class OrganizationController < ApplicationController
|
||||||
layout 'project_base'
|
layout 'project_base'
|
||||||
|
before_filter :require_admin, :except => [:index]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
#@projects = Project.find_by_sql("SELECT * FROM projects WHERE id IN (select MAX(id) from projects GROUP BY enterprise_name)")
|
#@projects = Project.find_by_sql("SELECT * FROM projects WHERE id IN (select MAX(id) from projects GROUP BY enterprise_name)")
|
||||||
@organizations = Organization.all
|
@organizations = Organization.all
|
||||||
|
@ -7,4 +9,47 @@ class OrganizationController < ApplicationController
|
||||||
format.html
|
format.html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@organizations = Organization.new
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@organizations = Organization.new
|
||||||
|
@organizations.name = params[:organization][:name]
|
||||||
|
if @organizations.save
|
||||||
|
redirect_to admin_organization_url
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@organization = Organization.find params[:id]
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
end
|
||||||
|
rescue Exception => e
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@organization = Organization.find params[:id]
|
||||||
|
@organization.name = params[:organization][:name]
|
||||||
|
if @organization.save
|
||||||
|
redirect_to admin_organization_url
|
||||||
|
end
|
||||||
|
rescue Exception => e
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@organization = Organization.find params[:id]
|
||||||
|
if @organization.destroy
|
||||||
|
redirect_to admin_organization_url
|
||||||
|
end
|
||||||
|
rescue Exception => e
|
||||||
|
render_404
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<%= error_messages_for 'project' %>
|
||||||
|
<!--[form:project]-->
|
||||||
|
<% unless @organizations.new_record? %>
|
||||||
|
<p>
|
||||||
|
<%= render :partial=>"avatar/avatar_form",:locals=> {source:@organizations} %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
<p>
|
||||||
|
<label for="project_description">
|
||||||
|
<%= l(:label_organization_name)%>:
|
||||||
|
<span class="required"> </span>
|
||||||
|
</label>
|
||||||
|
<%= f.text_field :name, :required => true, :size => 60, :style => "width:290px;" %>
|
||||||
|
</p>
|
||||||
|
<!--<p>-->
|
||||||
|
<!--<label for="project_description">-->
|
||||||
|
<%#= l(:field_description)%>
|
||||||
|
<!--<span class="required"> </span>-->
|
||||||
|
<!--</label>-->
|
||||||
|
<!--<%#= f.text_area :description, :required => true, :size => 60, :style => "width:490px;" %>-->
|
||||||
|
<!--</p>-->
|
|
@ -0,0 +1,25 @@
|
||||||
|
<%= form_for(@organization) do |f|%>
|
||||||
|
<h3>
|
||||||
|
<%=l(:label_organization_edit)%>
|
||||||
|
</h3>
|
||||||
|
<div class="box tabular" >
|
||||||
|
<%= error_messages_for 'project' %>
|
||||||
|
<p>
|
||||||
|
<%= render :partial=>"avatar/avatar_form",:locals=> {source:@organization} %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="project_description">
|
||||||
|
<%= l(:label_organization_name)%>:
|
||||||
|
<span class="required"> </span>
|
||||||
|
</label>
|
||||||
|
<%= f.text_field :name, :required => true, :size => 60, :style => "width:290px;" %>
|
||||||
|
</p>
|
||||||
|
<span style="padding-left: 60px">
|
||||||
|
<%= submit_tag l(:button_create), :class => "enterprise"%>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<%#= submit_tag l(:button_create_and_continue), :name => 'continue' %>
|
||||||
|
<%= javascript_tag "$('#project_name').focus();" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% html_title(l(:label_organization_edit)) -%>
|
|
@ -0,0 +1,18 @@
|
||||||
|
<%= form_for(@organizations, :method => :post,
|
||||||
|
:name => 'new_form',
|
||||||
|
:url => {:controller => 'organization',
|
||||||
|
:action => 'create'}) do |f|%>
|
||||||
|
<h3>
|
||||||
|
<%=l(:label_organization_new)%>
|
||||||
|
</h3>
|
||||||
|
<div class="box tabular" >
|
||||||
|
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||||
|
<span style="padding-left: 60px">
|
||||||
|
<%= submit_tag l(:button_create), :class => "enterprise"%>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<%#= submit_tag l(:button_create_and_continue), :name => 'continue' %>
|
||||||
|
<%= javascript_tag "$('#project_name').focus();" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% html_title(l(:label_organization_new)) -%>
|
|
@ -539,8 +539,10 @@ zh:
|
||||||
label_activity_project: '项目: ' #added by bai
|
label_activity_project: '项目: ' #added by bai
|
||||||
|
|
||||||
label_organization: 组织
|
label_organization: 组织
|
||||||
|
label_organization_name: 组织名称
|
||||||
label_organization_list: 组织列表
|
label_organization_list: 组织列表
|
||||||
label_organization_new: 新建组织
|
label_organization_new: 新建组织
|
||||||
|
label_organization_edit: 修改组织
|
||||||
label_project_plural: 项目列表
|
label_project_plural: 项目列表
|
||||||
label_first_page_made: 首页定制
|
label_first_page_made: 首页定制
|
||||||
label_project_first_page: 项目托管平台首页
|
label_project_first_page: 项目托管平台首页
|
||||||
|
|
Loading…
Reference in New Issue