From 2b10258ae1516777ec0684fb3ce58069a90e7509 Mon Sep 17 00:00:00 2001 From: nieguanghui Date: Tue, 5 Nov 2013 20:46:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BE=E7=A8=8B=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=98=BE=E7=A4=BA=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 4 +- app/helpers/application_helper.rb | 30 ++-- app/helpers/watchers_helper.rb | 15 ++ app/views/courses/_set_join.js.erb | 2 +- app/views/projects/_course.html.erb | 74 +++++++++ app/views/tags/_tag_name.html.erb | 6 +- config/locales/zh.yml | 4 + .../stylesheets/application.css | 144 +++++++++++++++++- 8 files changed, 260 insertions(+), 19 deletions(-) create mode 100644 app/views/projects/_course.html.erb diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 08e35566e..b7dbb5822 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -19,7 +19,7 @@ class CoursesController < ApplicationController 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])} } + format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Project.find(params[:object_id]), :object_id => params[:object_id]} } end end @@ -36,7 +36,7 @@ class CoursesController < ApplicationController 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])} } + format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Project.find(params[:object_id]), :object_id => params[:object_id]} } end end end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ce5d2040f..83a4dfd19 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -249,22 +249,30 @@ module ApplicationHelper end classes = (ancestors.empty? ? 'root' : 'child') s << "
  • " - s << h(block_given? ? yield(project) : project.name) - unless User.current.member_of?(@project) + if params[:project_type] == "0" + s << h(block_given? ? yield(project) : project.name) + else + end + + # if @project.project_type == 1 + # unless Course.find_by_extra(@project.identifier).nil? + # unless Course.find_by_extra(@project.identifier).tea_id == User.current.id + # s << "" + # s << join_in_course(@project, User.current)#, ['whiteButton']) + # s << "" + # end + # end + # end + if params[:project_type] == "0" + unless User.current.member_of?(@project) s << "" s << watcher_link(@project, User.current)#, ['whiteButton']) s << "" end - if @project.project_type == 1 - unless Course.find_by_extra(@project.identifier).nil? - unless Course.find_by_extra(@project.identifier).tea_id == User.current.id - s << "" - s << join_in_course(@project, User.current)#, ['whiteButton']) - s << "" - end - end + s << (render :partial => 'projects/project', :locals => {:project => project}).to_s + else + s << (render :partial => 'projects/course', :locals => {:project => project}).to_s end - s << (render :partial => 'projects/project', :locals => {:project => project}).to_s s << "
    \n" ancestors << project end diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 3f0149151..2fdb4fd1c 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -47,6 +47,7 @@ module WatchersHelper end # added by fq, modify nyan + # Somebody may use option params def join_in_course(course, user, options=[]) return '' unless user && user.logged? joined = user.member_of?(course) @@ -60,6 +61,20 @@ module WatchersHelper link_to text, url_f, :remote => true, :method => method, :id => 'join', :class => []+options end end + + def join_in_course_for_list(course, user, options=[]) + return '' unless user && user.logged? + joined = user.member_of?(course) + text = joined ? l(:label_exit_course) : l(:label_join_course) + 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 => "#{course.id}", :confirm => l(:text_are_you_sure_out), :class => []+options + else + link_to text, url_f, :remote => true, :method => method, :id => "#{course.id}", :class => []+options + end + end # Returns the css class used to identify watch links for a given +object+ def watcher_css(objects) diff --git a/app/views/courses/_set_join.js.erb b/app/views/courses/_set_join.js.erb index 32c7dc831..b0b4e8a94 100644 --- a/app/views/courses/_set_join.js.erb +++ b/app/views/courses/_set_join.js.erb @@ -1,4 +1,4 @@ -$('#join').replaceWith('<%= escape_javascript join_in_course(course, user) %>'); +$("#<%=object_id%>").replaceWith('<%= escape_javascript join_in_course_for_list(course, user) %>'); <% if @state %> <% if @state == 0 %> alert("加入成功") diff --git a/app/views/projects/_course.html.erb b/app/views/projects/_course.html.erb new file mode 100644 index 000000000..3a18ec88d --- /dev/null +++ b/app/views/projects/_course.html.erb @@ -0,0 +1,74 @@ +
    +
    + <% if get_avatar?(project)%> + <%= image_tag(url_to_avatar(project), :class => "avatar2") %> + <% else %> + <%= image_tag('../images/avatars/Project/course.jpg', :class => "avatar2") %> + <% end %> +
    + +
    +

    + <%= content_tag('span',"#{l(:label_bid_show_course_name)}:", :class => "course-font")%> + <%= content_tag('span', link_to("#{@project.name}", project_path(@project), :class => "info"))%> +

    +

    + <%= content_tag('span', "#{l(:label_institution_name)}:", :class => "course-font")%> + <%if @admin&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%> + <%= @admin.first.user.user_extensions.occupation %> + <% end %> +

    +

    + <%= content_tag('div', "#{l(:field_teacher_name)}:", :class => "info course-font teacher") %> + <% @admin = @project.project_infos%> + <% if @admin.size > 0 %> + <%= content_tag('a', @admin.collect{|u| link_to(u.user.lastname+u.user.firstname, user_path(u.user_id))}.join(", ").html_safe) %> + <% end %> +

    + +
    + +
    +

    + <%= content_tag('span', link_to("#{@project.homeworks.count}", homework_project_path(@project)), :class => "info") %> + <%= content_tag('span', l(:label_x_task, :count => @project.homeworks.count)) %> +

    +

    + <% files_count = @project.attachments.count %> + <% @project.versions.each do |version| %> + <% files_count += version.attachments.count %> + <% end %> + <%= content_tag('span', link_to(files_count, file_project_path(@project)), :class => "info") %> + <%= content_tag('span', l(:label_x_data,:count => files_count)) %> +

    +

    + <%= content_tag('span', link_to("#{@project.members.count}", member_project_path(@project)), :class => "info") %> + <%= content_tag('span', l(:label_x_member, :count => @project.members.count)) %> +

    +
    + + <%= join_in_course_for_list(@project, User.current,['regular'])%> +
    +
    +
    + +
    +
    + <%= content_tag "span","#{l(:label_duration_time)}:", :class => "course-font"%> + <%= DateTime.parse(Course.find_by_extra(@project.identifier).setup_time.to_s).strftime("%Y年%m月%d日").to_s unless Course.find_by_extra(@project.identifier).setup_time.nil? %> + <%= '-' unless Course.find_by_extra(@project.identifier).setup_time.nil? %> + <%= DateTime.parse(Course.find_by_extra(@project.identifier).endup_time.to_s).strftime("%Y年%m月%d日").to_s unless Course.find_by_extra(@project.identifier).endup_time.nil? %> +
    +
    + +
    + <%= content_tag "span", "#{l(:label_course_brief_introduction)}:", :class => "course-font" %> + <%= content_tag "div", project.short_description, :class => "brief_introduction", :title => project.short_description %> +
    + +
    +
    + <%= image_tag( "/images/sidebar/tags.png") %> + <%= render :partial => 'tags/tag_name', :locals => {:obj => @project,:object_flag => "2",:non_list_all => true }%> +
    +
    diff --git a/app/views/tags/_tag_name.html.erb b/app/views/tags/_tag_name.html.erb index 489594274..220f886e0 100644 --- a/app/views/tags/_tag_name.html.erb +++ b/app/views/tags/_tag_name.html.erb @@ -76,9 +76,9 @@ <% end %> <% else %> -
    - <%= l(:label_tags_no) %> -
    + +    <%= l(:label_tags_no) %> + <% end %> <% end %> \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 337e2714e..94e83385b 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1688,3 +1688,7 @@ zh: label_update_homework_succeed: 作业更新成功 label_task_plural: 作业 label_search_by_student_id: 按学号过滤 + label_institution_name: 单位名称 + label_duration_time: 授课时间 + label_course_brief_introduction: 课程简介 + field_teacher_name: 教 师 diff --git a/public/themes/redpenny-master/stylesheets/application.css b/public/themes/redpenny-master/stylesheets/application.css index 94f928837..8e34a62e4 100644 --- a/public/themes/redpenny-master/stylesheets/application.css +++ b/public/themes/redpenny-master/stylesheets/application.css @@ -1153,7 +1153,24 @@ div.wiki-description { a.project { float: left; }*/ - +.information_for_course { + margin-top: 20px; + margin-left: 507px; + float: left; + height: auto; + width: 300px; + font-family: '微软雅黑',helvetica,arial,sans-serif; /*modify by men*/ + color: rgb(0, 0, 0); + font-size: 13px; + line-height: 18px; + position: absolute; + } +.img-tag-2{ + float: left; + margin-top: 15px; + width: 64px; + height: 64px; +} .project-block { float: left; margin-top: 0px; @@ -1883,9 +1900,132 @@ div.avatar_user{ float:left; margin-top:-30px; margin-left: 550px; -}.create-share{ +} +.create-share{ border-radius: 5px; padding-top: 3px; margin-top: 5px; margin-bottom: 5px; +} + +.buttons a, .buttons button{ + display:block; + float:left; + margin:0 7px 0 0; + background-color:#ec6300; + border:1px solid #dedede; + border-top:1px solid #eee; + border-left:1px solid #eee; + + font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif; + font-size:12px; + line-height:130%; + text-decoration:none; + font-weight:bold; + color:#565656; + cursor:pointer; + padding:5px 10px 6px 7px; /* Links */ +} +.buttons button{ + width:auto; + overflow:visible; + padding:4px 10px 3px 7px; /* IE6 */ +} +.buttons button[type]{ + padding:5px 10px 5px 7px; /* Firefox */ + line-height:17px; /* Safari */ +} +*:first-child+html button[type]{ + padding:4px 10px 3px 7px; /* IE7 */ +} +.buttons button img, .buttons a img{ + margin:0 3px -3px 0 !important; + padding:0; + border:none; + width:16px; + height:16px; +} + +/* STANDARD */ + +button:hover, .buttons a:hover{ + background-color:#dff4ff; + border:1px solid #c2e1ef; + color:#336699; +} +.buttons a:active{ + background-color:#6299c5; + border:1px solid #6299c5; + color:#fff; +} + +/* POSITIVE */ + +button.positive, .buttons a.positive{ + color:#529214; +} +.buttons a.positive:hover, button.positive:hover{ + background-color:#E6EFC2; + border:1px solid #C6D880; + color:#529214; +} +.buttons a.positive:active{ + background-color:#529214; + border:1px solid #529214; + color:#fff; +} + +/* NEGATIVE */ + +.buttons a.negative, button.negative{ + color:#d12f19; +} +.buttons a.negative:hover, button.negative:hover{ + background:#fbe3e4; + border:1px solid #fbc2c4; + color:#d12f19; +} +.buttons a.negative:active{ + background-color:#d12f19; + border:1px solid #d12f19; + color:#fff; +} + +/* REGULAR */ + +button.regular, .buttons a.regular{ + color:#ffffff; +} +.buttons a.regular:hover, button.regular:hover{ + background-color:#dff4ff; + border:1px solid #c2e1ef; + color:#336699; +} +.buttons a.regular:active{ + background-color:#6299c5; + border:1px solid #6299c5; + color:#fff; +} + + +.course-font { + color:#8c8a8a; +} + +.teacher { + display: inline-block; + word-spacing: 22px; + width: 55px; + text-justify:inter-ideograph; + text-align: justify; +} +.brief_introduction { + margin-top: -18px; + margin-left: 60px; + /*display: inline-block;*/ + width: 500px; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + -o-text-overflow: ellipsis; } \ No newline at end of file