diff --git a/Client.html b/Client.html index 5ba9775f..fbb7cec5 100644 --- a/Client.html +++ b/Client.html @@ -1,4 +1,4 @@ - + @@ -8,15 +8,15 @@ Client <body> <hr /> - <h2>һͼƬ</h2> + <h2>这是一张图片</h2> <p>photo<a href="http://10.0.47.15:3000/shares/new?access_token='2d3dda45dsd'&comment='verygood'&title=davide&share_type=1&url=http://www.baidu.com"> Share A </a></p> <hr /> - <h2>һƵ</h2> + <h2>这是一段视频</h2> <p>Text<a href="http://10.0.47.15:3000/shares/new?access_token=2d3dda45dsd&comment=verygood&title=kaka&share_type=2&url=http://www.sina.com"> Share B </a></p> <hr /> - <h2>һƪ</h2> + <h2>这是一篇文章</h2> <p>Text<a href="http://10.0.47.15:3000/shares/new?access_token=2d3dda45dsd&comment=verygood&title=pepe&share_type=3&url=http://www.sina.com"> Share C </a></p> <hr /> diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index cf39898f..af848786 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -276,10 +276,18 @@ class AccountController < ApplicationController set_autologin_cookie(user) end call_hook(:controller_account_success_authentication_after, {:user => user }) - #by young -# redirect_back_or_default my_page_path - redirect_back_or_default User.current -# redirect_to User.current + + code = /\d*/ + #根据home_url生产正则表达式 + eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/") + if code=~params[:back_url] + redirect_to user_activities_path(user) + else + #by young + #redirect_back_or_default my_page_path + redirect_back_or_default User.current + #redirect_to User.current + end end def set_autologin_cookie(user) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 90048736..51259bb5 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -22,7 +22,6 @@ class AttachmentsController < ApplicationController before_filter :authorize_global, :only => :upload before_filter :login_without_softapplication, only: [:download] - accept_api_auth :show, :download, :upload def show @@ -125,7 +124,7 @@ class AttachmentsController < ApplicationController end respond_to do |format| - format.html { redirect_to_referer_or project_path(@project) } + format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum,@attachment.container) } format.js end end @@ -224,4 +223,11 @@ private referer = request.headers['Referer'] require_login unless referer =~ /softapplication/ end + + def renderTag + @attachmentNew = Attachment.find(params[:attchmentId]) + respond_to do |format| + format.js + end + end end diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 206421e5..2273de4e 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -18,6 +18,8 @@ class BidsController < ApplicationController helper :attachments include AttachmentsHelper include ApplicationHelper + include BidsHelper + helper :projects helper :words helper :welcome @@ -503,10 +505,12 @@ class BidsController < ApplicationController #删除已提交的项目作业(不删项目) def delete binding_project = params[:binding_project] - if BidingProject.delete(binding_project) - redirect_to project_for_bid_path - else - redirect_to 403; + if can_delete_project_homework(BidingProject.find(binding_project),User.current) + if BidingProject.delete(binding_project) + redirect_to project_for_bid_path + else + redirect_to 403; + end end end ## 新建留言 @@ -728,9 +732,9 @@ class BidsController < ApplicationController def update @bid = Bid.find(params[:id]) @project = @bid.courses.first#Project.find(params[:course_id]) - if @bid.update_attributes(params[:bid]) + @bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) + if @bid.update_attributes(params[:bid]) && @bid.save flash[:notice] = l(:label_update_homework_succeed) - #@project = Project.find(params[:course_id]) redirect_to project_homework_path(@project) else @bid.safe_attributes = params[:bid] diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index a2dd8c86..f9236d0b 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -52,16 +52,59 @@ class FilesController < ApplicationController end def create - container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) - attachments = Attachment.attach_filesex(container, params[:attachments],params[:attachment_type]) - render_attachment_warning_if_needed(container) + if params[:tag_name] + tag_saveEx + render :text =>"success" + else + @addTag=false + container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) + attachments = Attachment.attach_filesex(container, params[:attachments],params[:attachment_type]) + render_attachment_warning_if_needed(container) - if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') - Mailer.attachments_added(attachments[:files]).deliver + if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') + Mailer.attachments_added(attachments[:files]).deliver + end + redirect_to project_files_path(@project) end - redirect_to project_files_path(@project) end + def tag_saveEx + @tags = params[:tag_name][:name] + @obj_id = params[:object_id] + @obj_flag = params[:object_flag] + + case @obj_flag + when '1' then + @obj = User.find_by_id(@obj_id) + when '2' then + @obj = Project.find_by_id(@obj_id) + when '3' then + @obj = Issue.find_by_id(@obj_id) + when '4' then + @obj = Bid.find_by_id(@obj_id) + when '5' then + @obj = Forum.find_by_id(@obj_id) + when '6' + @obj = Attachment.find_by_id(@obj_id) + when '7' then + @obj = Contest.find_by_id(@obj_id) + when '8' + @obj = OpenSourceProject.find_by_id(@obj_id) + else + @obj = nil + end + unless @obj.nil? + @obj.tag_list.add(@tags.split(",")) + else + return + end + if @obj.save + ## 执行成功的操作。 + else + #捕获异常 + end + end + # 返回制定资源类型的资源列表 def getattachtype sort_init 'created_on', 'desc' diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb new file mode 100644 index 00000000..2a0f9761 --- /dev/null +++ b/app/controllers/homework_attach_controller.rb @@ -0,0 +1,90 @@ +class HomeworkAttachController < ApplicationController + #显示作业信息 + def show + @homework = HomeworkAttach.find(params[:id]) + # 打分统计 + stars_reates = @homework. + rates(:quality) + stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count + stars_status = stars_reates.select("stars, count(*) as scount"). + group("stars") + @stars_status_map = Hash.new(0.0) + stars_status.each do |star_status| + percent = (star_status.scount * 1.0/ stars_reates_count) * 100.to_f + percent_m = format("%.2f", percent) + @stars_status_map["star#{star_status.stars.to_i}".to_sym] = + percent_m.to_s + "%" + end + @jours = @homework.journals_for_messages.order("created_on DESC") + @limit = 10 + @feedback_count = @jours.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + @jour = @jours[@offset, @limit] + end + + #删除留言 + def destroy + @journal_destroyed = JournalsForMessage.delete_message(params[:object_id]) + #@homework = HomeworkAttach.find(params[:id]) + #@jours = @homework.journals_for_messages.order("created_on DESC") + #@limit = 10 + #@feedback_count = @jours.count + #@feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + #@offset ||= @feedback_pages.offset + #@jour = @jours[@offset, @limit] + respond_to do |format| + format.js + end + end + + #添加留言 + def addjours + @homework = HomeworkAttach.find(params[:jour_id]) + @homework.addjours User.current.id, params[:new_form][:user_message],0 + @jours = @homework.journals_for_messages.order("created_on DESC") + #@limit = 10 + #@feedback_count = @jours.count + #@feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + #@offset ||= @feedback_pages.offset + #@jour = @jours[@offset, @limit] + respond_to do |format| + format.js + end + end + + #获取指定作业的平均得分 + def score + #stars_reates = @homework.rates(:quality) + #percent = 0 + #stars_reates.each do |star_reates| + # percent = percent + star_reates.stars + #end + #stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count + #result = percent * 1.0 / stars_reates_count + #result + end + + #添加回复 + def add_jour_reply + parent_id = params[:reference_id] + author_id = User.current.id + reply_user_id = params[:reference_user_id] + reply_id = params[:reference_message_id] # 暂时不实现 + content = params[:user_notes] + options = {:user_id => author_id, + :m_parent_id => parent_id, + :m_reply_id => reply_id, + :reply_id => reply_user_id, + :notes => content, + :is_readed => false} + @jfm = JournalsForMessage.new(options) + @jfm.save + respond_to do |format| + format.js{ + @save_succ = true if @jfm.errors.empty? + } + end + end +end + diff --git a/app/controllers/homework_users_controller.rb b/app/controllers/homework_users_controller.rb new file mode 100644 index 00000000..cb55d965 --- /dev/null +++ b/app/controllers/homework_users_controller.rb @@ -0,0 +1,3 @@ +class HomeworkUsersController < ApplicationController + +end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 116ccd5d..d9996e73 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -15,9 +15,8 @@ # 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 layout :select_project_layout + menu_item :overview menu_item :roadmap, :only => :roadmap menu_item :settings, :only => :settings @@ -32,18 +31,7 @@ class ProjectsController < ApplicationController menu_item :feedback, :only => :feedback 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, :course, :enterprise_course, :course_enterprise] # before_filter :authorize, :except => [:new_join, :new_homework, :homework, :statistics, :search, :watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, @@ -52,11 +40,11 @@ class ProjectsController < ApplicationController before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen] before_filter :authorize_global, :only => [:new, :create] before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar] - #by young - # before_filter :member, :file, :statistics, :watcherlist - # modified by fq before_filter :file, :statistics, :watcherlist - # + + # 除非项目内人员,不可查看成员, TODO: 完了写报表里去 + before_filter :memberAccess, only: :member + accept_rss_auth :index accept_api_auth :index, :show, :create, :update, :destroy @@ -89,27 +77,6 @@ class ProjectsController < ApplicationController ### added by william include ActsAsTaggableOn::TagsHelper - # Lists visible projects - # def index - # respond_to do |format| - # format.html { - # scope = Project - # unless params[:closed] - # scope = scope.active - # end - # @projects = scope.visible.order('lft').all - # } - # format.api { - # @offset, @limit = api_offset_and_limit - # @project_count = Project.visible.count - # @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all - # } - # format.atom { - # projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all - # render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}") - # } - # end - # end def enterprise_course session[:enterprise_college] = 2 respond_to do |format| @@ -384,36 +351,6 @@ class ProjectsController < ApplicationController end #gcmend - # def search - # #modified by nie - # project_type = params[:project_type].to_i - # projects_all = (project_type.eql? Project::ProjectType_course) ? Project.course_entities : Project.project_entities - # @projects = projects_all.visible - # @projects = @projects.visible.like(params[:name]) if params[:name].present? - # @offset, @limit = api_offset_and_limit({:limit => 10}) - # @project_count = @projects.visible.count - # @project_pages = Paginator.new @project_count, @limit, params['page'] - # @offset ||= @project_pages.offset - # @projects = @projects.visible.offset(@offset).limit(@limit).all - # respond_to do |format| - # format.html { - # render :layout => 'base' - # scope = Project - # unless params[:closed] - # scope = scope.active - # end - # } - # format.api { - # # @offset, @limit = api_offset_and_limit - # # @project_count = Project.visible.count - # # @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all - # } - # format.atom { - # projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all - # render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}") - # } - # end - # end # added by fq def new_join @@ -861,22 +798,7 @@ class ProjectsController < ApplicationController memberlist 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 @@ -999,12 +921,8 @@ class ProjectsController < ApplicationController # end before_filter :toggleCourse, only: [:finishcourse, :restartcourse] - # TODO:#finishcourse and #restartcourse 没有设置权限,也就是说,任何人的调用都会关闭or重启课程。 # 最好通过用户与项目的权限解决这种事情。还没写 def finishcourse - #course_prefs = Course.find_by_extra(@project.identifier) - # setup_time = Time.parse(course_prefs.setup_time) - # end_time = Time.parse(course_prefs.endup_time) yesterday = Date.today.prev_day.to_time @course_prefs.endup_time = yesterday @@ -1016,7 +934,6 @@ class ProjectsController < ApplicationController end def restartcourse - #course_prefs = Course.find_by_extra(@project.identifier) day = Time.parse("3000-01-01") @course_prefs.endup_time = day @@ -1030,6 +947,14 @@ class ProjectsController < ApplicationController end private + + def memberAccess + # 是课程,则判断当前用户是否参加了课程 + return 0 if @project.project_type == Project::ProjectType_project + currentUser = User.current + render_403 unless currentUser.member_of?(@project) + end + def toggleCourse @course_prefs = Course.find_by_extra(@project.identifier) unless (@course_prefs.teacher == User.current || User.current.admin?) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9a21e26f..7365e404 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -30,7 +30,7 @@ class UsersController < ApplicationController #Ended by young - before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info, + before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info, :user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index, :activity_score_index, :influence_score_index, :score_index] #edit has been deleted by huang, 2013-9-23 @@ -39,10 +39,10 @@ class UsersController < ApplicationController :watch_bids, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, :activity_score_index, :influence_score_index, :score_index] before_filter :auth_user_extension, only: :show - accept_api_auth :index, :show, :create, :update, :destroy,:tag_save + accept_api_auth :index, :show, :create, :update, :destroy,:tag_save , :tag_saveEx #william - before_filter :require_login, :only => :tag_save + before_filter :require_login, :only => [:tag_save,:tag_saveEx] helper :sort @@ -209,6 +209,8 @@ class UsersController < ApplicationController ## 判断课程是否过期 [需封装] @memberships_doing = [] @memberships_done = [] + @OwningCouses =[] + @JoinCouses=[] now_time = Time.now.year @memberships.map { |e| end_time = e.project.course_extra.get_time.year @@ -218,6 +220,12 @@ class UsersController < ApplicationController else @memberships_doing.push e end + + if e.project.course_extra.tea_id == User.current.id + @OwningCouses.push e + else + @JoinCouses.push e + end } # respond_to do |format| # format.html @@ -683,11 +691,51 @@ class UsersController < ApplicationController #捕获异常 end respond_to do |format| - format.html format.js - end + format.html + end + end + + def tag_saveEx + @tags = params[:tag_name][:name] + @obj_id = params[:obj_id] + @obj_flag = params[:obj_flag] + + case @obj_flag + when '1' then + @obj = User.find_by_id(@obj_id) + when '2' then + @obj = Project.find_by_id(@obj_id) + when '3' then + @obj = Issue.find_by_id(@obj_id) + when '4' then + @obj = Bid.find_by_id(@obj_id) + when '5' then + @obj = Forum.find_by_id(@obj_id) + when '6' + @obj = Attachment.find_by_id(@obj_id) + when '7' then + @obj = Contest.find_by_id(@obj_id) + when '8' + @obj = OpenSourceProject.find_by_id(@obj_id) + else + @obj = nil + end + unless @obj.nil? + @obj.tag_list.add(@tags.split(",")) + else + return + end + if @obj.save + ## 执行成功的操作。 + else + #捕获异常 + end + respond_to do |format| + format.js + format.html + end end - ###add by huang def user_watchlist end diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index c83c123f..bfc1eacb 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -193,7 +193,9 @@ class WordsController < ApplicationController elsif ( referer.match(/contests/) || referer.match(/contests/) ) #new added obj = Contest.find_by_id(obj_id) elsif ( referer.match(/softapplications/) || referer.match(/softapplications/) ) #new added - obj = Softapplication.find_by_id(obj_id) + obj = Softapplication.find_by_id(obj_id) + elsif ( referer.match(/homework_attach/) || referer.match(/homework_attach/) ) #new added + obj = HomeworkAttach.find_by_id(obj_id) else raise 'create reply obj unknow type.' end @@ -211,7 +213,9 @@ class WordsController < ApplicationController elsif obj.kind_of? Contest obj.add_jour(nil, nil, obj.id, options) #new added elsif obj.kind_of? Softapplication - obj.add_jour(nil, nil, obj.id, options) #new added + obj.add_jour(nil, nil, obj.id, options) #new added + elsif obj.kind_of? HomeworkAttach + obj.add_jour(nil, nil, obj.id, options) #new added else raise 'create reply obj unknow type.' end diff --git a/app/helpers/bids_helper.rb b/app/helpers/bids_helper.rb index bd39d6c2..38b32e69 100644 --- a/app/helpers/bids_helper.rb +++ b/app/helpers/bids_helper.rb @@ -151,4 +151,8 @@ module BidsHelper tmp end + def can_delete_project_homework bind_project,current_user + current_user.id == bind_project.user.id || current_user.admin + end + end \ No newline at end of file diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 35a907ec..97cca617 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -31,6 +31,31 @@ module CoursesHelper # searchStudent(project).count end + # garble count 混淆数量 + # alias projectCountOrigin projectCount + # def projectCount project + # count = projectCountOrigin project + # garble count + # end + + alias teacherCountOrigin teacherCount + def teacherCount project + count = teacherCountOrigin project + garble count + end + + alias studentCountOrigin studentCount + def studentCount project + count = studentCountOrigin project + garble count + end + + def garble count + count = count.round( 1-count.to_s.size ).to_i + return count.to_s if count.to_s.size.eql?(1) + count.to_s << '+' + end + # ===================================================================================== # return people list def searchTeacherAndAssistant project diff --git a/app/helpers/homework_users_helper.rb b/app/helpers/homework_users_helper.rb new file mode 100644 index 00000000..48a9a8e4 --- /dev/null +++ b/app/helpers/homework_users_helper.rb @@ -0,0 +1,2 @@ +module HomeworkUsersHelper +end diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index e05f789a..33001021 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -154,10 +154,11 @@ module WelcomeHelper sort_course_by_hot limit end - def find_all_new_hot_course limit = 9 + def find_all_new_hot_course limit = 9 ,school_id = 0 #sort_project_by_hot_rails 1, 'course_ac_para DESC', limit time_now = Time.new.strftime("%Y"); - Project.visible.joins(:project_status).where("#{Project.table_name}.project_type = ? and #{Project.table_name}.created_on like '%#{time_now}%'", 1).order("course_ac_para DESC").limit(limit).all + Project.visible.joins(:project_status).where("#{Project.table_name}.project_type = ? and #{Project.table_name}.created_on like '%#{time_now}%' and #{Project.table_name}.identifier not in + (select extra from courses where school_id = ?)", 1,school_id).order("course_ac_para DESC").limit(limit).all end def find_all_hot_bid diff --git a/app/models/homework_attach.rb b/app/models/homework_attach.rb index fb743ab5..e395e65e 100644 --- a/app/models/homework_attach.rb +++ b/app/models/homework_attach.rb @@ -1,10 +1,37 @@ class HomeworkAttach < ActiveRecord::Base include Redmine::SafeAttributes + + #attr_accessible :name, :description, :state, :user_id, :bid_id + belongs_to :user belongs_to :bid + has_many :journals_for_messages, :as => :jour, :dependent => :destroy + has_many :homework_users, :dependent => :destroy + seems_rateable :allow_update => true, :dimensions => :quality safe_attributes "bid_id", "user_id" acts_as_attachable - + + def addjours user_id,message,status = 0 + jfm = self.journals_for_messages.build(:user_id => user_id,:notes =>message,:status => status) + jfm.save + jfm + end + + def score + stars_reates = self.rates(:quality) + percent = 0 + stars_reates.each do |star_reates| + percent = percent + star_reates.stars + end + result = percent * 1.0 / stars_reates.count + result + end + + def add_jours options + jfm = self.journals_for_messages.build(options) + jfm.save + jfm + end end diff --git a/app/models/homework_user.rb b/app/models/homework_user.rb new file mode 100644 index 00000000..da7e65af --- /dev/null +++ b/app/models/homework_user.rb @@ -0,0 +1,6 @@ +class HomeworkUser < ActiveRecord::Base + attr_accessible :homework_attach_id, :user_id + + belongs_to :homework_attach + has_one :user +end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 2c4f1088..7356b737 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -21,6 +21,7 @@ class JournalsForMessage < ActiveRecord::Base belongs_to :jour, :polymorphic => true belongs_to :user + belongs_to :homework_attach belongs_to :at_user, :class_name => "User", :foreign_key => 'reply_id' acts_as_event :title => Proc.new {|o| "#{l(:label_my_message)}"}, @@ -73,7 +74,8 @@ class JournalsForMessage < ActiveRecord::Base def self.reference_message(user_id) @user = User.find(user_id) - message = JournalsForMessage.find_by_sql("select * from journals_for_messages where reply_id = #{@user.id} or (jour_type = 'Bid' and jour_id in (select id from bids where author_id = #{@user.id}))") + message = JournalsForMessage.find_by_sql("select * from journals_for_messages where reply_id = #{@user.id} + or (jour_type = 'Bid' and jour_id in (select id from bids where author_id = #{@user.id}))") message end diff --git a/app/models/user.rb b/app/models/user.rb index d16d790d..84027579 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -68,6 +68,8 @@ class User < Principal ['none', :label_user_mail_option_none] ] + has_one :homework_user + has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)}, :after_remove => Proc.new {|user, group| group.user_removed(user)} has_many :changesets, :dependent => :nullify diff --git a/app/views/attachments/_app_link.html.erb b/app/views/attachments/_app_link.html.erb index ecef4dda..6934b76e 100644 --- a/app/views/attachments/_app_link.html.erb +++ b/app/views/attachments/_app_link.html.erb @@ -1,10 +1,15 @@ <!-- #wang --> -<% for attachment in attachments %><%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%> - <% if attachment.is_text? %> +<% for attachment in attachments %> + <% if attachments.count > 1 && attachment != attachments.first%> + <br/>                 + <% end %> + <%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%> + <% if attachment.is_text? %> <%= link_to image_tag('magnifier.png'), :controller => 'attachments', :action => 'show', :id => attachment, :filename => attachment.filename %> <% end %> <%= h(" - #{attachment.description}") unless attachment.description.blank? %> <span class="size">(<%= number_to_human_size attachment.filesize %>)</span> + <% end -%> diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb index f34a0e4e..bdf65a96 100644 --- a/app/views/attachments/_form.html.erb +++ b/app/views/attachments/_form.html.erb @@ -1,11 +1,12 @@ <span id="attachments_fields"> <% if defined?(container) && container && container.saved_attachments %> - <% container.saved_attachments.each_with_index do |attachment, i| %> - <span id="attachments_p<%= i %>"> - <span style="width:100px;"><%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename', :maxlength => 10)%> - </span> - <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 155, :placeholder => l(:label_optional_description), :class => 'description') + + <% container.attachments.each_with_index do |attachment, i| %> + <span id="attachments_p<%= i %>" class="attachment"> + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%> + + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") + link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %> + <%= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> </span> <% end %> diff --git a/app/views/attachments/renderTag.js.erb b/app/views/attachments/renderTag.js.erb new file mode 100644 index 00000000..7e45299d --- /dev/null +++ b/app/views/attachments/renderTag.js.erb @@ -0,0 +1,3 @@ +<%if @attachmentNew != nil%> +$("#div-attachments[" + @attachmentNew.id + "]").html('<%= j(render :partial => 'tags/tag', :locals => {:obj => @attachmentNew, :object_flag => "6"})%>'); +<%end%> diff --git a/app/views/attachments/upload.js.erb b/app/views/attachments/upload.js.erb index 82b79bb6..674d73b7 100644 --- a/app/views/attachments/upload.js.erb +++ b/app/views/attachments/upload.js.erb @@ -11,4 +11,7 @@ fileSpan.find('a.remove-upload') "href": '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>' }) .off('click'); +var divattach = fileSpan.find('div.div_attachments'); +divattach.html('<%#= j(render :partial => 'tags/tagEx', :locals => {:obj => @attachment, :object_flag => "6"})%>'); + <% end %> diff --git a/app/views/bids/_homework_form.html.erb b/app/views/bids/_homework_form.html.erb index fe6f35fb..5aa3462f 100644 --- a/app/views/bids/_homework_form.html.erb +++ b/app/views/bids/_homework_form.html.erb @@ -37,5 +37,5 @@ <p><%= hidden_field_tag 'course_id', @project_id %> </p> <fieldset><legend><%= l(:label_attachment_plural) %></legend> -<p><%= render :partial => 'attachments/form', :locals => {:container => @homework} %></p> +<div class="tabDiv"><%= render :partial => 'attachments/form', :locals => {:container => @bid} %></div> </fieldset> \ No newline at end of file diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 8f87a6b3..35c41469 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -25,8 +25,31 @@ <td colspan="2" valign="top" width="50" ><%= image_tag(url_to_avatar(homework.user), :class => "avatar")%></td> <td> <table width="580px" border="0"> + <tr>   <strong>作业   :</strong>  + <% filename = "" %> + <% homework.attachments.map do |attachment| %> + <% filename = attachment.filename %> + <% if homework.attachments.count > 1%> + <% filename += "等#{homework.attachments.count}个文件" %> + <% end %> + <% break %> + <% end %> + <%= link_to filename , homework_attach_path(homework)%> + </tr> <tr> - <td colspan="1" valign="top"><strong> <%= link_to homework.user, user_path(homework.user)%></strong> <span class="font_lighter">已提交</span></td> + <td colspan="1" valign="top" style="width: 300px">  + <strong>发布人:  <%= link_to homework.user, user_path(homework.user)%></strong> + </td> + <td> + <strong>作业评分:</strong> + <% stars_reates = homework.rates(:quality) %> + <% sum = 0 %> + <% stars_reates.each do |star_reates| %> + <% sum = sum + star_reates.stars %> + <% end %> + <% stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count %> + <%= sum * 1.0 / stars_reates_count %> + </td> <td valign="top" align="right"> <% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.attachments[0].created_on.to_s) %> <span class="required">迟交</span> @@ -36,7 +59,7 @@ <tr> <td colspan="2" valign="top">  <% if display_id %> - <strong><%= l(:label_bidding_user_studentcode) %> :<%= homework.user.user_extensions.student_id%></strong> + <strong><%= l(:label_bidding_user_studentcode) %>  : <%= homework.user.user_extensions.student_id%></strong> <% end %> </td> </tr> diff --git a/app/views/bids/_list_projects.html.erb b/app/views/bids/_list_projects.html.erb index e51314c4..ce24a445 100644 --- a/app/views/bids/_list_projects.html.erb +++ b/app/views/bids/_list_projects.html.erb @@ -154,9 +154,9 @@ <% end %> </td> <td align="right"> - <% if b_project.user.id == User.current.id || User.current.id == b_project.bid.author.id + <% if can_delete_project_homework b_project,User.current %> - <%= link_to image_tag('delete.png'),{ :action => "delete", :binding_project => b_project}, :confirm => "Are you sure?" %> + <%= link_to image_tag('delete.png'),{ :action => "delete", :binding_project => b_project}, :confirm => l(:text_are_you_sure) %> <% end %> </td> </tr> diff --git a/app/views/bids/show_project.html.erb b/app/views/bids/show_project.html.erb index d22ddded..02ef72e7 100644 --- a/app/views/bids/show_project.html.erb +++ b/app/views/bids/show_project.html.erb @@ -60,7 +60,6 @@ $("#put-bid-form").hide(); } </script> - <% if User.current.logged? %> <!--我要竞标弹出框--> <div id = 'flash' style="float:left; width: 100%; display: none" ></div> @@ -89,15 +88,15 @@ <tr> <td><%= f.text_area :bid_message, :id => "bid_message", :required => true, :rows => 4, :cols => 40, :placeholder => l(:label_bid_reason), :style => "resize: none;", :class => 'noline'%></td> </tr> - <% end %> + <% end %> <tr> <td align="right"> <%= submit_tag l(:button_add), :name => nil , :class => "enterprise", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -30px'"%> - <%= submit_tag l(:button_cancel), :name => nil, :onclick => "cancel();", + <%= submit_tag l(:button_cancel), :name => nil, :onclick => "cancel();", :type => 'button', :class => "enterprise", :onmouseout => "this.style.backgroundPosition = 'left top'", - :onmouseover => "this.style.backgroundPosition = 'left -30px'" %> + :onmouseover => "this.style.backgroundPosition = 'left -30px'" %> </td> </tr> </table> diff --git a/app/views/contests/show_attendingcontest.html.erb b/app/views/contests/show_attendingcontest.html.erb index ad822222..7d2831e8 100644 --- a/app/views/contests/show_attendingcontest.html.erb +++ b/app/views/contests/show_attendingcontest.html.erb @@ -125,7 +125,7 @@ <br /> <br /> - <fieldset style="width: 500px", style="padding-top: 10px"> + <fieldset style="width: 500px; padding-top: 10px"> <legend> 上传作品软件包和作品截图 </legend> @@ -144,7 +144,7 @@ </fieldset> </fieldset></br> - <div class="align-center", style="padding-top: -3px; padding-bottom: 8px"> + <div class="align-center" style="padding-top: -3px; padding-bottom: 8px"> <%= submit_tag l(:button_create) %> <%= submit_tag l(:button_cancel), :name => nil, :onclick => "cancel();", :type => 'button', :class => "enterprise", :onmouseout => "this.style.backgroundPosition = 'left top'", diff --git a/app/views/files/_new.html.erb b/app/views/files/_new.html.erb index 4c1b97fa..a01143e0 100644 --- a/app/views/files/_new.html.erb +++ b/app/views/files/_new.html.erb @@ -2,25 +2,57 @@ <% versions = project.versions.sort %> <% attachmenttypes = project.attachmenttypes %> <%= error_messages_for 'attachment' %> -<%= form_tag(project_files_path(project), :multipart => true, :class => "tabular") do %> +<%= form_tag(project_files_path(project), :multipart => true,:name=>"upload_form", :class => "tabular") do %> <div class="box"> + <p> + <table> + <tr> + <% if versions.any? %> + <td><p><%= l(:field_version) %></p></td> + <td> + <%= select_tag "version_id", content_tag('option', '') + + options_from_collection_for_select(versions, "id", "name"), {style: 'width:100px'} %> + </td> + <% end %> -<% 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? %> + <td><%= l(:attachment_type) %></label></td> + <td> + <%= select_tag "attachment_type", + options_from_collection_for_select(attachmenttypes, "id", + "typeName", 2), {style: 'width:100px'} %> + </td> + <% end %> + </tr> + </table> - <% if attachmenttypes.any? %> - <p> <label for="attachment_type"><%=l(:attachment_type)%></label> - <%= select_tag "attachment_type", - options_from_collection_for_select(attachmenttypes, "id", - "typeName") %> - </p> - <% end %> -<p><label><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form' %></p> + </p> + +<p><%=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> \ No newline at end of file +<div class="line_under" style="margin:20px 0px;"></div> + +<script type='text/javascript'> + function tagAddClick(id,objId,objTag) + { + alert("OK"); + $.ajax({ + type :"POST", + url :'<%= users_tag_saveEx_path%>', + data: { + tagname: $('tag_name').value, + obj_id: encodeURIComponent(objId), + obj_flag:encodeURIComponent(objTag) + }, + success: function(data, textStatus){ + alert("OK"); + $(id).empty(); + $(id).html('123'); + $("#" + id + " #name").val(""); + } + }) + } +</script> diff --git a/app/views/files/_show_all_attachment.html.erb b/app/views/files/_show_all_attachment.html.erb index 07dc6a27..d34f95f7 100644 --- a/app/views/files/_show_all_attachment.html.erb +++ b/app/views/files/_show_all_attachment.html.erb @@ -20,6 +20,7 @@ <%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-contenttype") %> <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %> <%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %> + <%= sort_header_tag('tags', :caption => l(:label_tag), :id => "vzebra-tag") %> <!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> --> </tr> </thead> @@ -51,15 +52,14 @@ <%= link_to(image_tag('delete.png'), attachment_path(file), :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> </td> - </tr> - <tr> - <td class='description' colspan="6"> + <td class='filename' style="font-size: 13px; "> <div class="tags_area"> <%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %> <div class="tags_gradint"></div> </div> - <div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a></div> + <div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a> + </div> </td> </tr> <% end -%> diff --git a/app/views/files/_sort_by_attachtypel.html.erb b/app/views/files/_sort_by_attachtypel.html.erb index 01c57c49..9df26d7e 100644 --- a/app/views/files/_sort_by_attachtypel.html.erb +++ b/app/views/files/_sort_by_attachtypel.html.erb @@ -20,6 +20,7 @@ <%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope =>"col", :id=> "vzebra-contenttype")%> <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %> <%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %> + <%= sort_header_tag('tags', :caption => l(:label_tag), :id => "vzebra-tag") %> <!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> --> </tr> </thead> @@ -47,17 +48,15 @@ <%= link_to(image_tag('delete.png'), attachment_path(file), :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> </td> - </tr> - <tr> - <td class='description' colspan="6"> - <div class="tags_area"> - <%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> - <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %> - <div class="tags_gradint"></div> - </div> - <div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a> - </div> - </td> + <td class='filename' style="font-size: 13px; "> + <div class="tags_area"> + <%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> + <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %> + <div class="tags_gradint"></div> + </div> + <div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a> + </div> + </td> </tr> <% end -%> <% end -%> diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index a4f63e4b..231be8be 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -25,9 +25,10 @@ :onchange => "attachment_contenttypes_searchex(this.value)" %> <% end %> - <div id="upload_file_div" class="relation_file_div hidden"> - <%= render :partial => 'new', locals: {project: @project} %> - </div> + <div id="upload_file_div" class="relation_file_div hidden"> + <%= render :partial => 'new', locals: {project: @project} %> + </div> + <div id="relation_file_div" class="relation_file_div hidden"> <fieldset> <legend>搜索</legend> @@ -185,4 +186,27 @@ } }); } -</script> \ No newline at end of file +</script> + + +<script type='text/javascript'> + function tagAddClick(divid,objId,objTag) + { + alert("OK"); + $.ajax({ + type :"POST", + url :'/users/tag_saveEx', + data: { + tagname: $('tag_name').value, + obj_id: encodeURIComponent(objId), + obj_flag:encodeURIComponent(objTag) + }, + success: function(data, textStatus){ + alert("OK"); + $(divid).empty(); + $(divid).html('123'); + $("#" + divid + " #name").val(""); + } + }) + } +</script> diff --git a/app/views/homework_attach/_add_jour_reply.html.erb b/app/views/homework_attach/_add_jour_reply.html.erb new file mode 100644 index 00000000..1e202e6a --- /dev/null +++ b/app/views/homework_attach/_add_jour_reply.html.erb @@ -0,0 +1,14 @@ + +<%= form_tag({:controller => 'homework_attach', :action => 'add_jour_reply'}, :remote => true) do %> +<%= text_area_tag 'user_notes', "", :class => 'noline', + :style => "resize: none;", :rows => 4, + :placeholder => l(:label_projects_feedback_respond_content), + :maxlength => 250 %> +<span style="float: left; margin-top: 1px; margin-right: 4px;"></span> +<%= hidden_field_tag 'reference_id', params[:reference_id], :value => journal.id %> +<%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => m_reply_id.user.id %> +<%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => m_reply_id.id %> +<%= submit_tag l(:button_projects_feedback_respond), + :name => nil , :class => "enterprise", :style => "float: right; margin-top: 1px; margin-right: 4px;"%> + +<% end %> \ No newline at end of file diff --git a/app/views/homework_attach/_addjour.html.erb b/app/views/homework_attach/_addjour.html.erb new file mode 100644 index 00000000..a5e7bed6 --- /dev/null +++ b/app/views/homework_attach/_addjour.html.erb @@ -0,0 +1,93 @@ +<!-- fq --> +<style> + input[type="submit"].bid_btn { + vertical-align: middle; + width: 60px;/*modified by ming*/ + height: 25px; + line-height: 19px; + font-size: 14px; + color: rgb(0, 0, 0); + background: buttonface;/*url("/images/button/bg103.jpg") no-repeat scroll left top transparent;*/ + padding: 0px 0px 4px 0px; + border-radius: 2px; + border: 1px solid rgb(148, 148, 148); + box-shadow: none; + text-shadow: none; + margin-top: -10px; + /*margin-right: -4px;*/ + } + input[type="button"].bid_btn { + width: 60px;/*modified by ming*/ + height: 25px; + line-height: 19px; + font-size: 14px; + color: rgb(0, 0, 0); + background: buttonface;/*url("/images/button/bg103.jpg") no-repeat scroll left top transparent;*/ + padding: 0px 0px 4px 0px; + border-radius: 2px; + border: 1px solid rgb(148, 148, 148); + box-shadow: none; + text-shadow: none; + margin-top: -10px; + margin-right: -2px; + } + textarea:focus { + border: #d5dee9 1px solid; + } +</style> + +<script type="text/javascript" language="javascript"> + function clearInfo(id, content) { + var text = $('#' + id); + if (text.val() == content) { + $('#' + id).val(''); + } + } + + function showInfo(id, content) { + var text = $('#' + id); + if (text.val() == '') { + $('#' + id).val(content); + } + } +</script> + +<%= form_for('new_form', :remote => true, :method => :post, + :url => {:controller => 'homework_attach', + :action => 'addjours', + :jour_id => homework_attach.id, + :sta => sta}) do |f|%> + + <div id = 'pre_show'> + <%= render :partial => 'words/pre_show', :locals => {:content => @content} %> + </div> + + <% if User.current.logged? %> + <table border="0" width="525px" align="center" > + <tr> + <td><%= f.text_area 'user_message', :rows => 3, :cols => 65, :value => "#{l(:label_leave_a_message)}", + :onfocus => "clearInfo('new_form_user_message','#{l(:label_leave_a_message)}')", + :onblur => "showInfo('new_form_user_message','#{l(:label_leave_a_message)}')", + :style => "resize: none;", :class => 'noline'%></td> + </tr> + </table> + <%= f.text_field :reference_user_id, :style=>"display:none"%> + <table border="0" width="525px" align="center"> + <tr> + <td align="right"> <%= submit_tag l(:button_leave_meassge), + :name => nil , :class => "enterprise", + :onmouseout => "this.style.backgroundPosition = 'left top'", + :onmouseover => "this.style.backgroundPosition = 'left -31px'"%> + <%= submit_tag l(:button_clear), :name => nil, :class => "enterprise", + :onclick => "clearMessage('new_form_user_message');", + :onmouseout => "this.style.backgroundPosition = 'left top'", + :onmouseover => "this.style.backgroundPosition = 'left -31px'" %> </td> + </tr> + </table> + <% else %> + <div style="font-size: 14px;margin:10px;text-align: center"> + <%= l(:label_user_login_tips) %> + <%= link_to l(:label_user_login_new), signin_path %> + </div> + <% end %> +<% end %> diff --git a/app/views/homework_attach/_jour_reply.html.erb b/app/views/homework_attach/_jour_reply.html.erb new file mode 100644 index 00000000..0dd56f44 --- /dev/null +++ b/app/views/homework_attach/_jour_reply.html.erb @@ -0,0 +1,6 @@ +<% id = "journal_reply_ul_" + journal.id.to_s%> +<ul class="messages-for-user-reply" id = '<%= id %>' > + <% journal.children.each do |reply|%> + <%= render :partial => "journal_reply_items", :locals => {:reply => reply, :journal => journal, :m_reply_id => reply} %> + <% end %> +</ul> \ No newline at end of file diff --git a/app/views/homework_attach/_journal_reply_items.html.erb b/app/views/homework_attach/_journal_reply_items.html.erb new file mode 100644 index 00000000..85f7fa30 --- /dev/null +++ b/app/views/homework_attach/_journal_reply_items.html.erb @@ -0,0 +1,34 @@ +<% reply_allow = JournalsForMessage.create_by_user? User.current %> +<% ids_r = 'reply_respond_form_'+ reply.id.to_s %> +<li id='word_li_<%=reply.id.to_s%>' onmouseover="$('#<%= ids_r %>').show()" onmouseout="$('#<%= ids_r %>').hide()"> + <span class="portrait"> + <%= image_tag url_to_avatar(reply.user), :class => "avatar-3" %> + </span> + <div class="message-body"> + <% id = 'project_respond_form_'+ reply.id.to_s %> + <p> + <span><%= link_to reply.user.name, user_path(reply.user) %>: </span> + <span class="message-notes"> <%= reply.notes %></span> + </p> + <p> + <span class="time"><%= format_time reply.created_on %></span> + <span style="display: none; margin-left: 4px;" id='<%=ids_r%>' > + <% if reply_allow %> + <%= link_to l(:label_projects_feedback_respond),'', + {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{id}'), $('##{id} textarea'), '#{l(:label_reply_plural)} #{m_reply_id.user.name}: '); return false;"} + %> + <% end %> + <% if @user == User.current || User.current.admin? || reply.user.id == User.current.id %> + <%= link_to(l(:label_newfeedback_delete), {:controller => 'homework_attach', :action => 'destroy', :object_id => reply, :user_id => reply.user}, + :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) %> + <% end %> + </span> + </p> + </div> + <div id='<%=id %>' class="respond-form"> + <% if reply_allow %> + <%= render :partial => "add_jour_reply", :locals => {:journal => journal, :m_reply_id => m_reply_id} %> + <% end %> + </div> + <div style="clear: both;"></div> +</li> \ No newline at end of file diff --git a/app/views/homework_attach/_pre_show.html.erb b/app/views/homework_attach/_pre_show.html.erb new file mode 100644 index 00000000..1fb64318 --- /dev/null +++ b/app/views/homework_attach/_pre_show.html.erb @@ -0,0 +1,11 @@ +<!-- fq --> +<% unless content.nil?%> +<table width="60%" style="margin-left: 60px;"> + <tr> + <td> <%= textilizable content %></td> + </tr> + <tr> + <td><%= hidden_field_tag 'reference_content', params[:reference_content], :value => content%></td> + </tr> +</table> +<% end %> diff --git a/app/views/homework_attach/_showjour.html.erb b/app/views/homework_attach/_showjour.html.erb new file mode 100644 index 00000000..dbd7f254 --- /dev/null +++ b/app/views/homework_attach/_showjour.html.erb @@ -0,0 +1,73 @@ +<script> + var W3CDOM = document.createElement && document.getElementsByTagName; + + window.onload = setMaxLength; + + function setMaxLength() { + if (!W3CDOM) return; + var textareas = document.getElementsByTagName('textarea'); + for (var i=0;i<textareas.length;i++) { + var textarea = textareas[i]; + setMaxLengthItem(textareas[i]); + } + } + function setMaxLengthItem(textarea){ + if (textarea.getAttribute('maxlength')) { + var counter = document.createElement('div'); + counter.className = 'counter'; + var counterClone = counter.cloneNode(true); + counterClone.innerHTML = '<span>0</span>/'+textarea.getAttribute('maxlength'); + textarea.parentNode.insertBefore(counterClone,textarea.nextSibling); + textarea.relatedElement = counterClone.getElementsByTagName('span')[0]; + textarea.onkeyup = textarea.onchange = checkMaxLength; + textarea.onkeyup(); + } + } + + function checkMaxLength() { + var maxLength = this.getAttribute('maxlength'); + var currentLength = this.value.length; + if (currentLength > maxLength) + this.relatedElement.className = 'toomuch'; + else + this.relatedElement.className = ''; + this.relatedElement.firstChild.nodeValue = currentLength; + } + +</script> +<% if jour.size > 0 %> + <ul class="message-for-user"> + <% for journal in jour%> + <li id='word_li_<%= journal.id.to_s %>' class="outer-message-for-user"> + <span class="portrait"><%= image_tag(url_to_avatar(journal.user), :class => "avatar") %></span> + <span class="body"> + <span class="user"><%= link_to journal.user, user_path(journal.user)%></span> + <span class="font_lighter"><% label = l(:label_contest_requirement) %></span> + <div> <%= textilizable journal.notes%> </div> + <span class="font_lighter"><%= l(:label_bids_published) %> +  <%= time_tag(journal.created_on).html_safe %>  + <%= l(:label_bids_published_ago) %> + </span> + <% ids = 'project_respond_form_'+ journal.id.to_s%> + <span> + <%= link_to l(:label_projects_feedback_respond),'', + {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.name}: '); $('##{ids} textarea') ;return false;"} + %> + <% if journal.user==User.current|| User.current.admin? %> + <%= link_to(l(:label_bid_respond_delete), {:controller => 'homework_attach', :action => 'destroy', :object_id => journal, :user_id => journal.user}, + :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) %> + <% end %> + </span> + </span> + <div style="clear: both;"></div> + <div id='<%= ids %>' class="respond-form"> + <%= render :partial => 'add_jour_reply', :locals => {:journal => journal, :m_reply_id => journal} %> + </div> + <div style="clear: both;"></div> + <div> + <%= render :partial => "jour_reply", :locals => {:journal => journal } %> + </div> + </li> + <% end %> + </ul> +<% end %> \ No newline at end of file diff --git a/app/views/homework_attach/add_jour_reply.js.erb b/app/views/homework_attach/add_jour_reply.js.erb new file mode 100644 index 00000000..564229d8 --- /dev/null +++ b/app/views/homework_attach/add_jour_reply.js.erb @@ -0,0 +1,14 @@ +<% if @save_succ %> +var pre_append = $('<%= j( + render :partial => "journal_reply_items", + :locals => {:reply => @jfm, :journal => @jfm.parent, :m_reply_id => @jfm} + ) %>').hide(); +$('#journal_reply_ul_<%=@jfm.m_parent_id%>').append(pre_append); +pre_append.fadeIn(600); +var textarea = $('#project_respond_form_<%=@jfm.m_reply_id.to_s%> textarea'); +textarea.val(''); +$('#project_respond_form_<%=@jfm.m_reply_id.to_s%>').hide(); +setMaxLengthItem(pre_append.find('textarea')[0]); +<% else %> +alert("<%= l(:label_feedback_fail) %>"); +<% end %> \ No newline at end of file diff --git a/app/views/homework_attach/addjours.js.erb b/app/views/homework_attach/addjours.js.erb new file mode 100644 index 00000000..e0f32581 --- /dev/null +++ b/app/views/homework_attach/addjours.js.erb @@ -0,0 +1,4 @@ +$('#message').html('<%= escape_javascript(render(:partial => 'showjour', :locals => {:jour =>@jours, :state => false} )) %>'); +$('#pre_show').html('<%= escape_javascript(render(:partial => 'pre_show', :locals => {:content => nil})) %>'); +$('#new_form_user_message').val(""); +$('#new_form_reference_user_id').val(""); \ No newline at end of file diff --git a/app/views/homework_attach/destroy.js.erb b/app/views/homework_attach/destroy.js.erb new file mode 100644 index 00000000..22f7fc04 --- /dev/null +++ b/app/views/homework_attach/destroy.js.erb @@ -0,0 +1,8 @@ +<% if @journal_destroyed.nil? %> + alert('<%=l(:notice_failed_delete)%>'); +<% else %> + var destroyedItem = $('#word_li_<%=@journal_destroyed.id%>') + destroyedItem.fadeOut(600,function(){ + destroyedItem.remove(); + }); +<% end %> diff --git a/app/views/homework_attach/show.html.erb b/app/views/homework_attach/show.html.erb new file mode 100644 index 00000000..1400176c --- /dev/null +++ b/app/views/homework_attach/show.html.erb @@ -0,0 +1,125 @@ + +<style> + .softapplication-img .soft-application { + float: left; + width: 25%; + height: 200px; + } +</style> +<p id="notice"><%= notice %></p> +<!-- <%= image_tag(url_to_avatar(@user), :class => "avatar2") %> --> +<div style="height: auto; padding-bottom: 10px"> + <tr> + <td colspan="2" valign="top" width="320" > + </td> + <td> + <table width="100%" border="0"> + <tr style="font-size: 18px"> + <td colspan="2" valign="top"><strong>作业基础信息<%=@count %></strong></td> + </tr> + <tr> + <td style="width: 570px; padding-left:40px; word-wrap: break-word; word-break: break-all">发布人员:<%= link_to @homework.user, user_path(@homework.user)%></td> + <td>发布时间:<%=format_time @homework.created_at %></td> + + </tr> + <tr> + <td style="padding-left: 40px"> + <span>作业下载:</span> + <% options = {:author => true } %> + <%= render :partial => 'attachments/app_link', :locals => {:attachments => @homework.attachments, :options => options} %> + </td> + <td style="width: 240px; word-wrap: break-word; word-break: break-all">所属任务:<%= link_to(@homework.bid.name, project_for_bid_path(@homework.bid))%></td> + + </tr> + <tr> + <td style="padding-left: 40px" colspan="2">平均评分: + <%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %> + </td> + </tr> + </table> + </td> + </tr> +</div> +<div class="underline-contests_one"></div> + +<div style="height: auto; padding-bottom: 10px"> + <tr> + <td colspan="2" valign="top" width="320" > + </td> + <td> + <table width="100%" border="0"> + <tr> + <td colspan="2" valign="top"><strong><div style="font-size: 15px;">作业描述:</div></strong></td> + </tr> + <% @homework.attachments.map do |attachment| %> + <% if attachment.description != nil && attachment.description != "" %> + <tr> + <td style="width: 570px; padding-left:40px; word-wrap: break-word; word-break: break-all"> + <div style="padding-top: 5px"> <%= attachment.description %></div> + </td> + </tr> + <% end %> + <% end %> + </table> + </td> + </tr> +</div> +<div class="underline-contests_one"></div> + +<div style="height: auto; padding-bottom: 10px"> + <div style="font-size: 15px;"><strong>作业得分:</strong></div> + <div style="overflow: hidden"> + <div style="margin-left: 15%; float: left"> + <div style="padding-left: 45px; padding-bottom: 5px">得分比例</div> + <div> + <% 100.step(20,-20) do |star| %> + <div data-kls="Softapplication" data-id="2" data-dimension="quality" data-average="3.25" class="rateable div_inline jDisabled" style="height: 20px; width: 115px; overflow: hidden; z-index: 1; position: relative;"> + <div class="jRatingColor" style="width: <%=star%>%;"></div> + <div class="jRatingAverage" style="width: 0px; top: -20px;"></div> + <div class="jStar" style="width: 115px; height: 20px; top: -40px; background: url('/images/seems_rateable/stars.png') repeat-x scroll 0% 0% transparent;"> + </div> + </div> + <%= @stars_status_map["star#{(star/20).to_s}".to_sym] %> + <br> + <% end %> + </div> + </div> + <div style="float: left; padding-left: 100px; padding-top:35px "> + <div style="padding-left: 25px;">最终得分</div> + <div style="padding-top: 3px"> + <%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %> + </div> + </div> + <div style="float: left; padding-left: 100px; padding-top:35px "> + <div>打分总人数</div> + <div style="padding-left: 28px; padding-top: 1px; font-size: 25px; color: blue"> + <strong> + <%= @homework.raters(:quality).count%> + </strong> + </div> + </div> + </div> +</div> +<div class="underline-contests_one"></div> + +<div style="height: 50px"> + <div style="font-size: 15px"><strong>作业评论:</strong></div> + <div style="text-align: center;">评分: + <%= rating_for @homework, dimension: :quality, class: 'rateable div_inline' %> + <span style="font-size: 11px">(您可以重新打分,打分结果以最后一次打分为主!)</span> + </div> + +</div> + +<!--提示登录后对应用进行评价--> +<div id='leave-message'> + <%= render :partial => 'addjour', :locals => {:homework_attach => @homework, :sta => 0} %> +</div> + +<!-- 留言列表区 --> +<div id="message" style="font-size: 14px;"> + <%= render :partial => 'showjour', :locals => {:jour => @jours} %> +</div> +<div> +<%#= link_to '返回竞赛页面', show_softapplication_contest_path(@softapplication.contest) %> +</div> diff --git a/app/views/layouts/_base_footer.html.erb b/app/views/layouts/_base_footer.html.erb index ee7bcecf..baf438cb 100644 --- a/app/views/layouts/_base_footer.html.erb +++ b/app/views/layouts/_base_footer.html.erb @@ -1,6 +1,6 @@ <!--add by huang--> <div class="clearfix"></div> -<div id="footer" style="margin-left:-5px;padding-top: 150px;clear: both;font-size: 12px;"> +<div id="footer" style="margin-left:-5px;padding-top: 20px;clear: both;font-size: 12px;"> <div style="border-top:solid 1px #C6E9F1;"></div> <div class="base_footer"> <div align="center"> diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 41e0c2a1..785479bd 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -1,257 +1,272 @@ <% @nav_dispaly_course_label = 1 %> <!DOCTYPE html> <html lang="en"> - <head> - <meta charset="utf-8"> - <title><%= h html_title %> - - - <%= csrf_meta_tag %> - <%= favicon %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %> - <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> - <%= javascript_heads %> - <%= javascript_include_tag "jquery.leanModal.min" %> - <%= heads_for_theme %> - <%= call_hook :view_layouts_base_html_head %> - - <%= yield :header_tags -%> - - - -
-
-
- <%= render :partial => 'layouts/base_header'%> -
- -
- <% @project = Project.find_by_id(@project.id)%> - <% @course = Course.find_by_extra(@project.identifier)%> - - - - - - - - - - -
高校课程实践社区<%= l(:label_user_location) %> : - -
<%=link_to request.host()+"/course", :controller => 'projects', :action => 'course' %>

<%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> > <%=link_to @project.name, nil %>

-
- - - -
-
-
    -
  • - <%= link_to l(:label_course_overview), project_path(@project), :class => link_class(:overview) %> -
  • -
  • - <%= link_to l(:label_homework), homework_project_path(@project), :class => link_class(:homework) ,:project_type => 1 %> -
  • -
  • - <%= link_to l(:label_course_file), project_files_path(@project), :class => link_class(:files)%> -
  • -
  • - <%= link_to l(:label_course_news), {:controller => 'news', :action => 'index', :project_id => @project}, :class => link_class(:news) %> -
  • -
  • - <%= link_to l(:label_course_board), { :controller => 'boards', :action => 'index', :project_id => @project}, :class => link_class(:boards) %> -
  • -
  • - <%= link_to l(:label_course_feedback), project_feedback_path(@project), :class => link_class(:feedback)%> -
  • - - <% 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 = ?', 7, 9)).size >0))%> +
+
+ +
+
+ <%= l(:label_project_overview) %> +
+ +
+ <% if @project.description.size>0 %> +
+ + <%= textilizable @project.description %> +
+ <% else %> +
+ <%= l(:label_course_description_no) %> +
+ <% end %> +
+ <%= l(:label_create_time) %>:<%= format_time(@project.created_on) %> +
+
+
+
+ + +
+ +
+
+ <%= render :partial => 'tags/tag', :locals => {:obj => @project, :object_flag => "2"} %> +
+
+
+ +
+
+
+
+
+
    +
  • + <%= link_to l(:label_course_overview), project_path(@project), :class => link_class(:overview) %> +
  • +
  • + <%= link_to l(:label_homework), homework_project_path(@project), :class => link_class(:homework), :project_type => 1 %> +
  • +
  • + <%= link_to l(:label_course_file), project_files_path(@project), :class => link_class(:files) %> +
  • +
  • + <%= link_to l(:label_course_news), {:controller => 'news', :action => 'index', :project_id => @project}, :class => link_class(:news) %> +
  • +
  • + <%= link_to l(:label_course_board), {:controller => 'boards', :action => 'index', :project_id => @project}, :class => link_class(:boards) %> +
  • +
  • + <%= link_to l(:label_course_feedback), project_feedback_path(@project), :class => link_class(:feedback) %> +
  • + + <% 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 = ?', 7, 9)).size >0)) %> + + <% end %> +
+
+ <%= render_flash_messages %> + <%= yield %> + <%= call_hook :view_layouts_base_content %> +
+ + +
+ +<%= render :partial => 'layouts/base_footer' %> +
+ + +
+
+<%= call_hook :view_layouts_base_body_bottom %> + + - <% end %> - - - <%= render_flash_messages %> - <%= yield %> - <%= call_hook :view_layouts_base_content %> -
- - - - - <%= render :partial => 'layouts/base_footer'%> - - - - - - <%= call_hook :view_layouts_base_body_bottom %> - \ No newline at end of file diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 5c6f2452..99971e0f 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -66,7 +66,7 @@ <%= link_to(l(:label_user_edit), my_account_path(@user)) if User.current %> <% end %> - + <% messages_count = @user.messages.count %> <% messages_score = messages_count * 0.05%> @@ -158,9 +158,12 @@ <%= l(:label_user_login) %>:<%= format_time(@user.last_login_on) %> + + <% unless @user.user_extensions.nil? %> diff --git a/app/views/mailer/journals_for_message_add.html.erb b/app/views/mailer/journals_for_message_add.html.erb index d6c0bc48..bd2a3644 100644 --- a/app/views/mailer/journals_for_message_add.html.erb +++ b/app/views/mailer/journals_for_message_add.html.erb @@ -1,4 +1,4 @@ -尊敬的用户,<%= @user %>(<%= @user.mail%>)给你留言了: +尊敬的用户,<%= @user %>给你留言了:
<%= @message %>

点击链接查看最新回复<%= link_to(@url, @url) %>

diff --git a/app/views/mailer/journals_for_message_add.text.erb b/app/views/mailer/journals_for_message_add.text.erb index ae405d06..5eb47ef3 100644 --- a/app/views/mailer/journals_for_message_add.text.erb +++ b/app/views/mailer/journals_for_message_add.text.erb @@ -1,3 +1,3 @@ -尊敬的用户,<%= @user %>(<%= @user.mail%>)给你留言了: +尊敬的用户,<%= @user %>给你留言了: <%= @message %> 点击链接查看最新回复<%= link_to(@url, @url) %> diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index 642d7164..fcd10a01 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -140,3 +140,10 @@
<% end %> + + + \ No newline at end of file diff --git a/app/views/messages/show.html.erb b/app/views/messages/show.html.erb index 116c2593..4f22fd14 100644 --- a/app/views/messages/show.html.erb +++ b/app/views/messages/show.html.erb @@ -185,3 +185,9 @@ <% end %> <% html_title @topic.subject %> + + \ No newline at end of file diff --git a/app/views/news/index.html.erb b/app/views/news/index.html.erb index 499c58b3..4dfa21d5 100644 --- a/app/views/news/index.html.erb +++ b/app/views/news/index.html.erb @@ -1,100 +1,108 @@ - <% - if @project.project_type == 1 - btn_tips = l(:label_news_notice) - label_tips = l(:label_course_news) - else - btn_tips = l(:label_news_new) - label_tips = l(:label_news) - end + if @project.project_type == Project::ProjectType_course + btn_tips = l(:label_news_notice) + label_tips = l(:label_course_news) + else + btn_tips = l(:label_news_new) + label_tips = l(:label_news) + end %> -<% if @project && User.current.allowed_to?(:manage_news, @project) %> -
- <%= link_to(btn_tips, - new_project_news_path(@project), - :class => 'icon icon-add', - :onclick => 'showAndScrollTo("add-news", "news_title"); return false;') %> -
- + + <%= label_tips %> + +<%= link_to(btn_tips, + new_project_news_path(@project), + :class => 'icon icon-add', + :onclick => 'showAndScrollTo("add-news", "news_title"); return false;') %> + +<% if @project && User.current.allowed_to?(:manage_news, @project) %> + <% end %> - -

<%=label_tips%>

- <% if @newss.empty? %> -

- <%= l(:label_no_data) %> -

- <% else %> - <% @newss.each do |news| %> - - - - - - -
<%= link_to image_tag(url_to_avatar(news.author), :class => "avatar"), user_path(news.author) %> - - <% if @project.project_type == 1 %> - - - - <% else %> - - - - <% end %> - - - - - - - -
<%= link_to_user(news.author)if news.respond_to?(:author) %><%= l(:label_project_notice)%><%= link_to h(news.title), news_path(news) %> - <%= delete_link news_path(news) if User.current.allowed_to?(:manage_news, @project) %>
<%= link_to_user(news.author)if news.respond_to?(:author) %><%= l(:label_project_newshare)%> <%= link_to h(news.title), news_path(news) %> - <%= delete_link news_path(news) if User.current.allowed_to?(:manage_news, @project) %>
<%= textilizable(news, :description) %>
<%= l :label_update_time %>: <%= format_time(news.created_on) %><%= link_to l(:label_project_newother),news_path(news)%><%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count >= 0 %>
- <% end %> - <% end %> + <% if @newss.empty? %> +

+ <%= l(:label_no_data) %> +

+ <% else %> + <% @newss.each do |news| %> + + + + + + +
<%= link_to image_tag(url_to_avatar(news.author), :class => "avatar"), user_path(news.author) %> + + <% if @project.project_type == 1 %> + + + + <% else %> + + + + <% end %> + + + + + + + +
+ <%= link_to_user(news.author) if news.respond_to?(:author) %><%= l(:label_project_notice) %><%= link_to h(news.title), news_path(news) %> + <%= delete_link news_path(news) if User.current.allowed_to?(:manage_news, @project) %> +
+ <%= link_to_user(news.author) if news.respond_to?(:author) %><%= l(:label_project_newshare) %> <%= link_to h(news.title), news_path(news) %> + <%= delete_link news_path(news) if User.current.allowed_to?(:manage_news, @project) %> +
+ <%= textilizable(news, :description) %>
<%= l :label_update_time %> + : <%= format_time(news.created_on) %><%= link_to l(:label_project_newother), news_path(news) %><%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count >= 0 %>
+
+ <% end %> + <% end %>
- + - <% other_formats_links do |f| %> - <%= f.link_to 'Atom', :url => {:project_id => @project, :key => User.current.rss_key} %> - <% end %> + <% other_formats_links do |f| %> + <%= f.link_to 'Atom', :url => {:project_id => @project, :key => User.current.rss_key} %> + <% end %> - <% content_for :header_tags do %> - <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> - <%= stylesheet_link_tag 'scm' %> - <% end %> + <% content_for :header_tags do %> + <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> + <%= stylesheet_link_tag 'scm' %> + <% end %> - <% html_title(l(:label_news_plural)) -%> + <% html_title(l(:label_news_plural)) -%>
+ diff --git a/app/views/softapplications/_new_message.erb b/app/views/softapplications/_new_message.erb index 321c7911..ff63a367 100644 --- a/app/views/softapplications/_new_message.erb +++ b/app/views/softapplications/_new_message.erb @@ -15,7 +15,7 @@ } -<%= form_for('softapplication_message', +<%= form_for('softapplication_message', :remote => true, :method => :post, :url => {:controller => 'softapplications', :action => 'create_message', @@ -23,19 +23,19 @@ :sta => sta} ) do |f|%> -
+
<%= render :partial => 'pre_show', :locals => {:content => @content} %>
- + <% if User.current.logged? %>
<%= f.text_area 'message', :rows => 3, :cols => 65, :placeholder => l(:label_my_respond), :style => "resize: none;", :class => 'noline'%>
- + <%= f.text_field :reference_user_id, :style=>"display:none"%> - + diff --git a/app/views/tags/_tag.html.erb b/app/views/tags/_tag.html.erb index 20514392..d6ea964b 100644 --- a/app/views/tags/_tag.html.erb +++ b/app/views/tags/_tag.html.erb @@ -44,10 +44,10 @@ <%= render :partial => "tags/tag_name",:locals => {:obj => obj,:non_list_all => false ,:object_flag => object_flag} %> diff --git a/app/views/users/tag_saveEx.js.erb b/app/views/users/tag_saveEx.js.erb new file mode 100644 index 00000000..d567ee5d --- /dev/null +++ b/app/views/users/tag_saveEx.js.erb @@ -0,0 +1,20 @@ +<% if @obj_flag == '3'%> + +$('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_name', + :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); +//$('#put-tag-form-issue').hide(); +$('#name-issue').val(""); +<% elsif @obj_flag == '6'%> +$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty(); +$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_name', + :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); +//$("#put-tag-form-<%=@obj.class%>-<%=@obj.id%>").hide(); +$("#put-tag-form-<%=@obj.class%>-<%=@obj.id%> #name").val(""); +<% else %> + +$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name', + :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); +$('#put-tag-form #name').val(""); +//$('#put-tag-form').hide(); +<% end %> + diff --git a/app/views/welcome/_link_to_another.html.erb b/app/views/welcome/_link_to_another.html.erb new file mode 100644 index 00000000..f5f360d3 --- /dev/null +++ b/app/views/welcome/_link_to_another.html.erb @@ -0,0 +1,6 @@ +
+
+ 项目托管平台 + 课程实践平台 + 竞赛托管平台 +
\ No newline at end of file diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index ede51bdb..65238110 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -9,8 +9,23 @@ $(function(){ $("#main").find("a").attr("target", "_blank"); + setCss(); }); - + + //设置div居中 + function setCss() + { + var mainBar = $('#main-content-bar')[0]; + var topHeight = mainBar.offsetHeight; + var welcomeLeft = $('#welcome_left')[0]; + var leftHeight = welcomeLeft.offsetHeight; + var searchbar = $('#J_Slide')[0]; + var searchHeight = searchbar.offsetHeight; + welcomeLeft.style.marginTop = (topHeight - leftHeight)/2 + "px"; + searchbar.style.marginTop = (topHeight - searchHeight)/2 + "px"; + //alert((topHeight - leftHeight)/2 ); + } + function showInfo(id, content) { var text = $('#' + id); if (text.val() == '') { @@ -96,30 +111,16 @@ <%= image_tag '/images/qrweixin.jpg', size: '150x150', alt: 'trustie', class: "weixin" %>
微信扫码
-
+
<%= image_tag '/images/transparent.png', size: "75x75" %>
-
+
<%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_contest) %> , <%= l(:label_welcome_trustie_contest_description) %>
- - +
<%= form_tag({controller: 'contests', action: 'index'}, method: :get) do %> @@ -145,7 +146,7 @@ <% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %>
  • -
    +
    <%= image_tag('/images/contest1.png')%>
    @@ -177,7 +178,7 @@
    -

    +

    问题和反馈动态 <%= link_to "我要提问" , newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> <%= link_to "我要反馈" , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> @@ -192,11 +193,11 @@ <%= link_to '['+topic.forum.name + ']',forum_path(topic.forum),:class => 'memo_Bar_title' %><%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray" , :style => "font-size: 10pt !important;" %>
    - <%= l(:field_updated_on) %><%=time_tag_welcome(topic_last_time topic)%>前 + <%= l(:field_updated_on) %><%=time_tag_welcome(topic_last_time topic)%>前 由 <%= link_to topic.author ? topic.author : 'Anonymous', user_path(topic.author_id), :style => "font-size: 9pt !important; color: rgb(17, 102, 173);" %> 发表 - 回复(<%= link_to (topic.parent ? topic.parent.replies_count : topic.replies_count), topic.event_url %>) + 回复(<%= link_to (topic.parent ? topic.parent.replies_count : topic.replies_count), topic.event_url %>)

  • <% end %> @@ -213,7 +214,7 @@ <% find_all_hot_softapplication.map do |softapplication| break if(softapplication == find_all_hot_softapplication[5]) %>
  • -
    +
    <%= image_tag('/images/app1.png')%>
    @@ -222,7 +223,7 @@
    - ><%=softapplication.description.truncate(50, omission: '...')%> + ><%=softapplication.description.to_s.truncate(50, omission: '...')%>

    @@ -241,7 +242,7 @@
    - +<%= render partial: 'link_to_another' %> diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index eef2401f..06269665 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -5,8 +5,22 @@ $(function(){ $("#main").find("a").attr("target", "_blank"); + setCss(); }); + //设置div居中 + function setCss() + { + var mainBar = $('#main-content-bar')[0]; + var topHeight = mainBar.offsetHeight; + var welcomeLeft = $('#welcome_left')[0]; + var leftHeight = welcomeLeft.offsetHeight; + var searchbar = $('#search-bar')[0]; + var searchHeight = searchbar.offsetHeight; + welcomeLeft.style.marginTop = (topHeight - leftHeight)/2 + "px"; + searchbar.style.marginTop = (topHeight - searchHeight)/2 + "px"; + //alert((topHeight - leftHeight)/2 ); + } // 给主页用户弹新页面 $(document).ready(function($) { $("#loggedas").find("a").attr("target", "_blank"); @@ -19,13 +33,12 @@ <%= image_tag '/images/qrweixin.jpg', size: '150x150', alt: 'trustie', class: "weixin" %>
    微信扫码
  • -
    +
    <%= image_tag(@logoLink, size:'75x75') %>
    -
    -
    +
    <% if params[:school_id].nil? and User.current.user_extensions.school.nil? %> <% else%> <% if params[:school_id] == "0" %> @@ -48,7 +61,7 @@ <% end %> <% end %>
    -
    diff --git a/app/views/users/_my_course.html.erb b/app/views/users/_my_course.html.erb index b93afd41..2fb2b5bd 100644 --- a/app/views/users/_my_course.html.erb +++ b/app/views/users/_my_course.html.erb @@ -15,9 +15,14 @@ <%=l(:label_course_doing)%>(<%=@memberships_doing.count%>) <%= link_to"#{l(:label_course_new)}",{:controller=>'projects',:action=>'new', :course => 1, :project_type => 1}, :class => 'icon icon-add' if @user == User.current %>

    -
    - <%= render :partial => 'course_form', :locals => {:memberships => @memberships_doing}%> -
    +

    + <%= l(:label_created_course) %> +

    <%= render :partial => 'course_form', :locals => {:memberships => @OwningCouses}%> +

    +
    +

    <%= l(:label_joined_course) %> +

    <%= render :partial => 'course_form', :locals => {:memberships => @JoinCouses}%> +

    diff --git a/app/views/users/show_old.html.erb b/app/views/users/show_old.html.erb index 9ce6c160..d2de97b0 100644 --- a/app/views/users/show_old.html.erb +++ b/app/views/users/show_old.html.erb @@ -6,7 +6,7 @@
      -<% unless @user.pref.hide_mail %> +<% unless @user.pref.hide_mail && @user == User.current %>
    • <%=l(:field_mail)%>: <%= mail_to(h(@user.mail), nil, :encode => 'javascript') %>
    • <% end %> <% @user.visible_custom_field_values.each do |custom_value| %> @@ -107,9 +107,11 @@
    • <%= h @user.name %>

    • + <% if @user == User.current %>
    • <%= mail_to(h(@user.mail), nil, :encode => 'javascript') %>

    • + <% end %>
    <%= l(:field_last_login_on)%>: <%= format_date(@user.last_login_on) %>
    - \ No newline at end of file + +<%= render partial: 'link_to_another' %> \ No newline at end of file diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 0a69b1f7..fcdce62e 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -4,8 +4,21 @@ $(function(){ $("#main").find("a").attr("target", "_blank"); + setCss(); }); - + //设置div居中 + function setCss() + { + var mainBar = $('#main-content-bar')[0]; + var topHeight = mainBar.offsetHeight; + var welcomeLeft = $('#welcome_left')[0]; + var leftHeight = welcomeLeft.offsetHeight; + var searchbar = $('#search-bar')[0]; + var searchHeight = searchbar.offsetHeight; + welcomeLeft.style.marginTop = (topHeight - leftHeight)/2 + "px"; + searchbar.style.marginTop = (topHeight - searchHeight)/2 + "px"; + //alert((topHeight - leftHeight)/2 ); + } // 给主页用户弹新页面 $(document).ready(function($) { $("#loggedas").find("a").attr("target", "_blank"); @@ -18,14 +31,14 @@ <%= link_to image_tag('/images/qrweixin.jpg', size: '150x150', alt: 'trustie', class: "weixin" ), home_path %>
    微信扫码
    -
    +
    <%= image_tag '/images/transparent.png', size: "75x75" %>
    -
    +
    <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_project) %> , <%= l(:label_welcome_trustie_project_description) %>
    -
    +<%= render partial: 'link_to_another' %> \ No newline at end of file diff --git a/app/views/words/_message.html.erb b/app/views/words/_message.html.erb index 6b002746..3e066a51 100644 --- a/app/views/words/_message.html.erb +++ b/app/views/words/_message.html.erb @@ -54,7 +54,7 @@ function checkMaxLength() { <%= link_to l(:label_projects_feedback_respond),'', {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.name}: '); $('##{ids} textarea') ;return false;"} %> - <% end %> + <% end %> <% if @user == User.current || User.current.admin? || journal.user.id == User.current.id %> <%= link_to(l(:label_newfeedback_delete), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => user}, :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 0215d43b..58ce0dd2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1122,6 +1122,8 @@ en: label_activities_settings: Display settings #end + label_joined_course: Joined Courses + label_created_course: Created Courses #huang label_file_new: Download @@ -1611,4 +1613,4 @@ en: # ajax异步验证 - modal_valid_passing: can be used. + modal_valid_passing: can be used. diff --git a/config/locales/zh.yml b/config/locales/zh.yml index c6020d95..4ff4b0c5 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -143,7 +143,7 @@ zh: attachment_all: "全部" attachment_sufix_browse: "文件类型" attachment_browse: "内容类型" - attachment_type: '资源分类' + attachment_type: '分类' general_text_No: '否' general_text_Yes: '是' general_text_no: '否' @@ -1670,7 +1670,9 @@ zh: label_no_current_participate: 该竞赛暂无参与者 #end - + + label_joined_course: 参加的课程 + label_created_course: 创建的课程 label_course: 课程 label_course_new: 新建课程 label_course_join_student: 加入课程 diff --git a/config/routes.rb b/config/routes.rb index 201de887..f9aa041d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,13 +16,21 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. RedmineApp::Application.routes.draw do + resources :homework_users + + resources :no_uses delete 'no_uses', :to => 'no_uses#delete' resources :apply_project_masters delete 'apply_project_masters', :to => 'apply_project_masters#delete' - + resources :homework_attach do + collection do + match 'addjours', via: [:get, :post] + match 'add_jour_reply', via: [:get,:post] + end + end resources :open_source_projects do collection do match 'search', via: [:get, :post] @@ -37,6 +45,7 @@ RedmineApp::Application.routes.draw do end mount SeemsRateable::Engine => '/rateable', :as => :rateable + namespace :zipdown do match 'assort' end @@ -225,6 +234,7 @@ RedmineApp::Application.routes.draw do match 'users/:id/memberships', :to => 'users#edit_membership', :via => :post, :as => 'user_memberships' ################# added by william match 'users/tag_save', :to => 'users#tag_save', :via => :post, :as => 'tag' + match 'users/tag_saveEx', :to => 'users#tag_saveEx', :via => :post post 'watchers/watch', :to => 'watchers#watch', :as => 'watch' delete 'watchers/watch', :to => 'watchers#unwatch' @@ -460,9 +470,11 @@ RedmineApp::Application.routes.draw do get 'attachments/autocomplete' match 'attachments/autocomplete', :to => 'attachments#autocomplete', via: [:post] post 'attachments/relationfile', to: 'attachments#add_exist_file_to_project', as: 'attach_relation' + get 'attachments/renderTag/:attchmentId', :to => 'attachments#renderTag', :attchmentId => /\d+/ resources :attachments, :only => [:show, :destroy] do collection do match "updateType" , via: [:get, :post] + match "renderTag" , via: [:get, :post] end end diff --git a/db/migrate/20140519054846_create_homework_users.rb b/db/migrate/20140519054846_create_homework_users.rb new file mode 100644 index 00000000..46f03343 --- /dev/null +++ b/db/migrate/20140519054846_create_homework_users.rb @@ -0,0 +1,10 @@ +class CreateHomeworkUsers < ActiveRecord::Migration + def change + create_table :homework_users do |t| + t.string :homework_attach_id + t.string :user_id + + t.timestamps + end + end +end diff --git a/db/migrate/20140519070751_add_name_to_homework_attach.rb b/db/migrate/20140519070751_add_name_to_homework_attach.rb new file mode 100644 index 00000000..f819b51d --- /dev/null +++ b/db/migrate/20140519070751_add_name_to_homework_attach.rb @@ -0,0 +1,7 @@ +class AddNameToHomeworkAttach < ActiveRecord::Migration + def change + add_column :homework_attaches, :name, :string + add_column :homework_attaches, :description, :string + add_column :homework_attaches, :state, :int + end +end diff --git a/db/schema.rb b/db/schema.rb index b5cabfa7..4c60942a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140513073801) do +ActiveRecord::Schema.define(:version => 20140519070751) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -52,14 +52,11 @@ ActiveRecord::Schema.define(:version => 20140513073801) 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" + create_table "attachmentstypes", :force => true do |t| + t.integer "typeId", :null => false 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 @@ -325,9 +322,12 @@ ActiveRecord::Schema.define(:version => 20140513073801) do create_table "homework_attaches", :force => true do |t| t.integer "bid_id" t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "reward" + t.string "name" + t.string "description" + t.integer "state" end create_table "homework_for_courses", :force => true do |t| @@ -335,6 +335,13 @@ ActiveRecord::Schema.define(:version => 20140513073801) do t.integer "bid_id" end + create_table "homework_users", :force => true do |t| + t.string "homework_attach_id" + t.string "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "issue_categories", :force => true do |t| t.integer "project_id", :default => 0, :null => false t.string "name", :limit => 30, :default => "", :null => false @@ -756,7 +763,6 @@ ActiveRecord::Schema.define(:version => 20140513073801) do t.integer "softapplication_id" t.integer "is_public" t.string "application_developers" - t.string "deposit_project_url" end create_table "students_for_courses", :force => true do |t| @@ -865,10 +871,8 @@ ActiveRecord::Schema.define(:version => 20140513073801) do add_index "user_grades", ["user_id"], :name => "index_user_grades_on_user_id" create_table "user_levels", :force => true do |t| - t.integer "user_id" - t.integer "level" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.integer "user_id" + t.integer "level" end create_table "user_preferences", :force => true do |t| diff --git a/public/images/Edit/edit.png b/public/images/edit/edit.png similarity index 100% rename from public/images/Edit/edit.png rename to public/images/edit/edit.png diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 8e4db7fe..81160fa9 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -609,6 +609,14 @@ function toggleAndSettingWordsVal(parent_widget, text_widget, value){ text_widget.val(value) parent_widget.slideToggle(400) } +function transpotUrl (scope) { + $(scope).each(function(){ + var tmpContent = $(this).html(); + tmpContent = tmpContent.replace(/(^|[^\"\'])(http|ftp|mms|rstp|news|https)(\:\/\/[^<\s\+,,]+)/gi,"$1$2$3<\/a>"); + // tmpContent = tmpContent.replace(/(^|[^\/])(www\.[^<\s\+,,]+)/gi,"$1$2"); + $(this).html(tmpContent); + }); +} $(document).ready(setupAjaxIndicator); $(document).ready(hideOnLoad); diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js index 3d1520f8..663183b9 100644 --- a/public/javascripts/attachments.js +++ b/public/javascripts/attachments.js @@ -1,6 +1,17 @@ /* Redmine - project management software Copyright (C) 2006-2013 Jean-Philippe Lang */ +function postUpMsg(attachmentId) +{ + $.ajax({ + url: '/attachments/renderTag', + type: "GET", + data: { + attachmentId: attachmentId + } + + }) +} function addFile(inputEl, file, eagerUpload) { if ($('#attachments_fields').children().length < 10) { @@ -12,14 +23,15 @@ function addFile(inputEl, file, eagerUpload) { fileSpan.append( $('', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name), $('', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 255, 'placeholder': $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload), - $(' ').attr({ 'href': "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload) + $(' ').attr({ 'href': "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload), + $('
    ', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} ) ).appendTo('#attachments_fields'); - - if(eagerUpload) { - ajaxUpload(file, attachmentId, fileSpan, inputEl); - } - return attachmentId; + if(eagerUpload) { + ajaxUpload(file, attachmentId, fileSpan, inputEl); + + } + return attachmentId; } return null; } @@ -66,7 +78,7 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) { //gcm files count and add delete_all link - var count=$('#attachments_fields>span').length; + var count=$('#attachments_fields>span').length; $('#upload_file_count').html("已上传"+""+count+""+"个文件"); if(count>=1){ diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 7b0a0099..8e0a81cf 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1319,7 +1319,7 @@ tr.entry td.filename_no_report { width: 70%; } tr.entry td.size { text-align: right; font-size: 90%; } tr.entry td.revision, tr.entry td.author { text-align: center; } tr.entry td.age { text-align: right; } -tr.entry.file td.filename a { margin-left: 16px; } +tr.entry.file td.filename a { margin-center: 16px; } tr.entry.file td.filename_no_report a { margin-left: 16px; } tr span.expander {background-image: url(../images/bullet_toggle_plus.png); padding-left: 8px; margin-left: 0; cursor: pointer;} @@ -1769,6 +1769,14 @@ p.pagination {margin-top:8px; font-size: 90%} clear:left; } +.tabular .tabDiv{ + margin: 0; + padding: 3px 0 3px 0; + padding-left: 100px; /* width of left column containing the label elements *//*by young*/ + /*min-height: 1.8em;*/ + clear:left; +} + html>body .tabular p {overflow:hidden;} .tabular label{ @@ -1829,8 +1837,8 @@ fieldset#notified_events .parent { padding-left: 20px; } span.required {color: #bb0000;} .summary {font-style: italic;} -#attachments_fields input.description {margin-left:4px; width:340px; } -#attachments_fields span {display:block; white-space:nowrap; font-family:'微软雅黑';} +#attachments_fields input.description {margin-left:4px; width:100px; } +#attachments_fields span .boldSpan{display:block; white-space:nowrap; font-family:'微软雅黑';} #attachments_fields input.filename {border:0; height:1.8em; width:150px; color:#555; background-color:inherit; background:url(../images/attachment.png) no-repeat 1px 50%; padding-left:18px;}/*Modified by young*/ #attachments_fields .ajax-waiting input.filename {background:url(../images/hourglass.png) no-repeat 0px 50%;} #attachments_fields .ajax-loading input.filename {background:url(../images/loading.gif) no-repeat 0px 50%;} diff --git a/public/stylesheets/welcome.css b/public/stylesheets/welcome.css index f7756e5b..5ee72add 100644 --- a/public/stylesheets/welcome.css +++ b/public/stylesheets/welcome.css @@ -3,6 +3,20 @@ */ /************************** 某部分开始 *****************************/ /************************** 某部分结束 *****************************/ + +/************************** 页脚 footer 开始 *****************************/ +.linkother{ + width: 460px; + margin: 70px auto -35px ; +} +.link_other_item{ + width: 150px; + text-align: center; + display: inline-block; + font-size: 14px; +} +/************************** 页脚 footer 结束 *****************************/ + .top_bar{ height: auto; } @@ -312,11 +326,11 @@ a.attachments_list_color { } .main-content-bar{ margin: 0; - margin-top: 35px; + margin-top: 12px; padding: 0; - margin-bottom: 35px; - width: 100%; - height: auto; + margin-bottom: 2px; + width: 100%; + height: 78; } .weixin-content{ diff --git a/test/fixtures/homework_users.yml b/test/fixtures/homework_users.yml new file mode 100644 index 00000000..bec69e59 --- /dev/null +++ b/test/fixtures/homework_users.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + homework_attach_id: MyString + user_id: MyString + +two: + homework_attach_id: MyString + user_id: MyString