94 lines
1.5 KiB
Ruby
94 lines
1.5 KiB
Ruby
# -*- encoding : utf-8 -*-
|
|
|
|
class Admin::MOdrFilesController < ApplicationController
|
|
layout "admin"
|
|
before_action :auth_admin
|
|
|
|
before_action :admin_space
|
|
|
|
def admin_space
|
|
@admin_space = "default"
|
|
end
|
|
|
|
def index
|
|
@m_odr_files = MOdrFile.order(:name).all
|
|
|
|
end
|
|
|
|
def show
|
|
@m_odr_file = MOdrFile.find(params[:id])
|
|
|
|
end
|
|
|
|
def new
|
|
@m_odr_file = MOdrFile.new
|
|
|
|
end
|
|
|
|
def edit
|
|
@m_odr_file = MOdrFile.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
def download
|
|
@m_odr_file = MOdrFile.find(params[:id])
|
|
|
|
if @m_odr_file.file
|
|
send_file @m_odr_file.file.path, :disposition => (params[:disposition] || :inline)
|
|
end
|
|
end
|
|
|
|
|
|
def send_mail
|
|
@m_odr_file = MOdrFile.find(params[:id])
|
|
@m_odr_rep = @m_odr_file.m_odr_rep
|
|
|
|
@m_odr_rep.send_mail_type(params[:slug].to_s, @m_odr_file)
|
|
|
|
redirect_to [:admin, @m_odr_rep]
|
|
|
|
|
|
end
|
|
|
|
def create
|
|
@m_odr_file = MOdrFile.new(params.require(:m_odr_file).permit!)
|
|
|
|
if @m_odr_file.save
|
|
|
|
@m_odr_file.m_odr_rep.change_state("En cours de traitement")
|
|
|
|
else
|
|
render action: "new"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def update
|
|
@m_odr_file = MOdrFile.find(params[:id])
|
|
|
|
|
|
if @m_odr_file.update_attributes(params.require(:m_odr_file).permit!)
|
|
|
|
@m_odr_file.m_odr_rep.change_state("En cours de traitement")
|
|
|
|
else
|
|
render action: "edit"
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
def destroy
|
|
@m_odr_file = MOdrFile.find(params[:id])
|
|
@m_odr_file.destroy
|
|
|
|
end
|
|
end
|