diff --git a/.gitignore b/.gitignore index 52cf51417..a88fb8be7 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ test/* tmp/* /app/models/tag.rb /app/models/tag.rb +/public/images/requirements/reference - 副本 - 副本.jpg + +/public/images/requirements/*.jpg diff --git a/app/assets/javascripts/teachers.js b/app/assets/javascripts/teachers.js new file mode 100644 index 000000000..dee720fac --- /dev/null +++ b/app/assets/javascripts/teachers.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/teachers.css b/app/assets/stylesheets/teachers.css new file mode 100644 index 000000000..afad32db0 --- /dev/null +++ b/app/assets/stylesheets/teachers.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index fa4de26f9..b865328f5 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -88,10 +88,12 @@ class AccountController < ApplicationController # create a new token for password recovery token = Token.new(:user => user, :action => "recovery") if token.save - Mailer.lost_password(token).deliver - flash[:notice] = l(:notice_account_lost_email_sent) - redirect_to signin_path - return + Thread.new do + Mailer.lost_password(token).deliver + end + flash[:notice] = l(:notice_account_lost_email_sent) + redirect_to signin_path + return end end end diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 4d6ed2966..ebf3c3ba5 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -115,13 +115,30 @@ class AttachmentsController < ApplicationController format.js end end + + def delete_homework + @bid = @attachment.container.bid + # Make sure association callbacks are called + container = @attachment.container + @attachment.container.attachments.delete(@attachment) + if container.attachments.empty? + container.delete + end + + respond_to do |format| + format.html { redirect_to_referer_or respond_path(@bid) } + format.js + end + end private def find_project @attachment = Attachment.find(params[:id]) # Show 404 if the filename in the url is wrong raise ActiveRecord::RecordNotFound if params[:filename] && params[:filename] != @attachment.filename - @project = @attachment.project + unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' + @project = @attachment.project + end rescue ActiveRecord::RecordNotFound render_404 end diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 6e8484809..f41209d8c 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -3,11 +3,16 @@ class BidsController < ApplicationController #Added by young menu_item :respond menu_item :project, :only => [:show_project,:show_results] + menu_item :homework_respond, :only => :homework_respond + menu_item :homework_statistics, :only => :homework_statistics #Ended by young before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:new,:show_results] before_filter :require_login,:only => [:set_reward] helper :watchers + helper :attachments + include AttachmentsHelper + def index # Modified by nie # @requirement_title = "4" @@ -69,11 +74,17 @@ class BidsController < ApplicationController @state = false respond_to do |format| + if @bid.reward_type == 3 format.html { + render :layout => 'base_homework' + } + else + format.html { render :layout => 'base_bids' } + end format.api - + end end @@ -88,14 +99,51 @@ class BidsController < ApplicationController # @project = Project.where("id in []", a) @user = @bid.author @bidding_project = @bid.biding_projects + if @bid.homework_type == 1 + @homework = HomeworkAttach.new + @homework_list = @bid.homeworks + end respond_to do |format| + if @bid.reward_type == 3 format.html { + render :layout => 'base_homework' + } + else + format.html { render :layout => 'base_bids' } + end format.api end end + + ##### by huang + def show_project_homework + # flash[:notice] = "" + @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) + @option = [] + @membership.each do |membership| + @option << membership.project + end + # a = [1] + # @project = Project.where("id in []", a) + @user = @bid.author + @bidding_project = @bid.biding_projects + respond_to do |format| + if @bid.reward_type == 3 + format.html { + render :layout => 'base_homework' + } + else + format.html { + render :layout => 'base_bids' + } + end + format.api + end + end + ###添加应标项目 def add project = Project.where('name = ?', params[:bid]).first @@ -105,7 +153,11 @@ class BidsController < ApplicationController flash[:notice] = l(:label_bidding_succeed) end else + if @bid.reward_type == 3 + flash[:error] = l(:label_bidding_homework_fail) + else flash[:error] = l(:label_bidding_fail) + end end @bidding_project = @bid.biding_projects respond_to do |format| @@ -219,6 +271,70 @@ class BidsController < ApplicationController render :action => 'new_bid' end end + + def create_homework + @bid = Bid.new + @bid.name = params[:bid][:name] + @bid.description = params[:bid][:description] + @bid.reward_type = 3 + # @bid.budget = params[:bid][:budget] + @bid.deadline = params[:bid][:deadline] + @bid.budget = 0 + @bid.author_id = User.current.id + @bid.commit = 0 + @bid.homework_type = params[:bid][:homework_type] + @bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) + # @bid. + if @bid.save + HomeworkForCourse.create(:project_id => params[:course_id], :bid_id => @bid.id) + unless @bid.watched_by?(User.current) + if @bid.add_watcher(User.current) + flash[:notice] = l(:label_bid_succeed) + end + end + redirect_to respond_path(@bid) + else + @bid.safe_attributes = params[:bid] + render :action => 'new_bid' + end + end + + def add_homework + # homework = HomeworkAttach.create(:bid_id => @bid.id, :user_id => User.current.id) + # homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) + @homework = HomeworkAttach.new + @homework.bid_id = @bid.id + @homework.user_id = User.current.id + @homework.save_attachments(params[:attachments]) + @homework.save + @homework_list = @bid.homeworks + + end + + # 作业统计 + def homework_statistics + @course = @bid.courses.first + @member = [] + @course.memberships.each do |member| + unless (member.roles && Role.where('id = ? ', 3)).empty? + @member.push member + end + end + if @bid.homework_type = 1 + @student = User.where("id in (select DISTINCT user_id from #{HomeworkAttach.table_name} where bid_id = ? )", @bid.id) + @homework_type = true + else + + @homework_type = false + end + @user = @bid.author + render :layout => 'base_homework' + end + + def homework_respond + @user = @bid.author + render :layout => 'base_homework' + end def more @jour = @bid.journals_for_messages @@ -231,6 +347,7 @@ class BidsController < ApplicationController #format.api { render_api_ok } end end + def back @jour = @bid.journals_for_messages diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 999544e7b..81192c597 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -19,8 +19,9 @@ class BoardsController < ApplicationController layout 'base_projects'#by young default_search_scope :messages before_filter :find_project_by_project_id, :find_board_if_available - before_filter :authorize, :except => [:new, :show, :create] + before_filter :authorize, :except => [:new, :show, :create, :index] accept_rss_auth :index, :show + helper :sort include SortHelper @@ -33,6 +34,11 @@ class BoardsController < ApplicationController @board = @boards.first show end + if @project.project_type == 1 + render :layout => 'base_courses' + else + render :layout => false if request.xhr? + end end def show @@ -54,7 +60,11 @@ class BoardsController < ApplicationController preload(:author, {:last_reply => :author}). all @message = Message.new(:board => @board) - render :action => 'show', :layout => !request.xhr? + if @project.project_type + render :action => 'show', :layout => 'base_courses' + else + render :action => 'show', :layout => !request.xhr? + end } format.atom { @messages = @board.messages. @@ -70,6 +80,9 @@ class BoardsController < ApplicationController def new @board = @project.boards.build @board.safe_attributes = params[:board] + if @project.project_type + render :layout => 'base_courses' + end end def create @@ -90,6 +103,9 @@ class BoardsController < ApplicationController end def update + if @project.project_type + render :layout => 'base_courses' + end @board.safe_attributes = params[:board] if @board.save redirect_to_settings_in_projects diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb new file mode 100644 index 000000000..137079233 --- /dev/null +++ b/app/controllers/courses_controller.rb @@ -0,0 +1,42 @@ +class CoursesController < ApplicationController + + + before_filter :require_login, :only => [:join, :unjoin] + + def join + if User.current.logged? + course = Project.find(params[:object_id]) + if params[:course_password].to_i == Course.find_by_extra(course.identifier).state + members = [] + members << Member.new(:role_ids => [5], :user_id => User.current.id) + course.members << members + + StudentsForCourse.create(:student_id => User.current.id, :course_id => params[:object_id]) + @state = 0 + else + @state = 1 + end + end + respond_to do |format| + # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} + format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Project.find(params[:object_id])} } + end + end + + def unjoin + if User.current.logged? + + @member = Member.where('project_id = ? and user_id = ?', params[:object_id], User.current.id) + @member.first.destroy + + joined = StudentsForCourse.where('student_id = ? and course_id = ?', User.current.id, params[:object_id]) + joined.each do |join| + join.delete + end + end + respond_to do |format| + # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} + format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Project.find(params[:object_id])} } + end + end +end \ No newline at end of file diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index a311fc765..67c057eef 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -22,7 +22,7 @@ class DocumentsController < ApplicationController before_filter :find_project_by_project_id, :only => [:index, :new, :create] before_filter :find_model_object, :except => [:index, :new, :create] before_filter :find_project_from_association, :except => [:index, :new, :create] - before_filter :authorize #, :except => [:index]#Added by young + before_filter :authorize , :except => [:index]#Added by young helper :attachments @@ -40,11 +40,18 @@ class DocumentsController < ApplicationController @grouped = documents.group_by(&:category) end @document = @project.documents.build - render :layout => false if request.xhr? + if @project.project_type == 1 + render :layout => 'base_courses' + else + render :layout => false if request.xhr? + end end def show @attachments = @document.attachments.all + if @project.project_type + render :action => 'show', :layout => 'base_courses' + end end def new diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index cb4c1b8ff..1048c12bd 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -34,11 +34,20 @@ class FilesController < ApplicationController @containers = [ Project.includes(:attachments).reorder(sort_clause).find(@project.id)] @containers += @project.versions.includes(:attachments).reorder(sort_clause).all.sort.reverse - render :layout => !request.xhr? + + if @project.project_type == 1 + render :layout => 'base_courses' + else + render :layout => !request.xhr? + end end def new @versions = @project.versions.sort + @course_tag = @project.project_type + if @course_tag + render :layout => 'base_courses' + end end def create diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 27d195f0d..56422dcd6 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -49,7 +49,11 @@ class MessagesController < ApplicationController all @reply = Message.new(:subject => "RE: #{@message.subject}") - render :action => "show", :layout => "base_projects"#by young + if @message.board.project.project_type + render :action => "show", :layout => "base_courses"#by young + else + render :action => "show", :layout => "base_projects"#by young + end end # Create a new topic diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 48c6a7d59..21a474e89 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -77,7 +77,7 @@ class MyController < ApplicationController # ue.save # end - # added by bai 往数据库里写职业、性别和地区 + # added by bai if @user.user_extensions.nil? se = UserExtensions.new se.user_id = @user.id diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 91da55dda..bf02dabce 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -46,12 +46,18 @@ class NewsController < ApplicationController @newss = scope.all(:include => [:author, :project], :order => "#{News.table_name}.created_on DESC", :offset => @offset, - :limit => @limit) - + :limit => @limit) + respond_to do |format| format.html { @news = News.new # for adding news inline + # huang + + if @project.project_type == 1 + render :layout => 'base_courses' + else render :layout => false if request.xhr? + end } format.api format.atom { render_feed(@newss, :title => (@project ? @project.name : Setting.app_title) + ": #{l(:label_news_plural)}") } @@ -61,10 +67,18 @@ class NewsController < ApplicationController def show @comments = @news.comments @comments.reverse! if User.current.wants_comments_in_reverse_order? + @course_tag = @project.project_type + if @course_tag + render :layout => 'base_courses' + end end def new @news = News.new(:project => @project, :author => User.current) + @course_tag = @project.project_type + if @course_tag + render :layout => 'base_courses' + end end def create diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 926b6a648..67c0edb23 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -15,20 +15,40 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class ProjectsController < ApplicationController + # if @project.project_type == 1 layout 'base_projects'# by young menu_item :overview menu_item :roadmap, :only => :roadmap menu_item :settings, :only => :settings + menu_item l(:label_sort_by_time), :only => :index menu_item l(:label_sort_by_active), :only => :index menu_item l(:label_sort_by_influence), :only => :index - - before_filter :find_project, :except => [ :index, :search, :list, :new, :create, :copy ] - before_filter :authorize, :except => [:watcherlist, :index, :search, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, :statistics, :feedback, :project_respond] + + menu_item l(:label_homework), :only => :homework + menu_item l(:label_course_file), :only => :index + menu_item l(:label_course_news), :only => :index + # end + + + # layout 'base_courses'# by young + # menu_item :overview + # menu_item l(:label_homework), :only => :homework + # menu_item :files, :only => :files +# + # layout 'base_courses' + # menu_item l(:label_homework), :only => homework + # menu_item l(:label_course_file), :only => files + # menu_item l(:label_settings), :only => settings + + before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join] + before_filter :authorize, :except => [:new_join, :new_homework, :homework, :statistics, :search, :watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, :statistics, :feedback] before_filter :authorize_global, :only => [:new, :create] - before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ] + before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar] #by young - before_filter :member, :file, :statistics, :watcherlist + # before_filter :member, :file, :statistics, :watcherlist + # modified by fq + before_filter :file, :statistics, :watcherlist # accept_rss_auth :index accept_api_auth :index, :show, :create, :update, :destroy @@ -39,6 +59,8 @@ class ProjectsController < ApplicationController end end + helper :bids + include BidsHelper helper :sort include SortHelper helper :custom_fields @@ -222,6 +244,43 @@ class ProjectsController < ApplicationController end end + # added by fq + def new_join + @course = Project.find(params[:object_id]) + end + + #Added by young + def homework + @offset, @limit = api_offset_and_limit({:limit => 10}) + @bids = @project.homeworks + @bids = @bids.like(params[:name]) if params[:name].present? + @bid_count = @bids.count + @bid_pages = Paginator.new @bid_count, @limit, params['page'] + + @offset ||= @bid_pages.reverse_offset + #@bids = @bids.offset(@offset).limit(@limit).all.reverse + unless @offset == 0 + @bids = @bids.offset(@offset).limit(@limit).all.reverse + else + limit = @bid_count % @limit + @bids = @bids.offset(@offset).limit(limit).all.reverse + end + render :layout => 'base_courses' + + end + + def new_homework + if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0)) + @homework = Bid.new + @homework.safe_attributes = params[:bid] + render :layout => 'base_courses' + else + render_404 + end + + end + #Ended by young + def feedback @jours = @project.journals_for_messages.reverse @limit = 10 @@ -269,18 +328,36 @@ class ProjectsController < ApplicationController end def new + @course_tag = params[:course] @issue_custom_fields = IssueCustomField.sorted.all @trackers = Tracker.sorted.all @project = Project.new @project.safe_attributes = params[:project] + ##add by huang + @course=Course.new + @course.safe_attributes = params[:course] + ##end render :layout => 'base' end def create + @course_tag = params[:project][:project_type] + if(@course_tag=="1") + @course = Course.new + @course.extra='course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s + @course.safe_attributes = params[:project][:course] + @course.tea_id = User.current.id + @course.save + # project = ProjectInfo.create(:user_id => User.current.id, :project_id => @project.id) + # project_status = ProjectStatus.create(:project_id => @project.id) + end @issue_custom_fields = IssueCustomField.sorted.all @trackers = Tracker.sorted.all @project = Project.new @project.safe_attributes = params[:project] + if @course_tag == '1' + @project.identifier = @course.extra + end if validate_parent_id && @project.save @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') @@ -289,7 +366,7 @@ class ProjectsController < ApplicationController r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first m = Member.new(:user => User.current, :roles => [r]) project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id) - if params[:project][:is_public] == 1 + if params[:project][:is_public] == '1' || @course_tag=="1" project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0) end @project.members << m @@ -300,7 +377,12 @@ class ProjectsController < ApplicationController flash[:notice] = l(:notice_successful_create) if params[:continue] attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?} - redirect_to new_project_path(attrs) + redirect_to new_project_path(attrs, :course => '0') + #Added by young + + elsif params[:course_continue] + redirect_to new_project_path(:course => '1') + #Ended by young else redirect_to settings_project_path(@project) end @@ -358,7 +440,6 @@ class ProjectsController < ApplicationController @user = User.find_by_id(ProjectInfo.find_by_project_id(@project.id).user_id) cond = @project.project_condition(Setting.display_subprojects_issues?) - @open_issues_by_tracker = Issue.visible.open.where(cond).count(:group => :tracker) @total_issues_by_tracker = Issue.visible.where(cond).count(:group => :tracker) @@ -378,7 +459,9 @@ class ProjectsController < ApplicationController "show_issues" => true, "show_files" => true, "show_documents" => true, - "show_messages" => true + "show_messages" => true, + "show_news" => true, + "show_bids" => true } @date_to ||= Date.today + 1 @date_from = @date_to - @days @@ -415,8 +498,9 @@ class ProjectsController < ApplicationController end @document = @project.documents.build # + @base_courses_tag = @project.project_type respond_to do |format| - format.html + format.html{render :layout => 'base_courses' if @base_courses_tag==1} format.api end end @@ -427,6 +511,16 @@ class ProjectsController < ApplicationController @member ||= @project.members.new @trackers = Tracker.sorted.all @wiki ||= @project.wiki + #Added by young + # @course_tag = params[:course] + # if @course_tag == '1' + if @project.project_type == 1 + @course = Course.find_by_extra(@project.identifier) + render :layout => 'base_courses' + else + render :layout => 'base_projects' + end + #Ended by young end def edit @@ -434,9 +528,27 @@ class ProjectsController < ApplicationController #by young def member + if @project.project_type == 1 + render :layout => 'base_courses' + end end + + # def news + # if @project.project_type == 1 + # render :layout => 'base_courses' + # end + # end def file + # if @project.project_type == 1 + # render :layout => 'base_courses' + # end + # @course_tag = params[:course] + # if @course_tag == '1' + # render :layout => 'base_courses' + # end + + # User.current end def statistics @@ -447,6 +559,10 @@ class ProjectsController < ApplicationController def update @project.safe_attributes = params[:project] if validate_parent_id && @project.save + @course = Course.find_by_extra(@project.identifier) + @course.state = params[:project][:course][:state] + @course.term = params[:project][:course][:term] + @course.save @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') if params[:project][:is_public] == '0' @@ -459,7 +575,7 @@ class ProjectsController < ApplicationController respond_to do |format| format.html { flash[:notice] = l(:notice_successful_update) - redirect_to settings_project_path(@project) + redirect_to settings_project_path(@project,:course => @project.project_type) } format.api { render_api_ok } end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 94de4bfbb..61a3bfb51 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -43,15 +43,26 @@ class RepositoriesController < ApplicationController @repository = Repository.factory(scm) @repository.is_default = @project.repository.nil? @repository.project = @project - render :layout => 'base_projects' + @course_tag = params[:course] + if @course_tag == 1 + render :layout => 'base_courses' + else + render :layout => 'base_projects' + end end + def newrepo scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first @repository = Repository.factory(scm) @repository.is_default = @project.repository.nil? @repository.project = @project - render :layout => 'base_projects' + @course_tag = params[:course] + if @course_tag == 1 + render :layout => 'base_courses' + else + render :layout => 'base_projects' + end end def fork @@ -209,7 +220,12 @@ class RepositoriesController < ApplicationController @changesets = @repository.latest_changesets(@path, @rev) @properties = @repository.properties(@path, @rev) @repositories = @project.repositories - render :action => 'show', :layout => 'base_projects' + @course_tag = params[:course] + if @course_tag == 1 + render :action => 'show', :layout => 'base_courses' + else + render :action => 'show', :layout => 'base_projects' + end end end @@ -369,6 +385,8 @@ class RepositoriesController < ApplicationController end def stats + @project_id = params[:id] + @repository_id = @repository.identifier render :layout => 'base_projects' end diff --git a/app/controllers/teachers_controller.rb b/app/controllers/teachers_controller.rb new file mode 100644 index 000000000..b4d0c4839 --- /dev/null +++ b/app/controllers/teachers_controller.rb @@ -0,0 +1,5 @@ +class TeachersController < ApplicationController + def show + + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index fa8879921..825c79060 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -17,21 +17,23 @@ class UsersController < ApplicationController layout 'base_users' #Added by young - menu_item :activity + menu_item :activity menu_item :user_information, :only => :info menu_item :user_project, :only => :user_projects menu_item :requirement_focus, :only => :watch_bids menu_item :user_newfeedback, :only => :user_newfeedback + menu_item :user_course, :only => :user_courses #Ended by young - before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, :user_watchlist, :user_fanslist,:edit,:update] - before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, + before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, :user_watchlist, :user_fanslist,:update, :user_courses] + #edit has been deleted by huang, 2013-9-23 + before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info] accept_api_auth :index, :show, :create, :update, :destroy,:tag_save #william - before_filter :require_login,:only => :tag_save + before_filter :require_login, :only => :tag_save helper :sort @@ -117,6 +119,68 @@ class UsersController < ApplicationController end end # end + + # added by fq + def user_courses + case params[:type] + when "2" + @membership = @user.memberships.all(:conditions => Project.visible_condition(User.current)) + + @memberships = [] + @membership.each do |membership| + if membership.project.project_type == 1 + @membership << membership + end + end + @state = 2 + + when "1" + @membership = @user.memberships.all(:conditions => Project.visible_condition(User.current)) + + @memberships = [] + @membership.each do |membership| + if membership.project.project_type == 1 + @memberships << membership + end + end + @bid = [] + @memberships.each do |membership| + @bid += membership.project.homeworks + end + @bid = @bid.group_by {|bid| bid.courses.first.id} + @state = 1 + + else + @membership = @user.memberships.all(:conditions => Project.visible_condition(User.current)) + @memberships = [] + @membership.each do |membership| + if membership.project.project_type == 1 + @memberships << membership + end + end + @state = 0 + end + + # events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20) + # @events_by_day = events.group_by(&:event_date) + + # @state = 0 + + #add by huang + unless User.current.admin? + if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?) + render_404 + return + end + end + #end + + # respond_to do |format| + # format.html + # format.api + # end + end + # end # modified by fq def user_newfeedback diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb index 29901aa6b..b06b8cbb3 100644 --- a/app/controllers/watchers_controller.rb +++ b/app/controllers/watchers_controller.rb @@ -23,6 +23,41 @@ class WatchersController < ApplicationController def unwatch set_watcher(@watchables, User.current, false) end + + def join + if User.current.logged? + course = Project.find(params[:object_id]) + if params[:course_password] == '123' + members = [] + members << Member.new(:role_ids => [5], :user_id => User.current.id) + course.members << members + + StudentsForCourse.create(:student_id => User.current.id, :course_id => params[:object_id]) + else + end + end + respond_to do |format| + # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} + format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Project.find(params[:object_id])} } + end + end + + def unjoin + if User.current.logged? + + @member = Member.where('project_id = ? and user_id = ?', params[:object_id], User.current.id) + @member.first.destroy + + joined = StudentsForCourse.where('student_id = ? and course_id = ?', User.current.id, params[:object_id]) + joined.each do |join| + join.delete + end + end + respond_to do |format| + # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} + format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Project.find(params[:object_id])} } + end + end before_filter :find_project, :authorize, :only => [:new, :create, :append, :destroy, :autocomplete_for_user] accept_api_auth :create, :destroy diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5204788cf..54ab7b76b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -31,7 +31,18 @@ module ApplicationHelper extend Forwardable def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter - + + #Added by young + #Define the course menu's link class + def link_class(label) + if current_menu_item == label + @class = 'selected' + else + @class = '' + end + return @class + end + #Ended by young # Return true if user is authorized for controller/action, otherwise false def authorize_for(controller, action) User.current.allowed_to?({:controller => controller, :action => action}, @project) @@ -966,7 +977,7 @@ module ApplicationHelper end def lang_options_for_select(blank=true) - (blank ? [["(auto)", ""]] : []) + languages_options + { 'Chinese简体中文 '=> 'zh', :English => :en} end def label_tag_for(name, option_tags = nil, options = {}) diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index a4925343f..f61399c85 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -31,6 +31,15 @@ module AttachmentsHelper :locals => {:attachments => container.attachments, :options => options, :thumbnails => (options[:thumbnails] && Setting.thumbnails_enabled?)} end end + + def attach_delete(project) + if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0) || project.user_id == User.current.id) + true + else + false + end + + end def render_api_attachment(attachment, api) api.attachment do diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 0d12a22ea..1b8340721 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -35,6 +35,7 @@ module ProjectsHelper {:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities} ] tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)} + end def sort_project(state) @@ -60,6 +61,20 @@ module ProjectsHelper end + #Added by young + def course_settings_tabs + tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural, :course=>'1'}, + {:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural}, + # {:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository_plural}, + {:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural} + ] + tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)} + + end + #Ended by young + + + def parent_project_select_tag(project) selected = project.parent @@ -78,7 +93,13 @@ module ProjectsHelper # Renders the projects index def render_project_hierarchy(projects) render_project_nested_lists(projects) do |project| - s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}") + #Modified by young + if (project.project_type==1) + s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")+"(#{l(:label_course)})".html_safe + else + s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}") + end + #Ended by young if project.description.present? #Delete by nie. # s << content_tag('td', textilizable(project.short_description, :project => project), :class => 'wiki description') @@ -111,5 +132,18 @@ module ProjectsHelper def get_projects_by_tag(tag_name) Project.tagged_with(tag_name).order('updated_on desc') end + + # added by fq + def homework_type_option + type = [] + option1 = [] + option2 = [] + option1 << '作业最终以附件形式提交' + option1 << 1 + option2 << '作业最终以项目形式提交' + option2 << 2 + type << option1 + type << option2 + end end diff --git a/app/helpers/teachers_helper.rb b/app/helpers/teachers_helper.rb new file mode 100644 index 000000000..1015c8c9f --- /dev/null +++ b/app/helpers/teachers_helper.rb @@ -0,0 +1,2 @@ +module TeachersHelper +end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 32c4b6142..c813714d3 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -90,6 +90,26 @@ module UsersHelper end content_tag('div', content, :class => "pagination") end + + def user_course(state) + content = ''.html_safe + case state + when 0 + s = content_tag('span', '我的课程', :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to('我的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) + when 1 + s = content_tag('span', '我的作业', :class => "current-page") + content << content_tag('li', link_to('我的课程', {:controller => 'users', :action => 'user_courses'})) + content << content_tag('li', s, :class => "current-page") + when 2 + s = content_tag('span', '课程通知', :class => "current-page") + content << content_tag('li', link_to('课程通知', {:controller => 'users', :action => 'user_courses'})) + content << content_tag('li', s, :class => "current-page") + end + content_tag('div', content, :class => "pagination") + + end # added by huang def sort_user(state) diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 052c3fd25..2baee6479 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -45,6 +45,21 @@ module WatchersHelper link_to text, url, :remote => true, :method => method, :class => css end + + # added by fq + def join_in_course(course, user) + return '' unless user && user.logged? + joined = user.member_of?(course) + text = joined ? '退出课程' : '加入课程' + url_t = join_path(:object_id => course.id) + url_f = try_join_path(:object_id => course.id) + method = joined ? 'delete' : 'post' + if joined + link_to text, url_t, :remote => true, :method => method, :id => 'join', :confirm => l(:text_are_you_sure) + else + link_to text, url_f, :remote => true, :method => method, :id => 'join' + end + end # Returns the css class used to identify watch links for a given +object+ def watcher_css(objects) diff --git a/app/models/bid.rb b/app/models/bid.rb index 5821fb0c1..e6b8511c3 100644 --- a/app/models/bid.rb +++ b/app/models/bid.rb @@ -1,20 +1,26 @@ ####by fq class Bid < ActiveRecord::Base - #attr_accessible :author_id, :budget, :deadline, :name, :description + attr_accessible :author_id, :budget, :deadline, :name, :description, :homework_type include Redmine::SafeAttributes belongs_to :author, :class_name => 'User', :foreign_key => :author_id + belongs_to :course has_many :biding_projects, :dependent => :destroy has_many :projects, :through => :biding_projects has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy + has_many :homework_for_courses, :dependent => :destroy + has_many :courses, :through => :homework_for_courses, :source => :project + has_many :homeworks, :class_name => 'HomeworkAttach', :dependent => :destroy + + acts_as_attachable NAME_LENGTH_LIMIT = 60 DESCRIPTION_LENGTH_LIMIT = 250 validates_length_of :name, :maximum => NAME_LENGTH_LIMIT validates_length_of :description, :maximum => DESCRIPTION_LENGTH_LIMIT - validates_presence_of :author_id, :name, :deadline, :budget + validates_presence_of :author_id, :name, :deadline # validates_presence_of :deadline, :message => 'test' # validates_format_of :deadline, :with => validates_format_of :deadline, :with => /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/ @@ -46,7 +52,7 @@ class Bid < ActiveRecord::Base :author => :author, :url => Proc.new {|o| {:controller => 'bids', :action => 'show', :id => o.id}} - acts_as_activity_provider :find_options => {:include => [:author]}, + acts_as_activity_provider :find_options => {:include => [:projects, :author]}, :author_key => :author_id @@ -54,6 +60,10 @@ class Bid < ActiveRecord::Base 'description', 'budget', 'deadline' + + # safe_attributes 'name', + # 'description', + # 'deadline' def add_jour(user, notes, reference_user_id = 0) self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id) diff --git a/app/models/course.rb b/app/models/course.rb new file mode 100644 index 000000000..276cc7652 --- /dev/null +++ b/app/models/course.rb @@ -0,0 +1,20 @@ +class Course < ActiveRecord::Base + include Redmine::SafeAttributes + + attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term + belongs_to :project, :class_name => 'Project', :foreign_key => :extra # 定义一个project方法, 该方法通过extra来调用project表 + belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表 + has_many :bid + validates_presence_of :state, :term + safe_attributes 'extra', + 'time', + 'name', + 'extra', + 'code', + 'location', + 'tea_id', + 'state', + 'term' + + +end diff --git a/app/models/homework_attach.rb b/app/models/homework_attach.rb new file mode 100644 index 000000000..aea68abb5 --- /dev/null +++ b/app/models/homework_attach.rb @@ -0,0 +1,9 @@ +class HomeworkAttach < ActiveRecord::Base + attr_accessible :bid_id, :user_id + + belongs_to :user + belongs_to :bid + + acts_as_attachable + +end diff --git a/app/models/homework_for_course.rb b/app/models/homework_for_course.rb new file mode 100644 index 000000000..7a440449a --- /dev/null +++ b/app/models/homework_for_course.rb @@ -0,0 +1,8 @@ +class HomeworkForCourse < ActiveRecord::Base + attr_accessible :bid_id, :project_id + + belongs_to :bid + belongs_to :project + + +end diff --git a/app/models/journals_for_message_observer.rb b/app/models/journals_for_message_observer.rb new file mode 100644 index 000000000..3bca47791 --- /dev/null +++ b/app/models/journals_for_message_observer.rb @@ -0,0 +1,7 @@ +# Added by young +class JournalsForMessageObserver < ActiveRecord::Observer + def after_create(journal_for_message) + Mailer.journals_for_message_add(User.current, journal_for_message).deliver + end +end + diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 1db19f14e..ed942f0d3 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -26,6 +26,15 @@ class Mailer < ActionMailer::Base def self.default_url_options { :host => Setting.host_name, :protocol => Setting.protocol } end + + # Builds a Mail::Message object used to email recipients of the added journals for message. + # + # def journals_for_message_add(user, journals_for_message) + # @user = User.current + # @url = url_for(:controller => 'users', :action => 'user_newfeedback') + # mail :to => user.mail, + # :subject => "hello" + # end # Builds a Mail::Message object used to email recipients of the added issue. # diff --git a/app/models/project.rb b/app/models/project.rb index bd856f7d0..53e407246 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -53,13 +53,27 @@ class Project < ActiveRecord::Base has_many :changesets, :through => :repository # added by fq has_many :journals_for_messages, :as => :jour, :dependent => :destroy + has_many :homework_for_courses, :dependent => :destroy + has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy + has_many :students_for_courses, :dependent => :destroy + has_many :student, :through => :students_for_courses, :source => :user + # has_one :cour, :class_name => 'Course', :foreign_key => :extra, :dependent => :destroy + # end #ADDED BY NIE - has_many :project_infos, :dependent => :destroy + has_many :project_infos, :dependent => :destroy + has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy + has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy + has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy #end + has_one :wiki, :dependent => :destroy - # Custom field for the project issues + ##added by xianbo + has_one :course, :dependent => :destroy ,:order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC" + accepts_nested_attributes_for :course + ##end + # Custom field for the project issues has_and_belongs_to_many :issue_custom_fields, :class_name => 'IssueCustomField', :order => "#{CustomField.table_name}.position", @@ -682,7 +696,10 @@ class Project < ActiveRecord::Base 'custom_field_values', 'custom_fields', 'tracker_ids', - 'issue_custom_field_ids' + 'issue_custom_field_ids', + 'project_type' + + safe_attributes 'enabled_module_names', :if => lambda {|project, user| project.new_record? || user.allowed_to?(:select_project_modules, project) } @@ -1027,6 +1044,10 @@ class Project < ActiveRecord::Base def update_position_under_parent set_or_update_position_under(parent) end + + def course + @course + end # Inserts/moves the project so that target's children or root projects stay alphabetically sorted def set_or_update_position_under(target_parent) diff --git a/app/models/students_for_course.rb b/app/models/students_for_course.rb new file mode 100644 index 000000000..597d74da6 --- /dev/null +++ b/app/models/students_for_course.rb @@ -0,0 +1,10 @@ +class StudentsForCourse < ActiveRecord::Base + attr_accessible :course_id, :student_id + + belongs_to :course, :class_name => 'Project', :foreign_key => :course_id + belongs_to :student, :class_name => 'User', :foreign_key => :student_id + + validates_presence_of :course_id, :student_id + validates_uniqueness_of :student_id, :scope => :course_id + +end diff --git a/app/models/teacher.rb b/app/models/teacher.rb new file mode 100644 index 000000000..cf57a1be8 --- /dev/null +++ b/app/models/teacher.rb @@ -0,0 +1,13 @@ +class Teacher < ActiveRecord::Base + attr_accessible :course_code, :couurse_time, :location, :tea_name + include Redmine::SafeAttributes + + belongs_to :project + + safe_attributes'tea_name', + 'location', + 'couurse_time', + 'course_code', + 'extra' + +end diff --git a/app/models/user.rb b/app/models/user.rb index 978170017..981ff5af5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -82,8 +82,13 @@ class User < Principal has_many :bids, :foreign_key => 'author_id', :dependent => :destroy has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" - has_many :journal_replies - has_many :activities + has_many :journal_replies, :dependent => :destroy + has_many :activities, :dependent => :destroy + has_many :students_for_courses, :dependent => :destroy + has_many :courses, :through => :students_for_courses, :source => :project + has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy + has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy + has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy ##### @@ -150,13 +155,27 @@ class User < Principal self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id, :status => true) end + ### fq + def join_in?(course) + joined = StudentsForCourse.where('student_id = ? and course_id = ?', self.id, course.id) + if joined.size > 0 + true + else + false + end + end + ## end + def count_new_jour count = self.new_jours.count end def set_mail_notification + ##add byxianbo + thread=Thread.new do self.mail_notification = Setting.default_notification_option if self.mail_notification.blank? true + end end def update_hashed_password diff --git a/app/views/account/register.html.erb b/app/views/account/register.html.erb index 1c9dd6854..ce666940e 100644 --- a/app/views/account/register.html.erb +++ b/app/views/account/register.html.erb @@ -187,48 +187,6 @@ } - -

<%=l(:label_register)%> <%=link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %>

@@ -253,29 +211,14 @@ <%="#{l(:label_mail_attention)} "%>

<%= f.select :language, lang_options_for_select %>

- +

-
<%= l(:label_identity) %> * - - - - - -

- - + <%= select_tag 'identity', " + + ".html_safe %>

@@ -283,7 +226,7 @@ <%= select_tag 'gender', "".html_safe %>
<%= l(:label_gender) %>

-

+

<%= l(:label_location) %>
+ + <% unless bid.reward_type == 3 %> + + + + <% else %> + + + + <% end %> +
<%= l(:label_location) %> *
<%= submit_tag l(:button_submit) %>

<% end %> - <% if Setting.openid? %>

<%= f.text_field :identity_url %>

<% end %> diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index d2ab22ced..81eb416af 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -9,11 +9,19 @@ <%= h(" - #{attachment.description}") unless attachment.description.blank? %> (<%= number_to_human_size attachment.filesize %>) <% if options[:deletable] %> + <% unless attachment.container_type == 'HomeworkAttach' %> <%= link_to image_tag('delete.png'), attachment_path(attachment), :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :class => 'delete', :title => l(:button_delete) %> + <% else %> + <%= link_to image_tag('delete.png'), {:controller => 'attachments', :action => 'delete_homework', :id => attachment.id}, + :data => {:confirm => l(:text_are_you_sure)}, + :method => :delete, + :class => 'delete', + :title => l(:button_delete) %> + <% end %> <% end %> <% if options[:author] %> <%= h(attachment.author) %>, <%= format_time(attachment.created_on) %> diff --git a/app/views/attachments/delete.js.erb b/app/views/attachments/delete.js.erb new file mode 100644 index 000000000..3cfb5845f --- /dev/null +++ b/app/views/attachments/delete.js.erb @@ -0,0 +1 @@ +$('#attachments_<%= j params[:attachment_id] %>').remove(); diff --git a/app/views/bids/_bid_homework_show.html.erb b/app/views/bids/_bid_homework_show.html.erb new file mode 100644 index 000000000..cea2165d4 --- /dev/null +++ b/app/views/bids/_bid_homework_show.html.erb @@ -0,0 +1,46 @@ + +<% bids.each do |bid|%> + + + + + + +
<%= link_to(image_tag(url_to_avatar(bid.author), :class => 'avatar'), user_path(bid.author), :class => "avatar") %> + + + + + + + + + + + +
<%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author), :class => 'bid_user') %>:  <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %>
+ + + + + + + +
<% if bid.reward_type.nil? or bid.reward_type == 1 %> <%= l(:label_bids_reward_method) %><%= l(:label_call_bonus) %> <%= l(:label_RMB_sign) %> + <%= bid.budget%> <% elsif bid.reward_type == 2 %> <%= l(:label_bids_reward_method) %><%= bid.budget%> <% else %> + + <% end %>
<%= l(:label_x_homework_project, :count => bid.biding_projects.count) %>(<%= link_to bid.biding_projects.count, project_for_bid_path(bid.id) %>)<%= l(:label_x_responses, :count => bid.commit) %>(<%= link_to bid.commit, respond_path(bid) %>)
<%= format_time bid.created_on %>
+
+ + + + +
<%= bid.description%>
+
+<% end %> + + diff --git a/app/views/bids/_bid_show.html.erb b/app/views/bids/_bid_show.html.erb index 40760e12f..d3f1cbb74 100644 --- a/app/views/bids/_bid_show.html.erb +++ b/app/views/bids/_bid_show.html.erb @@ -1,100 +1,41 @@ - <% bids.each do |bid|%> - - - - -
<%= link_to(image_tag(url_to_avatar(bid.author), :class => 'avatar'), user_path(bid.author), :class => "avatar") %> - - - - - - - - - - - -
<%= link_to(bid.author, user_path(bid.author), :class => 'bid_user') %>:  <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %>
- - - - - -
- <% if bid.reward_type.nil? or bid.reward_type == 1%> - <%= l(:label_bids_reward_method) %><%= l(:label_call_bonus) %> <%= l(:label_RMB_sign) %><%= bid.budget%> - <% elsif bid.reward_type == 2%> - <%= l(:label_bids_reward_method) %><%= bid.budget%> - <% else %> - <%= l(:label_bids_reward_method) %><%= l(:label_bids_credit) %> <%= bid.budget%> <%= l(:label_bids_credit_number) %> - <% end %> - - -
- <%= l(:label_x_biding_project, :count => bid.biding_projects.count) %>(<%=link_to bid.biding_projects.count, project_for_bid_path(bid) %>) - <%= l(:label_x_responses, :count => bid.commit) %>(<%=link_to bid.commit, respond_path(bid) %>) - <%= l(:label_x_followers, :count => bid.watcher_users.count) %>(<%=link_to bid.watcher_users.count, respond_path(bid) %>) -
<%= format_time bid.created_on %>
-
- - - - -
<%= bid.description%>
-
-<% end %> - - - - <% end %>
<%= l(:label_x_biding_project, :count => bid.biding_projects.count) %>(<%= link_to bid.biding_projects.count, project_for_bid_path(bid) %>)<%= l(:label_x_bids_responses, :count => bid.commit) %>(<%= link_to bid.commit, respond_path(bid) %>) <%= l(:label_x_followers, :count => bid.watcher_users.count) %>(<%= link_to bid.watcher_users.count, respond_path(bid) %>)
<%= l(:label_x_homework_project, :count => bid.biding_projects.count) %>(<%= link_to bid.biding_projects.count, project_for_bid_path(bid) %>) <%= l(:label_x_responses, :count => bid.commit) %>(<%= link_to bid.commit, respond_path(bid) %>) <%= l(:label_x_followers, :count => bid.watcher_users.count) %>(<%= link_to bid.watcher_users.count, respond_path(bid) %>)
+ <%= format_time bid.created_on %> - <%= l(:field_deadline) %><%= format_time bid.created_on %> + +

+ + + + +
<%= bid.description%>
+
@@ -104,4 +45,5 @@