external link
This commit is contained in:
parent
aad7659b0e
commit
cc4bbc24e3
71
app/controllers/admin/external_links_controller.rb
Normal file
71
app/controllers/admin/external_links_controller.rb
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
# -*- encoding : utf-8 -*-
|
||||||
|
class Admin::ExternalLinksController < ApplicationController
|
||||||
|
before_filter :authenticate_admin!
|
||||||
|
layout "admin"
|
||||||
|
|
||||||
|
navigation :admins
|
||||||
|
|
||||||
|
def cible
|
||||||
|
@external_links = ExternalLink.all
|
||||||
|
render :layout => false
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@breadcrumb = [["liste des administrateurs", admin_admins_path],"Ajouter un administrateur"]
|
||||||
|
@external_link = ExternalLink.new
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
|
||||||
|
@external_link = ExternalLink.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def create
|
||||||
|
@external_link = ExternalLink.new(params[:external_link])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @external_link.save
|
||||||
|
flash[:notice] = "Le lien à été ajouté avec succès."
|
||||||
|
|
||||||
|
format.js
|
||||||
|
else
|
||||||
|
format.html { render :action => "new" }
|
||||||
|
format.js { render :action => "new" }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
|
||||||
|
@external_link = ExternalLink.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @external_link.update_attributes(params[:external_link])
|
||||||
|
|
||||||
|
|
||||||
|
format.js
|
||||||
|
else
|
||||||
|
|
||||||
|
format.js { render :action => "edit" }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@external_link = ExternalLink.find(params[:id])
|
||||||
|
@external_link.destroy
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
16
app/models/external_link.rb
Normal file
16
app/models/external_link.rb
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
class ExternalLink < ActiveRecord::Base
|
||||||
|
validates :url, :presence => true
|
||||||
|
|
||||||
|
|
||||||
|
def cible_name
|
||||||
|
"Lien externe : #{self.url}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def cible_url
|
||||||
|
|
||||||
|
self.url
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -62,6 +62,12 @@ Pharma::Application.routes.draw do
|
|||||||
namespace :admin do
|
namespace :admin do
|
||||||
root :to => "dashboard#index"
|
root :to => "dashboard#index"
|
||||||
resources :folders
|
resources :folders
|
||||||
|
resources :external_links do
|
||||||
|
collection do
|
||||||
|
get :cible
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
resources :articles
|
resources :articles
|
||||||
resources :admins
|
resources :admins
|
||||||
resources :menus
|
resources :menus
|
||||||
|
Loading…
x
Reference in New Issue
Block a user