From 4de089250f24f93b1043c1aea239511f8db91118 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 20 May 2014 09:59:33 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=95=99=E8=A8=80=E6=96=B9=E6=B3=95=E4=B8=BAdestroy=5Fjour?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=8F=8A=E7=9B=B8=E5=85=B3=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=EF=BC=8C=E8=AE=BF=E9=97=AEaction=E7=9A=84=E6=94=B9=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 55 ++++++++++++++++++- .../_journal_reply_items.html.erb | 4 +- app/views/homework_attach/_showjour.html.erb | 4 +- .../{destroy.js.erb => destroy_jour.js.erb} | 0 config/routes.rb | 1 + 5 files changed, 59 insertions(+), 5 deletions(-) rename app/views/homework_attach/{destroy.js.erb => destroy_jour.js.erb} (100%) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 2a0f9761..ed31f8f7 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -1,4 +1,57 @@ class HomeworkAttachController < ApplicationController + ############################### + def index + @homeworks = HomeworkAttach.all + respond_to do |format| + format.html # index.html.erb + format.json { render json: @homeworks } + end + end + + def create + @homework = HomeworkAttach.new(params[:homework]) + + respond_to do |format| + if @homework.save + format.html { redirect_to @homework, notice: 'Post was successfully created.' } + format.json { render json: @homework, status: :created, location: @homework } + else + format.html { render action: "new" } + format.json { render json: @homework.errors, status: :unprocessable_entity } + end + end + end + + def new + @homework = HomeworkAttach.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @homework } + end + end + + def edit + @homework = HomeworkAttach.find(params[:id]) + end + + def update + @homework = HomeworkAttach.find(params[:id]) + respond_to do |format| + if @post.update_attributes(params[:homework]) + format.html { redirect_to @homework, notice: 'Homework was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @homework.errors, status: :unprocessable_entity } + end + end + end + + def destroy + + end + #显示作业信息 def show @homework = HomeworkAttach.find(params[:id]) @@ -24,7 +77,7 @@ class HomeworkAttachController < ApplicationController end #删除留言 - def destroy + def destroy_jour @journal_destroyed = JournalsForMessage.delete_message(params[:object_id]) #@homework = HomeworkAttach.find(params[:id]) #@jours = @homework.journals_for_messages.order("created_on DESC") diff --git a/app/views/homework_attach/_journal_reply_items.html.erb b/app/views/homework_attach/_journal_reply_items.html.erb index 85f7fa30..e9aad84c 100644 --- a/app/views/homework_attach/_journal_reply_items.html.erb +++ b/app/views/homework_attach/_journal_reply_items.html.erb @@ -19,8 +19,8 @@ %> <% 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)) %> + <%= link_to(l(:label_newfeedback_delete), {:controller => 'homework_attach', :action => 'destroy_jour', :object_id => reply, :user_id => reply.user}, + :remote => true, :confirm => l(:text_are_you_sure), :title => l(:button_delete)) %> <% end %>

diff --git a/app/views/homework_attach/_showjour.html.erb b/app/views/homework_attach/_showjour.html.erb index dbd7f254..939deff3 100644 --- a/app/views/homework_attach/_showjour.html.erb +++ b/app/views/homework_attach/_showjour.html.erb @@ -54,8 +54,8 @@ {: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)) %> + <%= link_to(l(:label_bid_respond_delete), {:controller => 'homework_attach', :action => 'destroy_jour', :object_id => journal, :user_id => journal.user}, + :remote => true, :confirm => l(:text_are_you_sure), :title => l(:button_delete)) %> <% end %> diff --git a/app/views/homework_attach/destroy.js.erb b/app/views/homework_attach/destroy_jour.js.erb similarity index 100% rename from app/views/homework_attach/destroy.js.erb rename to app/views/homework_attach/destroy_jour.js.erb diff --git a/config/routes.rb b/config/routes.rb index f6717583..84b27727 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -29,6 +29,7 @@ RedmineApp::Application.routes.draw do collection do match 'addjours', via: [:get, :post] match 'add_jour_reply', via: [:get,:post] + match 'destroy_jour', via: [:get,:post] end end resources :open_source_projects do From c7b19d8f2e21a324ab038467e82c39e0157c020a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 21 May 2014 14:10:11 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 53 +++++++++++++++---- app/views/homework_attach/edit.html.erb | 0 app/views/homework_attach/new.html.erb | 33 ++++++++++++ config/locales/zh.yml | 5 ++ config/routes.rb | 2 +- 5 files changed, 82 insertions(+), 11 deletions(-) create mode 100644 app/views/homework_attach/edit.html.erb create mode 100644 app/views/homework_attach/new.html.erb diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index ed31f8f7..c3ac1519 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -8,22 +8,50 @@ class HomeworkAttachController < ApplicationController end end - def create - @homework = HomeworkAttach.new(params[:homework]) + def add_users users + if users != nil && users.count > 0 + users.each do |user| + @homework.homework_users.build(:user_id => user.id) + @homework.save + end + end + end - respond_to do |format| - if @homework.save - format.html { redirect_to @homework, notice: 'Post was successfully created.' } - format.json { render json: @homework, status: :created, location: @homework } - else - format.html { render action: "new" } - format.json { render json: @homework.errors, status: :unprocessable_entity } + def create + if User.current.logged? && (!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) + user_id = params[:user_id] + bid_id = params[:bid_id] + sta = 0 + name = params[:new_form][:name] + description = params[:new_form][:description] + options = { + :user_id => user_id, + :state => sta, + :name => name, + :description => description, + :bid_id => bid_id + } + + @homework = HomeworkAttach.new(options) + @homework.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(@homework) + + @homework.save + respond_to do |format| + if @homework.save + format.html { redirect_to @homework, notice: 'Post was successfully created.' } + format.json { render json: @homework, status: :created, location: @homework } + else + format.html { render action: "new" } + format.json { render json: @homework.errors, status: :unprocessable_entity } + end end end end def new @homework = HomeworkAttach.new + @bid = Bid.find(params[:id]) respond_to do |format| format.html # new.html.erb @@ -49,7 +77,12 @@ class HomeworkAttachController < ApplicationController end def destroy - + @homework = HomeworkAttach.find(params([:id])) + @homework.destroy + respond_to do |format| + format.html {render @homework} + format.json {render json: @homework} + end end #显示作业信息 diff --git a/app/views/homework_attach/edit.html.erb b/app/views/homework_attach/edit.html.erb new file mode 100644 index 00000000..e69de29b diff --git a/app/views/homework_attach/new.html.erb b/app/views/homework_attach/new.html.erb new file mode 100644 index 00000000..073ab21b --- /dev/null +++ b/app/views/homework_attach/new.html.erb @@ -0,0 +1,33 @@ +

<%=raw l(:label_new_homework)%>

+
+ <%= form_for('new_form', :remote => true, :method => :post, + :url => {:controller => 'homework_attach', + :action => 'create', + :user_id => User.current.id, + :bid_id => @bid + }) do |f|%> +

+ 标题: + <%= f.text_field "name", :required => true, :size => 60, :style => "width:490px;" %> +

+

+ 描述: + + <%= f.text_area "description", :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %> + +

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

+ <%= render :partial => 'attachments/form' %> +

+
+ + <%= submit_tag t(:label_new), :sta => 0, :class => "enterprise"%> + <%= submit_tag t(:label_memo_create), :sta => 1, :class => "enterprise"%> + +

+ <% end %> +
\ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 666b2874..886a9821 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -580,6 +580,10 @@ zh: label_course_done: 已结束的课程 label_homework_response: 作业咨询 label_bidding_homework: 提交作业 + label_add_homework: 添加作业 + label_edit_homework: 修改作业 + label_delete_homework: 删除作业 + label_new_homework: 创建作业 #end label_my_page: 我的工作台 @@ -962,6 +966,7 @@ zh: button_edit_associated_wikipage: "编辑相关wiki页面: %{page_title}" button_add: 新增 button_change: 修改 + button_ok_and_submit: 确定并提交 button_apply: 查询 button_clear: 清除留言 diff --git a/config/routes.rb b/config/routes.rb index 84b27727..d5317846 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -562,7 +562,7 @@ RedmineApp::Application.routes.draw do match 'calls/new_bid', :controller => 'bids', :action => 'new_bid' match 'contest/new_contest', :controller => 'bids', :action => 'new_contest' #huang match 'calls/:id/show_project', :controller => 'bids', :action => 'show_project', :as => 'project_for_bid' - match 'calls/:id/show_project_homework', :controller => 'bids', :action => 'show_project_homework', :as => 'project_for_bid_homework' # by huang + match 'calls/:id/new_homework', :controller => 'homework_attach', :action => 'new', :as => 'new_homework_attach' match 'calls/:id/add', :controller => 'bids', :action => 'add' match 'calls/:id/delete', :controller => 'bids', :action => 'delete' match 'calls/:id/add_homework', :controller => 'bids', :action => 'add_homework', via: :post From f44b930037b9aa6df837ec90a8eeaa1b5bc736e2 Mon Sep 17 00:00:00 2001 From: yanxd Date: Thu, 22 May 2014 15:33:38 +0800 Subject: [PATCH 3/5] 233 --- app/helpers/application_helper.rb | 3 +-- app/models/project.rb | 3 ++- app/views/applied_project/_set_applied.js.erb | 13 +++++++++++-- app/views/bids/_homework_list.html.erb | 11 ++++++----- app/views/bids/show_project.html.erb | 6 ++---- app/views/issues/_attributes.html.erb | 2 +- app/views/layouts/base_projects.html.erb | 1 + app/views/members/create.js.erb | 14 +++++++------- app/views/projects/_project.html.erb | 5 +++-- config/locales/en.yml | 1 + config/locales/zh.yml | 11 ++++++----- 11 files changed, 41 insertions(+), 29 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9418f474..228f57ab 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -28,7 +28,6 @@ module ApplicationHelper include AvatarHelper ## added by william include PraiseTreadHelper - # add by nyan include CoursesHelper extend Forwardable @@ -1330,7 +1329,7 @@ module ApplicationHelper def hubspot_head tags = javascript_include_tag('hubspot/messenger.min', 'hubspot/messenger-theme-future') - tags << stylesheet_link_tag('hubspot/messenger', 'hubspot/messenger-theme-future') + tags << stylesheet_link_tag('hubspot/messenger', 'hubspot/messenger-theme-future', 'hubspot/messenger-theme-flat') unless User.current.pref.warn_on_leaving_unsaved == '0' tags << "\n".html_safe + javascript_tag("$(window).load(function(){ warnLeavingUnsaved('#{escape_javascript l(:text_warn_on_leaving_unsaved)}'); });") end diff --git a/app/models/project.rb b/app/models/project.rb index 1c672c5f..20c5de89 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -122,7 +122,8 @@ class Project < ActiveRecord::Base after_save :update_position_under_parent, :if => Proc.new {|project| project.name_changed?} after_save :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?} - after_save :create_board_sync #nyan + # 创建project之后默认创建一个board,之后的board去掉了board的概念 + after_save :create_board_sync before_destroy :delete_all_members def remove_references_before_destroy return if self.id.nil? diff --git a/app/views/applied_project/_set_applied.js.erb b/app/views/applied_project/_set_applied.js.erb index e7759206..7403b963 100644 --- a/app/views/applied_project/_set_applied.js.erb +++ b/app/views/applied_project/_set_applied.js.erb @@ -1,4 +1,13 @@ <% selector = ".#{applied_css(@project)}" %> $("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript applied_link(@project, User.current) %>")}); - - +if (window.Messenger) { + Messenger.options = { + extraClasses: 'messenger-fixed messenger-on-bottom messenger-on-right', + theme: 'flat' + } + Messenger().post({ + id: "label_apply_project_waiting", + message: "<%= l(:label_apply_project_waiting) %>", + showCloseButton: true, + }); +}; diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 35c41469..1381df74 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -3,7 +3,12 @@
- + - + @@ -26,9 +28,11 @@ + - @@ -49,7 +53,7 @@
<%= l(:label_task_plural)%>(<%= @homework_list.count%>)<%= l(:label_task_plural)%>(<%= @homework_list.count%>) + <%= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if( + User.current.admin? || + !(User.current.roles_for_project(@bid.courses.first).map(&:id) & ([7,9])).empty? ) || + (Rails.env.development?) %> + <% end %> <% display_id = im_watching_student_id? @bid%> -<%= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;display: inline-block;" if( - User.current.admin? || - !(User.current.roles_for_project(@bid.courses.first).map(&:id) & ([7,9])).empty? ) || - (Rails.env.development?) %> <% @homework_list.each do |homework|%> <% if homework.attachments.any?%> diff --git a/app/views/bids/show_project.html.erb b/app/views/bids/show_project.html.erb index d5676c3c..c14d2e14 100644 --- a/app/views/bids/show_project.html.erb +++ b/app/views/bids/show_project.html.erb @@ -32,18 +32,16 @@
-
+
- <% if @bid.reward_type == 3 %> + <% if @bid.reward_type == Bid::Homework %> diff --git a/app/views/issues/_attributes.html.erb b/app/views/issues/_attributes.html.erb index 6aef01e1..f4857bd2 100644 --- a/app/views/issues/_attributes.html.erb +++ b/app/views/issues/_attributes.html.erb @@ -2,7 +2,7 @@
<%= select_tag 'bid', options_for_select(select_option_helper(@option)), :name => 'bid', :class => 'grayline' %> -

<%= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target => '_blank' %>
-

<%= f.text_area :bid_message, :id => "bid_message", :required => true, :rows => 4, :cols => 40, :placeholder => l(:label_bid_reason_homework), :style => "resize: none;", :class => 'noline' %>
@@ -6,8 +7,10 @@
<%= l(:label_task_plural)%>(<%= @homework_list.count%>)
@@ -25,16 +28,25 @@
<%= image_tag(url_to_avatar(homework.user), :class => "avatar")%> -    作业   :  - <% filename = "" %> - <% homework.attachments.map do |attachment| %> - <% filename = attachment.filename %> - <% if homework.attachments.count > 1%> - <% filename += "等#{homework.attachments.count}个文件" %> + + +
+   作业   :  + <% attachments = homework.attachments.map %> + <% for attachment in attachments %> + <% if attachments.count > 1 && attachment != attachments.first %> +
+ <% for item in 1..7 %> +   + <% end %> + <% end %> + <%= link_to_attachment attachment , :download => true -%> <% end %> - <% break %> - <% end %> - <%= link_to filename , homework_attach_path(homework)%> +
+ <% if display_id %> + <%= link_to "互评>>" , homework_attach_path(homework)%> + <% end %> +
  @@ -48,7 +60,7 @@ <% sum = sum + star_reates.stars %> <% end %> <% stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count %> - <%= sum * 1.0 / stars_reates_count %> + <%= format("%.2f", sum * 1.0 / stars_reates_count) %> <% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.attachments[0].created_on.to_s) %> @@ -58,20 +70,20 @@
  - <% if display_id %> - <%= l(:label_bidding_user_studentcode) %>  : <%= homework.user.user_extensions.student_id%> - <% end %> + <% if display_id %> + <%= l(:label_bidding_user_studentcode) %>  : <%= homework.user.user_extensions.student_id%> + <% end %>
- <% if (User.current == homework.user) || (!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 =?',3,7, 9)).size >0) %> -

- <% options = {:author => true, :deletable => attach_delete(homework)} %> - <%= render :partial => 'attachments/links', - :locals => {:attachments => homework.attachments, :options => options} %> -

- <% end %> + <% if (User.current == homework.user) || (!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 =?',3,7, 9)).size >0) %> +

+ <% options = {:author => true, :deletable => attach_delete(homework)} %> + <%= render :partial => 'attachments/links', + :locals => {:attachments => homework.attachments, :options => options} %> +

+ <% end %>
diff --git a/app/views/homework_attach/_app_link.html.erb b/app/views/homework_attach/_app_link.html.erb new file mode 100644 index 00000000..8adf5220 --- /dev/null +++ b/app/views/homework_attach/_app_link.html.erb @@ -0,0 +1,12 @@ + +<% for attachment in attachments %> + <% if attachments.count > 1 && attachment != attachments.first%> +
                 + <% 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 %> + <% end -%> diff --git a/app/views/homework_attach/show.html.erb b/app/views/homework_attach/show.html.erb index 1400176c..d7c1e8eb 100644 --- a/app/views/homework_attach/show.html.erb +++ b/app/views/homework_attach/show.html.erb @@ -18,7 +18,9 @@
作业基础信息<%=@count %>
发布人员:<%= link_to @homework.user, user_path(@homework.user)%> + 发布人员:<%= link_to @homework.user, user_path(@homework.user)%> + 发布时间:<%=format_time @homework.created_at %>
作业下载: <% options = {:author => true } %> - <%= render :partial => 'attachments/app_link', :locals => {:attachments => @homework.attachments, :options => options} %> + <%= render :partial => 'app_link', :locals => {:attachments => @homework.attachments, :options => options} %> + + 所属任务:<%= link_to(@homework.bid.name, project_for_bid_path(@homework.bid))%> 所属任务:<%= link_to(@homework.bid.name, project_for_bid_path(@homework.bid))%>
- + <% @homework.attachments.map do |attachment| %> <% if attachment.description != nil && attachment.description != "" %> @@ -67,16 +71,20 @@
-
作业得分:
+
+ 作业得分: +
得分比例
<% 100.step(20,-20) do |star| %> -
+
-
+
<%= @stars_status_map["star#{(star/20).to_s}".to_sym] %> @@ -85,7 +93,11 @@
-
最终得分
+
最终得分
+
+ <%= @homework.average(:quality).try(:avg).try(:round, 2).to_s %> + 分 +
<%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %>
@@ -102,6 +114,18 @@
+ +
作业评论:
评分: @@ -121,5 +145,4 @@ <%= render :partial => 'showjour', :locals => {:jour => @jours} %>
-<%#= link_to '返回竞赛页面', show_softapplication_contest_path(@softapplication.contest) %>
作业描述:
作业描述: