竞赛通知相关文件修改
This commit is contained in:
parent
9f29a6c82a
commit
bf71a38608
|
@ -0,0 +1,2 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -0,0 +1,4 @@
|
|||
/*
|
||||
Place all the styles related to the matching controller here.
|
||||
They will automatically be included in application.css.
|
||||
*/
|
|
@ -264,6 +264,12 @@ class ApplicationController < ActionController::Base
|
|||
render_404
|
||||
end
|
||||
|
||||
def find_contest_by_contest_id
|
||||
@contest = Contest.find(params[:contest_id])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
# Find a project based on params[:project_id]
|
||||
# TODO: some subclasses override this, see about merging their logic
|
||||
def find_optional_project
|
||||
|
@ -274,6 +280,14 @@ class ApplicationController < ActionController::Base
|
|||
render_404
|
||||
end
|
||||
|
||||
def find_optional_contest
|
||||
@contest = Contest.find(params[:contest_id]) unless params[:contest_id].blank?
|
||||
allowed = User.current.allowed_to?({:controller => params[:controller], :action => params[:action]}, @contest, :global => true)
|
||||
allowed ? true : deny_access
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
# Finds and sets @project based on @object.project
|
||||
def find_project_from_association
|
||||
render_404 unless @object.present?
|
||||
|
@ -281,6 +295,12 @@ class ApplicationController < ActionController::Base
|
|||
@project = @object.project
|
||||
end
|
||||
|
||||
def find_contest_from_association
|
||||
render_404 unless @object.present?
|
||||
|
||||
@contest = @object.contest
|
||||
end
|
||||
|
||||
def find_model_object
|
||||
model = self.class.model_object
|
||||
if model
|
||||
|
@ -291,6 +311,16 @@ class ApplicationController < ActionController::Base
|
|||
render_404
|
||||
end
|
||||
|
||||
def find_model_object_contest
|
||||
model = self.class.model_object
|
||||
if model
|
||||
@object = model.find(params[:id])
|
||||
self.instance_variable_set('@' + controller_name.singularize, @object) if @object
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def self.model_object(model)
|
||||
self.model_object = model
|
||||
end
|
||||
|
|
|
@ -19,6 +19,7 @@ class CommentsController < ApplicationController
|
|||
default_search_scope :news
|
||||
model_object News
|
||||
before_filter :find_model_object
|
||||
before_filter :find_model_object_contest
|
||||
before_filter :find_project_from_association
|
||||
before_filter :authorize
|
||||
|
||||
|
@ -50,4 +51,12 @@ class CommentsController < ApplicationController
|
|||
@comment = nil
|
||||
@news
|
||||
end
|
||||
|
||||
def find_model_object_contest
|
||||
super
|
||||
@contestnotification = @object
|
||||
@comment = nil
|
||||
@contestnotification
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,161 @@
|
|||
class ContestnotificationsController < ApplicationController
|
||||
# GET /contestnotifications
|
||||
# GET /contestnotifications.json
|
||||
layout 'base_contest'
|
||||
default_search_scope :contestnotification
|
||||
model_object Contestnotification
|
||||
before_filter :find_model_object_contest, :except => [:new, :create, :index]
|
||||
before_filter :find_contest_from_association, :except => [:new, :create, :index]
|
||||
before_filter :find_contest_by_contest_id, :only => [:new, :create]
|
||||
before_filter :authorize, :except => [:index]
|
||||
before_filter :find_optional_contest, :only => :index
|
||||
accept_rss_auth :index
|
||||
accept_api_auth :index
|
||||
|
||||
def index
|
||||
# @contestnotifications = Contestnotification.all
|
||||
#
|
||||
# respond_to do |format|
|
||||
# format.html # index.html.erb
|
||||
# format.json { render json: @contestnotifications }
|
||||
# end
|
||||
|
||||
### begin ###
|
||||
case params[:format]
|
||||
when 'xml', 'json'
|
||||
@offset, @limit = api_offset_and_limit
|
||||
else
|
||||
@limit = 10
|
||||
end
|
||||
|
||||
scope = @contest ? @contest.contestnotification.visible : Contestnotification.visible
|
||||
|
||||
@contestnotification_count = scope.count
|
||||
@contestnotification_pages = Paginator.new @contestnotification_count, @limit, params['page']
|
||||
@offset ||= @contestnotification_pages.offset
|
||||
@contestnotifications = scope.all(:include => [:author, :contest],
|
||||
:order => "#{Contestnotification.table_name}.created_on DESC",
|
||||
:offset => @offset,
|
||||
:limit => @limit)
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
@contestnotification = Contestnotification.new # for adding news inline
|
||||
render :layout => 'base_contest'
|
||||
}
|
||||
format.api
|
||||
format.atom { render_feed(@contestnotifications, :title => (@contest ? @contest.name : Setting.app_title) + ": #{l(:label_contest_notification)}") }
|
||||
end
|
||||
### end ###
|
||||
end
|
||||
|
||||
# GET /contestnotifications/1
|
||||
# GET /contestnotifications/1.json
|
||||
def show
|
||||
# @contestnotification = Contestnotification.find(params[:id])
|
||||
#
|
||||
# respond_to do |format|
|
||||
# format.html # show.html.erb
|
||||
# format.json { render json: @contestnotification }
|
||||
# end
|
||||
@comments = @contestnotification.comments
|
||||
@comments.reverse! if User.current.wants_comments_in_reverse_order?
|
||||
render :layout => 'base_contest'
|
||||
|
||||
end
|
||||
|
||||
# GET /contestnotifications/new
|
||||
# GET /contestnotifications/new.json
|
||||
def new
|
||||
# @contestnotification = Contestnotification.new
|
||||
#
|
||||
# respond_to do |format|
|
||||
# format.html # new.html.erb
|
||||
# format.json { render json: @contestnotification }
|
||||
# end
|
||||
@contestnotification = Contestnotification.new(:contest => @contest, :author => User.current)
|
||||
render :layout => 'base_contest'
|
||||
end
|
||||
|
||||
# GET /contestnotifications/1/edit
|
||||
def edit
|
||||
# @contestnotification = Contestnotification.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /contestnotifications
|
||||
# POST /contestnotifications.json
|
||||
def create
|
||||
# @contestnotification = Contestnotification.new(params[:contestnotification])
|
||||
#
|
||||
# respond_to do |format|
|
||||
# if @contestnotification.save
|
||||
# format.html { redirect_to @contestnotification, notice: 'Contestnotification was successfully created.' }
|
||||
# format.json { render json: @contestnotification, status: :created, location: @contestnotification }
|
||||
# else
|
||||
# format.html { render action: "new" }
|
||||
# format.json { render json: @contestnotification.errors, status: :unprocessable_entity }
|
||||
# end
|
||||
# end
|
||||
@contestnotification = Contestnotification.new(:contest => @contest, :author => User.current)
|
||||
@contestnotification.safe_attributes = params[:contestnotification]
|
||||
@news.save_attachments(params[:attachments])
|
||||
if @contestnotification.save
|
||||
render_attachment_warning_if_needed(@contestnotification)
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to project_news_index_path(@contest)
|
||||
else
|
||||
layout_file = 'base_contest'
|
||||
render :action => 'new', :layout => layout_file
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /contestnotifications/1
|
||||
# PUT /contestnotifications/1.json
|
||||
def update
|
||||
# @contestnotification = Contestnotification.find(params[:id])
|
||||
#
|
||||
# respond_to do |format|
|
||||
# if @contestnotification.update_attributes(params[:contestnotification])
|
||||
# format.html { redirect_to @contestnotification, notice: 'Contestnotification was successfully updated.' }
|
||||
# format.json { head :no_content }
|
||||
# else
|
||||
# format.html { render action: "edit" }
|
||||
# format.json { render json: @contestnotification.errors, status: :unprocessable_entity }
|
||||
# end
|
||||
# end
|
||||
@contestnotification.safe_attributes = params[:contestnotification]
|
||||
@contestnotification.save_attachments(params[:attachments])
|
||||
if @contestnotification.save
|
||||
render_attachment_warning_if_needed(@contestnotification)
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to contestnotification_path(@contestnotification)
|
||||
else
|
||||
render :action => 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /contestnotifications/1
|
||||
# DELETE /contestnotifications/1.json
|
||||
def destroy
|
||||
# @contestnotification = Contestnotification.find(params[:id])
|
||||
# @contestnotification.destroy
|
||||
#
|
||||
# respond_to do |format|
|
||||
# format.html { redirect_to contestnotifications_url }
|
||||
# format.json { head :no_content }
|
||||
# end
|
||||
@contestnotification.destroy
|
||||
redirect_to contest_contestnotification_index_path(@contest)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_optional_contest
|
||||
return true unless params[:contest_id]
|
||||
@contest = Contest.find(params[:contest_id])
|
||||
authorize
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
end
|
|
@ -21,6 +21,7 @@ class DocumentsController < ApplicationController
|
|||
model_object Document
|
||||
before_filter :find_project_by_project_id, :only => [:index, :new, :create]
|
||||
before_filter :find_model_object, :except => [:index, :new, :create]
|
||||
before_filter :find_model_object_contest, :except => [:index, :new, :create]
|
||||
before_filter :find_project_from_association, :except => [:index, :new, :create]
|
||||
before_filter :authorize , :except => [:index]#Added by young
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ class IssueCategoriesController < ApplicationController
|
|||
menu_item :settings
|
||||
model_object IssueCategory
|
||||
before_filter :find_model_object, :except => [:index, :new, :create]
|
||||
before_filter :find_model_object_contest, :except => [:index, :new, :create]
|
||||
before_filter :find_project_from_association, :except => [:index, :new, :create]
|
||||
before_filter :find_project_by_project_id, :only => [:index, :new, :create]
|
||||
before_filter :authorize
|
||||
|
@ -119,4 +120,10 @@ class IssueCategoriesController < ApplicationController
|
|||
super
|
||||
@category = @object
|
||||
end
|
||||
|
||||
def find_model_object_contest
|
||||
super
|
||||
@category = @object
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
class MembersController < ApplicationController
|
||||
model_object Member
|
||||
before_filter :find_model_object, :except => [:index, :create, :autocomplete]
|
||||
before_filter :find_model_object_contest, :except => [:index, :create, :autocomplete]
|
||||
before_filter :find_project_from_association, :except => [:index, :create, :autocomplete]
|
||||
before_filter :find_project_by_project_id, :only => [:index, :create, :autocomplete]
|
||||
before_filter :authorize
|
||||
|
|
|
@ -20,6 +20,7 @@ class VersionsController < ApplicationController
|
|||
menu_item :roadmap
|
||||
model_object Version
|
||||
before_filter :find_model_object, :except => [:index, :new, :create, :close_completed]
|
||||
before_filter :find_model_object_contest, :except => [:index, :new, :create]
|
||||
before_filter :find_project_from_association, :except => [:index, :new, :create, :close_completed]
|
||||
before_filter :find_project_by_project_id, :only => [:index, :new, :create, :close_completed]
|
||||
before_filter :authorize
|
||||
|
@ -154,6 +155,13 @@ class VersionsController < ApplicationController
|
|||
redirect_to settings_project_path(@project, :tab => 'versions')
|
||||
end
|
||||
|
||||
def close_completed_contest
|
||||
if request.put?
|
||||
@contest.close_completed_versions
|
||||
end
|
||||
redirect_to settings_contest_path(@contest, :tab => 'versions')
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @version.fixed_issues.empty?
|
||||
@version.destroy
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
module ContestnotificationsHelper
|
||||
end
|
|
@ -13,6 +13,7 @@ class Contest < ActiveRecord::Base
|
|||
has_many :join_in_competitions, foreign_key: 'competition_id', :dependent => :destroy
|
||||
has_many :join_in_contests, class_name: 'JoinInCompetition', foreign_key: 'competition_id', :dependent => :destroy
|
||||
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
|
||||
has_many :contestnotification, :dependent => :destroy, :include => :author
|
||||
|
||||
|
||||
|
||||
|
@ -93,6 +94,17 @@ class Contest < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
# Closes open and locked project versions that are completed
|
||||
def close_completed_versions_contest
|
||||
Version.transaction do
|
||||
versions.where(:status => %w(open locked)).all.each do |version|
|
||||
if version.completed?
|
||||
version.update_attribute(:status, 'closed')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def set_commit(commit)
|
||||
self.update_attribute(:commit, commit)
|
||||
end
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
class Contestnotification < ActiveRecord::Base
|
||||
attr_accessible :author_id, :comments_count, :contest_id, :description, :summary, :title
|
||||
|
||||
include Redmine::SafeAttributes
|
||||
belongs_to :contest
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_at"
|
||||
# fq
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
|
||||
validates_presence_of :title, :description
|
||||
validates_length_of :title, :maximum => 60
|
||||
validates_length_of :summary, :maximum => 255
|
||||
|
||||
acts_as_attachable :delete_permission => :manage_contestnotification
|
||||
acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], :include => :contest
|
||||
acts_as_event :url => Proc.new {|o| {:controller => 'contestnotification', :action => 'show', :id => o.id}}
|
||||
acts_as_activity_provider :find_options => {:include => [:contest, :author]},
|
||||
:author_key => :author_id
|
||||
acts_as_watchable
|
||||
|
||||
after_create :add_author_as_watcher, :reset_counters!
|
||||
|
||||
after_create :act_as_activity
|
||||
|
||||
|
||||
# scope :visible, lambda {|*args|
|
||||
# includes(:contest).where(Contest.allowed_to_condition(args.shift || User.current, :view_news, *args))
|
||||
# }
|
||||
|
||||
safe_attributes 'title', 'summary', 'description'
|
||||
|
||||
def visible?(user=User.current)
|
||||
!user.nil? && user.allowed_to?(:view_contestnotification, contest)
|
||||
end
|
||||
|
||||
# Returns true if the news can be commented by user
|
||||
def commentable?(user=User.current)
|
||||
user.allowed_to?(:comment_contestnotification, contest)
|
||||
end
|
||||
|
||||
def recipients
|
||||
contest.users.select {|user| user.notify_about?(self)}.map(&:mail)
|
||||
end
|
||||
|
||||
# returns latest news for contests visible by user
|
||||
def self.latest(user = User.current, count = 5)
|
||||
visible(user).includes([:author, :contest]).order("#{Contestnotification.table_name}.created_on DESC").limit(count).all
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def add_author_as_watcher
|
||||
Watcher.create(:watchable => self, :user => author)
|
||||
end
|
||||
## fq
|
||||
def act_as_activity
|
||||
self.acts << Activity.new(:user_id => self.author_id)
|
||||
end
|
||||
|
||||
end
|
|
@ -109,6 +109,7 @@ class User < Principal
|
|||
# added by bai
|
||||
has_many :join_in_contests, :dependent => :destroy
|
||||
has_many :news, :foreign_key => 'author_id'
|
||||
has_many :contestnotification, :foreign_key => 'author_id'
|
||||
has_many :comments, :foreign_key => 'author_id'
|
||||
has_many :wiki_contents, :foreign_key => 'author_id'
|
||||
has_many :journals
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<%= form_for(@contestnotification) do |f| %>
|
||||
<% if @contestnotification.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@contestnotification.errors.count, "error") %> prohibited this contestnotification from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @contestnotification.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :contest_id %><br />
|
||||
<%= f.number_field :contest_id %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :title %><br />
|
||||
<%= f.text_field :title %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :summary %><br />
|
||||
<%= f.text_field :summary %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :description %><br />
|
||||
<%= f.text_field :description %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :author_id %><br />
|
||||
<%= f.number_field :author_id %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :comments_count %><br />
|
||||
<%= f.number_field :comments_count %>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -0,0 +1,6 @@
|
|||
<h1>Editing contestnotification</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @contestnotification %> |
|
||||
<%= link_to 'Back', contestnotifications_path %>
|
|
@ -0,0 +1,133 @@
|
|||
<!-- <h1>Listing contestnotifications</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Contest</th>
|
||||
<th>Title</th>
|
||||
<th>Summary</th>
|
||||
<th>Description</th>
|
||||
<th>Author</th>
|
||||
<th>Comments count</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @contestnotifications.each do |contestnotification| %>
|
||||
<tr>
|
||||
<td><%= contestnotification.contest_id %></td>
|
||||
<td><%= contestnotification.title %></td>
|
||||
<td><%= contestnotification.summary %></td>
|
||||
<td><%= contestnotification.description %></td>
|
||||
<td><%= contestnotification.author_id %></td>
|
||||
<td><%= contestnotification.comments_count %></td>
|
||||
<td><%= link_to 'Show', contestnotification %></td>
|
||||
<td><%= link_to 'Edit', edit_contestnotification_path(contestnotification) %></td>
|
||||
<td><%= link_to 'Destroy', contestnotification, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to 'New Contestnotification', new_contestnotification_path %> -->
|
||||
|
||||
<!--begin-->
|
||||
<%
|
||||
btn_tips = l(:label_news_new)
|
||||
label_tips = l(:label_news)
|
||||
%>
|
||||
|
||||
<span style="font-size: 16px; border-bottom:1px solid #f0f0f0; margin-right: 15px;">
|
||||
<%= label_tips %>
|
||||
</span>
|
||||
|
||||
<%= link_to(btn_tips,
|
||||
new_contest_contestnotification_path(@contest),
|
||||
:class => 'icon icon-add',
|
||||
:onclick => 'showAndScrollTo("add-news", "news_title"); return false;') %>
|
||||
|
||||
<% if @contest && User.current.allowed_to?(:manage_news, @contest) %>
|
||||
<div id="add-news" class="add_frame" style="display:none;">
|
||||
<%= labelled_form_for @contestnotification, :url => contest_contestnotification_index_path(@contest),
|
||||
:html => {:id => 'news-form', :multipart => true} do |f| %>
|
||||
<%= render :partial => 'news/form', :locals => {:f => f} %>
|
||||
<%= 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'} %>
|
||||
|
|
||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-news").hide()', :class => 'whiteButton m3p10' %>
|
||||
<% end if @contest %>
|
||||
<div id="preview" class="wiki"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div>
|
||||
<% if @contestnotifications.empty? %>
|
||||
<p class="nodata">
|
||||
<%= l(:label_no_data) %>
|
||||
</p>
|
||||
<% else %>
|
||||
<% @contestnotifications.each do |contestnotification| %>
|
||||
|
||||
<table class="content-text-list">
|
||||
<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>
|
||||
<table width="580px" border="0">
|
||||
|
||||
<tr>
|
||||
<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>
|
||||
<span style="float: right"><%= delete_link contestnotification_path(news) if User.current.allowed_to?(:manage_contestnotification, @contest) %> </span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" width="580px">
|
||||
<span class="font_description"><%= textilizable(contestnotification, :description) %></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left"><span class="font_lighter"> <%= l :label_update_time %>
|
||||
: <%= format_time(contestnotification.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>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<!--end-->
|
||||
<div style="padding-right: 10px">
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<%= pagination_links_full @news_pages %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<% other_formats_links do |f| %>
|
||||
<%= f.link_to 'Atom', :url => {:project_id => @project, :key => User.current.rss_key} %>
|
||||
<% end %>
|
||||
|
||||
<% content_for :header_tags do %>
|
||||
<%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %>
|
||||
<%= stylesheet_link_tag 'scm' %>
|
||||
<% end %>
|
||||
|
||||
<% html_title(l(:label_news_plural)) -%>
|
||||
</div>
|
||||
|
||||
<script type='text/javascript'>
|
||||
$(document).ready(function ($) {
|
||||
$('.content-text-list').each(function () {
|
||||
$(this).find('.delete_icon').hide();
|
||||
$(this).mouseenter(function (event) {
|
||||
$(this).find('.delete_icon').show();
|
||||
});
|
||||
$(this).mouseleave(function (event) {
|
||||
$(this).find('.delete_icon').hide();
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!--end-->
|
|
@ -0,0 +1,16 @@
|
|||
<!-- <h1>New contestnotification</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', contestnotifications_path %> -->
|
||||
|
||||
|
||||
<!-- <h3><%=l(:label_news_new)%></h3> -->
|
||||
|
||||
<%= labelled_form_for @contestnotification, :url => contest_contestnotification_index_path(@contest),
|
||||
:html => { :id => 'news-form', :multipart => true } do |f| %>
|
||||
<%= render :partial => 'news/form', :locals => { :f => f } %>
|
||||
<%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %>
|
||||
<%= preview_link preview_news_path(:project_id => @project), 'news-form' ,target='preview',{:class => 'whiteButton m3p10'}%>
|
||||
<% end %>
|
||||
<div id="preview" class="wiki"></div>
|
|
@ -0,0 +1,35 @@
|
|||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<b>Contest:</b>
|
||||
<%= @contestnotification.contest_id %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Title:</b>
|
||||
<%= @contestnotification.title %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Summary:</b>
|
||||
<%= @contestnotification.summary %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Description:</b>
|
||||
<%= @contestnotification.description %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Author:</b>
|
||||
<%= @contestnotification.author_id %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Comments count:</b>
|
||||
<%= @contestnotification.comments_count %>
|
||||
</p>
|
||||
|
||||
|
||||
<%= link_to 'Edit', edit_contestnotification_path(@contestnotification) %> |
|
||||
<%= link_to 'Back', contestnotifications_path %>
|
|
@ -1961,6 +1961,8 @@ zh:
|
|||
label_attendingcontestwork_deposit_project: 托管项目
|
||||
label_attendingcontestwork_sorting_intimation: 您可以重新打分,打分结果以最后一次打分为主!
|
||||
|
||||
label_contest_notification: 竞赛通知
|
||||
|
||||
#end
|
||||
|
||||
# ajax异步验证
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
RedmineApp::Application.routes.draw do
|
||||
resources :contestnotifications
|
||||
|
||||
|
||||
resources :homework_users
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
class CreateContestnotifications < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :contestnotifications do |t|
|
||||
t.integer :contest_id
|
||||
t.string :title
|
||||
t.string :summary
|
||||
t.string :description
|
||||
t.integer :author_id
|
||||
t.integer :comments_count
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
13
db/schema.rb
13
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20140526104509) do
|
||||
ActiveRecord::Schema.define(:version => 20140530010015) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -210,6 +210,17 @@ ActiveRecord::Schema.define(:version => 20140526104509) do
|
|||
t.string "reward"
|
||||
end
|
||||
|
||||
create_table "contestnotifications", :force => true do |t|
|
||||
t.integer "contest_id"
|
||||
t.string "title"
|
||||
t.string "summary"
|
||||
t.string "description"
|
||||
t.integer "author_id"
|
||||
t.integer "comments_count"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "contests", :force => true do |t|
|
||||
t.string "name"
|
||||
t.string "budget", :default => ""
|
||||
|
|
|
@ -146,6 +146,12 @@ Redmine::AccessControl.map do |map|
|
|||
map.permission :comment_news, {:comments => :create}
|
||||
end
|
||||
|
||||
map.project_module :contestnotification do |map|
|
||||
map.permission :manage_contestnotification, {:contestnotification => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member
|
||||
map.permission :view_contestnotification, {:contestnotification => [:index, :show]}, :public => true, :read => true
|
||||
map.permission :comment_contestnotification, {:comments => :create}
|
||||
end
|
||||
|
||||
map.project_module :documents do |map|
|
||||
map.permission :add_documents, {:documents => [:new, :create, :add_attachment]}, :require => :loggedin
|
||||
map.permission :edit_documents, {:documents => [:edit, :update, :add_attachment]}, :require => :loggedin
|
||||
|
@ -390,6 +396,7 @@ Redmine::Activity.map do |activity|
|
|||
activity.register :issues, :class_name => %w(Issue Journal)
|
||||
activity.register :changesets
|
||||
activity.register :news
|
||||
activity.register :contestnotification
|
||||
activity.register :documents, :class_name => %w(Document Attachment)
|
||||
activity.register :files, :class_name => 'Attachment'
|
||||
activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false
|
||||
|
@ -405,6 +412,7 @@ end
|
|||
Redmine::Search.map do |search|
|
||||
search.register :issues
|
||||
search.register :news
|
||||
search.register :contestnotification
|
||||
search.register :documents
|
||||
search.register :changesets
|
||||
search.register :wiki_pages
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
|
||||
one:
|
||||
contest_id: 1
|
||||
title: MyString
|
||||
summary: MyString
|
||||
description: MyString
|
||||
author_id: 1
|
||||
comments_count: 1
|
||||
|
||||
two:
|
||||
contest_id: 1
|
||||
title: MyString
|
||||
summary: MyString
|
||||
description: MyString
|
||||
author_id: 1
|
||||
comments_count: 1
|
|
@ -0,0 +1,49 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ContestnotificationsControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@contestnotification = contestnotifications(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:contestnotifications)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create contestnotification" do
|
||||
assert_difference('Contestnotification.count') do
|
||||
post :create, contestnotification: { author_id: @contestnotification.author_id, comments_count: @contestnotification.comments_count, contest_id: @contestnotification.contest_id, description: @contestnotification.description, summary: @contestnotification.summary, title: @contestnotification.title }
|
||||
end
|
||||
|
||||
assert_redirected_to contestnotification_path(assigns(:contestnotification))
|
||||
end
|
||||
|
||||
test "should show contestnotification" do
|
||||
get :show, id: @contestnotification
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @contestnotification
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update contestnotification" do
|
||||
put :update, id: @contestnotification, contestnotification: { author_id: @contestnotification.author_id, comments_count: @contestnotification.comments_count, contest_id: @contestnotification.contest_id, description: @contestnotification.description, summary: @contestnotification.summary, title: @contestnotification.title }
|
||||
assert_redirected_to contestnotification_path(assigns(:contestnotification))
|
||||
end
|
||||
|
||||
test "should destroy contestnotification" do
|
||||
assert_difference('Contestnotification.count', -1) do
|
||||
delete :destroy, id: @contestnotification
|
||||
end
|
||||
|
||||
assert_redirected_to contestnotifications_path
|
||||
end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ContestnotificationTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ContestnotificationsHelperTest < ActionView::TestCase
|
||||
end
|
Loading…
Reference in New Issue