工具栏边距调整,讨论区的修改删除功能,项目竞赛边框顶出页面的问题。

This commit is contained in:
yanxd 2013-12-07 10:15:55 +08:00
parent 02b5f2bafa
commit c272783f1c
8 changed files with 91 additions and 45 deletions

View File

@ -2,6 +2,8 @@
class ForumsController < ApplicationController
# GET /forums
# GET /forums.json
before_filter :authenticate_user_edit, :only => [:edit, :update]
before_filter :authenticate_user_destroy, :only => [:destroy]
def index
@offset, @limit = api_offset_and_limit({:limit => 10})
@ -100,3 +102,23 @@ class ForumsController < ApplicationController
end
end
end
private
def find_forum
@forum = Forum.find(params[:id])
rescue ActiveRecord::RecordNotFound
render_404
nil
end
def authenticate_user_edit
find_forum
render_403 unless @forum.editable_by? User.current
end
def authenticate_user_destroy
find_forum
render_403 unless @forum.destroyable_by? User.current
end

View File

@ -21,6 +21,16 @@ class Forum < ActiveRecord::Base
self.class.reset_counters!(id)
end
def editable_by? user
# user && user.logged? || (self.author == usr && usr.allowed_to?(:edit_own_messages, project))
self.creator == user || user.admin?
end
def destroyable_by? user
# user && user.logged? && Forum.find(self.forum_id).creator_id == user.id || user.admin?
user.admin?
end
# Updates topic_count, memo_count and last_memo_id attributes for +board_id+
def self.reset_counters!(forum_id)
forum_id = forum_id.to_i

View File

@ -33,15 +33,14 @@ class Message < ActiveRecord::Base
:date_column => "#{table_name}.created_on"
acts_as_event :title => Proc.new {|o| "#{o.board.name}: #{o.subject}"},
:description => :content,
:datetime => :created_on,
# :datetime => "#{Message.table_name}.created_on",
:group => :parent,
:type => Proc.new {|o| o.parent_id.nil? ? 'message' : 'reply'},
:url => Proc.new {|o| {:controller => 'messages', :action => 'show', :board_id => o.board_id}.merge(o.parent_id.nil? ? {:id => o.id} :
{:id => o.parent_id, :r => o.id, :anchor => "message-#{o.id}"})}
acts_as_activity_provider :find_options => {:include => [{:board => :project}, :author]},
:author_key => :author_id,
:timestamp => :created_on
:author_key => :author_id
acts_as_watchable
validates_presence_of :board, :subject, :content

View File

@ -1,38 +1,38 @@
<!-- fq -->
<%= render_flash_messages %>
<% if @bid.reward_type == 3 %>
<% if User.current.logged?%>
<% if User.current.user_extensions.identity == 1 %>
<div class="font_lighter">
<p><%= l(:label_homework_prompt) %></p>
<P><%= l(:label_homework_prompt_content) %></P>
</div>
<% end %>
<% end %>
<table width="1000px" border="0" style="padding-left: 15px">
<td class="font_lighter" style="font-size: 15px;"><%= l(:label_homework_project) %>(<%= bidding_project.count%>)</td>
<td>
<% 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) %>
<div class='icon icon-add'>
<%= toggle_link l(:label_commit_homework), 'put-bid-form' %>
</div>
<% end %>
</td>
</table>
<% else %>
<table width="1000px" border="0" style="padding-left: 15px">
<td class="font_lighter" style="font-size: 15px;"><%= l(:label_bidding_project) %>(<%= bidding_project.count%>)</td>
<% if User.current.logged? %>
<td>
<div class='icon icon-add'>
<%= toggle_link l(:button_bidding), 'put-bid-form' %>
</div></td>
<% end %>
</table>
<% end %>
<%= render :partial=> "list_projects",:locals => {:bidding_project => bidding_project,:bid => @bid }%>
<!-- fq -->
<%= render_flash_messages %>
<% if @bid.reward_type == 3 %>
<% if User.current.logged?%>
<% if User.current.user_extensions.identity == 1 %>
<div class="font_lighter">
<p><%= l(:label_homework_prompt) %></p>
<P><%= l(:label_homework_prompt_content) %></P>
</div>
<% end %>
<% end %>
<table width="100%" border="0" style="padding-left: 15px">
<td width="80%" class="font_lighter" style="font-size: 15px;"><%= l(:label_homework_project) %>(<%= bidding_project.count%>)</td>
<td width="20%">
<% 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) %>
<div class='icon icon-add'>
<%= toggle_link l(:label_commit_homework), 'put-bid-form' %>
</div>
<% end %>
</td>
</table>
<% else %>
<table width="100%" border="0" style="padding-left: 15px">
<td width="80%" class="font_lighter" style="font-size: 15px;"><%= l(:label_bidding_project) %>(<%= bidding_project.count%>)</td>
<% if User.current.logged? %>
<td width="20%">
<div class='icon icon-add'>
<%= toggle_link l(:button_bidding), 'put-bid-form' %>
</div></td>
<% end %>
</table>
<% end %>
<%= render :partial=> "list_projects",:locals => {:bidding_project => bidding_project,:bid => @bid }%>

View File

@ -35,7 +35,20 @@
<%= link_to l(:label_memo_new_from_forum), new_forum_memo_path(@forum), :class => 'icon icon-add',
:onclick => 'showAndScrollTo("add-memo", "memo_subject"); return false;' if User.current.logged? %>
</span>
<% if User.current.admin?||User.current.login==@forum.creator.login %> |
<%= link_to '编辑帖子', edit_forum_path(@forum), :class => 'icon icon-edit' %>
<% end %>
<div class="contextual-borad">
<%= link_to(
image_tag('edit.png')+l(:label_forum_edit),
{:action => 'edit', :id => @forum},
:method => 'get',
:title => l(:button_edit)
) if @forum.editable_by?(User.current) %>
<%= link_to(
image_tag('delete.png')+'删除讨论区',
{:action => 'destroy', :id => @forum},
:method => :delete,
:data => {:confirm => l(:text_are_you_sure)},
:title => l(:button_delete)
) if @forum.destroyable_by?(User.current) %>
</div>
<%= render :partial => 'forums/show_topics', :locals => {:memos => @memos} %>

View File

@ -36,7 +36,7 @@
background: url("/images/sidebar/tool_tag_alpha.png") 10px 30% no-repeat transparent;
color: #3e3e3e;
font-weight: 400;
line-height: 1.2em;
line-height: 1.5em;
margin: 0px 0px 10px;
padding: 0px 0px 0px 30px;
font-size: 1.0em;

View File

@ -1569,6 +1569,7 @@ en:
label_memo_create_fail: Memo was failures created.
label_forum_create_succ: Forum was successfully created.
label_forum_create_fail: Forum was failures created.
label_forum_edit: Editing forum
label_memo_create: publish
label_memo_new: new memo
label_memo_edit: edit memo

View File

@ -1733,6 +1733,7 @@ zh:
label_memo_create_fail: 发布失败
label_forum_create_succ: 贴吧新建成功
label_forum_create_fail: 贴吧新建失败
label_forum_edit: 编辑讨论区
label_memo_create: 发布
label_memo_new: 新建主题
label_memo_edit: 修改主题