commit
955fece267
@ -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,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,4 @@
|
||||
/*
|
||||
Place all the styles related to the matching controller here.
|
||||
They will automatically be included in application.css.
|
||||
*/
|
@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the notificationcomments controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
@ -0,0 +1,187 @@
|
||||
class ContestnotificationsController < ApplicationController
|
||||
# GET /contestnotifications
|
||||
# GET /contestnotifications.json
|
||||
layout 'base_newcontest'
|
||||
default_search_scope :contestnotifications
|
||||
model_object Contestnotification
|
||||
# before_filter :find_model_object, :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 :find_contest
|
||||
before_filter :find_author
|
||||
# before_filter :authorize, :except => [:index]
|
||||
before_filter :find_optional_contest, :only => [:index]
|
||||
accept_rss_auth :index
|
||||
accept_api_auth :index
|
||||
|
||||
before_filter :access_edit_destroy, only: [:edit ,:update, :destroy]
|
||||
|
||||
def find_author
|
||||
@user = @contest.author
|
||||
render_404 if @user.nil?
|
||||
end
|
||||
def find_contest
|
||||
@contest = Contest.find(params[:contest_id])
|
||||
render_404 if @contest.nil?
|
||||
end
|
||||
|
||||
|
||||
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.contestnotifications.visible : Contestnotifications.visible
|
||||
|
||||
@contestnotifications_count = scope.count
|
||||
@contestnotifications_pages = Paginator.new @contestnotifications_count, @limit, params['page']
|
||||
@offset ||= @contestnotifications_pages.offset
|
||||
@contestnotificationss = scope.all(:include => [:author, :contest],
|
||||
:order => "#{Contestnotification.table_name}.created_at DESC",
|
||||
:offset => @offset,
|
||||
:limit => @limit)
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
@contestnotification = Contestnotification.new # for adding news inline
|
||||
render :layout => 'base_newcontest'
|
||||
}
|
||||
format.api
|
||||
format.atom { render_feed(@contestnotificationss, :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
|
||||
@notificationcomments = @contestnotification.notificationcomments
|
||||
@notificationcomments.reverse! if User.current.wants_notificationcomments_in_reverse_order?
|
||||
render :layout => 'base_newcontest'
|
||||
|
||||
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_newcontest'
|
||||
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]
|
||||
@contestnotification.save_attachments(params[:attachments])
|
||||
if @contestnotification.save
|
||||
render_attachment_warning_if_needed(@contestnotification)
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to contest_contestnotifications_path(@contest)
|
||||
else
|
||||
layout_file = 'base_newcontest'
|
||||
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 = Contestnotification.find(params[:id])
|
||||
@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 contest_contestnotification_path(@contestnotification.contest, @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 = Contestnotification.find(params[:id])
|
||||
@contestnotification.destroy
|
||||
redirect_to contest_contestnotifications_path(@contest)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_optional_contest
|
||||
return true unless params[:id]
|
||||
@contest = Contest.find(params[:id])
|
||||
# authorize
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def access_edit_destroy
|
||||
if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?)
|
||||
return true
|
||||
else
|
||||
render_403
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,27 @@
|
||||
class NotificationcommentsController < ApplicationController
|
||||
# default_search_scope :contestnotifications
|
||||
# model_object Contestnotifications
|
||||
# before_filter :authorize
|
||||
|
||||
def create
|
||||
#raise Unauthorized unless @contestnotifications.notificationcommentable?
|
||||
@contest = Contest.find(params[:contest_id])
|
||||
@contestnotification = Contestnotification.find(params[:contestnotification_id])
|
||||
|
||||
# @notificaioncomment = Notificationcomment.new
|
||||
# @notificaioncomment.safe_attributes = params[:notificationcomment]
|
||||
# @notificaioncomment.author = User.current
|
||||
comment = @contestnotification.notificationcomments.new(params[:notificationcomment].merge(author_id: User.current.id))
|
||||
if comment.save
|
||||
flash[:notice] = l(:label_comment_added)
|
||||
end
|
||||
|
||||
redirect_to contest_contestnotification_path(@contest, @contestnotification)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@contestnotifications.notificaioncomments.find(params[:notificaioncomment_id]).destroy
|
||||
redirect_to contest_contestnotification_path(@contestnotifications)
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,2 @@
|
||||
module ContestnotificationsHelper
|
||||
end
|
@ -0,0 +1,2 @@
|
||||
module NotificationcommentsHelper
|
||||
end
|
@ -0,0 +1,63 @@
|
||||
class Contestnotification < ActiveRecord::Base
|
||||
#attr_accessible :author_id, :notificationcomments_count, :contest_id, :description, :summary, :title
|
||||
|
||||
include Redmine::SafeAttributes
|
||||
#Contestnotification::Notificationcomment
|
||||
belongs_to :contest
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
has_many :notificationcomments, as: :notificationcommented, :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_contestnotifications
|
||||
acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], :include => :contest
|
||||
acts_as_event :url => Proc.new {|o| {:controller => 'contestnotifications', :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
|
||||
|
||||
after_create :act_as_activity
|
||||
|
||||
|
||||
scope :visible, lambda {|*args|
|
||||
nil
|
||||
#includes(:contest).where(Contest.allowed_to_condition(args.shift || User.current, :view_contestnotifications, *args))
|
||||
}
|
||||
|
||||
safe_attributes 'title', 'summary', 'description'
|
||||
|
||||
def visible?(user=User.current)
|
||||
!user.nil? && user.allowed_to?(:view_contestnotifications, contest)
|
||||
end
|
||||
|
||||
# Returns true if the news can be commented by user
|
||||
def notificationcommentable?(user=User.current)
|
||||
user.allowed_to?(:notificationcomment_contestnotifications, 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_at 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
|
@ -0,0 +1,11 @@
|
||||
class Notificationcomment < ActiveRecord::Base
|
||||
attr_accessible :author_id, :notificationcommented_id, :notificationcommented_type, :notificationcomments
|
||||
|
||||
include Redmine::SafeAttributes
|
||||
belongs_to :notificationcommented, :polymorphic => true#, :counter_cache => true
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
|
||||
validates_presence_of :notificationcommented, :author, :notificationcomments
|
||||
|
||||
# safe_attributes 'notificationcomments'
|
||||
end
|
@ -0,0 +1,11 @@
|
||||
<%= error_messages_for @contestnotifications %>
|
||||
<div class="add_frame_header" >
|
||||
<%= l(:bale_news_notice) %>
|
||||
</div>
|
||||
<div class="box tabular">
|
||||
<p><%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %></p>
|
||||
<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %></p>
|
||||
|
||||
</div>
|
||||
|
||||
<%= wikitoolbar_for 'news_description' %>
|
@ -0,0 +1,28 @@
|
||||
<!--<p><%= link_to_project(news.project) + ': ' unless @project %>
|
||||
<table><tr><td><img src="/images/new/news.png" width="40" height="40"/></td><td><%= link_to h(news.title), news_path(news) %>
|
||||
<%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %>
|
||||
|
||||
<% unless news.summary.blank? %></td><td><span class="fontligher"><%=h news.summary %></span><% end %></td>
|
||||
<td><span class="author"><%= authoring news.created_on, news.author %></span></td></tr></table></p>-->
|
||||
|
||||
<table width="660px" border="0" align="center">
|
||||
<tr>
|
||||
<td colspan="2" valign="top" width="50" ><img src="/images/new/news.png" width="40" height="40"/></td>
|
||||
<td><table width="580px" border="0">
|
||||
<tr>
|
||||
<td colspan="2" valign="top"><strong> <%=link_to contestnotifications.author,contest_contestnotification_path(contestnotifications)%></strong>
|
||||
<a class="font_lighter"><%= l(:label_project_newshare) %></a> <%= link_to h(contestnotifications.title), contest_contestnotification_path(contestnotifications) %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" width="580px" ><p class="font_description"><%=h contestnotifications.description%></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left"><a class="font_lighter"> <%= contestnotifications.created_at %></a></td>
|
||||
<td width="200" align="right" class="a"><%= link_to l(:label_project_newother),contest_contestnotification_path(contestnotifications)%>
|
||||
<%= "(#{l(:label_x_comments, :count => contestnotifications.notificationcomments_count)})" if contestnotifications.notificationcomments_count > 0 %>
|
||||
</td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
</table>
|
@ -0,0 +1,12 @@
|
||||
<h3><%=l(:label_news)%></h3>
|
||||
|
||||
<%= labelled_form_for @contestnotification, url: contest_contestnotification_path, :html => { :id => 'contestnotifications-form', :multipart => true, :method => :put } do |f| %>
|
||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<%= preview_link preview_contestnotifications_path(id: @contestnotification), 'contestnotifications-form' %>
|
||||
<% end %>
|
||||
<div id="preview" class="wiki"></div>
|
||||
|
||||
<% content_for :header_tags do %>
|
||||
<%= stylesheet_link_tag 'scm' %>
|
||||
<% end %>
|
@ -0,0 +1,14 @@
|
||||
api.array :contestnotifications, api_meta(:total_count => @contestnotifications_count, :offset => @offset, :limit => @limit) do
|
||||
@contestnotificationss.each do |contestnotifications|
|
||||
api.contestnotifications do
|
||||
api.id contestnotifications.id
|
||||
api.contest(:id => contestnotifications.contest_id, :name => contestnotifications.contest.name) unless contestnotifications.contest.nil?
|
||||
api.author(:id => contestnotifications.author_id, :name => contestnotifications.author.name) unless contestnotifications.author.nil?
|
||||
|
||||
api.title contestnotifications.title
|
||||
api.summary contestnotifications.summary
|
||||
api.description contestnotifications.description
|
||||
api.created_at contestnotifications.created_at
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,97 @@
|
||||
<span style="font-size: 16px; border-bottom:1px solid #f0f0f0; margin-right: 15px;">
|
||||
<%= l(:label_notification) %>
|
||||
</span>
|
||||
|
||||
<% if User.current.logged? && User.current == @contest.author %>
|
||||
<%= link_to(l(:bale_news_notice),
|
||||
new_contest_contestnotification_path(@contest),
|
||||
:class => 'icon icon-add',
|
||||
:onclick => 'showAndScrollTo("add-contestnotifications", "contestnotifications_title"); return false;') %>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
||||
<% if @contest %>
|
||||
<div id="add-contestnotifications" class="add_frame" style="display:none;">
|
||||
<%= labelled_form_for @contestnotification, :url => contest_contestnotifications_path(@contest),
|
||||
:html => {:id => 'contestnotifications-form', :multipart => true} do |f| %>
|
||||
<%= render :partial => 'contestnotifications/form', :locals => {:f => f} %>
|
||||
<%= submit_tag l(:button_create), :class => 'whiteButton m3p10 h30', :name => nil %>
|
||||
<%#= preview_link preview_contestnotifications_path(:contest_id => @contest), 'contestnotifications-form', target='preview', {:class => 'whiteButton m3p10'} %>
|
||||
|
|
||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-contestnotifications").hide(); return false;', :class => 'whiteButton m3p10' %>
|
||||
<% end if @contest %>
|
||||
<div id="preview" class="wiki"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div>
|
||||
<% if @contestnotificationss.empty? %>
|
||||
<p class="nodata">
|
||||
<%= l(:label_no_data) %>
|
||||
</p>
|
||||
<% else %>
|
||||
<% @contestnotificationss.each do |contestnotifications| %>
|
||||
|
||||
<table class="content-text-list">
|
||||
<tr>
|
||||
<td colspan="2" valign="top" width="50"><%= link_to image_tag(url_to_avatar(contestnotifications.author), :class => "avatar"), user_path(contestnotifications.author) %></td>
|
||||
<td>
|
||||
<table width="580px" border="0">
|
||||
|
||||
<tr>
|
||||
<td colspan="2" valign="top">
|
||||
<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(contestnotifications.title), contest_contestnotification_path(@contest, contestnotifications) %></span>
|
||||
<span style="float: right">
|
||||
<%= link_to l(:button_edit), edit_contest_contestnotification_path(@contest, contestnotifications) if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?) %>
|
||||
<%= delete_link contest_contestnotification_path(@contest, contestnotifications) if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?) %>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" width="580px">
|
||||
<span class="font_description"><%= textilizable(contestnotifications, :description) %></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left"><span class="font_lighter"> <%= l :label_update_time %>
|
||||
<%= format_time(contestnotifications.created_at) %></span></td>
|
||||
<td width="350" align="right" class="a"><%= link_to l(:label_check_comment), contest_contestnotification_path(@contest, contestnotifications) %><%#= "(#{l(:label_x_comments, :count => contestnotifications.notificationcomments_count)})" if contestnotifications.notificationcomments_count >= 0 %></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<!--end-->
|
||||
<div style="padding-right: 10px">
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<%= pagination_links_full @contestnotifications_pages %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<% 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,9 @@
|
||||
|
||||
<%= labelled_form_for @contestnotification, :url => contest_contestnotifications_path(@contest), :html => { :id => 'contestnotifications-form', :multipart => true } do |f| %>
|
||||
<%= render :partial => 'contestnotifications/form', :locals => { :f => f } %>
|
||||
<%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %>
|
||||
<%= submit_tag l(:button_cancel), :class => "whiteButton m3p10 h30",:onclick => "cancel();" %>
|
||||
|
||||
|
||||
<% end %>
|
||||
<div id="preview" class="wiki"></div>
|
@ -0,0 +1,91 @@
|
||||
|
||||
<div class="contextual">
|
||||
<%= link_to(l(:button_edit),
|
||||
edit_contest_contestnotification_path(@contest, @contestnotification),
|
||||
:class => 'icon icon-edit',
|
||||
:accesskey => accesskey(:edit),
|
||||
:onclick => '$("#edit-contestnotifications").show(); return true;') if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?)%>
|
||||
<%= delete_link contest_contestnotification_path(@contest, @contestnotification) if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?) %>
|
||||
</div>
|
||||
|
||||
<h3><strong><%=h @contestnotification.title %></strong></h3>
|
||||
|
||||
<div id="edit-contestnotifications" style="display:none;">
|
||||
<%= labelled_form_for @contestnotification, :url => contest_contestnotification_path(@contest),
|
||||
:html => { :id => 'contestnotifications-form', :multipart => true, :method => :put } do |f| %>
|
||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#edit-contestnotifications").hide(); return false;' %>
|
||||
<% end %>
|
||||
<div id="preview" class="wiki"></div>
|
||||
</div>
|
||||
|
||||
<div id="notificationcomments" style="margin-bottom:16px;">
|
||||
|
||||
<div style="margin:15px">
|
||||
<span class="font_description"> <%= textilizable(@contestnotification, :description) %> </span>
|
||||
<br/>
|
||||
<%#= link_to_attachments @contestnotification %>
|
||||
<br/>
|
||||
<!--add comment-->
|
||||
|
||||
<% if User.current.logged? %>
|
||||
<p>
|
||||
<%= toggle_link l(:label_comment_add), "add_notificationcomment_form", :focus => "notificationcomment_notificationcomments" %>
|
||||
</p>
|
||||
<% else %>
|
||||
<%= l(:label_user_login_notificationcomment) %>
|
||||
<%= link_to l(:label_user_login_new), signin_path %>
|
||||
<% end %>
|
||||
|
||||
<%= form_tag( contest_contestnotification_notificationcomments_path(@contest, @contestnotification) , :id => "add_notificationcomment_form", :style => "display:none;") do %>
|
||||
<div class="box">
|
||||
<%= text_area 'notificationcomment', 'notificationcomments', :cols => 80, :rows => 15, :class => 'wiki-edit' %>
|
||||
<%= wikitoolbar_for 'notificationcomment_notificationcomments' %>
|
||||
</div>
|
||||
<p>
|
||||
<%= submit_tag l(:button_add) %>
|
||||
<%= submit_tag l(:button_cancel), :onclick => "cancel();" %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
|
||||
<% html_title @contestnotification.title -%>
|
||||
|
||||
<% content_for :header_tags do %>
|
||||
<%= stylesheet_link_tag 'scm' %>
|
||||
<% end %>
|
||||
|
||||
<!--dispaly comments-->
|
||||
<div class="line_heng"></div>
|
||||
</div>
|
||||
<h3 class="notificationcomments"><%= l(:label_comment_plural) %></h3>
|
||||
<% notificationcomments = @notificationcomments.reverse %>
|
||||
<% notificationcomments.each do |notificationcomment| %>
|
||||
<% next if notificationcomment.new_record? %>
|
||||
<table width="660px" border="0" align="center">
|
||||
<tr>
|
||||
<td colspan="2" valign="top" width="50" ><%= image_tag(url_to_avatar(notificationcomment.author), :class => "avatar")%></td>
|
||||
<td>
|
||||
<table width="580px" border="0">
|
||||
<tr>
|
||||
<td colspan="2" valign="top"><strong><%= link_to_user(notificationcomment.author) if notificationcomment.respond_to?(:author) %> </strong><span class="font_lighter"><%= l(:label_project_newadd) %></span><%= l(:label_comment_plural) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" width="580px" >
|
||||
<p class="font_description">
|
||||
<%= textilizable(notificationcomment.notificationcomments) %>
|
||||
</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left"><span class="font_lighter"> <%= format_time(notificationcomment.created_at) %></span></td>
|
||||
<td width="200" align="right" class="a"><%#= link_to_if_authorized_contest image_tag('delete.png'), {:controller => 'notificationcomments', :action => 'destroy', :id => @contestnotifications, :notificationcomment_id => notificationcomment},
|
||||
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end if @notificationcomments.any? %>
|
||||
</div>
|
||||
|
||||
<!--end-->
|
@ -1,6 +1,6 @@
|
||||
<div class="clearfix"></div>
|
||||
<div class="linkother">
|
||||
<a href="http://forge.trustie.net" class="link_other_item">项目托管平台</a>
|
||||
<a href="http://course.trustie.net" class="link_other_item">课程实践平台</a>
|
||||
<a href="http://contest.trustie.net" class="link_other_item">竞赛托管平台</a>
|
||||
<a href="http://forge.trustie.net" class="link_other_item"><%=l(:label_projects_management_platform)%></a>
|
||||
<a href="http://course.trustie.net" class="link_other_item"><%=l(:label_courses_management_platform)%></a>
|
||||
<a href="http://contest.trustie.net" class="link_other_item"><%=l(:label_contests_management_platform)%></a>
|
||||
</div>
|
@ -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 :notificationcomments_count
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,12 @@
|
||||
class CreateNotificationcomments < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :notificationcomments do |t|
|
||||
t.string :notificationcommented_type
|
||||
t.integer :notificationcommented_id
|
||||
t.integer :author_id
|
||||
t.text :notificationcomments
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -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,13 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
|
||||
one:
|
||||
notificationcommented_type: MyString
|
||||
notificationcommented_id: 1
|
||||
author_id: 1
|
||||
notificationcomments: MyText
|
||||
|
||||
two:
|
||||
notificationcommented_type: MyString
|
||||
notificationcommented_id: 1
|
||||
author_id: 1
|
||||
notificationcomments: MyText
|
@ -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 NotificationcommentsControllerTest < ActionController::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# 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
|
@ -0,0 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class NotificationcommentsHelperTest < ActionView::TestCase
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class NotificationcommentsTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
Reference in new issue