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

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
redirect_to project_files_path(@project)
end
def show_by_attachtype
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表
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)

View File

@ -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')

View File

@ -174,6 +174,8 @@ div.pagination{
<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
<table class="list files" id="ver-zebra" >
<colgroup>
<col class="vzebra-odd" />
@ -190,7 +192,7 @@ div.pagination{
<%= sort_header_tag('operation', :caption => "", :scope =>"col", :id => "vzebra-children") %>
<!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> -->
</tr></thead>
<tbody>
<tbody>
<% @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)) -%>
<script type='text/javascript';>
<script type='text/javascript'>
var slideHeight = 29;
function readmore (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
attachment_type: 'Attachment Type'
general_text_No: 'No'
general_text_Yes: 'Yes'
general_text_no: 'no'

View File

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

View File

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

View File

@ -11,7 +11,7 @@
#
# 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|
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", ["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|
t.string "type", :limit => 30, :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.integer "project_type"
t.boolean "hidden_repo", :default => false, :null => false
t.integer "attachmenttype", :default => 1
end
add_index "projects", ["lft"], :name => "index_projects_on_lft"

View File

@ -60,6 +60,11 @@ module Redmine
@unsaved_attachments ||= []
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)
if attachments.is_a?(Hash)
attachments = attachments.stringify_keys
@ -91,6 +96,7 @@ module Redmine
end
next unless a
a.description = attachment['description'].to_s.strip
a.attachtype = @curattachment_type;
if a.new_record?
unsaved_attachments << a
else