1.设置帖子创建者可修改、删除帖子

2.设置新建、修改帖子时主题最大长度
3.修改权限判断
This commit is contained in:
sw 2014-11-20 15:55:43 +08:00
parent eb15db64ee
commit aef1cb31fa
6 changed files with 66 additions and 32 deletions

View File

@ -30,7 +30,7 @@ class Forum < ActiveRecord::Base
def destroyable_by? user
# user && user.logged? && Forum.find(self.forum_id).creator_id == user.id || user.admin?
user.admin?
self.creator == user || user.admin?
end
# Updates topic_count, memo_count and last_memo_id attributes for +board_id+

View File

@ -88,11 +88,11 @@ class Memo < ActiveRecord::Base
def editable_by? user
# user && user.logged? || (self.author == usr && usr.allowed_to?(:edit_own_messages, project))
user.admin?
(user && self.author == user) || user.admin?
end
def destroyable_by? user
(user && user.logged? && (Forum.find(self.forum_id).creator_id == user.id) ) || user.admin?
(user && self.author == user) || user.admin?
#self.author == user || user.admin?
end

View File

@ -15,7 +15,7 @@
<% end %>
<div style="width: 120%;">
<div class="field">
<%= f.text_field :name, :required => true, :style => 'width: 100%;', :class => 'create-share' %>
<%= f.text_field :name, :required => true, :style => 'width: 100%;', :class => 'create-share', :maxlength => 50%>
</div>
<div>
<% if User.current.logged? && User.current.admin? %>
@ -36,7 +36,9 @@
</p>
<script type="text/javascript">var ckeditor=CKEDITOR.replace('editor01');</script>
<p style="color: #ff0000">(<%= l(:label_forums_max_length) %>)</p>
<p style="color: #ff0000">
(<%= l(:label_forums_max_length) %>)
</p>
</div>
<div class="actions" style=" padding-top: 10px; float:right">
<%= submit_tag l(:button_submit) %>

View File

@ -7,12 +7,15 @@
<table width="940px">
<tr>
<td class="info_font" style="width: 220px; color: #15bccf">公共贴吧 </td>
<td class="location-list"><strong><%= l(:label_user_location) %> :</strong></td>
<td class="location-list">
<strong>
<%= l(:label_user_location) %> :
</strong>
</td>
<td rowspan="2">
<% if User.current.logged? %>
<%= link_to( l(:label_forum_new), new_forum_path, :class => 'icon icon-add') %>
<% end %>
</td>
<td rowspan="2" width="250px" >
<div class="top-content-search">
@ -24,8 +27,15 @@
</td>
</tr>
<tr>
<td style="padding-left: 8px"><a><%= link_to request.host()+"/forums", forums_path %> </a></td>
<td ><%= link_to l(:field_homepage), home_path %> > <%= link_to "公共贴吧", forums_path %></td>
<td style="padding-left: 8px">
<a>
<%= link_to request.host()+"/forums", forums_path %>
</a>
</td>
<td >
<%= link_to l(:field_homepage), home_path %> >
<%= link_to "公共贴吧", forums_path %>
</td>
</tr>
</table>
</div>

View File

@ -1,15 +1,24 @@
<!-- added by fq -->
<div id="add-memo" class='lz' style="<% unless @memo.errors.any?%>display: none;<% end %> padding: 20px;">
<h3><%=l(:label_memo_new)%></h3>
<h3>
<%=l(:label_memo_new)%>
</h3>
<% if User.current.logged? %>
<%= labelled_form_for(@memo, :url => create_memo_forum_path(@forum), :html => {:multipart => true} ) do |f| %>
<div class="actions" style="max-width:680px">
<p><%= f.text_field :subject, :required => true%></p>
<p style="max-width:680px"><%= f.text_area :content, :required => true, :id => 'editor02' %></p>
<script type="text/javascript">var ckeditor=CKEDITOR.replace('editor02');</script>
<p style="color: #ff0000">(<%= l(:label_memos_max_length) %>)</p>
<p>
<%= l(:label_attachment_plural) %><br />
<%= f.text_field :subject, :required => true, :maxlength => 50%>
</p>
<p style="max-width:680px">
<%= f.text_area :content, :required => true, :id => 'editor02' %>
</p>
<script type="text/javascript">var ckeditor=CKEDITOR.replace('editor02');</script>
<p style="color: #ff0000">
(<%= l(:label_memos_max_length) %>)
</p>
<p>
<%= l(:label_attachment_plural) %>
<br />
<%= render :partial => 'attachments/form', :locals => {:container => @memo} %>
</p>
<%= f.submit :value => l(:label_memo_create) %>

View File

@ -4,30 +4,43 @@
<%= labelled_form_for(@memo, :url => forum_memo_path(@memo.forum_id, @memo)) do |f| %>
<% if @memo.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@memo.errors.count, "error") %> prohibited this memo from being saved:</h2>
<h2>
<%= pluralize(@memo.errors.count, "error") %>
prohibited this memo from being saved:
</h2>
<ul>
<% @memo.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<li>
<%= msg %>
</li>
<% end %>
</ul>
</div>
<% end %>
<div class="actions">
<p><%= f.text_field :subject, :required => true, :size => 96 ,:readonly => @replying%></p>
<p>
<%= f.text_field :subject, :required => true, :size => 96 ,:readonly => @replying, :maxlength => 50%>
</p>
<% if User.current.admin?%>
<p>
<% unless @replying %>
<% if @memo.safe_attribute? 'sticky' %>
<%= f.check_box :sticky %> <%= label_tag 'memo_sticky', l(:label_board_sticky) %>
<%= f.check_box :sticky %>
<%= label_tag 'memo_sticky', l(:label_board_sticky) %>
<% end %>
<% if @memo.safe_attribute? 'lock' %>
<%= f.check_box :lock %> <%= label_tag 'memo_locked', l(:label_board_locked) %>
<% end %>
<% end %>
</p>
<p><%= f.text_area :content, :required => true, :size => 80, id: 'editor01' %></p>
<% end %>
<p>
<%= f.text_area :content, :required => true, :size => 80, id: 'editor01' %>
</p>
<script type="text/javascript">var ckeditor=CKEDITOR.replace('editor01');</script>
<p>
<%= l(:label_attachment_plural) %><br />
<%= l(:label_attachment_plural) %>
<br />
<%= render :partial => 'attachments/form', :locals => {:container => @memo} %>
</p>
<br/>