From 104ee13ac7a90e0db9c426e68b87350f1593b377 Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 21 May 2014 16:45:11 +0800 Subject: [PATCH 1/7] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E5=8A=A0=E5=85=A5=E9=A1=B9=E7=9B=AEcontrl?= =?UTF-8?q?=E3=80=81model=E5=8F=8A=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91=202?= =?UTF-8?q?.=E9=A1=B9=E7=9B=AE=E7=95=8C=E9=9D=A2=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E5=8A=A0=E5=85=A5=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/applied_project_controller.rb | 16 ++++++++++++++ app/controllers/watchers_controller.rb | 2 +- app/helpers/applied_project_helper.rb | 21 +++++++++++++++++++ app/helpers/watchers_helper.rb | 19 +++++++++++++++++ app/models/applied_project.rb | 6 ++++++ app/models/project.rb | 3 ++- app/views/layouts/base_projects.html.erb | 8 +++++++ config/locales/en.yml | 2 ++ config/locales/zh.yml | 3 ++- config/routes.rb | 3 +++ .../20140521072851_create_applied_projects.rb | 12 +++++++++++ db/schema.rb | 18 +++++++++++++--- 12 files changed, 107 insertions(+), 6 deletions(-) create mode 100644 app/controllers/applied_project_controller.rb create mode 100644 app/helpers/applied_project_helper.rb create mode 100644 app/models/applied_project.rb create mode 100644 db/migrate/20140521072851_create_applied_projects.rb diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb new file mode 100644 index 000000000..2f8879636 --- /dev/null +++ b/app/controllers/applied_project_controller.rb @@ -0,0 +1,16 @@ +class AppliedProjectController < ApplicationController + + #申请加入项目 + def applied_join_project + AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id]) + redirect_to_referer_or {render :text => ( 'applied success.'), :layout => true} + end + + #取消申请 + def unapplied_join_project + @applied = AppliedProject.find(params[:id]) + @applied.destroy + redirect_to_referer_or {render :text => ( 'unsubscribe success.'), :layout => true} + end + +end diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb index b06b8cbb3..b1fbfb8ea 100644 --- a/app/controllers/watchers_controller.rb +++ b/app/controllers/watchers_controller.rb @@ -158,6 +158,6 @@ class WatchersController < ApplicationController respond_to do |format| format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} format.js { render :partial => 'set_watcher', :locals => {:user => user, :watched => watchables} } - end + end end end diff --git a/app/helpers/applied_project_helper.rb b/app/helpers/applied_project_helper.rb new file mode 100644 index 000000000..a766976a4 --- /dev/null +++ b/app/helpers/applied_project_helper.rb @@ -0,0 +1,21 @@ +module AppliedProjectHelper + + def applied_link(project, user, options=[]) + return '' unless user && user.logged? + applied = project.applied_projects.find_by_user_id(user.id) + text = applied ? l(:label_unapply_project) : l(:label_apply_project) + + if applied + appliedid = applied.id + end + + url = appliedproject_path( + :id=>appliedid, + :user_id => user.id, + :project_id => project.id + ) + method = applied ? 'delete' : 'post' + + link_to text, url, :remote => true, :method => method + end +end diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index fcaf63604..1d7e2bcf9 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -187,4 +187,23 @@ module WatchersHelper :class => "floating" end.join.html_safe end + + def applied_link(project, user, options=[]) + return '' unless user && user.logged? + applied = project.applied_projects.find_by_user_id(user.id) + text = applied ? l(:label_unapply_project) : l(:label_apply_project) + + if applied + appliedid = applied.id + end + + url = appliedproject_path( + :id=>appliedid, + :user_id => user.id, + :project_id => project.id + ) + method = applied ? 'delete' : 'post' + + link_to text, url, :remote => true, :method => method + end end diff --git a/app/models/applied_project.rb b/app/models/applied_project.rb new file mode 100644 index 000000000..04056cadc --- /dev/null +++ b/app/models/applied_project.rb @@ -0,0 +1,6 @@ +class AppliedProject < ActiveRecord::Base + attr_accessible :project_id, :user_id + + belongs_to :user + belongs_to :project +end diff --git a/app/models/project.rb b/app/models/project.rb index 3c2956a94..5da9f674e 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -64,7 +64,8 @@ class Project < ActiveRecord::Base # has_many :students_for_courses, :dependent => :destroy has_many :student, :through => :students_for_courses, :source => :user has_one :course_extra, :class_name => 'Course', :foreign_key => :extra,:primary_key => :identifier, :dependent => :destroy - + has_many :applied_projects + # end #ADDED BY NIE has_many :project_infos, :dependent => :destroy diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 7504e5755..8d4de3a7c 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -103,6 +103,14 @@ <%= watcher_link(@project, User.current) %> <% end %> + +
+ + <% if ( !(User.current.member_of? @project) && User.current.login?) %> + <%= applied_link(@project, User.current) %> + <% end %> +
+ diff --git a/config/locales/en.yml b/config/locales/en.yml index 58ce0dd29..e7d24c329 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1165,6 +1165,8 @@ en: label_tags_bid_description: call description label_tags_issue_description: issue description label_tags_all_objects: all objects + label_apply_project: Apply Project + label_unapply_project: Unsubscribe #fq button_leave_meassge: Submit diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 4ff4b0c55..b5d9639db 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1326,7 +1326,8 @@ zh: label_tags_bid_description: 需求描述 label_tags_issue_description: 问题描述 label_tags_all_objects: 所有 - + label_apply_project: 申请加入 + label_unapply_project: 取消申请 #fq button_leave_meassge: 留言 diff --git a/config/routes.rb b/config/routes.rb index f9aa041d7..6a4b1d7a3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -247,6 +247,9 @@ RedmineApp::Application.routes.draw do post 'issues/:object_id/watchers', :to => 'watchers#create', :object_type => 'issue' delete 'issues/:object_id/watchers/:user_id' => 'watchers#destroy', :object_type => 'issue' + post 'appliedproject/applied', :to => 'applied_project#applied_join_project', :as => 'appliedproject' + delete 'appliedproject/applied', :to => 'applied_project#unapplied_join_project' + resources :bids, :only=>[:edit,:update,:show] do member do match 'homework_ajax_modal' diff --git a/db/migrate/20140521072851_create_applied_projects.rb b/db/migrate/20140521072851_create_applied_projects.rb new file mode 100644 index 000000000..3b0efbd97 --- /dev/null +++ b/db/migrate/20140521072851_create_applied_projects.rb @@ -0,0 +1,12 @@ +class CreateAppliedProjects < ActiveRecord::Migration + def self.up + create_table :applied_projects do |t| + t.column :project_id, :integer, :null => false + t.column :user_id, :integer, :null => false + end + end + + def self.down + drop_table :applied_projects + end +end diff --git a/db/schema.rb b/db/schema.rb index 4c60942a3..e2afdaae2 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 => 20140519070751) do +ActiveRecord::Schema.define(:version => 20140521072851) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -23,6 +23,11 @@ ActiveRecord::Schema.define(:version => 20140519070751) do add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type" add_index "activities", ["user_id"], :name => "index_activities_on_user_id" + create_table "applied_projects", :force => true do |t| + t.integer "project_id", :null => false + t.integer "user_id", :null => false + end + create_table "apply_project_masters", :force => true do |t| t.integer "user_id" t.string "apply_type" @@ -52,11 +57,14 @@ ActiveRecord::Schema.define(:version => 20140519070751) 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", :force => true do |t| - t.integer "typeId", :null => false + create_table "attachmentstypes", :id => false, :force => true do |t| + t.integer "id", :null => false + t.integer "typeId" t.string "typeName", :limit => 50 end + add_index "attachmentstypes", ["id"], :name => "id" + create_table "auth_sources", :force => true do |t| t.string "type", :limit => 30, :default => "", :null => false t.string "name", :limit => 60, :default => "", :null => false @@ -675,6 +683,9 @@ ActiveRecord::Schema.define(:version => 20140519070751) do t.integer "viewed_count_crawl", :default => 0 t.integer "viewed_count_local", :default => 0 t.string "url" + t.string "username" + t.string "userhomeurl" + t.date "date_collected" end create_table "repositories", :force => true do |t| @@ -763,6 +774,7 @@ ActiveRecord::Schema.define(:version => 20140519070751) 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| From 21e58ce3dff58ed79ba733a9ac1f56e0a59c8843 Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 21 May 2014 17:33:02 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E4=B8=AD=E8=AF=BE=E7=A8=8B=E6=88=90=E5=91=98=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E6=98=BE=E7=A4=BAn+=EF=BC=88=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=B2=BE=E7=A1=AE=E6=95=B0=EF=BC=89=20=E5=8F=AA=E6=9C=89?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=88=90=E5=91=98=E8=83=BD=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E6=95=99=E5=B8=88=E6=95=B0=E9=87=8F=E5=AD=A6=E7=94=9F=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E7=9A=84=E9=93=BE=E6=8E=A5=E5=92=8C=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E5=B7=B2=E6=8F=90=E4=BA=A4=E4=BD=9C=E4=B8=9A=E7=9A=84=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 11 ++++++++++- app/views/layouts/base_courses.html.erb | 12 ++++++++++-- app/views/layouts/base_homework.html.erb | 4 +++- app/views/projects/_course.html.erb | 2 +- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 2273de4e4..d63f0cfbb 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -14,6 +14,8 @@ class BidsController < ApplicationController # end before_filter :require_login,:only => [:set_reward, :destroy, :add, :new, ] + before_filter :memberAccess, only: :show_project + helper :watchers helper :attachments include AttachmentsHelper @@ -875,7 +877,14 @@ class BidsController < ApplicationController end rescue render_404 - end + end + + def memberAccess + # 是课程,则判断当前用户是否参加了课程 + return 0 if @bid.courses.first.project_type == Project::ProjectType_project + currentUser = User.current + render_403 unless currentUser.member_of?(@bid.courses.first) + end end diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 785479bd5..4e0135eaa 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -114,10 +114,18 @@ - <%= link_to "#{teacherCount(@project)}", project_member_path(@project, :role => 1), :course => '1' %> + <% if User.current.member_of?(@project) %> + <%= link_to "#{teacherCount(@project)}", project_member_path(@project, :role => 1), :course => '1' %> + <% else %> + <%= teacherCount(@project)%> + <% end%> - <%= link_to "#{studentCount(@project)}", project_member_path(@project, :role => 2), :course => '1' %> + <% if User.current.member_of?(@project) %> + <%= link_to "#{studentCount(@project)}", project_member_path(@project, :role => 2), :course => '1' %> + <% else %> + <%= studentCount(@project)%> + <% end %> <%= link_to files_count, project_files_path(@project) %> diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index aa60f3645..cfdea4a5e 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -151,6 +151,7 @@
  • <%= link_to l(:label_question_student), {:controller => 'bids', :action => 'show' },:class => link_class(:respond)%>
  • + <% if User.current.member_of? @bid.courses.first%>
  • <% if User.current.logged? && @bid.courses.first && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) %> <%= link_to l(:label_homework_commit), {:controller => 'bids', :action => 'show_project' },:class => link_class(:project)%> @@ -159,9 +160,10 @@ <% end %>
  • + <% end %> <%= yield %> diff --git a/app/views/projects/_course.html.erb b/app/views/projects/_course.html.erb index adc7c9306..6ea802037 100644 --- a/app/views/projects/_course.html.erb +++ b/app/views/projects/_course.html.erb @@ -45,7 +45,7 @@ <%= content_tag('span', l(:label_x_data,:count => files_count)) %>

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

    From c5a3a5bac3073294d734afcd9a817084ccb9fda9 Mon Sep 17 00:00:00 2001 From: yanxd Date: Wed, 21 May 2014 18:21:57 +0800 Subject: [PATCH 3/7] user_courses.html --- app/controllers/users_controller.rb | 8 -- .../users/_course_list_have_entity.html.erb | 40 ++++++ app/views/users/_my_course.html.erb | 50 ++----- public/stylesheets/application.css | 1 - public/stylesheets/nyan.css | 133 +++++++++++++++--- 5 files changed, 169 insertions(+), 63 deletions(-) create mode 100644 app/views/users/_course_list_have_entity.html.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7365e4048..6174e2124 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -209,8 +209,6 @@ 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 @@ -220,12 +218,6 @@ 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 diff --git a/app/views/users/_course_list_have_entity.html.erb b/app/views/users/_course_list_have_entity.html.erb new file mode 100644 index 000000000..6b5725a1f --- /dev/null +++ b/app/views/users/_course_list_have_entity.html.erb @@ -0,0 +1,40 @@ +
    + + +
    +
    + <%= render :partial => 'course_form', :locals => {:memberships => @memberships_doing} %> +
    +
    + + +
    + + \ No newline at end of file diff --git a/app/views/users/_my_course.html.erb b/app/views/users/_my_course.html.erb index 8feb0ecca..26cfd48e0 100644 --- a/app/views/users/_my_course.html.erb +++ b/app/views/users/_my_course.html.erb @@ -1,38 +1,16 @@
    -<% if @memberships.empty? %> - <% if @user != User.current %> -

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

    - <% else %> -

    - - <%= l(:label_project_course_unadd) %><%= link_to"#{l(:label_course_new)}",{:controller=>'projects',:action=>'new', :course => 1, :project_type => 1}, :class => 'icon icon-add' %> -

    - <% end %> -<% else %> -

    - <%=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 %> -

    -

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

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

    -
    -

    <%= l(:label_joined_course) %> -

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

    - -
    - -

    - <%= link_to l(:label_course_done)+"("+@memberships_done.count.to_s+")", 'javascript:void(0);', :onclick => '$("#courses_history_block").slideToggle(400);' , style:"color:#666666" if User.current.logged? %> -

    - - - -<% end %> + <% if @memberships.empty? %> + <% if @user != User.current %> +

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

    + <% else %> +

    + + <%= l(:label_project_course_unadd) %><%= link_to "#{l(:label_course_new)}", {:controller => 'projects', :action => 'new', :course => 1, :project_type => 1}, :class => 'icon icon-add' %> +

    + <% end %> + <% else %> + <%= render partial: 'course_list_have_entity' %> + <% end %>
    diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 8e0a81cf6..977aef8fe 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -493,7 +493,6 @@ a.bids_user { } .line{ - width: 905px; height: 1px; margin: 0px; background-color: #cacaca; diff --git a/public/stylesheets/nyan.css b/public/stylesheets/nyan.css index 0135b1e46..42d196734 100644 --- a/public/stylesheets/nyan.css +++ b/public/stylesheets/nyan.css @@ -1,14 +1,17 @@ /* TODO: base/common/page 准备封装一些基本样式组合调用 参考YUI *******************************************************************************/ -span[id^=valid_user]{ - padding-left: 10px; +span[id^=valid_user] { + padding-left: 10px; } -.red{ - color: red; + +.red { + color: red; } -.green{ - color: green; + +.green { + color: green; } + .border_box { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; @@ -1007,7 +1010,7 @@ div.issue { } #ver-zebra1 td { - padding: 8px ; + padding: 8px; border-right: 1px solid #fff; border-left: 1px solid #fff; color: #669; @@ -1133,11 +1136,13 @@ div.pagination { -o-transition: 1s width; transition: 1s width; } -.all_browse_div table .description{ - border-bottom: 1px solid #efffff; + +.all_browse_div table .description { + border-bottom: 1px solid #efffff; } -.all_browse_div table td{ - vertical-align: middle; + +.all_browse_div table td { + vertical-align: middle; } /* softapplication show @@ -1146,6 +1151,7 @@ div.pagination { margin: 0; padding: 0; } + .softapplication-img { margin: 5px auto; width: 860px; @@ -1154,25 +1160,29 @@ div.pagination { box-shadow: 5px 5px 20px 5px #ccc; border-radius: 5px; } + .soft-application { width: 326px; height: 580px; } -.softapplication-img .title{ + +.softapplication-img .title { width: 326px; position: absolute; left: 0; bottom: 0; } -.softapplication-img .title a{ + +.softapplication-img .title a { display: block; text-decoration: none; color: #fff; font-size: 20px; padding: 20px; - background: rgba(0,0,0,0.5); + background: rgba(0, 0, 0, 0.5); } -.softapplication-img li{ + +.softapplication-img li { list-style-type: none; position: relative; float: left; @@ -1182,11 +1192,98 @@ div.pagination { -ms-transition: all 0.5s; -o-transition: all 0.5s; transition: all 0.5s; - box-shadow: -1px 0 3px 1px rgba(0,0,0,0.3); + box-shadow: -1px 0 3px 1px rgba(0, 0, 0, 0.3); } -.softapplication-img ul:hover li{ + +.softapplication-img ul:hover li { width: 160px; } -.softapplication-img ul li:hover{ + +.softapplication-img ul li:hover { width: 326px; } + +/* user_courses +*******************************************************************************/ +.user_course_list { + margin: 0; + padding: 0; + position: relative; + margin-top: -15px; +} + +.user_course_list .menu{ + display: block; + background-color: #f9f9f9; + border-radius: 2px 2px 0 0; + position: relative; + height: 40px; + line-height: 40px; + border-bottom: 1px solid #ddd; + text-align: left; + margin-left: -10px; + padding-left: 15px; +} + +.user_course_list .menu:after { + content: "."; + visibility: hidden; + display: block; + height: 0; + clear: both; +} + +.user_course_list .menu ul { + margin: 0; + padding: 0; + float: right; + margin-right: 30px; +} +.user_course_list .menu ul { +} + +.user_course_list .menu li { + display: inline-block; + position: relative; + width: 40px; + height: 40px; + line-height: 40px; + cursor: pointer; +} + +.user_course_list .menu li:hover { + color: #00a1d6; +} + +.user_course_list .menu li.on { + color: #00a1d6; + font-weight: bold; +} + + +.user_course_list .list_top { + margin: 20px auto 0px; +} + +.user_course_list .created_course { + position: relative; + display: block; + padding-top: 20px; +} + +.user_course_list .created_course:after { + content: "."; + visibility: hidden; + display: block; + height: 0; + clear: both; +} + +.user_course_list .created_course .field { + position: absolute; + display: inline-block; + color: rgb(213, 213, 213); + top: 0; + right: 5%; +} + From 3e8decf1d173bd597fc079eb8eb83062d2e907f4 Mon Sep 17 00:00:00 2001 From: yanxd Date: Wed, 21 May 2014 18:29:56 +0800 Subject: [PATCH 4/7] student user_course --- .../users/_course_list_have_entity.html.erb | 18 ---------- app/views/users/_my_joinedcourse.html.erb | 34 +++++++++++-------- app/views/users/user_courses.html.erb | 19 +++++++++++ 3 files changed, 38 insertions(+), 33 deletions(-) diff --git a/app/views/users/_course_list_have_entity.html.erb b/app/views/users/_course_list_have_entity.html.erb index 6b5725a1f..87dd52635 100644 --- a/app/views/users/_course_list_have_entity.html.erb +++ b/app/views/users/_course_list_have_entity.html.erb @@ -20,21 +20,3 @@ - \ No newline at end of file diff --git a/app/views/users/_my_joinedcourse.html.erb b/app/views/users/_my_joinedcourse.html.erb index dc759a809..31780e301 100644 --- a/app/views/users/_my_joinedcourse.html.erb +++ b/app/views/users/_my_joinedcourse.html.erb @@ -11,23 +11,27 @@

    <% end %> <% else %> -

    - <%=l(:label_course_doing)%>(<%=@memberships_doing.count%>) - <%= link_to"#{l(:label_course_view_student)}",{:controller=>'projects',:action=>'course', :course => 1}, :class => 'icon icon-add' %> -

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

    - <%= link_to l(:label_course_done)+"("+@memberships_done.count.to_s+")", 'javascript:void(0);', :onclick => '$("#courses_history_block").slideToggle(400); ', style:"color:#666666" if User.current.logged? %> -

    - - + +
    <% end %> diff --git a/app/views/users/user_courses.html.erb b/app/views/users/user_courses.html.erb index aa4a366fc..6a4d7afdd 100644 --- a/app/views/users/user_courses.html.erb +++ b/app/views/users/user_courses.html.erb @@ -12,3 +12,22 @@ }); + + \ No newline at end of file From 9edb8a49dea1f9731476ad222893e4f3f39159b9 Mon Sep 17 00:00:00 2001 From: yanxd Date: Wed, 21 May 2014 18:38:46 +0800 Subject: [PATCH 5/7] fontsize fix --- public/stylesheets/nyan.css | 1 - 1 file changed, 1 deletion(-) diff --git a/public/stylesheets/nyan.css b/public/stylesheets/nyan.css index 42d196734..7910c2a64 100644 --- a/public/stylesheets/nyan.css +++ b/public/stylesheets/nyan.css @@ -1245,7 +1245,6 @@ div.pagination { .user_course_list .menu li { display: inline-block; position: relative; - width: 40px; height: 40px; line-height: 40px; cursor: pointer; From 4fffd321d20be8b917b6a0f88e5614a7561e3894 Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 21 May 2014 18:52:15 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E3=80=81=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E4=B8=BB=E9=A1=B5=E8=B4=B4=E5=90=A7=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=8F=8A=E8=B4=B4=E5=90=A7=E5=86=85=E5=B8=96=E5=AD=90=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=B7=BB=E5=8A=A0=E6=9C=80=E5=90=8E=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/forums/_forum_list.html.erb | 2 +- app/views/forums/_show_topics.html.erb | 3 +++ app/views/welcome/contest.html.erb | 22 +++++++++++++++------- app/views/welcome/course.html.erb | 20 ++++++++++++++------ 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/app/views/forums/_forum_list.html.erb b/app/views/forums/_forum_list.html.erb index faf1cbe5e..0bbb0ddd4 100644 --- a/app/views/forums/_forum_list.html.erb +++ b/app/views/forums/_forum_list.html.erb @@ -7,7 +7,7 @@

    <%= link_to h(forum.name), forum_path(forum) %>

    <%= forum.description%>

    -

    <%= authoring forum.created_at, forum.creator %>

    +

    <%= authoring forum.created_at, forum.creator %>

    <%= link_to (forum.memo_count), forum_path(forum) %><%= link_to (forum.topic_count), forum_path(forum) %>
    回答帖子
    diff --git a/app/views/forums/_show_topics.html.erb b/app/views/forums/_show_topics.html.erb index 057d6a258..7a9eb4316 100644 --- a/app/views/forums/_show_topics.html.erb +++ b/app/views/forums/_show_topics.html.erb @@ -25,6 +25,9 @@ <%= authoring topic.created_at, topic.author %> + + 最后回复:<%=link_to_user topic.last_reply.try(:author) %> +
    diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index 65238110b..3e0fecceb 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -192,13 +192,21 @@       <%= 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)%>前 - - 由 <%= 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 %>) - +
    + + <%= "#{l(:label_updated_time, value: time_tag_welcome(topic_last_time topic))}".html_safe %> + + + 楼主: <%= link_to_user(topic.author) %> + + + 最后回复:<%=link_to_user topic.last_reply.try(:author) %> + + + 回复(<%= link_to topic.try(:replies_count), topic.event_url %>) + +
    + <% end %> diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index 06269665e..c4a091299 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -239,12 +239,20 @@       <%= 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)%>前 - - 由 <%= 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 %>) +
    + + <%= "#{l(:label_updated_time, value: time_tag_welcome(topic_last_time topic))}".html_safe %> + + + 楼主: <%= link_to_user(topic.author) %> + + + 最后回复:<%=link_to_user topic.last_reply.try(:author) %> + + + 回复(<%= link_to topic.try(:replies_count), topic.event_url %>) + +
    <% end %> From 1d6816419ddd9ab2f59df0dd9e6c4a980bf90766 Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 21 May 2014 19:30:49 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E5=8A=A0=E5=85=A5=E9=A1=B9=E7=9B=AE=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/applied_project_controller.rb | 17 +++++++++++++++-- app/helpers/applied_project_helper.rb | 11 +++++++++-- app/helpers/watchers_helper.rb | 18 +++++++++++++----- app/views/applied_project/_set_applied.js.erb | 4 ++++ app/views/layouts/base_projects.html.erb | 6 +++--- 5 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 app/views/applied_project/_set_applied.js.erb diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb index 2f8879636..0bf9394aa 100644 --- a/app/controllers/applied_project_controller.rb +++ b/app/controllers/applied_project_controller.rb @@ -2,15 +2,28 @@ class AppliedProjectController < ApplicationController #申请加入项目 def applied_join_project + @user_id = params[:user_id] + @project = Project.find(params[:project_id]) AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id]) - redirect_to_referer_or {render :text => ( 'applied success.'), :layout => true} + #redirect_to project_path(params[:project_id]) + #redirect_to_referer_or {render :text => ( 'applied success.'), :layout => true} + respond_to do |format| + format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} + format.js { render :partial => 'set_applied'} + end end #取消申请 def unapplied_join_project + @project = Project.find(params[:project_id]) @applied = AppliedProject.find(params[:id]) @applied.destroy - redirect_to_referer_or {render :text => ( 'unsubscribe success.'), :layout => true} + #redirect_to project_path(params[:project_id]) + #redirect_to_referer_or {render :text => ( 'unsubscribe success.'), :layout => true} + respond_to do |format| + format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} + format.js { render :partial => 'set_applied' } + end end end diff --git a/app/helpers/applied_project_helper.rb b/app/helpers/applied_project_helper.rb index a766976a4..eef4c9ccf 100644 --- a/app/helpers/applied_project_helper.rb +++ b/app/helpers/applied_project_helper.rb @@ -1,14 +1,21 @@ module AppliedProjectHelper + def applied_css(project) + id = project.id + "#{project.class.to_s.underscore}-#{id}-applied" + end + def applied_link(project, user, options=[]) return '' unless user && user.logged? applied = project.applied_projects.find_by_user_id(user.id) text = applied ? l(:label_unapply_project) : l(:label_apply_project) + @applied_flag = project.instance_of?(Project) + css = @applied_flag ? ([applied_css(project), applied ? 'icon ' : 'icon '].join(' ') << options[0].to_s) : + ([applied_css(project), applied ? 'icon icon-applied ' : 'icon icon-applied-off '].join(' ') << options[0].to_s) if applied appliedid = applied.id end - url = appliedproject_path( :id=>appliedid, :user_id => user.id, @@ -16,6 +23,6 @@ module AppliedProjectHelper ) method = applied ? 'delete' : 'post' - link_to text, url, :remote => true, :method => method + link_to text, url, :remote => true, :method => method ,:class=>css end end diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 1d7e2bcf9..50170ee9e 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -30,7 +30,7 @@ module WatchersHelper objects = Array.wrap(objects) watched = objects.any? {|object| object.watched_by?(user)} - @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or objects.first.instance_of?(Contest) or (objects.first.instance_of?(Bid))) + @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or objects.first.instance_of?(Contest) or (objects.first.instance_of?(Bid))) css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) : ([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s) @@ -188,22 +188,30 @@ module WatchersHelper end.join.html_safe end + def applied_css(project) + id = project.id + "#{project.class.to_s.underscore}-#{id}-applied" + end + def applied_link(project, user, options=[]) return '' unless user && user.logged? applied = project.applied_projects.find_by_user_id(user.id) text = applied ? l(:label_unapply_project) : l(:label_apply_project) + @applied_flag = project.instance_of?(Project) + css = @applied_flag ? ([applied_css(project), applied ? 'icon ' : 'icon '].join(' ') << options[0].to_s) : + ([applied_css(project), applied ? 'icon icon-applied ' : 'icon icon-applied-off '].join(' ') << options[0].to_s) if applied appliedid = applied.id end - - url = appliedproject_path( + url = appliedproject_path( :id=>appliedid, :user_id => user.id, :project_id => project.id ) method = applied ? 'delete' : 'post' - link_to text, url, :remote => true, :method => method + link_to text, url, :remote => true, :method => method ,:class=>css end -end + + end diff --git a/app/views/applied_project/_set_applied.js.erb b/app/views/applied_project/_set_applied.js.erb new file mode 100644 index 000000000..e77592060 --- /dev/null +++ b/app/views/applied_project/_set_applied.js.erb @@ -0,0 +1,4 @@ +<% selector = ".#{applied_css(@project)}" %> +$("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript applied_link(@project, User.current) %>")}); + + diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 8d4de3a7c..653b5ae5d 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -105,9 +105,9 @@
    - - <% if ( !(User.current.member_of? @project) && User.current.login?) %> - <%= applied_link(@project, User.current) %> + <% if ( !(User.current.member_of? @project) && User.current.login?) %> + + <%= applied_link(@project, User.current) %> <% end %>