From aef1cb31fa3471f2f36ecb2d49f4e26e96a0accc Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 20 Nov 2014 15:55:43 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=AE=BE=E7=BD=AE=E5=B8=96=E5=AD=90=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E8=80=85=E5=8F=AF=E4=BF=AE=E6=94=B9=E3=80=81=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=B8=96=E5=AD=90=202.=E8=AE=BE=E7=BD=AE=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E3=80=81=E4=BF=AE=E6=94=B9=E5=B8=96=E5=AD=90=E6=97=B6?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E6=9C=80=E5=A4=A7=E9=95=BF=E5=BA=A6=203.?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9D=83=E9=99=90=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/forum.rb | 2 +- app/models/memo.rb | 4 ++-- app/views/forums/_form.html.erb | 6 +++-- app/views/forums/index.html.erb | 24 ++++++++++++++------ app/views/forums/show.html.erb | 23 +++++++++++++------ app/views/memos/edit.html.erb | 39 ++++++++++++++++++++++----------- 6 files changed, 66 insertions(+), 32 deletions(-) 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} %>