1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-03-13 12:43:08 +00:00
redmine/mailing_lists/app/controllers/mailing_lists_controller.rb
Jean-Philippe Lang 73e822834d added mailing_list model and controller
git-svn-id: http://redmine.rubyforge.org/svn/branches/work@264 e93f8b46-1217-0410-a6f0-8f06a7374b81
2007-02-25 10:13:48 +00:00

60 lines
2.1 KiB
Ruby

# redMine - project management software
# Copyright (C) 2006-2007 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class MailingListsController < ApplicationController
layout 'base'
before_filter :find_project, :authorize
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
verify :method => :post, :only => [ :destroy ]
def add
@mailing_list = MailingList.new(:project => @project, :admin => logged_in_user)
@mailing_list.attributes = params[:mailing_list]
if request.post? and @mailing_list.save
flash[:notice] = l(:notice_successful_create)
redirect_to :controller => 'projects', :action => 'settings', :tab => 'mailing-lists', :id => @project
end
end
def edit
@mailing_list = MailingList.find(params[:id])
if request.post? and @mailing_list.update_attributes(params[:mailing_list])
flash[:notice] = l(:notice_successful_update)
redirect_to :controller => 'projects', :action => 'settings', :tab => 'mailing-lists', :id => @project
end
end
def destroy
@mailing_list.destroy
redirect_to :controller => 'projects', :action => 'settings', :tab => 'mailing-lists', :id => @project
end
private
def find_project
if params[:id]
@mailing_list = MailingList.find(params[:id])
@project = @mailing_list.project
else
@project = Project.find(params[:project_id])
end
rescue ActiveRecord::RecordNotFound
render_404
end
end