commit
61d2fd199c
@ -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
|
|
@ -1,16 +0,0 @@
|
|||||||
module ExpireHelper
|
|
||||||
#index.html 中 “projects”塊 緩存過期
|
|
||||||
def expire_project_cache
|
|
||||||
ActionController::Base.new.expire_fragment('projects')
|
|
||||||
end
|
|
||||||
|
|
||||||
#index.html 中 “activities”塊 緩存過期
|
|
||||||
def expire_activitie_cache
|
|
||||||
ActionController::Base.new.expire_fragment('activities')
|
|
||||||
end
|
|
||||||
|
|
||||||
#welcome/index.html 中 “forums”塊 緩存過期
|
|
||||||
def expire_forum_cache
|
|
||||||
ActionController::Base.new.expire_fragment('forums')
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,10 +1,6 @@
|
|||||||
class ContestNotification < ActiveRecord::Base
|
class ContestNotification < ActiveRecord::Base
|
||||||
include ExpireHelper
|
|
||||||
attr_accessible :content, :title
|
attr_accessible :content, :title
|
||||||
validates :title, length: {maximum: 30}
|
validates :title, length: {maximum: 30}
|
||||||
after_create :expire_forum_cache
|
|
||||||
after_update :expire_forum_cache
|
|
||||||
before_destroy :expire_forum_cache
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
# Time 2015-02-06 10:42:34
|
||||||
|
# Author lizanle
|
||||||
|
# Description 这是保存Project相关的动态的公共表
|
||||||
|
class ForgeActivity < ActiveRecord::Base
|
||||||
|
# 公共表中活动类型,命名规则:TYPE_OF_{类名}_ACT
|
||||||
|
TYPE_OF_ISSUE_ACT = "Issue"
|
||||||
|
TYPE_OF_MESSAGE_ACT = "Message"
|
||||||
|
TYPE_OF_ATTACHMENT_ACT = "Attachment"
|
||||||
|
TYPE_OF_DOCUMENT_ACT = "Document"
|
||||||
|
TYPE_OF_JOURNAL_ACT = "Journal"
|
||||||
|
TYPE_OF_WIKI_ACT = "Wiki"
|
||||||
|
TYPE_OF_NEWS_ACT = "News"
|
||||||
|
attr_accessible :forge_act_id, :forge_act_type,:project_id,:user_id,:org_id
|
||||||
|
# 虚拟关联
|
||||||
|
belongs_to :forge_act ,:polymorphic => true
|
||||||
|
belongs_to :project
|
||||||
|
belongs_to :user
|
||||||
|
validates :user_id,presence: true
|
||||||
|
validates :project_id,presence: true
|
||||||
|
validates :forge_act_id,presence: true
|
||||||
|
validates :forge_act_type, presence: true
|
||||||
|
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)) -%>
|
|
@ -0,0 +1,13 @@
|
|||||||
|
class CreateForgeActivities < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :forge_activities do |t|
|
||||||
|
t.integer :user_id
|
||||||
|
t.integer :project_id
|
||||||
|
t.references :forge_act, polymorphic: true, index: true
|
||||||
|
t.integer :org_id
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index :forge_activities ,:forge_act_id
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,46 @@
|
|||||||
|
# Time 2015-02-37 15:03:42
|
||||||
|
# Author lizanle
|
||||||
|
# Description 将Issue中的数据导入forge_activities表
|
||||||
|
class ImportIssueDataToForgeActivities < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
issue_arr = select_all("SELECT\n" +
|
||||||
|
" `issues`.`id` AS id,\n" +
|
||||||
|
" `issues`.`project_id` AS project_id,\n" +
|
||||||
|
" `issues`.`author_id` AS author_id,\n" +
|
||||||
|
" `issues`.`created_on` AS created_on,\n" +
|
||||||
|
" `issues`.`updated_on` AS updated_on\n" +
|
||||||
|
"FROM\n" +
|
||||||
|
" `issues`\n" +
|
||||||
|
"LEFT OUTER JOIN `projects` ON `projects`.`id` = `issues`.`project_id`\n" +
|
||||||
|
"LEFT OUTER JOIN `users` ON `users`.`id` = `issues`.`author_id`\n" +
|
||||||
|
"AND `users`.`type` IN ('User', 'AnonymousUser')\n" +
|
||||||
|
"LEFT OUTER JOIN `trackers` ON `trackers`.`id` = `issues`.`tracker_id`\n" +
|
||||||
|
"WHERE\n" +
|
||||||
|
" (\n" +
|
||||||
|
" projects. STATUS <> 9\n" +
|
||||||
|
" AND projects.id IN (\n" +
|
||||||
|
" SELECT\n" +
|
||||||
|
" em.project_id\n" +
|
||||||
|
" FROM\n" +
|
||||||
|
" enabled_modules em\n" +
|
||||||
|
" WHERE\n" +
|
||||||
|
" em. NAME = 'issue_tracking'\n" +
|
||||||
|
" )\n" +
|
||||||
|
" )");
|
||||||
|
issue_arr.each do |e|
|
||||||
|
ForgeActivity.connection.execute("insert into forge_activities(forge_act_id,
|
||||||
|
forge_act_type,
|
||||||
|
project_id,
|
||||||
|
user_id,
|
||||||
|
created_at,
|
||||||
|
updated_at)
|
||||||
|
values(#{e["id"]},'#{Issue.to_s}',#{e["project_id"]},#{e["author_id"]},
|
||||||
|
'#{e["created_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}',
|
||||||
|
'#{e["updated_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}')")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
ForgeActivity.delete_all([" forge_act_type = ?",ForgeActivity::TYPE_OF_ISSUE_ACT])
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,51 @@
|
|||||||
|
class AddJournalDataToForgeActivities < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
journal_arr = select_all("SELECT\n" +
|
||||||
|
" `journals`.`id` AS id,\n" +
|
||||||
|
" `journals`.`created_on` AS created_on,\n" +
|
||||||
|
" `projects`.`id` AS project_id,\n" +
|
||||||
|
" `issues`.`updated_on` AS updated_on,\n" +
|
||||||
|
" `users`.`id` AS author_id\n" +
|
||||||
|
"FROM\n" +
|
||||||
|
" `journals`\n" +
|
||||||
|
"LEFT OUTER JOIN `issues` ON `issues`.`id` = `journals`.`journalized_id`\n" +
|
||||||
|
"LEFT OUTER JOIN `projects` ON `projects`.`id` = `issues`.`project_id`\n" +
|
||||||
|
"LEFT OUTER JOIN `journal_details` ON `journal_details`.`journal_id` = `journals`.`id`\n" +
|
||||||
|
"LEFT OUTER JOIN `users` ON `users`.`id` = `journals`.`user_id`\n" +
|
||||||
|
"AND `users`.`type` IN ('User', 'AnonymousUser')\n" +
|
||||||
|
"WHERE\n" +
|
||||||
|
" (\n" +
|
||||||
|
" projects. STATUS <> 9\n" +
|
||||||
|
" AND projects.id IN (\n" +
|
||||||
|
" SELECT\n" +
|
||||||
|
" em.project_id\n" +
|
||||||
|
" FROM\n" +
|
||||||
|
" enabled_modules em\n" +
|
||||||
|
" WHERE\n" +
|
||||||
|
" em. NAME = 'issue_tracking'\n" +
|
||||||
|
" )\n" +
|
||||||
|
" )\n" +
|
||||||
|
" AND (\n" +
|
||||||
|
" journals.journalized_type = 'Issue'\n" +
|
||||||
|
" AND (\n" +
|
||||||
|
" journal_details.prop_key = 'status_id'\n" +
|
||||||
|
" OR journals.notes <> ''\n" +
|
||||||
|
" )\n" +
|
||||||
|
" )");
|
||||||
|
journal_arr.each do |e|
|
||||||
|
ForgeActivity.connection.execute("insert into forge_activities(forge_act_id,
|
||||||
|
forge_act_type,
|
||||||
|
project_id,
|
||||||
|
user_id,
|
||||||
|
created_at,
|
||||||
|
updated_at)
|
||||||
|
values(#{e["id"]},'#{Journal.to_s}',#{e["project_id"]},#{e["author_id"]},
|
||||||
|
'#{e["created_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}',
|
||||||
|
'#{e["updated_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}')")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
ForgeActivity.delete_all([" forge_act_type = ?",ForgeActivity::TYPE_OF_JOURNAL_ACT])
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,41 @@
|
|||||||
|
class ImportMessageDataToForgeActivities < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
issue_arr = select_all("SELECT\n" +
|
||||||
|
" `messages`.`id` AS id,\n" +
|
||||||
|
" `messages`.`author_id` AS author_id,\n" +
|
||||||
|
" `projects`.`id` AS project_id,\n" +
|
||||||
|
" `messages`.`created_on` AS created_on,\n" +
|
||||||
|
" `messages`.`updated_on` AS updated_on\n" +
|
||||||
|
"FROM\n" +
|
||||||
|
" `messages`\n" +
|
||||||
|
"LEFT OUTER JOIN `boards` ON `boards`.`id` = `messages`.`board_id`\n" +
|
||||||
|
"LEFT OUTER JOIN `projects` ON `projects`.`id` = `boards`.`project_id`\n" +
|
||||||
|
"LEFT OUTER JOIN `users` ON `users`.`id` = `messages`.`author_id`\n" +
|
||||||
|
"AND `users`.`type` IN ('User', 'AnonymousUser')\n" +
|
||||||
|
"WHERE\n" +
|
||||||
|
" projects. STATUS <> 9\n" +
|
||||||
|
" AND projects.id IN (\n" +
|
||||||
|
" SELECT\n" +
|
||||||
|
" em.project_id\n" +
|
||||||
|
" FROM\n" +
|
||||||
|
" enabled_modules em\n" +
|
||||||
|
" WHERE\n" +
|
||||||
|
" em. NAME = 'boards'\n" +
|
||||||
|
")");
|
||||||
|
issue_arr.each do |e|
|
||||||
|
ForgeActivity.connection.execute("insert into forge_activities(forge_act_id,
|
||||||
|
forge_act_type,
|
||||||
|
project_id,
|
||||||
|
user_id,
|
||||||
|
created_at,
|
||||||
|
updated_at)
|
||||||
|
values(#{e["id"]},'#{Message.to_s}',#{e["project_id"]},#{e["author_id"]},
|
||||||
|
'#{e["created_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}',
|
||||||
|
'#{e["updated_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}')")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
ForgeActivity.delete_all([" forge_act_type = ?",ForgeActivity::TYPE_OF_MESSAGE_ACT])
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,41 @@
|
|||||||
|
class ImportNewsDataToForgeActivities < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
issue_arr = select_all("SELECT\n" +
|
||||||
|
" `messages`.`id` AS id,\n" +
|
||||||
|
" `messages`.`author_id` AS author_id,\n" +
|
||||||
|
" `projects`.`id` AS project_id,\n" +
|
||||||
|
" `messages`.`created_on` AS created_on,\n" +
|
||||||
|
" `messages`.`updated_on` AS updated_on\n" +
|
||||||
|
"FROM\n" +
|
||||||
|
" `messages`\n" +
|
||||||
|
"LEFT OUTER JOIN `boards` ON `boards`.`id` = `messages`.`board_id`\n" +
|
||||||
|
"LEFT OUTER JOIN `projects` ON `projects`.`id` = `boards`.`project_id`\n" +
|
||||||
|
"LEFT OUTER JOIN `users` ON `users`.`id` = `messages`.`author_id`\n" +
|
||||||
|
"AND `users`.`type` IN ('User', 'AnonymousUser')\n" +
|
||||||
|
"WHERE\n" +
|
||||||
|
" projects. STATUS <> 9\n" +
|
||||||
|
" AND projects.id IN (\n" +
|
||||||
|
" SELECT\n" +
|
||||||
|
" em.project_id\n" +
|
||||||
|
" FROM\n" +
|
||||||
|
" enabled_modules em\n" +
|
||||||
|
" WHERE\n" +
|
||||||
|
" em. NAME = 'boards'\n" +
|
||||||
|
")");
|
||||||
|
issue_arr.each do |e|
|
||||||
|
ForgeActivity.connection.execute("insert into forge_activities(forge_act_id,
|
||||||
|
forge_act_type,
|
||||||
|
project_id,
|
||||||
|
user_id,
|
||||||
|
created_at,
|
||||||
|
updated_at)
|
||||||
|
values(#{e["id"]},'#{News.to_s}',#{e["project_id"]},#{e["author_id"]},
|
||||||
|
'#{e["created_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}',
|
||||||
|
'#{e["created_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}')")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
ForgeActivity.delete_all([" forge_act_type = ?",ForgeActivity::TYPE_OF_NEWS_ACT])
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,6 @@
|
|||||||
|
class AddColumnProjectIssueIndexToIssues < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :issues, :project_issues_index, :integer
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,10 @@
|
|||||||
|
class AddDataToProjectIssuesIndexsInIssue < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
for i in 1 ... 1000 do i
|
||||||
|
Issue.page(i).per(10).each do |e|
|
||||||
|
index = e.project.issues.index(e).to_i + 1
|
||||||
|
execute("update issues set project_issues_index = #{index} where id = #{e.id}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,37 @@
|
|||||||
|
class ImportDocumentDataToForgeActivities < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
doc_arr = select_all("SELECT\n" +
|
||||||
|
" `documents`.`id` AS id,\n" +
|
||||||
|
" `documents`.`project_id` AS project_id,\n" +
|
||||||
|
" `documents`.`created_on` AS created_on,\n" +
|
||||||
|
" `documents`.`user_id` AS author_id\n" +
|
||||||
|
"FROM\n" +
|
||||||
|
" `documents`\n" +
|
||||||
|
"LEFT OUTER JOIN `projects` ON `projects`.`id` = `documents`.`project_id`\n" +
|
||||||
|
"WHERE\n" +
|
||||||
|
" projects. STATUS <> 9\n" +
|
||||||
|
" AND projects.id IN (\n" +
|
||||||
|
" SELECT\n" +
|
||||||
|
" em.project_id\n" +
|
||||||
|
" FROM\n" +
|
||||||
|
" enabled_modules em\n" +
|
||||||
|
" WHERE\n" +
|
||||||
|
" em. NAME = 'documents'\n" +
|
||||||
|
")");
|
||||||
|
doc_arr.each do |e|
|
||||||
|
ForgeActivity.connection.execute("insert into forge_activities(forge_act_id,
|
||||||
|
forge_act_type,
|
||||||
|
project_id,
|
||||||
|
user_id,
|
||||||
|
created_at,
|
||||||
|
updated_at)
|
||||||
|
values(#{e["id"]},'#{Document.to_s}',#{e["project_id"]},#{e["author_id"]},
|
||||||
|
'#{e["created_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}',
|
||||||
|
'#{e["created_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}')")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
ForgeActivity.delete_all([" forge_act_type = ?",ForgeActivity::TYPE_OF_DOCUMENT_ACT])
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,43 @@
|
|||||||
|
class ImportAttachmentsDataToForgeActivities < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
attach_arr = select_all("SELECT\n" +
|
||||||
|
" attachments.author_id as author_id,\n" +
|
||||||
|
" attachments.created_on as created_on,\n" +
|
||||||
|
" attachments.id as id,\n" +
|
||||||
|
" projects.id as project_id\n" +
|
||||||
|
"FROM\n" +
|
||||||
|
" `attachments`\n" +
|
||||||
|
"LEFT JOIN versions ON attachments.container_type = 'Version'\n" +
|
||||||
|
"AND versions.id = attachments.container_id\n" +
|
||||||
|
"LEFT JOIN projects ON versions.project_id = projects.id\n" +
|
||||||
|
"OR (\n" +
|
||||||
|
" attachments.container_type = 'Project'\n" +
|
||||||
|
" AND attachments.container_id = projects.id\n" +
|
||||||
|
")\n" +
|
||||||
|
"WHERE\n" +
|
||||||
|
" projects. STATUS <> 9\n" +
|
||||||
|
" AND projects.id IN (\n" +
|
||||||
|
" SELECT\n" +
|
||||||
|
" em.project_id\n" +
|
||||||
|
" FROM\n" +
|
||||||
|
" enabled_modules em\n" +
|
||||||
|
" WHERE\n" +
|
||||||
|
" em. NAME = 'files'\n" +
|
||||||
|
" )");
|
||||||
|
attach_arr.each do |e|
|
||||||
|
ForgeActivity.connection.execute("insert into forge_activities(forge_act_id,
|
||||||
|
forge_act_type,
|
||||||
|
project_id,
|
||||||
|
user_id,
|
||||||
|
created_at,
|
||||||
|
updated_at)
|
||||||
|
values(#{e["id"]},'#{Attachment.to_s}',#{e["project_id"]},#{e["author_id"]},
|
||||||
|
'#{e["created_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}',
|
||||||
|
'#{e["created_on"].to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S")}')")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
ForgeActivity.delete_all([" forge_act_type = ?",ForgeActivity::TYPE_OF_ATTACHMENT_ACT])
|
||||||
|
end
|
||||||
|
end
|
@ -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 |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,5 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe ForgeActivity do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
@ -0,0 +1,5 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Organization do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Loading…
Reference in new issue