parent
960b59c807
commit
c2302dc0c7
|
@ -116,6 +116,21 @@ class AttachmentsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete_homework
|
||||||
|
@bid = @attachment.container.bid
|
||||||
|
# Make sure association callbacks are called
|
||||||
|
container = @attachment.container
|
||||||
|
@attachment.container.attachments.delete(@attachment)
|
||||||
|
if container.attachments.empty?
|
||||||
|
container.delete
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to_referer_or respond_path(@bid) }
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_project
|
def find_project
|
||||||
@attachment = Attachment.find(params[:id])
|
@attachment = Attachment.find(params[:id])
|
||||||
|
|
|
@ -135,6 +135,7 @@ class UsersController < ApplicationController
|
||||||
@memberships.each do |membership|
|
@memberships.each do |membership|
|
||||||
@bid += membership.project.homeworks
|
@bid += membership.project.homeworks
|
||||||
end
|
end
|
||||||
|
@bid = @bid.group_by {|bid| bid.courses.first.id}
|
||||||
@state = 1
|
@state = 1
|
||||||
else
|
else
|
||||||
@membership = @user.memberships.all(:conditions => Project.visible_condition(User.current))
|
@membership = @user.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||||
|
|
|
@ -32,6 +32,15 @@ module AttachmentsHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def attach_delete(project)
|
||||||
|
if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0) || project.user_id == User.current.id)
|
||||||
|
true
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
def render_api_attachment(attachment, api)
|
def render_api_attachment(attachment, api)
|
||||||
api.attachment do
|
api.attachment do
|
||||||
api.id attachment.id
|
api.id attachment.id
|
||||||
|
|
|
@ -9,11 +9,19 @@
|
||||||
<%= h(" - #{attachment.description}") unless attachment.description.blank? %>
|
<%= h(" - #{attachment.description}") unless attachment.description.blank? %>
|
||||||
<span class="size">(<%= number_to_human_size attachment.filesize %>)</span>
|
<span class="size">(<%= number_to_human_size attachment.filesize %>)</span>
|
||||||
<% if options[:deletable] %>
|
<% if options[:deletable] %>
|
||||||
|
<% unless attachment.container_type == 'HomeworkAttach' %>
|
||||||
<%= link_to image_tag('delete.png'), attachment_path(attachment),
|
<%= link_to image_tag('delete.png'), attachment_path(attachment),
|
||||||
:data => {:confirm => l(:text_are_you_sure)},
|
:data => {:confirm => l(:text_are_you_sure)},
|
||||||
:method => :delete,
|
:method => :delete,
|
||||||
:class => 'delete',
|
:class => 'delete',
|
||||||
:title => l(:button_delete) %>
|
:title => l(:button_delete) %>
|
||||||
|
<% else %>
|
||||||
|
<%= link_to image_tag('delete.png'), {:controller => 'attachments', :action => 'delete_homework', :id => attachment.id},
|
||||||
|
:data => {:confirm => l(:text_are_you_sure)},
|
||||||
|
:method => :delete,
|
||||||
|
:class => 'delete',
|
||||||
|
:title => l(:button_delete) %>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if options[:author] %>
|
<% if options[:author] %>
|
||||||
<span class="author"><%= h(attachment.author) %>, <%= format_time(attachment.created_on) %></span>
|
<span class="author"><%= h(attachment.author) %>, <%= format_time(attachment.created_on) %></span>
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
$('#attachments_<%= j params[:attachment_id] %>').remove();
|
|
@ -15,7 +15,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" width="580px" >
|
<td colspan="2" width="580px" >
|
||||||
<p class="font_description">
|
<p class="font_description">
|
||||||
<% options = {:author => true} %>
|
<% options = {:author => true, :deletable => attach_delete(homework)} %>
|
||||||
<%= render :partial => 'attachments/links',
|
<%= render :partial => 'attachments/links',
|
||||||
:locals => {:attachments => homework.attachments, :options => options} %>
|
:locals => {:attachments => homework.attachments, :options => options} %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
<!-- fq -->
|
<!-- fq -->
|
||||||
<% if @bid.size > 0%>
|
<% if @bid.size > 0%>
|
||||||
|
|
||||||
<% for bid in @bid%>
|
<% @bid.each do |bids|%>
|
||||||
|
<h2><%= link_to(Project.find(bids[0]).name, project_path(bids[0])) %></h2>
|
||||||
|
|
||||||
|
<% for bid in bids[1]%>
|
||||||
|
|
||||||
<table width="90%" border="0" align="center" style="border-bottom: 1px dashed rgb(204, 204, 204); margin-bottom: 10px; margin-top: 30px;font-size:14px;">
|
<table width="90%" border="0" align="center" style="border-bottom: 1px dashed rgb(204, 204, 204); margin-bottom: 10px; margin-top: 30px;font-size:14px;">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -42,6 +45,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|
|
@ -446,6 +446,7 @@ RedmineApp::Application.routes.draw do
|
||||||
|
|
||||||
post 'join_in/join', :to => 'courses#join', :as => 'join'
|
post 'join_in/join', :to => 'courses#join', :as => 'join'
|
||||||
delete 'join_in/join', :to => 'courses#unjoin'
|
delete 'join_in/join', :to => 'courses#unjoin'
|
||||||
|
delete 'attachment/:id', :to => 'attachments#delete_homework'
|
||||||
match 'new_join', :to => 'projects#new_join', :as => 'try_join'
|
match 'new_join', :to => 'projects#new_join', :as => 'try_join'
|
||||||
match 'projects/:id/respond', :to => 'projects#project_respond', :via => :post
|
match 'projects/:id/respond', :to => 'projects#project_respond', :via => :post
|
||||||
## 测试用
|
## 测试用
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddTechnicalTitleToUserExtensions < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :user_extensions, :technical_title, :string
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20130913125835) do
|
ActiveRecord::Schema.define(:version => 20130918004629) do
|
||||||
|
|
||||||
create_table "a_user_watchers", :force => true do |t|
|
create_table "a_user_watchers", :force => true do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
|
@ -173,6 +173,8 @@ ActiveRecord::Schema.define(:version => 20130913125835) do
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.string "location"
|
t.string "location"
|
||||||
|
t.string "term"
|
||||||
|
t.string "string"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "custom_fields", :force => true do |t|
|
create_table "custom_fields", :force => true do |t|
|
||||||
|
@ -692,6 +694,7 @@ ActiveRecord::Schema.define(:version => 20130913125835) do
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.integer "identity"
|
t.integer "identity"
|
||||||
|
t.string "technical_title"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "user_preferences", :force => true do |t|
|
create_table "user_preferences", :force => true do |t|
|
||||||
|
|
|
@ -285,8 +285,9 @@ Redmine::MenuManager.map :course_menu do |menu|
|
||||||
end
|
end
|
||||||
Redmine::MenuManager.map :user_menu do |menu|
|
Redmine::MenuManager.map :user_menu do |menu|
|
||||||
menu.push :activity, {:controller => 'users', :action => 'show' }
|
menu.push :activity, {:controller => 'users', :action => 'show' }
|
||||||
menu.push :user_project, {:controller => 'users', :action => 'user_projects'}
|
|
||||||
menu.push :user_course, {:controller => 'users', :action => 'user_courses'}
|
menu.push :user_course, {:controller => 'users', :action => 'user_courses'}
|
||||||
|
menu.push :user_project, {:controller => 'users', :action => 'user_projects'}
|
||||||
|
|
||||||
menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids'}
|
menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids'}
|
||||||
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback'}
|
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback'}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue