修改forge,localhost首页不能显示的问题

This commit is contained in:
wanglinchun 2014-06-03 09:27:07 +08:00
parent 09ea833dcb
commit 528af32f91
12 changed files with 59 additions and 58 deletions

View File

@ -296,9 +296,9 @@ class ApplicationController < ActionController::Base
end end
def find_contest_from_association def find_contest_from_association
render_404 unless @object.present? render_404 unless @contest.present?
@contest = @object.contest @contest = @contest.contest
end end
def find_model_object def find_model_object

View File

@ -54,9 +54,9 @@ class CommentsController < ApplicationController
def find_model_object_contest def find_model_object_contest
super super
@contestnotification = @object @contestnotifications = @object
@comment = nil @comment = nil
@contestnotification @contestnotifications
end end
end end

View File

@ -28,23 +28,23 @@ class ContestnotificationsController < ApplicationController
@limit = 10 @limit = 10
end end
scope = @contest ? @contest.contestnotification.visible : Contestnotification.visible scope = @contest ? @contest.contestnotifications.visible : Contestnotifications.visible
@contestnotification_count = scope.count @contestnotification_count = scope.count
@contestnotification_pages = Paginator.new @contestnotification_count, @limit, params['page'] @contestnotification_pages = Paginator.new @contestnotification_count, @limit, params['page']
@offset ||= @contestnotification_pages.offset @offset ||= @contestnotification_pages.offset
@contestnotifications = scope.all(:include => [:author, :contest], @contestnotificationss = scope.all(:include => [:author, :contest],
:order => "#{Contestnotification.table_name}.created_on DESC", :order => "#{Contestnotification.table_name}.created_on DESC",
:offset => @offset, :offset => @offset,
:limit => @limit) :limit => @limit)
respond_to do |format| respond_to do |format|
format.html { format.html {
@contestnotification = Contestnotification.new # for adding news inline @contestnotifications = Contestnotifications.new # for adding news inline
render :layout => 'base_contest' render :layout => 'base_contest'
} }
format.api format.api
format.atom { render_feed(@contestnotifications, :title => (@contest ? @contest.name : Setting.app_title) + ": #{l(:label_contest_notification)}") } format.atom { render_feed(@contestnotificationss, :title => (@contest ? @contest.name : Setting.app_title) + ": #{l(:label_contest_notification)}") }
end end
### end ### ### end ###
end end
@ -58,7 +58,7 @@ class ContestnotificationsController < ApplicationController
# format.html # show.html.erb # format.html # show.html.erb
# format.json { render json: @contestnotification } # format.json { render json: @contestnotification }
# end # end
@comments = @contestnotification.comments @comments = @contestnotifications.comments
@comments.reverse! if User.current.wants_comments_in_reverse_order? @comments.reverse! if User.current.wants_comments_in_reverse_order?
render :layout => 'base_contest' render :layout => 'base_contest'
@ -73,7 +73,7 @@ class ContestnotificationsController < ApplicationController
# format.html # new.html.erb # format.html # new.html.erb
# format.json { render json: @contestnotification } # format.json { render json: @contestnotification }
# end # end
@contestnotification = Contestnotification.new(:contest => @contest, :author => User.current) @contestnotifications = Contestnotifications.new(:contest => @contest, :author => User.current)
render :layout => 'base_contest' render :layout => 'base_contest'
end end
@ -96,11 +96,11 @@ class ContestnotificationsController < ApplicationController
# format.json { render json: @contestnotification.errors, status: :unprocessable_entity } # format.json { render json: @contestnotification.errors, status: :unprocessable_entity }
# end # end
# end # end
@contestnotification = Contestnotification.new(:contest => @contest, :author => User.current) @contestnotifications = Contestnotifications.new(:contest => @contest, :author => User.current)
@contestnotification.safe_attributes = params[:contestnotification] @contestnotifications.safe_attributes = params[:contestnotifications]
@news.save_attachments(params[:attachments]) @news.save_attachments(params[:attachments])
if @contestnotification.save if @contestnotifications.save
render_attachment_warning_if_needed(@contestnotification) render_attachment_warning_if_needed(@contestnotifications)
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
redirect_to project_news_index_path(@contest) redirect_to project_news_index_path(@contest)
else else
@ -123,12 +123,12 @@ class ContestnotificationsController < ApplicationController
# format.json { render json: @contestnotification.errors, status: :unprocessable_entity } # format.json { render json: @contestnotification.errors, status: :unprocessable_entity }
# end # end
# end # end
@contestnotification.safe_attributes = params[:contestnotification] @contestnotifications.safe_attributes = params[:contestnotifications]
@contestnotification.save_attachments(params[:attachments]) @contestnotifications.save_attachments(params[:attachments])
if @contestnotification.save if @contestnotifications.save
render_attachment_warning_if_needed(@contestnotification) render_attachment_warning_if_needed(@contestnotifications)
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to contestnotification_path(@contestnotification) redirect_to contestnotification_path(@contestnotifications)
else else
render :action => 'edit' render :action => 'edit'
end end
@ -144,7 +144,7 @@ class ContestnotificationsController < ApplicationController
# format.html { redirect_to contestnotifications_url } # format.html { redirect_to contestnotifications_url }
# format.json { head :no_content } # format.json { head :no_content }
# end # end
@contestnotification.destroy @contestnotifications.destroy
redirect_to contest_contestnotification_index_path(@contest) redirect_to contest_contestnotification_index_path(@contest)
end end

View File

@ -319,9 +319,10 @@ module WelcomeHelper
"show_documents" => true, "show_documents" => true,
"show_messages" => true, "show_messages" => true,
"show_news" => true, "show_news" => true,
"show_bids" => true "show_bids" => true,
"show_contest" => true
} }
activity.scope_select{|t| ['changesets', 'documents', 'memos', 'messages', 'journals_for_messages', 'bids', 'news'].include?(t) ? nil : 'You may think you know what the following code does, may be. but why don"t you close this file and go play with something else, Now?' } activity.scope_select{|t| ['changesets', 'documents', 'memos', 'messages', 'journals_for_messages', 'bids', 'news', 'contestnotification'].include?(t) ? nil : 'You may think you know what the following code does, may be. but why don"t you close this file and go play with something else, Now?' }
activity.events_welcome(nil, nil, {:limit => limit, :types => 'welcome'}) activity.events_welcome(nil, nil, {:limit => limit, :types => 'welcome'})
end end

View File

@ -45,7 +45,7 @@ class Contestnotification < ActiveRecord::Base
# returns latest news for contests visible by user # returns latest news for contests visible by user
def self.latest(user = User.current, count = 5) def self.latest(user = User.current, count = 5)
visible(user).includes([:author, :contest]).order("#{Contestnotification.table_name}.created_on DESC").limit(count).all visible(user).includes([:author, :contest]).order("#{Contestnotifications.table_name}.created_on DESC").limit(count).all
end end
private private

View File

@ -10,17 +10,17 @@
<td colspan="2" valign="top" width="50" ><img src="/images/new/news.png" width="40" height="40"/></td> <td colspan="2" valign="top" width="50" ><img src="/images/new/news.png" width="40" height="40"/></td>
<td><table width="580px" border="0"> <td><table width="580px" border="0">
<tr> <tr>
<td colspan="2" valign="top"><strong> <%=link_to contestnotification.author,contestnotification_path(contestnotification)%></strong> <td colspan="2" valign="top"><strong> <%=link_to contestnotifications.author,contestnotifications_path(contestnotifications)%></strong>
<a class="font_lighter"><%= l(:label_project_newshare) %></a> <%= link_to h(contestnotification.title), news_path(contestnotification) %> <a class="font_lighter"><%= l(:label_project_newshare) %></a> <%= link_to h(contestnotifications.title), news_path(contestnotifications) %>
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2" width="580px" ><p class="font_description"><%=h contestnotification.description%></p></td> <td colspan="2" width="580px" ><p class="font_description"><%=h contestnotifications.description%></p></td>
</tr> </tr>
<tr> <tr>
<td align="left"><a class="font_lighter"> <%= contestnotification.created_on %></a></td> <td align="left"><a class="font_lighter"> <%= contestnotifications.created_on %></a></td>
<td width="200" align="right" class="a"><%= link_to l(:label_project_newother),contestnotification_path(contestnotification)%> <td width="200" align="right" class="a"><%= link_to l(:label_project_newother),contestnotifications_path(contestnotifications)%>
<%= "(#{l(:label_x_comments, :count => contestnotification.comments_count)})" if contestnotification.comments_count > 0 %> <%= "(#{l(:label_x_comments, :count => contestnotifications.comments_count)})" if contestnotifications.comments_count > 0 %>
</td> </td>
</tr> </tr>
</table></td> </table></td>

View File

@ -41,7 +41,7 @@
<% end %> --> <% end %> -->
<%= error_messages_for @contestnotification %> <%= error_messages_for @contestnotifications %>
<div class="add_frame_header" > <div class="add_frame_header" >
<% str =l(:label_news_new) %> <% str =l(:label_news_new) %>
</div> </div>
@ -49,7 +49,7 @@
<p><%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %></p> <p><%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %></p>
<!-- <p style="margin-left:-10px;"><%= f.text_area :summary, :cols => 60, :rows => 2, :style => "width:490px;margin-left:10px;" %></p> --> <!-- <p style="margin-left:-10px;"><%= f.text_area :summary, :cols => 60, :rows => 2, :style => "width:490px;margin-left:10px;" %></p> -->
<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %></p> <p><%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %></p>
<p id="attachments_form" style="margin-left:-10px;"><label style="padding-right: 15px;"><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @contestnotification} %></p> <p id="attachments_form" style="margin-left:-10px;"><label style="padding-right: 15px;"><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @contestnotifications} %></p>
</div> </div>
<%= wikitoolbar_for 'news_description' %> <%= wikitoolbar_for 'news_description' %>

View File

@ -7,10 +7,10 @@
<h3><%=l(:label_news)%></h3> <h3><%=l(:label_news)%></h3>
<%= labelled_form_for @contestnotification, :html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %> <%= labelled_form_for @contestnotifications, :html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %> <%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %> <%= submit_tag l(:button_save) %>
<%= preview_link preview_news_path(:project_id => @contest, :id => @contestnotification), 'news-form' %> <%= preview_link preview_news_path(:project_id => @contest, :id => @contestnotifications), 'news-form' %>
<% end %> <% end %>
<div id="preview" class="wiki"></div> <div id="preview" class="wiki"></div>

View File

@ -49,11 +49,11 @@
<% if @contest && User.current.allowed_to?(:manage_news, @contest) %> <% if @contest && User.current.allowed_to?(:manage_news, @contest) %>
<div id="add-news" class="add_frame" style="display:none;"> <div id="add-news" class="add_frame" style="display:none;">
<%= labelled_form_for @contestnotification, :url => contest_contestnotification_index_path(@contest), <%= labelled_form_for @contestnotifications, :url => contest_contestnotifications_index_path(@contest),
:html => {:id => 'news-form', :multipart => true} do |f| %> :html => {:id => 'news-form', :multipart => true} do |f| %>
<%= render :partial => 'news/form', :locals => {:f => f} %> <%= render :partial => 'news/form', :locals => {:f => f} %>
<%= submit_tag l(:button_create), :class => 'whiteButton m3p10 h30', :name => nil %><!-- button-submit --> | <%= submit_tag l(:button_create), :class => 'whiteButton m3p10 h30', :name => nil %><!-- button-submit --> |
<%= preview_link preview_contestnotification_path(:contest_id => @contest), 'news-form', target='preview', {:class => 'whiteButton m3p10'} %> <%= preview_link preview_contestnotifications_path(:contest_id => @contest), 'news-form', target='preview', {:class => 'whiteButton m3p10'} %>
| |
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-news").hide()', :class => 'whiteButton m3p10' %> <%= link_to l(:button_cancel), "#", :onclick => '$("#add-news").hide()', :class => 'whiteButton m3p10' %>
<% end if @contest %> <% end if @contest %>
@ -61,33 +61,33 @@
</div> </div>
<% end %> <% end %>
<div> <div>
<% if @contestnotifications.empty? %> <% if @contestnotificationss.empty? %>
<p class="nodata"> <p class="nodata">
<%= l(:label_no_data) %> <%= l(:label_no_data) %>
</p> </p>
<% else %> <% else %>
<% @contestnotifications.each do |contestnotification| %> <% @contestnotificationss.each do |contestnotifications| %>
<table class="content-text-list"> <table class="content-text-list">
<tr> <tr>
<td colspan="2" valign="top" width="50"><%= link_to image_tag(url_to_avatar(contestnotification.author), :class => "avatar"), user_path(contestnotification.author) %></td> <td colspan="2" valign="top" width="50"><%= link_to image_tag(url_to_avatar(contestnotifications.author), :class => "avatar"), user_path(contestnotifications.author) %></td>
<td> <td>
<table width="580px" border="0"> <table width="580px" border="0">
<tr> <tr>
<td colspan="2" valign="top"> <td colspan="2" valign="top">
<strong><%= link_to_user(contestnotification.author) if contestnotification.respond_to?(:author) %></strong><span style="margin-left: 4px;" class="font_lighter"><%= l(:label_project_notice) %></span><span><%= link_to h(news.title), news_path(news) %></span> <strong><%= link_to_user(contestnotifications.author) if contestnotifications.respond_to?(:author) %></strong><span style="margin-left: 4px;" class="font_lighter"><%= l(:label_project_notice) %></span><span><%= link_to h(news.title), news_path(news) %></span>
<span style="float: right"><%= delete_link contestnotification_path(news) if User.current.allowed_to?(:manage_contestnotification, @contest) %> </span> <span style="float: right"><%= delete_link contestnotifications_path(news) if User.current.allowed_to?(:manage_contestnotification, @contest) %> </span>
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2" width="580px"> <td colspan="2" width="580px">
<span class="font_description"><%= textilizable(contestnotification, :description) %></span></td> <span class="font_description"><%= textilizable(contestnotifications, :description) %></span></td>
</tr> </tr>
<tr> <tr>
<td align="left"><span class="font_lighter"> <%= l :label_update_time %> <td align="left"><span class="font_lighter"> <%= l :label_update_time %>
&nbsp;<%= format_time(contestnotification.created_at) %></span></td> &nbsp;<%= format_time(contestnotifications.created_at) %></span></td>
<td width="350" align="right" class="a"><%= link_to l(:label_project_newother), contestnotification_path(contestnotification) %><%= "(#{l(:label_x_comments, :count => contestnotification.comments_count)})" if contestnotification.comments_count >= 0 %></td> <td width="350" align="right" class="a"><%= link_to l(:label_project_newother), contestnotifications_path(contestnotifications) %><%= "(#{l(:label_x_comments, :count => contestnotifications.comments_count)})" if contestnotifications.comments_count >= 0 %></td>
</tr> </tr>
</table> </table>
</td> </td>

View File

@ -7,7 +7,7 @@
<!-- <h3><%=l(:label_news_new)%></h3> --> <!-- <h3><%=l(:label_news_new)%></h3> -->
<%= labelled_form_for @contestnotification, :url => contest_contestnotification_index_path(@contest), <%= labelled_form_for @contestnotifications, :url => contest_contestnotifications_index_path(@contest),
:html => { :id => 'news-form', :multipart => true } do |f| %> :html => { :id => 'news-form', :multipart => true } do |f| %>
<%= render :partial => 'news/form', :locals => { :f => f } %> <%= render :partial => 'news/form', :locals => { :f => f } %>
<%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> <%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %>

View File

@ -36,24 +36,24 @@
<!--begin--> <!--begin-->
<div class="contextual"> <div class="contextual">
<%= watcher_link(@contestnotification, User.current) %> <%= watcher_link(@contestnotifications, User.current) %>
<%= link_to(l(:button_edit), <%= link_to(l(:button_edit),
edit_news_path(@news), edit_news_path(@news),
:class => 'icon icon-edit', :class => 'icon icon-edit',
:accesskey => accesskey(:edit), :accesskey => accesskey(:edit),
:onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_contestnotification, @contest) %> :onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_contestnotification, @contest) %>
<%= delete_link news_path(@contestnotification) if User.current.allowed_to?(:manage_contestnotification, @contest) %> <%= delete_link news_path(@contestnotifications) if User.current.allowed_to?(:manage_contestnotification, @contest) %>
</div> </div>
<h3><strong><%=h @contestnotification.title %></strong></h3> <h3><strong><%=h @contestnotifications.title %></strong></h3>
<% if authorize_for('contestnotification', 'edit') %> <% if authorize_for('contestnotifications', 'edit') %>
<div id="edit-news" style="display:none;"> <div id="edit-news" style="display:none;">
<%= labelled_form_for :contestnotification, @contestnotification, :url => contestnotification_path(@contestnotification), <%= labelled_form_for :contestnotifications, @contestnotifications, :url => contestnotifications_path(@contestnotifications),
:html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %> :html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %> <%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %> <%= submit_tag l(:button_save) %>
<%= preview_link preview_contestnotification_path(:contest_id => @contest, :id => @contestnotification), 'news-form',target='preview',{:class => ''} %> | <%= preview_link preview_contestnotifications_path(:contest_id => @contest, :id => @contestnotifications), 'news-form',target='preview',{:class => ''} %> |
<%= link_to l(:button_cancel), "#", :onclick => '$("#edit-news").hide(); return false;' %> <%= link_to l(:button_cancel), "#", :onclick => '$("#edit-news").hide(); return false;' %>
<% end %> <% end %>
<div id="preview" class="wiki"></div> <div id="preview" class="wiki"></div>
@ -63,16 +63,16 @@
<div id="comments" style="margin-bottom:16px;"> <div id="comments" style="margin-bottom:16px;">
<div style="margin:15px"> <div style="margin:15px">
<span class="font_description"> <%= textilizable(@contestnotification, :description) %> </span> <span class="font_description"> <%= textilizable(@contestnotifications, :description) %> </span>
<br/> <br/>
<%= link_to_attachments @contestnotification %> <%= link_to_attachments @contestnotifications %>
<br/> <br/>
<!--add comment--> <!--add comment-->
<% if @contestnotification.commentable? %> <% if @contestnotifications.commentable? %>
<p> <p>
<%= toggle_link l(:label_comment_add), "add_comment_form", :focus => "comment_comments" %> <%= toggle_link l(:label_comment_add), "add_comment_form", :focus => "comment_comments" %>
</p> </p>
<%= form_tag({:controller => 'comments', :action => 'create', :id => @contestnotification}, :id => "add_comment_form", :style => "display:none;") do %> <%= form_tag({:controller => 'comments', :action => 'create', :id => @contestnotifications}, :id => "add_comment_form", :style => "display:none;") do %>
<div class="box"> <div class="box">
<%= text_area 'comment', 'comments', :cols => 80, :rows => 15, :class => 'wiki-edit' %> <%= text_area 'comment', 'comments', :cols => 80, :rows => 15, :class => 'wiki-edit' %>
<%= wikitoolbar_for 'comment_comments' %> <%= wikitoolbar_for 'comment_comments' %>
@ -83,7 +83,7 @@
<% end %> <% end %>
<% end %> <% end %>
<% html_title @contestnotification.title -%> <% html_title @contestnotifications.title -%>
<% content_for :header_tags do %> <% content_for :header_tags do %>
<%= stylesheet_link_tag 'scm' %> <%= stylesheet_link_tag 'scm' %>
@ -112,7 +112,7 @@
</tr> </tr>
<tr> <tr>
<td align="left"><span class="font_lighter"> <%= format_time(comment.created_on) %></span></td> <td align="left"><span class="font_lighter"> <%= format_time(comment.created_on) %></span></td>
<td width="200" align="right" class="a"><%= link_to_if_authorized image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @contestnotification, :comment_id => comment}, <td width="200" align="right" class="a"><%= link_to_if_authorized image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @contestnotifications, :comment_id => comment},
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %></td> :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %></td>
</tr> </tr>
</table></td> </table></td>

View File

@ -147,8 +147,8 @@ Redmine::AccessControl.map do |map|
end end
map.project_module :contestnotification do |map| map.project_module :contestnotification do |map|
map.permission :manage_contestnotification, {:contestnotification => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member map.permission :manage_contestnotification, {:contestnotifications => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member
map.permission :view_contestnotification, {:contestnotification => [:index, :show]}, :public => true, :read => true map.permission :view_contestnotification, {:contestnotifications => [:index, :show]}, :public => true, :read => true
map.permission :comment_contestnotification, {:comments => :create} map.permission :comment_contestnotification, {:comments => :create}
end end