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] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=A0=E9=99=A4=E7=95=99?= =?UTF-8?q?=E8=A8=80=E6=96=B9=E6=B3=95=E4=B8=BAdestroy=5Fjour=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E7=9B=B8=E5=85=B3=E8=B7=AF=E7=94=B1=EF=BC=8C?= =?UTF-8?q?=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 2a0f97613..ed31f8f77 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 85f7fa304..e9aad84ce 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 dbd7f2547..939deff3b 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 f6717583b..84b277274 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