Conflicts:
	db/schema.rb
This commit is contained in:
z9hang 2014-08-13 11:21:37 +08:00
commit 56aa2fb8dc
30 changed files with 288 additions and 188 deletions

View File

@ -119,8 +119,8 @@ class AccountController < ApplicationController
@user = User.new
@user.safe_attributes = user_params
if params[:identity] == "2" # 2 企业
#@user.firstname = params[:enterprise_name]
#@user.lastname = l(:field_enterprise)
@user.firstname = params[:enterprise_name]
@user.lastname = l(:field_enterprise)
end
@user.admin = false
@user.register

View File

@ -893,6 +893,18 @@ class ProjectsController < ApplicationController
end
end
def exit_project
@project = Project.find params[:id]
if User.current.login?
members = Member.where(:user_id => User.current.id, :project_id=>params[:id]).first
if members != nil
members.destroy
end
respond_to do |format|
format.js
end
end
end
private
def memberAccess
@ -1039,4 +1051,5 @@ class ProjectsController < ApplicationController
end
#gcmend
end

View File

@ -1300,10 +1300,10 @@ module ApplicationHelper
start_of_week = start_of_week.to_i % 7
tags = javascript_tag(
"var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: #{start_of_week}, " +
"var datepickerOptions={dateFormat: 'yy-mm-dd',minDate: new Date(), firstDay: #{start_of_week}, " +
"showOn: 'button', buttonImageOnly: true, buttonImage: '" +
path_to_image('/images/calendar.png') +
"', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true};")
"', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true, onClose: function(dateText, inst) {TimeClose(dateText,inst);}, beforeShow : function(input){TimeBeforeShow(input);} };")
jquery_locale = l('jquery.locale', :default => current_language.to_s)
unless jquery_locale == 'en'
tags << javascript_include_tag("i18n/jquery.ui.datepicker-#{jquery_locale}.js")

View File

@ -246,4 +246,7 @@ module WatchersHelper
link_to text, url, :remote => true, :method => method ,:class=>css
end
end
def exit_project_link(project)
link_to("退出项目",exit_cur_project_path(project.id),:remote => true )
end
end

View File

@ -231,12 +231,12 @@ module WelcomeHelper
# modif by nwb
def find_all_new_hot_course limit = 9 ,school_id = 0
#sort_project_by_hot_rails 1, 'course_ac_para DESC', limit
time_now = Time.new.strftime("%Y");
time_now = Time.new.strftime("%Y")
if school_id
courses = Course.visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id <>
courses = Course.includes(:school, :members).visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id <>
?", school_id).order("course_ac_para DESC").limit(limit).all
else
courses = Course.visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id is not NULL
courses = Course.includes(:school, :members).visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id is not NULL
").order("course_ac_para DESC").limit(limit).all
end
courses

View File

@ -0,0 +1,3 @@
class CourseAttachment < ActiveRecord::Base
attr_accessible :attachtype, :author_id, :content_type, :description, :digest, :disk_directory, :disk_filename, :downloads, :filename, :filesize, :integer, :is_public
end

View File

@ -0,0 +1,4 @@
class ProjectScore < ActiveRecord::Base
attr_accessible :project_id, :score
belongs_to :project, foreign_key: :project_id
end

View File

@ -1,45 +1,45 @@
<div class="contextual">
<%= link_to l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add' %>
</div>
<h3><%=l(:label_project_plural)%></h3>
<%= form_tag({}, :method => :get) do %>
<fieldset><legend><%= l(:label_filter_plural) %></legend>
<label for='status'><%= l(:field_status) %> :</label>
<%= select_tag 'status', project_status_options_for_select(@status), :class => "small", :onchange => "this.form.submit(); return false;" %>
<label for='name'><%= l(:label_project) %>:</label>
<%= text_field_tag 'name', params[:name], :size => 30 %>
<%= submit_tag l(:button_apply), :class => "small", :name => nil %>
<%= link_to l(:button_clear), {:controller => 'admin', :action => 'projects'}, :class => 'icon icon-reload' %>
</fieldset>
<% end %>
&nbsp;
<div class="autoscroll">
<table class="list">
<thead><tr>
<th><%=l(:label_project)%></th>
<th><%=l(:field_is_public)%></th>
<th><%=l(:field_created_on)%></th>
<th></th>
</tr></thead>
<tbody>
<% project_tree(@projects) do |project, level| %>
<tr class="<%= cycle("odd", "even") %> <%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
<td class="name"><span><%= link_to_project_settings(project, {}, :title => project.short_description) %></span></td>
<td align="center"><%= checked_image project.is_public? %></td>
<td align="center"><%= format_date(project.created_on) %></td>
<td class="buttons">
<%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project, :status => params[:status] }, :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock') unless project.archived? %>
<%= link_to(l(:button_unarchive), { :controller => 'projects', :action => 'unarchive', :id => project, :status => params[:status] }, :method => :post, :class => 'icon icon-unlock') if project.archived? && (project.parent.nil? || !project.parent.archived?) %>
<%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %>
<%= link_to(l(:button_delete), project_path(project), :method => :delete, :class => 'icon icon-del') %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% html_title(l(:label_project_plural)) -%>
<div class="contextual">
<%= link_to l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add' %>
</div>
<h3><%=l(:label_project_plural)%></h3>
<%= form_tag({}, :method => :get) do %>
<fieldset><legend><%= l(:label_filter_plural) %></legend>
<label for='status'><%= l(:field_status) %> :</label>
<%= select_tag 'status', project_status_options_for_select(@status), :class => "small", :onchange => "this.form.submit(); return false;" %>
<label for='name'><%= l(:label_project) %>:</label>
<%= text_field_tag 'name', params[:name], :size => 30 %>
<%= submit_tag l(:button_apply), :class => "small", :name => nil %>
<%= link_to l(:button_clear), {:controller => 'admin', :action => 'projects'}, :class => 'icon icon-reload' %>
</fieldset>
<% end %>
&nbsp;
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed">
<thead><tr>
<th><%=l(:label_project)%></th>
<th><%=l(:field_is_public)%></th>
<th><%=l(:field_created_on)%></th>
<th></th>
</tr></thead>
<tbody>
<% project_tree(@projects) do |project, level| %>
<tr class="<%= cycle("odd", "even") %> <%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=project.name%>'><span><%= link_to_project_settings(project, {}) %></span></td>
<td align="center"><%= checked_image project.is_public? %></td>
<td align="center"><%= format_date(project.created_on) %></td>
<td class="buttons">
<%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project, :status => params[:status] }, :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock') unless project.archived? %>
<%= link_to(l(:button_unarchive), { :controller => 'projects', :action => 'unarchive', :id => project, :status => params[:status] }, :method => :post, :class => 'icon icon-unlock') if project.archived? && (project.parent.nil? || !project.parent.archived?) %>
<%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %>
<%= link_to(l(:button_delete), project_path(project), :method => :delete, :class => 'icon icon-del') %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% html_title(l(:label_project_plural)) -%>

View File

@ -40,13 +40,13 @@
<th></th>
</tr>
</thead>
<col style="width: 20%" />
<col style="width: 10%" />
<col style="width: 5%" />
<col style="width: 20%" />
<col style="width: 5%" />
<col style="width: 15%" />
<col style="width: 15%" />
<col style="width: 10%" />
<col style="width: 5%" />
<col style="width: 10%" />
<col style="width: 10%" />
<col style="width: 5%" />
<col style="width: 5%" />
<tbody>

View File

@ -46,6 +46,43 @@
<p><%= f.text_field :estimated_hours, :size => 3, :disabled => !@issue.leaf?, :required => @issue.required_attribute?('estimated_hours') %> <%= l(:field_hours) %></p>
<% end %>
<script type="text/javascript">
// window.onload=function(){
// var img=$("#issue_due_date").next("img");
// img.attr("onclick","SetMinValue();");
// }
function TimeClose(dateText, inst) {
if(inst.id=="issue_start_date"){
time=dateText;
}
}
var time=new Date();
function TimeBeforeShow(input){
if(input.id=="issue_due_date"){
//var minDate = $(input).datepicker('option', 'minDate');
var tempdata=$("#issue_start_date").attr("value");
$(input).datepicker('option', 'minDate',new Date(tempdata.replace(/-/g, "/")));
//$('.selector').datepicker('option', 'minDate', '12/25/2012');
}
}
function SetMinValue(){
/// var tempdata=$("#issue_start_date").attr("value");
//$('.selector').datepicker('option', 'minDate', '12/25/2012');
//alert(tempdata);
//$("#issue_due_date").datepicker({
// minDate: new Date(2014,08,23)
//var datepickerOptions=
//{dateFormat: 'yy-mm-dd',minDate: new Date(2014,08,23), showOn: 'button', buttonImageOnly: true, buttonImage: "path_to_image('/images/calendar.png')", showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true};
//alert( $('.issue_due_date').length);
//$('.selector')[1].datepicker('option', 'minDate', new Date(2014, 0 - 8, 23));
//$("#issue_due_date").datepicker(datepickerOptions);
//$("##{issue_due_date}").datepicker(datepickerOptions);
//$("#issue_due_date").datepicker(
// {dateFormat: 'yy-mm-dd',minDate: new Date(2014,08,23), showOn: 'button', buttonImageOnly: true, buttonImage: "path_to_image('/images/calendar.png')", showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true}
//)
//});
}
function PrecentChange(obj){
var _v= obj;
if(_v==100)

View File

@ -0,0 +1,20 @@
<div style="margin-left: 20px;">
<% if ( !(User.current.member_of? @project) && User.current.login?) %> <!--added by linchun-->
<span class="icon-fav icon"></span><%= watcher_link(@project, User.current) %>
<% end %>
</div>
<!--添加项目申请-->
<div style="margin-left: 20px;">
<% if ( !(User.current.member_of? @project) && User.current.login?) %>
<span class="icon-fav icon"></span>
<%= applied_link(@project, User.current) %>
<% end %>
</div>
<!--添加退出项目-->
<div style="margin-left: 20px;">
<% if ((User.current.member_of? @project) && User.current.login?) %>
<%= exit_project_link(@project) %>
<% end %>
</div>

View File

@ -74,20 +74,9 @@
<% end %>
<!-- end -->
</div>
<div style="margin-left: 20px;">
<% if ( !(User.current.member_of? @project) && User.current.login?) %> <!--added by linchun-->
<span class="icon-fav icon"></span><%= watcher_link(@project, User.current) %>
<% end %>
</div>
<!--添加项目申请-->
<div style="margin-left: 20px;">
<% if ( !(User.current.member_of? @project) && User.current.login?) %>
<span class="icon-fav icon"></span>
<%= applied_link(@project, User.current) %>
<% end %>
<div id="join_exit_project_div">
<%= render 'layouts/join_exit_project' %>
</div>
</td>
</tr>
</table>

View File

@ -161,7 +161,8 @@
<td class="comments">
<div class="wiki">
<%= textilizable message, :content, :attachments => message.attachments %>
<%#= textilizable message,:content,:attachments => message.attachments %>
<%= message.content.html_safe %>
</div>
<%= link_to_attachments message, :author => false %> </td>
</tr>

View File

@ -1,5 +1,5 @@
<% if @project %>
<%= render :partial => 'project_show', locals: {project: @project} %>
<% elsif @course %>
<%= render :partial => 'course_show', locals: {course: @course} %>
<% end %>
<% if @project %>
<%= render :partial => 'project_show', locals: {project: @project} %>
<% elsif @course %>
<%= render :partial => 'course_show', locals: {course: @course} %>
<% end %>

View File

@ -13,7 +13,7 @@
<p><label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
<%= password_field_tag 'new_password_confirmation', nil, :size => 25 %></p>
<%= submit_tag l(:button_apply) %>
<%= submit_tag l(:label_button_ok) %>
</div>
<% end %>

View File

@ -0,0 +1 @@
$('#join_exit_project_div').html("<%= escape_javascript(render(:partial => 'layouts/join_exit_project')) %>");

View File

@ -0,0 +1,28 @@
<% course_list.map do |course| %>
<li class='<%= cycle("odd", "even") %>' title=<%= course.description.to_s.gsub(/<\/?.*?>/,"") %>>
<div class='avatar'>
<%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
</div>
<!-- 上左下右 -->
<div class='desc_item'>
<span class=''>
<% if (course.school == nil) %>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<% else %>
<%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course', :school_id => course.school.id}, html_options={:method => 'get'} %>
<% end %>
</span>
<span class='font_bolder'>
<%= link_to(course.try(:teacher).try(:realname), user_path(course.teacher)) %>
<%#=course.try(:teacher).try(:name)%>
</span>
</div>
<div class='desc_item text_nowrap'>
[<%= get_course_term course %>]
<%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
(<%= course.members.count %>人)
<%# files_count = course.attachments.count.to_s %>
(<%= link_to "#{course.attachments.count.to_s}份", course_files_path(course) %>资料)
</div>
</li>
<% end %>

View File

@ -0,0 +1,5 @@
<h1></h1>
<p id="errorExplanation">
<%= course_title%>
</p>
<h1></h1>

View File

@ -88,51 +88,20 @@
<span><%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => nil} %></span>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
</ul>
<ul class="d-p-projectlist">
<% if User.current.logged? %>
<h1></h1>
<p id="errorExplanation">
该学校未开设任何课程,您可以查看其他学校课程
</p>
<h1></h1>
<% end %>
<% find_all_new_hot_course(9, @school_id).map do |course| %>
<li class='<%= cycle("odd", "even") %>' title=<%= course.description.to_s.gsub(/<\/?.*?>/,"") %>>
<div class='avatar'>
<%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
</div>
<!-- 上左下右 -->
<div class='desc_item'>
<span class=''>
<% if (course.school == nil) %>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<% else %>
<%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course', :school_id => course.school.id}, html_options={:method => 'get'} %>
<% end %>
</span>
<span class='font_bolder'>
<%= link_to(course.try(:teacher).try(:realname), user_path(course.teacher)) %>
<%#=course.try(:teacher).try(:name)%>
</span>
</div>
<div class='desc_item text_nowrap'>
[<%= get_course_term course %>]
<%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
(<%= "#{memberCount(course)}人" %>)
<% files_count = course.attachments.count.to_s %>
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
</div>
<li>
<%= render :partial => 'no_course_title', :locals => {:course_title => l(:lable_school_no_course)} %>
</li>
<%= render :partial => 'course_list', :locals => {:course_list => find_all_new_hot_course(9, @school_id)} %>
<% else %>
<%= render :partial => 'course_list', :locals => {:course_list => find_all_new_hot_course(10, @school_id)} %>
<% end %>
</ul>
</div>
<% else %>
<% if school_course.count < 9 %>
<% if school_course.count < 10 %>
<span>
<%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => nil} %>
</span>
@ -143,80 +112,12 @@
<% end %>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
</ul>
<ul class="d-p-projectlist">
<% school_course.map do |course| %>
<% if course.school%>
<li class='<%= cycle("odd", "even") %>' title=<%= course.description.to_s.gsub(/<\/?.*?>/,"") %>>
<div class='avatar'>
<%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
</div>
<!-- 上左下右 -->
<div class='desc_item'>
<span class=''>
<%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course', :school_id => course.school.id}, html_options={:method => 'get'} %>
</span>
<span class='font_bolder'>
<%= link_to(course.try(:teacher).try(:realname), user_path(course.teacher)) %>
</span>
</div>
<div class='desc_item text_nowrap'>
[<%= get_course_term course %>]
<%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
(<%= "#{memberCount(course)}人" %>)
<% files_count = course.attachments.count.to_s %>
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
</div>
<!--
<div class='join_course_link'>
<%# if !course_endTime_timeout?(course) %>
<div>
<%#= join_in_course(course, User.current) %>
</div>
<%# end %>
</div>
-->
</li>
<%end%>
<% end; reset_cycle %>
<% if school_course.count < 9 %>
<%= render :partial => 'course_list', :locals => {:course_list => school_course} %>
<% if school_course.count < 10 %>
<li>
<h1></h1>
<p id="errorExplanation">
该学校开设课程较少,您可以查看其他学校课程
</p>
<%= render :partial => 'no_course_title', :locals => {:course_title => l(:lable_school_less_course)} %>
</li>
<% find_all_new_hot_course(9 - school_course.count, @school_id).map do |course| %>
<li class='<%= cycle("odd", "even") %>' title=<%= course.description.to_s.gsub(/<\/?.*?>/,"") %>>
<div class='avatar'>
<%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
</div>
<!-- 上左下右 -->
<div class='desc_item'>
<span class=''>
<% if (course.school == nil) %>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<% else %>
<!-- modified by zjc 添加超链接 -->
<%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course', :school_id => course.school.id}, html_options={:method => 'get'} %>
<% end %>
</span>
<span class='font_bolder'>
<%= link_to(course.try(:teacher).try(:name), user_path(course.teacher)) %>
</span>
</div>
<div class='desc_item text_nowrap'>
[<%= get_course_term course %>]
<%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
(<%= "#{memberCount(course)}人" %> )
<% files_count = course.attachments.count.to_i.to_s %>
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
</div>
</li>
<% end %>
<%= render :partial => 'course_list', :locals => {:course_list => find_all_new_hot_course(9 - school_course.count, @school_id)} %>
<% end %>
</ul>
</div>

View File

@ -1,4 +1,5 @@
<div class="wiki wiki-page">
<%= textilizable content, :text, :attachments => content.page.attachments,
:edit_section_links => (@sections_editable && {:controller => 'wiki', :action => 'edit', :project_id => @page.project, :id => @page.title}) %>
<%#= content.text.html_safe %>
</div>

View File

@ -1,5 +1,6 @@
<%= wiki_page_breadcrumb(@page) %>
<script src="/javascripts/ckeditor/ckeditor.js?1404953555" type="text/javascript"></script>
<h3><%= h @page.pretty_title %></h3>
<%= form_for @content, :as => :content,
@ -12,8 +13,15 @@
<% end %>
<%= error_messages_for 'content' %>
<div class="actions" style="max-width:680px">
<p style="max-width:680px;"><%=text_area_tag 'content[text]', @text, :required => true, :id => 'editor02', :cols => 100, :rows => 25 %></p>
<script type="text/javascript">
var ckeditor=CKEDITOR.replace('editor02');
</script>
</div>
<div class="box tabular">
<%= text_area_tag 'content[text]', @text, :cols => 100, :rows => 25,
<%#= text_area_tag 'content[text]', @text, :cols => 100, :rows => 25,
:class => 'wiki-edit', :accesskey => accesskey(:edit) %>
<!--p style="max-width:680px"><input id="editor02" required="true" /><%#= f.text_area :comments, :required => true, :id => 'editor02' %></p>
@ -31,7 +39,7 @@
<% end %>
<% end %>
<p><label><%= l(:field_comments) %></label><%= f.text_field :comments, :size => 120 %></p>
<p style="width: 100%;"><label><%= l(:field_comments) %></label><%= f.text_field :comments, :style => "width:75%;" %></p>
<p><label><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form' %></p>
</div>

View File

@ -1197,6 +1197,7 @@ en:
label_tags_issue_description: issue description
label_tags_all_objects: all objects
label_apply_project: Apply Project
label_exit_project: Exit Project
label_apply_project_waiting: "Application has been submitted, please wait for administrator review."
label_unapply_project: Unsubscribe

View File

@ -1409,6 +1409,7 @@ zh:
label_tags_issue_description: 问题描述
label_tags_all_objects: 所有
label_apply_project: 申请加入
label_exit_project: 退出项目
label_apply_project_waiting: 已处理申请,请等待管理员审核
label_unapply_project: 取消申请
@ -2100,4 +2101,7 @@ zh:
# ajax异步验证
modal_valid_passing: 可以使用
label_bug: 漏洞
lable_school_no_course: 该学校未开设任何课程,您可以查看其他学校课程
lable_school_less_course: 该学校开设课程较少,您可以查看其他学校课程

View File

@ -510,6 +510,7 @@ RedmineApp::Application.routes.draw do
get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil
get 'projects/:id/repository', :to => 'repositories#show', :path => nil
get 'projects/:id/exit', :to => 'projects#exit_project', :as => 'exit_cur_project'
# additional routes for having the file name at the end of url
get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment'

View File

@ -0,0 +1,10 @@
class CreateProjectScores < ActiveRecord::Migration
def change
create_table :project_scores do |t|
t.string :project_id
t.integer :score
t.timestamps
end
end
end

View File

@ -0,0 +1,20 @@
class CreateCourseAttachments < ActiveRecord::Migration
def change
create_table :course_attachments do |t|
t.string :filename
t.string :disk_filename
t.integer :filesize
t.string :content_type
t.string :digest
t.integer :downloads
t.string :author_id
t.string :integer
t.string :description
t.string :disk_directory
t.integer :attachtype
t.integer :is_public
t.timestamps
end
end
end

View File

@ -0,0 +1,5 @@
class AddColunToCourseAttachments < ActiveRecord::Migration
def change
add_column :course_attachments, :container_id, :integer, :default => 0
end
end

View File

@ -0,0 +1,29 @@
class UpdateCourseAttachments < ActiveRecord::Migration
def up
attachments = Attachment.where(" container_type = 'Course'")
attachments.each do |attachment|
course_attachment = CourseAttachment.new
course_attachment.container_id = attachment.container_id
course_attachment.filename = attachment.filename
course_attachment.disk_filename = attachment.disk_filename
course_attachment.filesize = attachment.filesize
course_attachment.content_type = attachment.content_type
course_attachment.digest = attachment.digest
course_attachment.downloads = attachment.downloads
course_attachment.author_id = attachment.author_id
course_attachment.created_at = attachment.created_on
course_attachment.description = attachment.description
course_attachment.disk_directory = attachment.disk_directory
course_attachment.attachtype = attachment.attachtype
course_attachment.is_public = attachment.is_public
course_attachment.save(:validate => false)
end
end
def down
coll = CourseAttachment.all
coll.each do |model|
model.destroy
end
end
end

9
test/fixtures/project_scores.yml vendored Normal file
View File

@ -0,0 +1,9 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
project_id: MyString
score: 1
two:
project_id: MyString
score: 1

View File

@ -0,0 +1,7 @@
require 'test_helper'
class ProjectScoreTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end