Conflicts: app/controllers/application_controller.rb app/views/attachments/upload.js.erb app/views/courses/_homework_form.html.erb app/views/layouts/base_courses.html.erb app/views/users/_my_joinedcourse.html.erb db/schema.rb lib/redmine.rb lib/redmine/access_control.rbCourseModify
commit
099e8a0912
@ -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
|
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,14 @@
|
||||
class HomeworkUsersController < ApplicationController
|
||||
|
||||
#新增数据
|
||||
def create option
|
||||
user = HomeworkUser.new option
|
||||
user.save
|
||||
user
|
||||
end
|
||||
#删除数据
|
||||
def destory homework_user
|
||||
user = HomeworkUser.find homework_user
|
||||
user.destroy
|
||||
user
|
||||
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
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue