diff --git a/app/models/course.rb b/app/models/course.rb index b2da58a81..6bb7a75d4 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -1,3 +1,4 @@ + class Course < ActiveRecord::Base include Redmine::SafeAttributes @@ -33,10 +34,10 @@ class Course < ActiveRecord::Base acts_as_attachable :view_permission => :view_files, :delete_permission => :manage_files - validates :password, presence: true - validates :term, presence: true - validates :name, presence: true - validates :class_period, presence: true,format: {:with =>/^\d*$/} + validates_presence_of :password, :term,:name,:description + validates_format_of :class_period, :with =>/^[1-9]\d*$/ + validates_format_of :name,:with =>/^[a-zA-Z0-9_\u4e00-\u9fa5]+$/ + validates_length_of :description, :maximum => 10000 before_save :self_validate after_create :create_board_sync before_destroy :delete_all_members @@ -309,3 +310,5 @@ class Course < ActiveRecord::Base # read_attribute('name') || Project.find_by_identifier(self.extra).try(:name) #end end + + diff --git a/app/models/news.rb b/app/models/news.rb index 4f8601796..4d153e81f 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -29,6 +29,7 @@ class News < ActiveRecord::Base validates_presence_of :title, :description validates_length_of :title, :maximum => 60 validates_length_of :summary, :maximum => 255 + validates_length_of :description, :maximum => 10000 acts_as_attachable :delete_permission => :manage_news acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], :include => :project diff --git a/app/models/project.rb b/app/models/project.rb index ddb92a587..14763347f 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -41,7 +41,7 @@ class Project < ActiveRecord::Base has_many :principals, :through => :member_principals, :source => :principal has_many :enabled_modules, :dependent => :delete_all has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position" - has_many :issues, :dependent => :destroy, :include => [:status, :tracker] + has_many :issues, :dependent => :destroy, :include => [:status, :tracker],:order => "id ASC" has_many :issue_changes, :through => :issues, :source => :journals has_many :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC" has_many :time_entries, :dependent => :delete_all @@ -1151,3 +1151,4 @@ class Project < ActiveRecord::Base end + diff --git a/app/views/contests/show_attendingcontest.html.erb b/app/views/contests/show_attendingcontest.html.erb index afdb96574..f8c231550 100644 --- a/app/views/contests/show_attendingcontest.html.erb +++ b/app/views/contests/show_attendingcontest.html.erb @@ -1,315 +1,316 @@ - - - -<%= render_flash_messages %> - -
-
- <%= l(:label_wellmeaning_intimation_contentone) %> -
-
- 1) <%= l(:label_wellmeaning_intimation_contenttwo) %> -
-
- 2) <%= l(:label_wellmeaning_intimation_contentthree) %> -
-
- -<% if User.current.logged? %> -
-
- <%= l(:label_attending_contest) %>: - - <%= link_to l(:label_new_attendingcontest_work), - "javascript:void(0);", - onclick: "$('#put-project-form').slideToggle();" - %> - -
-
-
- <%= render "new_softapplication" %> -
- -<% else %> -
- <%= l(:label_user_login_attending_contest) %> - <%= link_to l(:label_user_login_new), signin_path %> -
-<% end %> -
- - - -<% if @contest.id == 2 or @contest.id == 3 or @contest.id == 6 %> - - <% @contesting_project.sort.reverse.each do |c_project| %> - <% if c_project.project %> -
-
-
-
<%= l(:label_contest_work) %> - : <%= link_to(c_project.project.name, project_path(c_project.project), :target => '_blank') %> - -
- - - - <% if get_prize(c_project).nil? or get_prize(c_project) == "" %> - <% if @contest.deadline < Date.today %> - <%= l(:label_noawards) %> - <% else %> - <%= l(:label_noawards_current) %> - <% end %> - <% else %> - <% case get_prize(c_project) %> - <% when '-1' %> - <%= image_tag("/images/bid/special_reward.png") %> - <% when '0' %> - <%= image_tag("/images/bid/first_reward.png") %> - <% when '1' %> - <%= image_tag("/images/bid/second_reward.png") %> - <% when '2' %> - <%= image_tag("/images/bid/third_reward.png") %> - <% when '3' %> - <%= image_tag("/images/bid/forth_reward.png") %> - <% when '4' %> - <%= image_tag("/images/bid/fifth_reward.png") %> - <% when '5' %> - <%= image_tag("/images/bid/qualified.png") %> - <% end %> - <% end %> - - - - - - <% if ((User.current.id == @contest.author_id) && (@contest.deadline > Date.today))||User.current.admin %> - - <%= toggle_link l(:label_reward), c_project.id.to_s %> - - - - <% end %> -
-
-
-
-
-
- - <%= l(:label_profile) %>: - - <%#= c_project.project.description.truncate(90, omission: '...') %> - <%= c_project.project.description %> - - -
-
-
- <%= l(:label_attendingcontest_time) %> - :<%= format_time c_project.created_at %> - <%= l(:label_attendingcontest_spoksman) %> - - <% unless c_project.nil? || c_project.user.nil? %> - :<%= link_to c_project.user.name,user_path(c_project.user) %> - <% end %> -
- -
- -
-
- <% end %> -
- <% end %> -<% else %> - <% @contesting_softapplication.each do |c_softapplication| %> - <% if c_softapplication.softapplication %> -
-
- - <%= l(:label_contest_work) %>: - <%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication), :target => '_blank') %> - -
-
- -
- - <%= l(:label_profile) %>: - - <%#= c_softapplication.softapplication.description.truncate(90, omission: '...') %> - <%= c_softapplication.softapplication.description %> - - -
-
- -
- <%= l(:label_attendingcontest_time) %> - :<%= format_time c_softapplication.created_at %> - <%= l(:label_attendingcontest_spoksman) %> - - <% unless c_softapplication.nil? || c_softapplication.softapplication.nil? || c_softapplication.softapplication.user.nil? %> - :<%= link_to c_softapplication.softapplication.user.name,user_path(c_softapplication.softapplication.user) %> - <% end %> -
- - -
- <% score = c_softapplication.softapplication.average(:quality).try(:avg).try(:round, 2).to_f %> - <%= l(:label_final_scores) %> - :<%= format("%.2f" , score) %> - 分 - - - - - <% if get_prize(c_softapplication).nil? or get_prize(c_softapplication) == "" %> - <% if @contest.deadline < Date.today %> - <%= l(:label_noawards) %> - <% else %> - <%= l(:label_noawards_current) %> - <% end %> - <% else %> - <% case get_prize(c_softapplication) %> - <% when '-1' %> - <%= image_tag("/images/bid/special_reward.png") %> - <% when '0' %> - <%= image_tag("/images/bid/first_reward.png") %> - <% when '1' %> - <%= image_tag("/images/bid/second_reward.png") %> - <% when '2' %> - <%= image_tag("/images/bid/third_reward.png") %> - <% when '3' %> - <%= image_tag("/images/bid/forth_reward.png") %> - <% when '4' %> - <%= image_tag("/images/bid/fifth_reward.png") %> - <% when '5' %> - <%= image_tag("/images/bid/qualified.png") %> - <% end %> - <% end %> - - - - - - <% if ((User.current.id == @contest.author_id) && (@contest.deadline > Date.today))||User.current.admin %> -
- <%= toggle_link '评奖', c_softapplication.id.to_s %> - - -
- <% end %> -
-
-
- <% end %> -
- <% end %> -<% end %> - - -<% html_title(l(:label_contest_joincontest)) -%> + + + +<%= render_flash_messages %> + +
+
+ <%= l(:label_wellmeaning_intimation_contentone) %> +
+
+ 1) <%= l(:label_wellmeaning_intimation_contenttwo) %> +
+
+ 2) <%= l(:label_wellmeaning_intimation_contentthree) %> +
+
+ +<% if User.current.logged? %> +
+
+ <%= l(:label_attending_contest) %>: + + <%= link_to l(:label_new_attendingcontest_work), + "javascript:void(0);", + onclick: "$('#put-project-form').slideToggle();" + %> + +
+
+
+ <%= render "new_softapplication" %> +
+ +<% else %> +
+ <%= l(:label_user_login_attending_contest) %> + <%= link_to l(:label_user_login_new), signin_path %> +
+<% end %> +
+ + + +<% if @contest.id == 2 or @contest.id == 3 or @contest.id == 6 %> + + <% @contesting_project.sort.reverse.each do |c_project| %> + <% if c_project.project %> +
+
+
+
<%= l(:label_contest_work) %> + : <%= link_to(c_project.project.name, project_path(c_project.project), :target => '_blank') %> + +
+ + + + <% if get_prize(c_project).nil? or get_prize(c_project) == "" %> + <% if @contest.deadline < Date.today %> + <%= l(:label_noawards) %> + <% else %> + <%= l(:label_noawards_current) %> + <% end %> + <% else %> + <% case get_prize(c_project) %> + <% when '-1' %> + <%= image_tag("/images/bid/special_reward.png") %> + <% when '0' %> + <%= image_tag("/images/bid/first_reward.png") %> + <% when '1' %> + <%= image_tag("/images/bid/second_reward.png") %> + <% when '2' %> + <%= image_tag("/images/bid/third_reward.png") %> + <% when '3' %> + <%= image_tag("/images/bid/forth_reward.png") %> + <% when '4' %> + <%= image_tag("/images/bid/fifth_reward.png") %> + <% when '5' %> + <%= image_tag("/images/bid/qualified.png") %> + <% end %> + <% end %> + + + + + + <% if ((User.current.id == @contest.author_id) && (@contest.deadline > Date.today))||User.current.admin %> + + <%= toggle_link l(:label_reward), c_project.id.to_s %> + + + + <% end %> +
+
+
+
+
+
+ + <%= l(:label_profile) %>: + + <%#= c_project.project.description.truncate(90, omission: '...') %> + <%= c_project.project.description %> + + +
+
+
+ <%= l(:label_attendingcontest_time) %> + :<%= format_time c_project.created_at %> + <%= l(:label_attendingcontest_spoksman) %> + + <% unless c_project.nil? || c_project.user.nil? %> + :<%= link_to c_project.user.name,user_path(c_project.user) %> + <% end %> +
+ +
+ +
+
+ <% end %> +
+ <% end %> +<% else %> + <% @contesting_softapplication.each do |c_softapplication| %> + <% if c_softapplication.softapplication %> +
+
+ + <%= l(:label_contest_work) %>: + <%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication), :target => '_blank') %> + +
+
+ +
+ + <%= l(:label_profile) %>: + + <%#= c_softapplication.softapplication.description.truncate(90, omission: '...') %> + <%= c_softapplication.softapplication.description %> + + +
+
+ +
+ <%= l(:label_attendingcontest_time) %> + :<%= format_time c_softapplication.created_at %> + <%= l(:label_attendingcontest_spoksman) %> + + <% unless c_softapplication.nil? || c_softapplication.softapplication.nil? || c_softapplication.softapplication.user.nil? %> + :<%= link_to c_softapplication.softapplication.user.name,user_path(c_softapplication.softapplication.user) %> + <% end %> +
+ + +
+ <% score = c_softapplication.softapplication.average(:quality).try(:avg).try(:round, 2).to_f %> + <%= l(:label_final_scores) %> + :<%= format("%.2f" , score) %> + 分 + + + + + <% if get_prize(c_softapplication).nil? or get_prize(c_softapplication) == "" %> + <% if @contest.deadline < Date.today %> + <%= l(:label_noawards) %> + <% else %> + <%= l(:label_noawards_current) %> + <% end %> + <% else %> + <% case get_prize(c_softapplication) %> + <% when '-1' %> + <%= image_tag("/images/bid/special_reward.png") %> + <% when '0' %> + <%= image_tag("/images/bid/first_reward.png") %> + <% when '1' %> + <%= image_tag("/images/bid/second_reward.png") %> + <% when '2' %> + <%= image_tag("/images/bid/third_reward.png") %> + <% when '3' %> + <%= image_tag("/images/bid/forth_reward.png") %> + <% when '4' %> + <%= image_tag("/images/bid/fifth_reward.png") %> + <% when '5' %> + <%= image_tag("/images/bid/qualified.png") %> + <% end %> + <% end %> + + + + + + <% if ((User.current.id == @contest.author_id) && (@contest.deadline > Date.today))||User.current.admin %> +
+ <%= toggle_link '评奖', c_softapplication.id.to_s %> + + +
+ <% end %> +
+
+
+ <% end %> +
+ <% end %> +<% end %> + + +<% html_title(l(:label_contest_joincontest)) -%> + diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index 9f476aba8..c48900426 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -1,4 +1,3 @@ - <% attachmenttypes = @course.attachmenttypes %> <% sufixtypes = @course.contenttypes %> @@ -10,40 +9,12 @@ <%#= link_to(l(:label_attachment_new), 'javascript:void(0);', :onclick=>"$('#file_buttons').slideToggle();", :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @course) %>
+ <%= link_to(l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @course) %> <%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @course) %>

- - +
diff --git a/app/views/files/_course_new.html.erb b/app/views/files/_course_new.html.erb index 2eaa70cb6..f864f8629 100644 --- a/app/views/files/_course_new.html.erb +++ b/app/views/files/_course_new.html.erb @@ -20,6 +20,28 @@ <% end %>
+ +
+ <%=l(:label_attachment_new)%> + <% attachmenttypes = course.attachmenttypes %> + <%= error_messages_for 'attachment' %> + <%= form_tag(course_files_path(course), :multipart => true,:remote => true,:method => :post,:name=>"upload_form", :class => "tabular") do %> + +

+ <% if attachmenttypes.any? %> + <%= l(:attachment_type) %> + <%= select_tag "attachment_type", + options_from_collection_for_select(attachmenttypes, "id", + "typeName", 2), {style: 'width:100px'} %> + <% end %> +

+ +

<%=l(:label_attachment_plural)%><%= render :partial => 'attachments/form' %>

+ + <%= submit_tag l(:button_add) %> + <% end %> +
+ + + +
+<% end %> +