commit
a6b3ddcfcb
@ -0,0 +1,55 @@
|
|||||||
|
class OrganizationController < ApplicationController
|
||||||
|
layout 'project_base'
|
||||||
|
before_filter :require_admin, :except => [:index]
|
||||||
|
|
||||||
|
def index
|
||||||
|
#@projects = Project.find_by_sql("SELECT * FROM projects WHERE id IN (select MAX(id) from projects GROUP BY enterprise_name)")
|
||||||
|
@organizations = Organization.all
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
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
|
@ -1,6 +0,0 @@
|
|||||||
class OrganizationsController < ApplicationController
|
|
||||||
layout 'project_base'
|
|
||||||
def index
|
|
||||||
@projects = Project.find_by_sql("SELECT * FROM projects WHERE id IN (select MAX(id) from projects GROUP BY enterprise_name)")
|
|
||||||
end
|
|
||||||
end
|
|
@ -0,0 +1,5 @@
|
|||||||
|
class Organization < ActiveRecord::Base
|
||||||
|
attr_accessible :logo_link, :name
|
||||||
|
|
||||||
|
has_many :projects
|
||||||
|
end
|
@ -0,0 +1,43 @@
|
|||||||
|
<div class="contextual">
|
||||||
|
<%= link_to l(:label_organization_new), new_organization_path, :class => 'icon icon-add' %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>
|
||||||
|
<%=l(:label_organization_list)%>
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<div class="autoscroll">
|
||||||
|
<table class="list" style="width: 100%;table-layout: fixed">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
<%=l(:label_organization)%>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<%=l(:field_created_on)%>
|
||||||
|
</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @organizations.each do |org|%>
|
||||||
|
<tr class="<%= cycle("odd", "even") %>">
|
||||||
|
<td style="text-align:center;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=org.name%>'>
|
||||||
|
<span>
|
||||||
|
<%= link_to org.name,home_path(:organization => org.id) %>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<%= format_date(org.created_at) %>
|
||||||
|
</td>
|
||||||
|
<td class="buttons">
|
||||||
|
<%= link_to(l(:button_change), edit_organization_path(org.id), :class => 'icon icon-copy') %>
|
||||||
|
<%= link_to(l(:button_delete), organization_path(org.id), :method => :delete,:confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end%>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% html_title(l(:label_project_plural)) -%>
|
@ -0,0 +1,31 @@
|
|||||||
|
<title>
|
||||||
|
<%= l(:label_all_enterprises) %>
|
||||||
|
</title>
|
||||||
|
<div class="content_syqy">
|
||||||
|
<div class="list">
|
||||||
|
<%= l(:label_all_enterprises) %>
|
||||||
|
</div>
|
||||||
|
<div class="syqy_box">
|
||||||
|
<% if @organizations.empty? %>
|
||||||
|
<h3>
|
||||||
|
<%= l(:label_enterprise_nil) %>
|
||||||
|
</h3>
|
||||||
|
<% else %>
|
||||||
|
<% @organizations.each do |organization| %>
|
||||||
|
<% unless organization.name.blank? %>
|
||||||
|
<ul>
|
||||||
|
<li >
|
||||||
|
<img src="/images/organization_logo.jpg" width="30" height="30" alt="<%= organization.name%>" />
|
||||||
|
<%= link_to organization.name, home_path(:organization => organization.id) %>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="clear: both"></div>
|
||||||
|
<div class="school-index">
|
||||||
|
<ul id="schoollist" style="line-height: 25px"></ul>
|
||||||
|
</div>
|
||||||
|
<% html_title(l(:label_enterprise_all)) -%>
|
@ -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)) -%>
|
@ -1,23 +0,0 @@
|
|||||||
<title><%= l(:label_all_enterprises) %></title>
|
|
||||||
<div class="content_syqy">
|
|
||||||
<div class="list"><%= l(:label_all_enterprises) %></div>
|
|
||||||
<div class="syqy_box">
|
|
||||||
<% if @projects.count == 0 %>
|
|
||||||
<h3><%= l(:label_enterprise_nil) %></h3>
|
|
||||||
<% else %>
|
|
||||||
<% @projects.each do |organization| %>
|
|
||||||
<% unless organization.enterprise_name.blank? %>
|
|
||||||
<ul>
|
|
||||||
<li ><img src="/images/organization_logo.jpg" width="30" height="30" alt="#{project.enterprise_name}" />
|
|
||||||
<%= link_to organization.enterprise_name, home_path(:organization => organization) %></li>
|
|
||||||
</ul>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style="clear: both"></div>
|
|
||||||
<div class="school-index">
|
|
||||||
<ul id="schoollist" style="line-height: 25px"></ul>
|
|
||||||
</div>
|
|
||||||
<% html_title(l(:label_enterprise_all)) -%>
|
|
@ -1,6 +1,4 @@
|
|||||||
$("#polls_title").val("<%= @poll.polls_name%>");
|
$("#polls_head_show").html("<%= escape_javascript(render :partial => 'show_head', :locals => {:poll => @poll}) %>");
|
||||||
$("#polls_description").val("<%= @poll.polls_description %>");
|
$("#polls_head_edit").html("<%= escape_javascript(render :partial => 'edit_head', :locals => {:poll => @poll}) %>");
|
||||||
$("#polls_name_h").html("<%= @poll.polls_name %>");
|
|
||||||
$("#polls_description_p").html("<%= @poll.polls_description %>");
|
|
||||||
$("#polls_head_edit").hide();
|
$("#polls_head_edit").hide();
|
||||||
$("#polls_head_show").show();
|
$("#polls_head_show").show();
|
@ -0,0 +1,10 @@
|
|||||||
|
class CreateOrganizations < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :organizations do |t|
|
||||||
|
t.string :name
|
||||||
|
t.string :logo_link
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,9 @@
|
|||||||
|
class AddOrganizationToProject < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
add_column :projects, :organization_id, :integer
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_column :projects, :organization_id
|
||||||
|
end
|
||||||
|
end
|
After Width: | Height: | Size: 55 KiB |
@ -0,0 +1,5 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Organization do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Loading…
Reference in new issue