diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index f0597fafb..e2f5e3731 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -29,8 +29,9 @@ class ContestsController < ApplicationController # @contests = Contest.visible # @contests ||= [] @offset, @limit = api_offset_and_limit({:limit => 10}) - @contests = Contest.visible - @contests = @contests.like(params[:name]) if params[:name].present? + #@contests = Contest.visible + #@contests = @contests.like(params[:name]) if params[:name].present? + @contests = Contest.visible.where("name like '%#{params[:name]}%'") if params[:contests_search] (redirect_to contests_path, :notice => l(:label_sumbit_empty);return) if params[:name].blank? end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index ba01aa990..1318e40a5 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -71,8 +71,8 @@ class TagsController < ApplicationController @projects_results, @issues_results, @bids_results, - @forums_results, - attachments_results, + @forums_results, + @attachments_results, @contests_results, @courses_results, @open_source_projects_results= refresh_results(@obj_id,@obj_flag,@selected_tags) @@ -107,8 +107,8 @@ class TagsController < ApplicationController @projects_results, @issues_results, @bids_results, - @forums_results, - attachments_results, + @forums_results, + @attachments_results, @contests_results, @courses_results, @open_source_projects_results= refresh_results(@obj_id,@show_flag) @@ -130,8 +130,8 @@ class TagsController < ApplicationController @projects_results, @issues_results, @bids_results, - @forums_results, - attachments_results, + @forums_results, + @attachments_results, @contests_results, @courses_results, @open_source_projects_results= refresh_results(@obj_id,@show_flag) @@ -199,7 +199,7 @@ class TagsController < ApplicationController @bids_results = nil @contests_results = nil @forums_results = nil - attachments_results = nil + @attachments_results = nil @open_source_projects_results = nil @obj_pages = nil @obj = nil @@ -228,8 +228,9 @@ class TagsController < ApplicationController # modifed by Long Jun # this is used to find the attachments that came from the same project and tagged with the same tag. - @result = get_attachments_by_project_tag(selected_tags, @obj) - @obj_pages, attachments_results, @results_count = for_pagination(@result) + #@result = get_attachments_by_project_tag(selected_tags, @obj) + @result = get_attachments_by_tag(selected_tags) + @obj_pages, @attachments_results, @results_count = for_pagination(@result) when '7' @obj = Contest.find_by_id(obj_id) @obj_pages,@contests_results,@results_count = for_pagination(get_contests_by_tag(selected_tags)) @@ -249,8 +250,8 @@ class TagsController < ApplicationController @projects_results, @issues_results, @bids_results, - @forums_results, - attachments_results, + @forums_results, + @attachments_results, @contests_results, @courses_results, @open_source_projects_results] diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index b43eb22f1..ee9d2a70d 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -87,8 +87,9 @@ module AttachmentsHelper @project_id = obj.container_id end - Attachment.tagged_with(tag_name).order('created_on desc').where("(container_id = :project_id and container_type = 'Project') or + attachments = Attachment.tagged_with(tag_name).order('created_on desc').where("(container_id = :project_id and container_type = 'Project') or (container_id in (select id from versions where project_id =:project_id) and container_type = 'Version')", {:project_id => @project_id}) + return attachments end diff --git a/app/models/contest.rb b/app/models/contest.rb index e1706b166..f1503f593 100644 --- a/app/models/contest.rb +++ b/app/models/contest.rb @@ -6,7 +6,7 @@ class Contest < ActiveRecord::Base has_many :contesting_projects, :dependent => :destroy has_many :projects, :through => :contesting_projects has_many :contesting_softapplications, :dependent => :destroy - has_many :softapplications, :through => :contesting_softapplications + has_many :softapplications, :through => :contesting_softapplications, :dependent => :destroy has_many :projects_member, :class_name => 'User', :through => :projects has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy diff --git a/app/models/contesting_softapplication.rb b/app/models/contesting_softapplication.rb index f880818d9..f91c16f69 100644 --- a/app/models/contesting_softapplication.rb +++ b/app/models/contesting_softapplication.rb @@ -3,7 +3,7 @@ class ContestingSoftapplication < ActiveRecord::Base attr_accessible :contest_id, :description, :softapplication_id, :user_id belongs_to :contest - belongs_to :softapplication + belongs_to :softapplication, :dependent => :destroy belongs_to :user diff --git a/app/models/issue_overdue.rb b/app/models/issue_overdue.rb index 342790f55..5caec94c9 100644 --- a/app/models/issue_overdue.rb +++ b/app/models/issue_overdue.rb @@ -18,7 +18,7 @@ class IssueOverdue < ActiveRecord::Base sleep 5 else #发邮件 - puts "11" + issue.id.to_s + #puts "11" + issue.id.to_s #Mailer.issue_expire(issue).deliver Mailer.issue_add(issue).deliver break diff --git a/app/views/contests/index.html.erb b/app/views/contests/index.html.erb index 8c999f941..6f8430ca0 100644 --- a/app/views/contests/index.html.erb +++ b/app/views/contests/index.html.erb @@ -6,17 +6,17 @@ <%= l(:label_user_location) %> : <% if User.current.logged? %> - <% unless User.current.user_extensions.identity == 1 %> - <%= link_to(l(:label_newtype_contest), {:controller => 'contests', :action => 'new_contest'}, :class => 'icon icon-add', :target => "_blank") %> - <% end %> - <% end %> + <% unless User.current.user_extensions.identity == 1 %> + <%= link_to(l(:label_newtype_contest), {:controller => 'contests', :action => 'new_contest'}, :class => 'icon icon-add', :target => "_blank") %> + <% end %> + <% end %> - - diff --git a/app/views/contests/show_attendingcontest.html.erb b/app/views/contests/show_attendingcontest.html.erb index 415897492..96fac7677 100644 --- a/app/views/contests/show_attendingcontest.html.erb +++ b/app/views/contests/show_attendingcontest.html.erb @@ -276,7 +276,7 @@ <% if ((User.current.id == @contest.author_id) && (@contest.deadline > Date.today))||User.current.admin %> -
+
<%= toggle_link '评奖', c_softapplication.id.to_s %>
diff --git a/app/views/tags/_show_attachments.html.erb b/app/views/tags/_show_attachments.html.erb index 43ed76e02..8b0bb1f8b 100644 --- a/app/views/tags/_show_attachments.html.erb +++ b/app/views/tags/_show_attachments.html.erb @@ -1,5 +1,5 @@
-<% if attachments_results.try(:size).to_i < 0 %> +<% if attachments_results.nil? || attachments_results.try(:size).to_i < 0 %> <% else %>
<% attachments_results.each do |file| %> diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index 27afed749..f2140fd9b 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -157,7 +157,7 @@
<% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %> - +
  • <%= image_tag('/images/contest1.png')%> @@ -173,7 +173,7 @@ <% end %>
    -
    +
    <%=contest.description.truncate(100, omission: '...')%>

    diff --git a/db/migrate/20140324015819_create_open_source_projects.rb b/db/migrate/20140324015819_create_open_source_projects.rb index 22034c3bb..e454b3473 100644 --- a/db/migrate/20140324015819_create_open_source_projects.rb +++ b/db/migrate/20140324015819_create_open_source_projects.rb @@ -2,7 +2,7 @@ class CreateOpenSourceProjects < ActiveRecord::Migration def change create_table :open_source_projects do |t| t.column "name", :string, :default => nil, :null => true - t.column "description", :string, :default => '', :null => true + t.column "description", :text, :null => true t.column "commit_count", :integer, :default => 0 t.column "code_line", :integer, :default => 0 t.column "users_count",:integer, :default => 0 diff --git a/db/migrate/20140411011700_change_description_type_to_open_source_project.rb b/db/migrate/20140411011700_change_description_type_to_open_source_project.rb deleted file mode 100644 index 8c8804d8a..000000000 --- a/db/migrate/20140411011700_change_description_type_to_open_source_project.rb +++ /dev/null @@ -1,9 +0,0 @@ -class ChangeDescriptionTypeToOpenSourceProject < ActiveRecord::Migration - def up - change_column :open_source_projects, :description, :text - end - - def down - raise ActiveRecord::IrreversibleMigration - end -end diff --git a/db/migrate/20140505082635_drop_user_scores.rb b/db/migrate/20140505082635_drop_user_scores.rb deleted file mode 100644 index fc65788f2..000000000 --- a/db/migrate/20140505082635_drop_user_scores.rb +++ /dev/null @@ -1,5 +0,0 @@ -class DropUserScores < ActiveRecord::Migration - def change - drop_table :user_scores - end -end diff --git a/db/migrate/20140505083430_create_user_scores.rb b/db/migrate/20140505083430_create_user_scores.rb deleted file mode 100644 index 6c63aa327..000000000 --- a/db/migrate/20140505083430_create_user_scores.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateUserScores < ActiveRecord::Migration - def change - create_table :user_scores do |t| - t.integer :user_id - t.integer :collaboration - t.integer :influence - t.integer :skill - t.integer :activity - end - end -end diff --git a/db/migrate/20140606028512_add_course_roles.rb b/db/migrate/20140606028512_add_course_roles.rb index 3435dd25f..05c678c62 100644 --- a/db/migrate/20140606028512_add_course_roles.rb +++ b/db/migrate/20140606028512_add_course_roles.rb @@ -4,49 +4,49 @@ class AddCourseRoles < ActiveRecord::Migration # 添加课程权限 Role.all.each do |role| if role.name == 'Non member' - role.permissions.append(:view_course ) - role.permissions.append(:search_course ) - role.permissions.append(:add_course ) + role.add_permission!(:view_course ) + role.add_permission!(:search_course ) + role.add_permission!(:add_course ) elsif role.name == 'Anonymous' - role.permissions.append(:view_course ) - role.permissions.append(:search_course ) + role.add_permission!(:view_course ) + role.add_permission!(:search_course ) elsif role.name == 'Manager' - role.permissions.append(:view_course ) - role.permissions.append(:search_course ) - role.permissions.append(:add_course ) - role.permissions.append(:close_course ) - role.permissions.append(:select_course_modules ) - role.permissions.append(:edit_course ) + role.add_permission!(:view_course ) + role.add_permission!(:search_course ) + role.add_permission!(:add_course ) + role.add_permission!(:close_course ) + role.add_permission!(:select_course_modules ) + role.add_permission!(:edit_course ) elsif role.name =='Developer' - role.permissions.append(:view_course ) - role.permissions.append(:search_course ) - role.permissions.append(:add_course ) - role.permissions.append(:close_course ) - role.permissions.append(:select_course_modules ) - role.permissions.append(:edit_course ) + role.add_permission!(:view_course ) + role.add_permission!(:search_course ) + role.add_permission!(:add_course ) + role.add_permission!(:close_course ) + role.add_permission!(:select_course_modules ) + role.add_permission!(:edit_course ) elsif role.name == 'Reporter' - role.permissions.append(:view_course ) - role.permissions.append(:search_course ) + role.add_permission!(:view_course ) + role.add_permission!(:search_course ) elsif role.name == '助教' - role.permissions.append(:view_course ) - role.permissions.append(:search_course ) - role.permissions.append(:add_course ) - role.permissions.append(:select_course_modules ) - role.permissions.append(:edit_course ) + role.add_permission!(:view_course ) + role.add_permission!(:search_course ) + role.add_permission!(:add_course ) + role.add_permission!(:select_course_modules ) + role.add_permission!(:edit_course ) elsif role.name == '老师' - role.permissions.append(:view_course ) - role.permissions.append(:search_course ) - role.permissions.append(:add_course ) - role.permissions.append(:close_course ) - role.permissions.append(:select_course_modules ) - role.permissions.append(:edit_course ) + role.add_permission!(:view_course ) + role.add_permission!(:search_course ) + role.add_permission!(:add_course ) + role.add_permission!(:close_course ) + role.add_permission!(:select_course_modules ) + role.add_permission!(:edit_course ) elsif role.name == '学生' - role.permissions.append(:view_course ) - role.permissions.append(:search_course ) + role.add_permission!(:view_course ) + role.add_permission!(:search_course ) end - role.permissions.append(:view_course_files ) - role.permissions.append(:view_course_journals_for_messages ) - role.permissions.append(:view_course_messages ) + role.add_permission!(:view_course_files ) + role.add_permission!(:view_course_journals_for_messages ) + role.add_permission!(:view_course_messages ) role.save(:validate => false) end end diff --git a/db/migrate/20140710071720_create_first_pages.rb b/db/migrate/20140710071720_create_first_pages.rb index c33283a06..a6af63ca4 100644 --- a/db/migrate/20140710071720_create_first_pages.rb +++ b/db/migrate/20140710071720_create_first_pages.rb @@ -9,12 +9,13 @@ class CreateFirstPages < ActiveRecord::Migration t.timestamps end + fp = FirstPage.new fp.web_title = "Trustie - 为大学生技术创新筑巢" fp.title = "Trustie在线项目托管平台" fp.description = "面向中国大学生与软件从业者,提供社交化的项目管理、代码托管、资源共享、合作交流。" fp.page_type = "project" - fp.save + fp.save(:validate => false) end end diff --git a/db/migrate/20140711012924_add_contest_and_course_first_page.rb b/db/migrate/20140711012924_add_contest_and_course_first_page.rb index 801219bd5..8a7673b11 100644 --- a/db/migrate/20140711012924_add_contest_and_course_first_page.rb +++ b/db/migrate/20140711012924_add_contest_and_course_first_page.rb @@ -6,12 +6,12 @@ class AddContestAndCourseFirstPage < ActiveRecord::Migration fp.title = "Trustie在线课程实践平台" fp.description = "面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。" fp.page_type = "course" - fp.save + fp.save(:validate => false) fp1 = FirstPage.new fp1.web_title = "" fp1.title = "Trustie在线竞赛实战平台" fp1.description = "面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。" fp1.page_type = "contest" - fp1.save + fp1.save(:validate => false) end end diff --git a/db/migrate/20140714081030_set_web_title.rb b/db/migrate/20140714081030_set_web_title.rb index 51b1f6d89..73a536d1c 100644 --- a/db/migrate/20140714081030_set_web_title.rb +++ b/db/migrate/20140714081030_set_web_title.rb @@ -3,7 +3,7 @@ class SetWebTitle < ActiveRecord::Migration def change FirstPage.all.each do |fp| fp.web_title = "Trustie - 为大学生技术创新筑巢" - fp.save + fp.save(:validate => false) end end end diff --git a/db/migrate/20140716021558_set_sort_type.rb b/db/migrate/20140716021558_set_sort_type.rb index 04511ca2b..0042749ba 100644 --- a/db/migrate/20140716021558_set_sort_type.rb +++ b/db/migrate/20140716021558_set_sort_type.rb @@ -2,7 +2,7 @@ class SetSortType < ActiveRecord::Migration def change FirstPage.all.each do |fp| fp.sort_type = 1 - fp.save + fp.save(:validate => false) end end end diff --git a/db/migrate/20140719080032_repair_first_page.rb b/db/migrate/20140719080032_repair_first_page.rb index a1faf7f90..60e429f04 100644 --- a/db/migrate/20140719080032_repair_first_page.rb +++ b/db/migrate/20140719080032_repair_first_page.rb @@ -9,7 +9,7 @@ class RepairFirstPage < ActiveRecord::Migration fp.description = "面向中国大学生与软件从业者,提供社交化的项目管理、代码托管、资源共享、合作交流。" fp.page_type = "project" fp.sort_type = 1 - fp.save + fp.save(:validate => false) else fp = pro_fps.first fp.web_title = "Trustie - 为大学生技术创新筑巢" @@ -17,7 +17,7 @@ class RepairFirstPage < ActiveRecord::Migration fp.description = "面向中国大学生与软件从业者,提供社交化的项目管理、代码托管、资源共享、合作交流。" fp.page_type = "project" fp.sort_type = 1 - fp.save + fp.save(:validate => false) end course_fps = FirstPage.where("page_type = 'course'") if course_fps.nil? || course_fps.first.nil? @@ -27,7 +27,7 @@ class RepairFirstPage < ActiveRecord::Migration fp.description = "面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。" fp.page_type = "course" fp.sort_type = 1 - fp.save + fp.save(:validate => false) else fp = course_fps.first fp.web_title = "Trustie - 为大学生技术创新筑巢" @@ -35,7 +35,7 @@ class RepairFirstPage < ActiveRecord::Migration fp.description = "面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。" fp.page_type = "course" fp.sort_type = 1 - fp.save + fp.save(:validate => false) end contest_fps = FirstPage.where("page_type = 'contest'") if contest_fps.nil? || contest_fps.first.nil? @@ -45,7 +45,7 @@ class RepairFirstPage < ActiveRecord::Migration fp1.description = "面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。" fp1.page_type = "contest" fp1.sort_type = 1 - fp1.save + fp1.save(:validate => false) else fp1 = contest_fps.first fp1.web_title = "Trustie - 为大学生技术创新筑巢" @@ -53,7 +53,7 @@ class RepairFirstPage < ActiveRecord::Migration fp1.description = "面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。" fp1.page_type = "contest" fp1.sort_type = 1 - fp1.save + fp1.save(:validate => false) end end end diff --git a/db/schema.rb b/db/schema.rb index 0df71c97b..72e6ccba9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140730021521) do +ActiveRecord::Schema.define(:version => 20140730024419) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -177,58 +177,6 @@ ActiveRecord::Schema.define(:version => 20140730021521) do add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true - create_table "code_review_assignments", :force => true do |t| - t.integer "issue_id" - t.integer "change_id" - t.integer "attachment_id" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.string "action_type" - t.integer "changeset_id" - end - - create_table "code_review_project_settings", :force => true do |t| - t.integer "project_id" - t.integer "tracker_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "updated_by" - t.boolean "hide_code_review_tab", :default => false - t.integer "auto_relation", :default => 1 - t.integer "assignment_tracker_id" - t.text "auto_assign" - t.integer "lock_version", :default => 0, :null => false - t.boolean "tracker_in_review_dialog", :default => false - end - - create_table "code_review_user_settings", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "mail_notification", :default => 0, :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "code_reviews", :force => true do |t| - t.integer "project_id" - t.integer "change_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "line" - t.integer "updated_by_id" - t.integer "lock_version", :default => 0, :null => false - t.integer "status_changed_from" - t.integer "status_changed_to" - t.integer "issue_id" - t.string "action_type" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.integer "attachment_id" - t.integer "file_count", :default => 0, :null => false - t.boolean "diff_all" - end - create_table "comments", :force => true do |t| t.string "commented_type", :limit => 30, :default => "", :null => false t.integer "commented_id", :default => 0, :null => false @@ -272,7 +220,7 @@ ActiveRecord::Schema.define(:version => 20140730021521) do t.integer "contest_id" t.string "title" t.string "summary" - t.string "description" + t.text "description" t.integer "author_id" t.integer "notificationcomments_count" t.datetime "created_at", :null => false @@ -419,9 +367,9 @@ ActiveRecord::Schema.define(:version => 20140730021521) do t.string "web_title" t.string "title" t.text "description" + t.string "page_type" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false - t.string "page_type" t.integer "sort_type" t.integer "image_width", :default => 107 t.integer "image_height", :default => 63 @@ -882,19 +830,6 @@ ActiveRecord::Schema.define(:version => 20140730021521) do add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" - create_table "rich_rich_files", :force => true do |t| - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "rich_file_file_name" - t.string "rich_file_content_type" - t.integer "rich_file_file_size" - t.datetime "rich_file_updated_at" - t.string "owner_type" - t.integer "owner_id" - t.text "uri_cache" - t.string "simplified_type", :default => "file" - end - create_table "roles", :force => true do |t| t.string "name", :limit => 30, :default => "", :null => false t.integer "position", :default => 1 @@ -945,11 +880,10 @@ ActiveRecord::Schema.define(:version => 20140730021521) do t.string "url" t.string "title" t.integer "share_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "project_id" t.integer "user_id" - t.string "description" end create_table "softapplications", :force => true do |t| @@ -1055,8 +989,8 @@ ActiveRecord::Schema.define(:version => 20140730021521) do t.integer "zip_code" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false - t.string "technical_title" t.integer "identity" + t.string "technical_title" t.string "student_id" t.string "teacher_realname" t.string "student_realname" @@ -1114,6 +1048,9 @@ ActiveRecord::Schema.define(:version => 20140730021521) do t.integer "active" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false + t.integer "level" + t.integer "file" + t.integer "issue" end create_table "user_statuses", :force => true do |t|