diff --git a/app/models/forum.rb b/app/models/forum.rb index e0592723e..61ba528a0 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -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+ diff --git a/app/models/memo.rb b/app/models/memo.rb index b02564834..847795b4f 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -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 diff --git a/app/views/forums/_form.html.erb b/app/views/forums/_form.html.erb index 9b3519b05..ac9c298ff 100644 --- a/app/views/forums/_form.html.erb +++ b/app/views/forums/_form.html.erb @@ -15,7 +15,7 @@ <% end %>
- <%= 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%>
<% if User.current.logged? && User.current.admin? %> @@ -36,7 +36,9 @@

-

(<%= l(:label_forums_max_length) %>)

+

+ (<%= l(:label_forums_max_length) %>) +

<%= submit_tag l(:button_submit) %> diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index 31d00891e..18ac7f752 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -7,12 +7,15 @@ - + - - + +
公共贴吧 <%= l(:label_user_location) %> : + + <%= l(:label_user_location) %> : + + - <% if User.current.logged? %> - <%= link_to( l(:label_forum_new), new_forum_path, :class => 'icon icon-add') %> - <% end %> - + <% if User.current.logged? %> + <%= link_to( l(:label_forum_new), new_forum_path, :class => 'icon icon-add') %> + <% end %>
<%= link_to request.host()+"/forums", forums_path %> <%= link_to l(:field_homepage), home_path %> > <%= link_to "公共贴吧", forums_path %> + + <%= link_to request.host()+"/forums", forums_path %> + + + <%= link_to l(:field_homepage), home_path %> > + <%= link_to "公共贴吧", forums_path %> +
diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 642cf5b15..85fa8093a 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -1,16 +1,25 @@
-

<%=l(:label_memo_new)%>

+

+ <%=l(:label_memo_new)%> +

<% if User.current.logged? %> <%= labelled_form_for(@memo, :url => create_memo_forum_path(@forum), :html => {:multipart => true} ) do |f| %>
-

<%= f.text_field :subject, :required => true%>

-

<%= f.text_area :content, :required => true, :id => 'editor02' %>

- -

(<%= l(:label_memos_max_length) %>)

- <%= l(:label_attachment_plural) %>
- <%= render :partial => 'attachments/form', :locals => {:container => @memo} %> + <%= f.text_field :subject, :required => true, :maxlength => 50%> +

+

+ <%= f.text_area :content, :required => true, :id => 'editor02' %> +

+ +

+ (<%= l(:label_memos_max_length) %>) +

+

+ <%= l(:label_attachment_plural) %> +
+ <%= render :partial => 'attachments/form', :locals => {:container => @memo} %>

<%= f.submit :value => l(:label_memo_create) %> <%= link_to l(:button_cancel), "#", :onclick => '$("#add-memo").hide(); return false;' %> diff --git a/app/views/memos/edit.html.erb b/app/views/memos/edit.html.erb index ded3a1b12..09e4262fe 100644 --- a/app/views/memos/edit.html.erb +++ b/app/views/memos/edit.html.erb @@ -4,30 +4,43 @@ <%= labelled_form_for(@memo, :url => forum_memo_path(@memo.forum_id, @memo)) do |f| %> <% if @memo.errors.any? %>
-

<%= pluralize(@memo.errors.count, "error") %> prohibited this memo from being saved:

+

+ <%= pluralize(@memo.errors.count, "error") %> + prohibited this memo from being saved: +

    <% @memo.errors.full_messages.each do |msg| %> -
  • <%= msg %>
  • +
  • + <%= msg %> +
  • <% end %>
<% end %>
-

<%= f.text_field :subject, :required => true, :size => 96 ,:readonly => @replying%>

- <% unless @replying %> - <% if @memo.safe_attribute? '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 %> + <%= f.text_field :subject, :required => true, :size => 96 ,:readonly => @replying, :maxlength => 50%> +

+ <% if User.current.admin?%> +

+ <% unless @replying %> + <% if @memo.safe_attribute? '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 %> +

+ <% end %> +

+ <%= f.text_area :content, :required => true, :size => 80, id: 'editor01' %>

-

<%= f.text_area :content, :required => true, :size => 80, id: 'editor01' %>

- <%= l(:label_attachment_plural) %>
+ <%= l(:label_attachment_plural) %> +
<%= render :partial => 'attachments/form', :locals => {:container => @memo} %>