课时限制为只能输入正整数

This commit is contained in:
nwb 2014-05-09 17:13:23 +08:00
parent 753746f833
commit 7ccbc5e88a
10 changed files with 69 additions and 5 deletions

View File

@ -61,4 +61,8 @@ class FilesController < ApplicationController
end end
redirect_to project_files_path(@project) redirect_to project_files_path(@project)
end end
def show_by_attachtype
end
end end

View File

@ -7,6 +7,7 @@ class Course < ActiveRecord::Base
belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school该方法通过school_id来调用School表 belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school该方法通过school_id来调用School表
has_many :bid has_many :bid
validates_presence_of :password, :term validates_presence_of :password, :term
validates_format_of :class_period, :message => "class period can only digital!", :with =>/^[1-9]\d*$/
safe_attributes 'extra', safe_attributes 'extra',
'time', 'time',
'name', 'name',
@ -18,6 +19,13 @@ class Course < ActiveRecord::Base
'term', 'term',
'password' 'password'
#自定义验证
def validate
if !class_period.match([0-9])
errors.add_to_base("class period can only digital")
end
end
def get_endup_time def get_endup_time
begin begin
end_time = Time.parse(self.endup_time) end_time = Time.parse(self.endup_time)

View File

@ -164,6 +164,13 @@ class Project < ActiveRecord::Base
@attachmenttypes = Attachmentstype.find(:all, :conditions => ["#{Attachmentstype.table_name}.typeId= ?",self.attachmenttype ]) @attachmenttypes = Attachmentstype.find(:all, :conditions => ["#{Attachmentstype.table_name}.typeId= ?",self.attachmenttype ])
end end
#自定义验证
def validation
if !class_period.match([0-9])
errors.add_to_base("class period can only digital")
end
end
# 项目留言 added by fq # 项目留言 added by fq
def self.add_jour(user, notes) def self.add_jour(user, notes)
project = Project.find('trustie') project = Project.find('trustie')

View File

@ -174,6 +174,8 @@ div.pagination{
<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %> <% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
<table class="list files" id="ver-zebra" > <table class="list files" id="ver-zebra" >
<colgroup> <colgroup>
<col class="vzebra-odd" /> <col class="vzebra-odd" />
@ -233,7 +235,7 @@ div.pagination{
<% html_title(l(:label_attachment_plural)) -%> <% html_title(l(:label_attachment_plural)) -%>
<script type='text/javascript';> <script type='text/javascript'>
var slideHeight = 29; var slideHeight = 29;
function readmore (aNode) { function readmore (aNode) {
// console.log(aNode) // console.log(aNode)

View File

@ -0,0 +1,26 @@
<h3><%=l(:label_attachment_new)%></h3>
<% versions = project.versions.sort %>
<% attachmenttypes = project.attachmenttypes %>
<%= error_messages_for 'attachment' %>
<%= form_tag(project_files_path(project), :multipart => true, :class => "tabular") do %>
<div class="box">
<% if versions.any? %>
<p><label for="version_id"><%=l(:field_version)%></label>
<%= select_tag "version_id", content_tag('option', '') +
options_from_collection_for_select(versions, "id", "name") %></p>
<% end %>
<% if attachmenttypes.any? %>
<p> <label for="attachment_type"><%=l(:attachment_type)%></label>
<%= select_tag "attachment_type", content_tag('option', '') +
options_from_collection_for_select(attachmenttypes, "id",
"typeName") %>
</p>
<% end %>
<p><label><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form' %></p>
</div>
<%= submit_tag l(:button_add) %>
<% end %>
<div class="line_under" style="margin:20px 0px;"></div>

View File

@ -132,6 +132,7 @@ en:
actionview_instancetag_blank_option: Please select actionview_instancetag_blank_option: Please select
attachment_type: 'Attachment Type'
general_text_No: 'No' general_text_No: 'No'
general_text_Yes: 'Yes' general_text_Yes: 'Yes'
general_text_no: 'no' general_text_no: 'no'

View File

@ -140,6 +140,7 @@ zh:
actionview_instancetag_blank_option: 请选择 actionview_instancetag_blank_option: 请选择
attachment_type: '资源分类'
general_text_No: '否' general_text_No: '否'
general_text_Yes: '是' general_text_Yes: '是'
general_text_no: '否' general_text_no: '否'

View File

@ -1,5 +1,5 @@
class AddAttachtypeToAttachments < ActiveRecord::Migration class AddAttachtypeToAttachments < ActiveRecord::Migration
def change def change
add_column :attachments, :attachtype, :int add_column :attachments, :attachtype, :int ,default: 1
end end
end end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140508030358) do ActiveRecord::Schema.define(:version => 20140509020307) do
create_table "activities", :force => true do |t| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false
@ -43,6 +43,14 @@ ActiveRecord::Schema.define(:version => 20140508030358) do
add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type" add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type"
add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on" add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on"
create_table "attachmentstypes", :id => false, :force => true do |t|
t.integer "id", :null => false
t.integer "typeId"
t.string "typeName", :limit => 50
end
add_index "attachmentstypes", ["id"], :name => "id"
create_table "auth_sources", :force => true do |t| create_table "auth_sources", :force => true do |t|
t.string "type", :limit => 30, :default => "", :null => false t.string "type", :limit => 30, :default => "", :null => false
t.string "name", :limit => 60, :default => "", :null => false t.string "name", :limit => 60, :default => "", :null => false
@ -585,6 +593,7 @@ ActiveRecord::Schema.define(:version => 20140508030358) do
t.boolean "inherit_members", :default => false, :null => false t.boolean "inherit_members", :default => false, :null => false
t.integer "project_type" t.integer "project_type"
t.boolean "hidden_repo", :default => false, :null => false t.boolean "hidden_repo", :default => false, :null => false
t.integer "attachmenttype", :default => 1
end end
add_index "projects", ["lft"], :name => "index_projects_on_lft" add_index "projects", ["lft"], :name => "index_projects_on_lft"

View File

@ -60,6 +60,11 @@ module Redmine
@unsaved_attachments ||= [] @unsaved_attachments ||= []
end end
def save_attachmentsex(attachments, author=User.current,attachment_type)
@curattachment_type = attachment_type
result = save_attachments(attachments,author)
result
end
def save_attachments(attachments, author=User.current) def save_attachments(attachments, author=User.current)
if attachments.is_a?(Hash) if attachments.is_a?(Hash)
attachments = attachments.stringify_keys attachments = attachments.stringify_keys
@ -91,6 +96,7 @@ module Redmine
end end
next unless a next unless a
a.description = attachment['description'].to_s.strip a.description = attachment['description'].to_s.strip
a.attachtype = @curattachment_type;
if a.new_record? if a.new_record?
unsaved_attachments << a unsaved_attachments << a
else else