上传附件

This commit is contained in:
cxt 2019-01-09 15:05:46 +08:00
parent 0608c7ceb9
commit 0c7fb625b7
6 changed files with 18 additions and 1 deletions

View File

@ -15,6 +15,7 @@ class ArticleHomepagesController < ApplicationController
@article.homepage_id = User.current.homepage.id
@article.title = params[:article_homepage][:title]
@article.content = params[:article_homepage][:content]
@article.save_attachments_containers(params[:attachments], User.current, true)
if @article.save
if params[:set_homepage]
User.current.homepage.update_attribute(:article_id, @article.id)
@ -55,6 +56,7 @@ class ArticleHomepagesController < ApplicationController
end
end
if @article.save
Attachment.attach_files(@article, params[:attachments])
redirect_to user_homepages_path(:user_id => User.current.id)
end
else

View File

@ -772,7 +772,10 @@ class AttachmentsController < ApplicationController
elsif @attachment.container_type == 'Statistic'
@statistic = @attachment.container
else
unless @attachment.container_type == 'Syllabus' || @attachment.container_type == 'Bid' || @attachment.container_type == 'Organization' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' || @attachment.container_type == 'Work'|| @attachment.container_type == 'ContestantWork'|| @attachment.container_type == 'Contest' || @attachment.container_type == 'HomeworkBank'
unless @attachment.container_type == 'Syllabus' || @attachment.container_type == 'Bid' || @attachment.container_type == 'Organization' || @attachment.container_type == 'HomeworkAttach' ||
@attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' ||
@attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' || @attachment.container_type == 'Work'|| @attachment.container_type == 'ContestantWork'||
@attachment.container_type == 'Contest' || @attachment.container_type == 'HomeworkBank' || @attachment.container_type == 'ArticleHomepage'
@project = @attachment.project
end
end

View File

@ -2596,6 +2596,8 @@ module ApplicationHelper
candown = true
elsif attachment.container.class.to_s=="Syllabus" #论坛资源允许下载
candown = true
elsif attachment.container.class.to_s=="ArticleHomepage" #主页帖子的下载权限
candown = true
elsif attachment.container.class.to_s == "User"
candown = (attachment.is_public == 1 || attachment.is_public == true || attachment.author_id == User.current.id)
elsif attachment.container_type == "Bid" && attachment.container && attachment.container.courses

View File

@ -2,4 +2,5 @@ class ArticleHomepage < ActiveRecord::Base
belongs_to :user
belongs_to :homepage
attr_accessible :content, :title, :user_id, :homepage_id
acts_as_attachable
end

View File

@ -31,6 +31,11 @@
<input type="checkbox" value="1" id="set_homepage" name="set_homepage"/>
<label for="set_homepage">设为主页</label>
</div>
<div class="mt10">
<div class="fl" id="topic_attachments">
<%= render :partial => 'attachments/form_course', :locals => {:container => @article, :isReply => @isReply} %>
</div>
</div>
<div class="cl"></div>
<div class="mt5">
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_article();">确定</a>

View File

@ -61,6 +61,10 @@
<div class="break_word mt10" style="padding: 5px 5px 0 0" id="intro_content">
<%=@article.content.html_safe %>
</div>
<div class="cl"></div>
<div class="mt10" style="font-weight:normal;">
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @article} %>
</div>
<% end %>
</div>
</div>