From 7ccbc5e88a2918851716b6cf7f516538c16e82d5 Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 9 May 2014 17:13:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E6=97=B6=E9=99=90=E5=88=B6=E4=B8=BA?= =?UTF-8?q?=E5=8F=AA=E8=83=BD=E8=BE=93=E5=85=A5=E6=AD=A3=E6=95=B4=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 4 +++ app/models/course.rb | 10 ++++++- app/models/project.rb | 7 +++++ app/views/files/index.html.erb | 6 +++-- app/views/files/show_by_attachtype.html.erb | 26 +++++++++++++++++++ config/locales/en.yml | 1 + config/locales/zh.yml | 1 + ...508030358_add_attachtype_to_attachments.rb | 2 +- db/schema.rb | 11 +++++++- .../lib/acts_as_attachable.rb | 6 +++++ 10 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 app/views/files/show_by_attachtype.html.erb diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index dc60b24a1..8f2b79bd3 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -61,4 +61,8 @@ class FilesController < ApplicationController end redirect_to project_files_path(@project) end + + def show_by_attachtype + + end end diff --git a/app/models/course.rb b/app/models/course.rb index d2f1abfef..9f0c42c6f 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -7,6 +7,7 @@ class Course < ActiveRecord::Base belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表 has_many :bid validates_presence_of :password, :term + validates_format_of :class_period, :message => "class period can only digital!", :with =>/^[1-9]\d*$/ safe_attributes 'extra', 'time', 'name', @@ -17,7 +18,14 @@ class Course < ActiveRecord::Base 'password', 'term', 'password' - + + #自定义验证 + def validate + if !class_period.match([0-9]) + errors.add_to_base("class period can only digital") + end + end + def get_endup_time begin end_time = Time.parse(self.endup_time) diff --git a/app/models/project.rb b/app/models/project.rb index 827ed0990..007f7e300 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -164,6 +164,13 @@ class Project < ActiveRecord::Base @attachmenttypes = Attachmentstype.find(:all, :conditions => ["#{Attachmentstype.table_name}.typeId= ?",self.attachmenttype ]) end + #自定义验证 + def validation + if !class_period.match([0-9]) + errors.add_to_base("class period can only digital") + end + end + # 项目留言 added by fq def self.add_jour(user, notes) project = Project.find('trustie') diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 7552b9941..b9da42d91 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -174,6 +174,8 @@ div.pagination{ <% delete_allowed = User.current.allowed_to?(:manage_files, @project) %> + + @@ -190,7 +192,7 @@ div.pagination{ <%= sort_header_tag('operation', :caption => "", :scope =>"col", :id => "vzebra-children") %> - + <% @containers.each do |container| %> <% next if container.attachments.empty? -%> <% if container.is_a?(Version) -%> @@ -233,7 +235,7 @@ div.pagination{ <% html_title(l(:label_attachment_plural)) -%> -