initial
This commit is contained in:
commit
d4484275e8
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
.bundle
|
||||
db/*.sqlite3
|
||||
db/schema.rb
|
||||
log/*.log
|
||||
tmp/**/*
|
||||
|
||||
public/assets/stylesheets/*
|
||||
|
||||
.sass-cache/**
|
||||
|
4
Capfile
Normal file
4
Capfile
Normal file
@ -0,0 +1,4 @@
|
||||
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
|
||||
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
|
||||
|
||||
load 'config/deploy' # remove this line to skip loading any of the default tasks
|
47
Gemfile
Normal file
47
Gemfile
Normal file
@ -0,0 +1,47 @@
|
||||
source 'http://rubygems.org'
|
||||
|
||||
gem 'rails', '3.0.6'
|
||||
|
||||
# Bundle edge Rails instead:
|
||||
# gem 'rails', :git => 'git://github.com/rails/rails.git'
|
||||
|
||||
gem 'sqlite3'
|
||||
|
||||
# Asset template engines
|
||||
|
||||
gem 'sass'
|
||||
|
||||
gem 'jquery-rails'
|
||||
|
||||
# Use unicorn as the web server
|
||||
# gem 'unicorn'
|
||||
|
||||
# Deploy with Capistrano
|
||||
gem 'capistrano'
|
||||
|
||||
# To use debugger
|
||||
# gem 'ruby-debug'
|
||||
|
||||
|
||||
|
||||
gem "simple-navigation"
|
||||
|
||||
gem "kaminari"
|
||||
gem 'formtastic'
|
||||
|
||||
gem "acts_as_tree"
|
||||
gem "acts_as_list"
|
||||
|
||||
gem 'rmagick'
|
||||
|
||||
gem 'carrierwave'
|
||||
|
||||
gem 'mimetype-fu'
|
||||
|
||||
gem "cancan"
|
||||
|
||||
gem "meta_where"
|
||||
gem 'meta_search'
|
||||
|
||||
gem "devise"
|
||||
gem "haml", ">= 3.0.0"
|
140
Gemfile.lock
Normal file
140
Gemfile.lock
Normal file
@ -0,0 +1,140 @@
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
abstract (1.0.0)
|
||||
actionmailer (3.0.6)
|
||||
actionpack (= 3.0.6)
|
||||
mail (~> 2.2.15)
|
||||
actionpack (3.0.6)
|
||||
activemodel (= 3.0.6)
|
||||
activesupport (= 3.0.6)
|
||||
builder (~> 2.1.2)
|
||||
erubis (~> 2.6.6)
|
||||
i18n (~> 0.5.0)
|
||||
rack (~> 1.2.1)
|
||||
rack-mount (~> 0.6.14)
|
||||
rack-test (~> 0.5.7)
|
||||
tzinfo (~> 0.3.23)
|
||||
activemodel (3.0.6)
|
||||
activesupport (= 3.0.6)
|
||||
builder (~> 2.1.2)
|
||||
i18n (~> 0.5.0)
|
||||
activerecord (3.0.6)
|
||||
activemodel (= 3.0.6)
|
||||
activesupport (= 3.0.6)
|
||||
arel (~> 2.0.2)
|
||||
tzinfo (~> 0.3.23)
|
||||
activeresource (3.0.6)
|
||||
activemodel (= 3.0.6)
|
||||
activesupport (= 3.0.6)
|
||||
activesupport (3.0.6)
|
||||
acts_as_list (0.1.2)
|
||||
acts_as_tree (0.1.1)
|
||||
arel (2.0.9)
|
||||
bcrypt-ruby (2.1.4)
|
||||
builder (2.1.2)
|
||||
cancan (1.6.4)
|
||||
capistrano (2.6.0)
|
||||
highline
|
||||
net-scp (>= 1.0.0)
|
||||
net-sftp (>= 2.0.0)
|
||||
net-ssh (>= 2.0.14)
|
||||
net-ssh-gateway (>= 1.1.0)
|
||||
carrierwave (0.5.3)
|
||||
activesupport (~> 3.0)
|
||||
devise (1.3.4)
|
||||
bcrypt-ruby (~> 2.1.2)
|
||||
orm_adapter (~> 0.0.3)
|
||||
warden (~> 1.0.3)
|
||||
erubis (2.6.6)
|
||||
abstract (>= 1.0.0)
|
||||
formtastic (1.2.3)
|
||||
actionpack (>= 2.3.7)
|
||||
activesupport (>= 2.3.7)
|
||||
i18n (~> 0.4)
|
||||
haml (3.1.1)
|
||||
highline (1.6.1)
|
||||
i18n (0.5.0)
|
||||
jquery-rails (1.0.2)
|
||||
railties (~> 3.0)
|
||||
thor (~> 0.14)
|
||||
kaminari (0.12.4)
|
||||
rails (>= 3.0.0)
|
||||
mail (2.2.19)
|
||||
activesupport (>= 2.3.6)
|
||||
i18n (>= 0.4.0)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
meta_search (1.0.5)
|
||||
actionpack (~> 3.0.2)
|
||||
activerecord (~> 3.0.2)
|
||||
activesupport (~> 3.0.2)
|
||||
arel (~> 2.0.2)
|
||||
meta_where (1.0.4)
|
||||
activerecord (~> 3.0.0)
|
||||
activesupport (~> 3.0.0)
|
||||
arel (~> 2.0.7)
|
||||
mime-types (1.16)
|
||||
mimetype-fu (0.1.2)
|
||||
net-scp (1.0.4)
|
||||
net-ssh (>= 1.99.1)
|
||||
net-sftp (2.0.5)
|
||||
net-ssh (>= 2.0.9)
|
||||
net-ssh (2.1.4)
|
||||
net-ssh-gateway (1.1.0)
|
||||
net-ssh (>= 1.99.1)
|
||||
orm_adapter (0.0.5)
|
||||
polyglot (0.3.1)
|
||||
rack (1.2.2)
|
||||
rack-mount (0.6.14)
|
||||
rack (>= 1.0.0)
|
||||
rack-test (0.5.7)
|
||||
rack (>= 1.0)
|
||||
rails (3.0.6)
|
||||
actionmailer (= 3.0.6)
|
||||
actionpack (= 3.0.6)
|
||||
activerecord (= 3.0.6)
|
||||
activeresource (= 3.0.6)
|
||||
activesupport (= 3.0.6)
|
||||
bundler (~> 1.0)
|
||||
railties (= 3.0.6)
|
||||
railties (3.0.6)
|
||||
actionpack (= 3.0.6)
|
||||
activesupport (= 3.0.6)
|
||||
rake (>= 0.8.7)
|
||||
thor (~> 0.14.4)
|
||||
rake (0.8.7)
|
||||
rmagick (2.13.1)
|
||||
sass (3.1.1)
|
||||
simple-navigation (3.2.0)
|
||||
activesupport (>= 2.3.2)
|
||||
sqlite3 (1.3.3)
|
||||
thor (0.14.6)
|
||||
treetop (1.4.9)
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (0.3.27)
|
||||
warden (1.0.4)
|
||||
rack (>= 1.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
acts_as_list
|
||||
acts_as_tree
|
||||
cancan
|
||||
capistrano
|
||||
carrierwave
|
||||
devise
|
||||
formtastic
|
||||
haml (>= 3.0.0)
|
||||
jquery-rails
|
||||
kaminari
|
||||
meta_search
|
||||
meta_where
|
||||
mimetype-fu
|
||||
rails (= 3.0.6)
|
||||
rmagick
|
||||
sass
|
||||
simple-navigation
|
||||
sqlite3
|
256
README
Normal file
256
README
Normal file
@ -0,0 +1,256 @@
|
||||
== Welcome to Rails
|
||||
|
||||
Rails is a web-application framework that includes everything needed to create
|
||||
database-backed web applications according to the Model-View-Control pattern.
|
||||
|
||||
This pattern splits the view (also called the presentation) into "dumb"
|
||||
templates that are primarily responsible for inserting pre-built data in between
|
||||
HTML tags. The model contains the "smart" domain objects (such as Account,
|
||||
Product, Person, Post) that holds all the business logic and knows how to
|
||||
persist themselves to a database. The controller handles the incoming requests
|
||||
(such as Save New Account, Update Product, Show Post) by manipulating the model
|
||||
and directing data to the view.
|
||||
|
||||
In Rails, the model is handled by what's called an object-relational mapping
|
||||
layer entitled Active Record. This layer allows you to present the data from
|
||||
database rows as objects and embellish these data objects with business logic
|
||||
methods. You can read more about Active Record in
|
||||
link:files/vendor/rails/activerecord/README.html.
|
||||
|
||||
The controller and view are handled by the Action Pack, which handles both
|
||||
layers by its two parts: Action View and Action Controller. These two layers
|
||||
are bundled in a single package due to their heavy interdependence. This is
|
||||
unlike the relationship between the Active Record and Action Pack that is much
|
||||
more separate. Each of these packages can be used independently outside of
|
||||
Rails. You can read more about Action Pack in
|
||||
link:files/vendor/rails/actionpack/README.html.
|
||||
|
||||
|
||||
== Getting Started
|
||||
|
||||
1. At the command prompt, create a new Rails application:
|
||||
<tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
|
||||
|
||||
2. Change directory to <tt>myapp</tt> and start the web server:
|
||||
<tt>cd myapp; rails server</tt> (run with --help for options)
|
||||
|
||||
3. Go to http://localhost:3000/ and you'll see:
|
||||
"Welcome aboard: You're riding Ruby on Rails!"
|
||||
|
||||
4. Follow the guidelines to start developing your application. You can find
|
||||
the following resources handy:
|
||||
|
||||
* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
|
||||
* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
|
||||
|
||||
|
||||
== Debugging Rails
|
||||
|
||||
Sometimes your application goes wrong. Fortunately there are a lot of tools that
|
||||
will help you debug it and get it back on the rails.
|
||||
|
||||
First area to check is the application log files. Have "tail -f" commands
|
||||
running on the server.log and development.log. Rails will automatically display
|
||||
debugging and runtime information to these files. Debugging info will also be
|
||||
shown in the browser on requests from 127.0.0.1.
|
||||
|
||||
You can also log your own messages directly into the log file from your code
|
||||
using the Ruby logger class from inside your controllers. Example:
|
||||
|
||||
class WeblogController < ActionController::Base
|
||||
def destroy
|
||||
@weblog = Weblog.find(params[:id])
|
||||
@weblog.destroy
|
||||
logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
|
||||
end
|
||||
end
|
||||
|
||||
The result will be a message in your log file along the lines of:
|
||||
|
||||
Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
|
||||
|
||||
More information on how to use the logger is at http://www.ruby-doc.org/core/
|
||||
|
||||
Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
|
||||
several books available online as well:
|
||||
|
||||
* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
|
||||
* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
|
||||
|
||||
These two books will bring you up to speed on the Ruby language and also on
|
||||
programming in general.
|
||||
|
||||
|
||||
== Debugger
|
||||
|
||||
Debugger support is available through the debugger command when you start your
|
||||
Mongrel or WEBrick server with --debugger. This means that you can break out of
|
||||
execution at any point in the code, investigate and change the model, and then,
|
||||
resume execution! You need to install ruby-debug to run the server in debugging
|
||||
mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
|
||||
|
||||
class WeblogController < ActionController::Base
|
||||
def index
|
||||
@posts = Post.all
|
||||
debugger
|
||||
end
|
||||
end
|
||||
|
||||
So the controller will accept the action, run the first line, then present you
|
||||
with a IRB prompt in the server window. Here you can do things like:
|
||||
|
||||
>> @posts.inspect
|
||||
=> "[#<Post:0x14a6be8
|
||||
@attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
|
||||
#<Post:0x14a6620
|
||||
@attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
|
||||
>> @posts.first.title = "hello from a debugger"
|
||||
=> "hello from a debugger"
|
||||
|
||||
...and even better, you can examine how your runtime objects actually work:
|
||||
|
||||
>> f = @posts.first
|
||||
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
|
||||
>> f.
|
||||
Display all 152 possibilities? (y or n)
|
||||
|
||||
Finally, when you're ready to resume execution, you can enter "cont".
|
||||
|
||||
|
||||
== Console
|
||||
|
||||
The console is a Ruby shell, which allows you to interact with your
|
||||
application's domain model. Here you'll have all parts of the application
|
||||
configured, just like it is when the application is running. You can inspect
|
||||
domain models, change values, and save to the database. Starting the script
|
||||
without arguments will launch it in the development environment.
|
||||
|
||||
To start the console, run <tt>rails console</tt> from the application
|
||||
directory.
|
||||
|
||||
Options:
|
||||
|
||||
* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
|
||||
made to the database.
|
||||
* Passing an environment name as an argument will load the corresponding
|
||||
environment. Example: <tt>rails console production</tt>.
|
||||
|
||||
To reload your controllers and models after launching the console run
|
||||
<tt>reload!</tt>
|
||||
|
||||
More information about irb can be found at:
|
||||
link:http://www.rubycentral.org/pickaxe/irb.html
|
||||
|
||||
|
||||
== dbconsole
|
||||
|
||||
You can go to the command line of your database directly through <tt>rails
|
||||
dbconsole</tt>. You would be connected to the database with the credentials
|
||||
defined in database.yml. Starting the script without arguments will connect you
|
||||
to the development database. Passing an argument will connect you to a different
|
||||
database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
|
||||
PostgreSQL and SQLite 3.
|
||||
|
||||
== Description of Contents
|
||||
|
||||
The default directory structure of a generated Ruby on Rails application:
|
||||
|
||||
|-- app
|
||||
| |-- controllers
|
||||
| |-- helpers
|
||||
| |-- mailers
|
||||
| |-- models
|
||||
| `-- views
|
||||
| `-- layouts
|
||||
|-- config
|
||||
| |-- environments
|
||||
| |-- initializers
|
||||
| `-- locales
|
||||
|-- db
|
||||
|-- doc
|
||||
|-- lib
|
||||
| `-- tasks
|
||||
|-- log
|
||||
|-- public
|
||||
| |-- images
|
||||
| |-- javascripts
|
||||
| `-- stylesheets
|
||||
|-- script
|
||||
|-- test
|
||||
| |-- fixtures
|
||||
| |-- functional
|
||||
| |-- integration
|
||||
| |-- performance
|
||||
| `-- unit
|
||||
|-- tmp
|
||||
| |-- cache
|
||||
| |-- pids
|
||||
| |-- sessions
|
||||
| `-- sockets
|
||||
`-- vendor
|
||||
`-- plugins
|
||||
|
||||
app
|
||||
Holds all the code that's specific to this particular application.
|
||||
|
||||
app/controllers
|
||||
Holds controllers that should be named like weblogs_controller.rb for
|
||||
automated URL mapping. All controllers should descend from
|
||||
ApplicationController which itself descends from ActionController::Base.
|
||||
|
||||
app/models
|
||||
Holds models that should be named like post.rb. Models descend from
|
||||
ActiveRecord::Base by default.
|
||||
|
||||
app/views
|
||||
Holds the template files for the view that should be named like
|
||||
weblogs/index.html.erb for the WeblogsController#index action. All views use
|
||||
eRuby syntax by default.
|
||||
|
||||
app/views/layouts
|
||||
Holds the template files for layouts to be used with views. This models the
|
||||
common header/footer method of wrapping views. In your views, define a layout
|
||||
using the <tt>layout :default</tt> and create a file named default.html.erb.
|
||||
Inside default.html.erb, call <% yield %> to render the view using this
|
||||
layout.
|
||||
|
||||
app/helpers
|
||||
Holds view helpers that should be named like weblogs_helper.rb. These are
|
||||
generated for you automatically when using generators for controllers.
|
||||
Helpers can be used to wrap functionality for your views into methods.
|
||||
|
||||
config
|
||||
Configuration files for the Rails environment, the routing map, the database,
|
||||
and other dependencies.
|
||||
|
||||
db
|
||||
Contains the database schema in schema.rb. db/migrate contains all the
|
||||
sequence of Migrations for your schema.
|
||||
|
||||
doc
|
||||
This directory is where your application documentation will be stored when
|
||||
generated using <tt>rake doc:app</tt>
|
||||
|
||||
lib
|
||||
Application specific libraries. Basically, any kind of custom code that
|
||||
doesn't belong under controllers, models, or helpers. This directory is in
|
||||
the load path.
|
||||
|
||||
public
|
||||
The directory available for the web server. Contains subdirectories for
|
||||
images, stylesheets, and javascripts. Also contains the dispatchers and the
|
||||
default HTML files. This should be set as the DOCUMENT_ROOT of your web
|
||||
server.
|
||||
|
||||
script
|
||||
Helper scripts for automation and generation.
|
||||
|
||||
test
|
||||
Unit and functional tests along with fixtures. When using the rails generate
|
||||
command, template test files will be generated for you and placed in this
|
||||
directory.
|
||||
|
||||
vendor
|
||||
External libraries that the application depends on. Also includes the plugins
|
||||
subdirectory. If the app has frozen rails, those gems also go here, under
|
||||
vendor/rails/. This directory is in the load path.
|
7
Rakefile
Normal file
7
Rakefile
Normal file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env rake
|
||||
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
||||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
||||
|
||||
require File.expand_path('../config/application', __FILE__)
|
||||
|
||||
PharmacieboissierCom::Application.load_tasks
|
2595
app/assets/stylesheets/admin/admin.scss
Normal file
2595
app/assets/stylesheets/admin/admin.scss
Normal file
File diff suppressed because it is too large
Load Diff
35
app/assets/stylesheets/connexion.scss
Normal file
35
app/assets/stylesheets/connexion.scss
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
*=require admin/core/reset
|
||||
*= require_self
|
||||
*= require admin/core/forms
|
||||
*= require admin/core/elements
|
||||
*= require admin/core/general
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
body {
|
||||
background: #3f94eb;
|
||||
font-family: verdana;
|
||||
padding:0px;
|
||||
margin:0px;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande", arial, helvetica, sans-serif; }
|
||||
body #title {
|
||||
width: 520px;
|
||||
margin: auto;
|
||||
margin-top: 10%;
|
||||
color: #9fc9f5;
|
||||
text-shadow: 0 1px 1px #3f94eb;
|
||||
padding: 0px;
|
||||
text-transform: uppercase; }
|
||||
body #main {
|
||||
background: white;
|
||||
width: 500px;
|
||||
padding: 10px;
|
||||
margin: auto;
|
||||
-webkit-box-shadow: #666666 0px 0px 20px;
|
||||
-moz-box-shadow: #666666 0px 0px 20px;
|
||||
box-shadow: #666666 0px 0px 20px; }
|
75
app/assets/stylesheets/mixins/_css3.scss
Normal file
75
app/assets/stylesheets/mixins/_css3.scss
Normal file
@ -0,0 +1,75 @@
|
||||
// ==== CSS3 SASS MIXINS ====
|
||||
// https://github.com/madr/css3-sass-mixins
|
||||
|
||||
// Should IE filters be used or not?
|
||||
// PROS: gradients, drop shadows etc will be handled by css.
|
||||
// CONS: will harm the site performance badly,
|
||||
// especially on sites with heavy rendering and scripting.
|
||||
$useIEFilters: 0; // might be 0 or 1. disabled by default.
|
||||
|
||||
@mixin border-radius ($values) {
|
||||
-moz-border-radius: $values;
|
||||
-webkit-border-radius: $values;
|
||||
border-radius: $values;
|
||||
}
|
||||
|
||||
@mixin box-shadow ($x, $y, $offset, $hex, $ie: $useIEFilters) {
|
||||
-moz-box-shadow: $x $y $offset $hex;
|
||||
-o-box-shadow: $x $y $offset $hex;
|
||||
-webkit-box-shadow: $x $y $offset $hex;
|
||||
box-shadow: $x $y $offset $hex;
|
||||
|
||||
@if $ie == 1 {
|
||||
$iecolor: '#' + red($hex) + green($hex) + blue($hex);
|
||||
filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=#{$x}, OffY=#{$y}, Color='#{$iecolor}');
|
||||
-ms-filter: quote(progid:DXImageTransform.Microsoft.dropshadow(OffX=#{$x}, OffY=#{$y}, Color='#{$iecolor}'));
|
||||
}
|
||||
}
|
||||
|
||||
@mixin linear-gradient($from, $to, $ie: $useIEFilters) {
|
||||
@if $ie != 1 {
|
||||
background-color: $to;
|
||||
}
|
||||
|
||||
background-image: -moz-linear-gradient(top, $from, $to);
|
||||
background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, $from),color-stop(1, $to));
|
||||
|
||||
@if $ie == 1 {
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$from}', endColorstr='#{$to}');
|
||||
-ms-filter: quote(progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$from}', endColorstr='#{$to}'));
|
||||
}
|
||||
}
|
||||
|
||||
@mixin rgba($hex, $alpha, $ie: $useIEFilters) {
|
||||
@if $ie == 1 {
|
||||
// this formula is not accurate enough, will be fixed with sass 3.1
|
||||
$hexopac: '#' + ceil((($alpha * 255)/16) *10) + $hex;
|
||||
background-color: none;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#{$hexopac}',EndColorStr='#{$hexopac}}');
|
||||
-ms-filter: quote(progid:DXImageTransform.Microsoft.gradient(startColorStr='#{$hexopac}',EndColorStr='#{$hexopac}'));
|
||||
}
|
||||
@else {
|
||||
background-color: $hex;
|
||||
background-color: rgba(red($hex), green($hex), blue($hex), $alpha);
|
||||
}
|
||||
}
|
||||
|
||||
@mixin rotate ($deg, $ie: $useIEFilters) {
|
||||
-moz-transform: rotate(#{$deg}deg);
|
||||
-o-transform: rotate(#{$deg}deg);
|
||||
-webkit-transform: rotate(#{$deg}deg);
|
||||
// not ready, impediment: cos required!
|
||||
//@if $ie == 1 {
|
||||
// filter: progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand', M11=0.99144486137381, M12=--0.130526192220052, M21=0.130526192220052, M22=0.99144486137381);
|
||||
// -ms-filter: quote(progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.99144486137381, M12=--0.130526192220052, M21=0.130526192220052, M22=0.99144486137381));
|
||||
// zoom: 1;
|
||||
//}
|
||||
}
|
||||
|
||||
@mixin transition ($value) {
|
||||
-moz-transition: $value;
|
||||
-o-transition: $value;
|
||||
-webkit-transition: $value;
|
||||
transition: $value;
|
||||
}
|
||||
// ==== /CSS3 SASS MIXINS ====
|
246
app/assets/stylesheets/public/public.scss
Normal file
246
app/assets/stylesheets/public/public.scss
Normal file
@ -0,0 +1,246 @@
|
||||
/*
|
||||
* FIXME: Introduce SCSS & Sprockets
|
||||
*= require_self
|
||||
*= require prettyPhoto
|
||||
*= require formtastic
|
||||
|
||||
|
||||
*= require_tree .
|
||||
|
||||
*/
|
||||
|
||||
|
||||
@import "../mixins/css3";
|
||||
|
||||
body {
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
font-size: 14px;
|
||||
font-family: "Verdana";
|
||||
color:#1d1d1d;
|
||||
}
|
||||
a {
|
||||
|
||||
color: #001c6d;
|
||||
text-decoration: none;
|
||||
|
||||
img {
|
||||
border: 0px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
color:#68c545;
|
||||
}
|
||||
}
|
||||
|
||||
#breadcrumb{
|
||||
color:#848484;
|
||||
|
||||
*{
|
||||
color:#848484;
|
||||
}
|
||||
}
|
||||
|
||||
#public_core{
|
||||
|
||||
margin:auto;
|
||||
width:960px;
|
||||
margin-top:20px;
|
||||
@include box-shadow(0px, 0px, 10px, rgba(0, 0, 0, 0.4));
|
||||
border:1px solid #87c51c;
|
||||
background:white;
|
||||
|
||||
|
||||
|
||||
#header{
|
||||
padding:1px;
|
||||
|
||||
table{
|
||||
width:100%;
|
||||
}
|
||||
|
||||
#logo {
|
||||
width:160px;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
|
||||
h1{
|
||||
margin-top:0px;
|
||||
text-align:center;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#menu_top {
|
||||
background:#87c51c;
|
||||
text-align:center;
|
||||
|
||||
a {
|
||||
display:inline-block;
|
||||
padding: 5px 10px 5px 10px;
|
||||
text-transform:uppercase;
|
||||
color:white;
|
||||
text-decoration: none;
|
||||
min-width:100px;
|
||||
text-align:center;
|
||||
border-bottom:2px solid transparent;
|
||||
|
||||
&:hover{
|
||||
border-color : #001871;
|
||||
color:white;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#page_main {
|
||||
#sidebar {
|
||||
float: left;
|
||||
width: 240px;
|
||||
position: relative;
|
||||
min-height: 400px;
|
||||
background:#eaeaea;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#menu_left ul {
|
||||
list-style: none;
|
||||
padding-left: 0px;
|
||||
|
||||
li{
|
||||
|
||||
|
||||
a{
|
||||
display:block;
|
||||
padding:5px;
|
||||
color:#3f3f3f;
|
||||
|
||||
border-bottom: 1px solid white;
|
||||
|
||||
&:hover{
|
||||
background:#f8f8f8;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ul {
|
||||
//padding-left: 20px;
|
||||
padding-bottom:10px;
|
||||
li{
|
||||
a{
|
||||
color:#5b5b5b;
|
||||
padding-left: 20px;
|
||||
border-bottom: 1px dotted white;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#public #header {
|
||||
width: 960px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
body .clear {
|
||||
clear: both; }
|
||||
|
||||
|
||||
|
||||
|
||||
body #page_main {
|
||||
width: 960px;
|
||||
margin: auto; }
|
||||
|
||||
body #page_main #content {
|
||||
float: left;
|
||||
width: 700px;
|
||||
padding:10px;
|
||||
|
||||
|
||||
}
|
||||
body #menu_bottom {
|
||||
margin: auto;
|
||||
width: 960px;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px; }
|
||||
body #menu_bottom #left_bottom {
|
||||
float: left; }
|
||||
body #menu_bottom #right_bottom {
|
||||
float: right; }
|
||||
body .article {
|
||||
border: 1px solid RGB(129, 178, 11);
|
||||
padding: 10px;
|
||||
margin-bottom: 10px; }
|
||||
body .article h3 {
|
||||
color: RGB(129, 178, 11); }
|
||||
body .article .image_file {
|
||||
float: left;
|
||||
margin-right: 10px; }
|
||||
body .article .title, body .article .description {
|
||||
margin-left: 130px; }
|
||||
body .article .title a, body .article .description a {
|
||||
color: #604435;
|
||||
text-decoration: none; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#flash_notice{
|
||||
border:3px solid #6bb800;
|
||||
padding:10px;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
.portlet.table_content table {
|
||||
width: 100%;
|
||||
border-collapse: collapse; }
|
||||
.portlet.table_content table td {
|
||||
border: 1px solid black; }
|
||||
|
||||
.portlet.block_content .two_column .column {
|
||||
float: left;
|
||||
width: 50%; }
|
||||
.portlet.block_content .two_column .column .block {
|
||||
padding: 10px; }
|
||||
|
||||
.portlet.link_content{
|
||||
padding:5px;
|
||||
|
||||
|
||||
}
|
||||
|
||||
.portlet.download_content{
|
||||
padding:5px;
|
||||
padding-left:20px;
|
||||
|
||||
border:1px solid #6bb800;
|
||||
|
||||
}
|
138
app/assets/stylesheets/qi/forms.scss
Executable file
138
app/assets/stylesheets/qi/forms.scss
Executable file
@ -0,0 +1,138 @@
|
||||
|
||||
/* tutorial */
|
||||
|
||||
input[type=text],input[type=password], textarea {
|
||||
padding: 5px;
|
||||
border: solid 1px #C9C9C9;
|
||||
outline: 0;
|
||||
font: normal 13px/100% Verdana, Tahoma, sans-serif;
|
||||
width: 200px;
|
||||
|
||||
background: -webkit-gradient(linear, left top, left 25, from(#FFFFFF), color-stop(4%, #F7F7F7), to(#FFFFFF));
|
||||
background: -moz-linear-gradient(top, #FFFFFF, #F7F7F7 1px, #FFFFFF 25px);
|
||||
|
||||
}
|
||||
|
||||
textarea {
|
||||
width: 400px;
|
||||
max-width: 400px;
|
||||
height: 150px;
|
||||
line-height: 150%;
|
||||
}
|
||||
|
||||
input:hover, textarea:hover,
|
||||
input:focus, textarea:focus {
|
||||
box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
|
||||
-moz-box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
|
||||
-webkit-box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
|
||||
|
||||
}
|
||||
|
||||
label {
|
||||
|
||||
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.button{
|
||||
display: inline-block;
|
||||
background: #3c74a8;
|
||||
background: -webkit-gradient(linear, 0% 100%, 0% 0%, from(rgb(239,242,242)), to(rgb(255,255,255)));
|
||||
background: -moz-linear-gradient(bottom, rgb(239,242,242), rgb(255,255,255));
|
||||
box-shadow: rgba(0,0,0, 0.4) 0px 0px 3px;
|
||||
-moz-box-shadow: rgba(0,0,0, 0.4) 0px 0px 3px;
|
||||
-webkit-box-shadow: rgba(0,0,0, 0.4) 0px 0px 3px;
|
||||
border: none;
|
||||
-moz-border-radius: 20px;
|
||||
-webkit-border-radius: 20px;
|
||||
border-radius: 20px;
|
||||
color: RGB(46,46,46);
|
||||
|
||||
|
||||
|
||||
|
||||
padding: 5px 15px;
|
||||
margin:0px 5px 0px 5px;
|
||||
font-weight:normal;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.button:hover {
|
||||
box-shadow: rgba(0,0,0, 0.6) 0px 0px 5px;
|
||||
-moz-box-shadow: rgba(0,0,0, 0.6) 0px 0px 5px;
|
||||
-webkit-box-shadow: rgba(0,0,0, 0.6) 0px 0px 5px;
|
||||
color: RGB(46,46,46);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
.actions{
|
||||
text-align:right;
|
||||
}
|
||||
|
||||
button,input[type=submit] {
|
||||
display: inline-block;
|
||||
background: #3c74a8;
|
||||
background: -webkit-gradient(linear, 0% 100%, 0% 0%, from(rgb(60,116,168)), to(rgb(103,146,187)));
|
||||
background: -moz-linear-gradient(bottom, rgb(60,116,168), rgb(103,146,187));
|
||||
box-shadow: rgba(0,0,0, 0.4) 0px 0px 3px;
|
||||
-moz-box-shadow: rgba(0,0,0, 0.4) 0px 0px 3px;
|
||||
-webkit-box-shadow: rgba(0,0,0, 0.4) 0px 0px 3px;
|
||||
border: none;
|
||||
-moz-border-radius: 20px;
|
||||
-webkit-border-radius: 20px;
|
||||
border-radius: 20px;
|
||||
color: white;
|
||||
|
||||
margin:0px 5px 0px 5px;
|
||||
|
||||
padding: 5px 15px;
|
||||
text-shadow: 0 1px 1px rgba(0,0,0,0.6);
|
||||
font-weight:normal;
|
||||
font-size:13px;
|
||||
|
||||
}
|
||||
|
||||
button:hover,input[type=submit]:hover {
|
||||
box-shadow: rgba(0,0,0, 0.6) 0px 0px 5px;
|
||||
-moz-box-shadow: rgba(0,0,0, 0.6) 0px 0px 5px;
|
||||
-webkit-box-shadow: rgba(0,0,0, 0.6) 0px 0px 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.field_with_errors{
|
||||
display:inline;
|
||||
color:red;
|
||||
|
||||
}
|
||||
|
||||
.field_with_errors input{
|
||||
display:inline;
|
||||
border-color:red;
|
||||
|
||||
|
||||
}
|
||||
|
||||
.errorExplanation{
|
||||
border-top: 1px solid black;
|
||||
border-bottom: 1px solid black;
|
||||
padding:5px;
|
||||
border-color:#F2EDA1;
|
||||
background:#FEFCDB;
|
||||
|
||||
}
|
||||
.errorExplanation h2{
|
||||
font-size:13px;
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
|
47
app/assets/stylesheets/qi/general.scss
Normal file
47
app/assets/stylesheets/qi/general.scss
Normal file
@ -0,0 +1,47 @@
|
||||
.message{
|
||||
border: 4px solid black;
|
||||
border-radius:10px;
|
||||
padding:5px;
|
||||
margin:20px;
|
||||
-webkit-box-shadow: rgba(0,0,0,0.5) 1px 1px 40px;
|
||||
-moz-box-shadow: rgba(0,0,0,0.5) 1px 1px 40px;
|
||||
box-shadow: rgba(0,0,0,0.5) 1px 1px 40px;
|
||||
}
|
||||
.alert{
|
||||
border-color: rgb(242,237,161);
|
||||
background: rgba(254,252,219,0.8);
|
||||
}
|
||||
|
||||
.notice{
|
||||
border-color:rgb(205,230,245);
|
||||
background:rgba(236,248,254,0.8);
|
||||
}
|
||||
#flash{
|
||||
position:fixed;
|
||||
bottom:0px;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
a img{
|
||||
border:0px;
|
||||
}
|
||||
|
||||
table{
|
||||
border-collapse:collapse;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
|
||||
a{
|
||||
color : #3C74A8;
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
a:hover{
|
||||
color:#3F94EB;
|
||||
}
|
||||
|
52
app/assets/stylesheets/qi/qi.scss
Normal file
52
app/assets/stylesheets/qi/qi.scss
Normal file
@ -0,0 +1,52 @@
|
||||
.QI_background_middle {
|
||||
background-color: #e2eef7; }
|
||||
|
||||
.QI_background_middle_alt1 {
|
||||
background-color: #a9d64b; }
|
||||
|
||||
.QI_padding_small {
|
||||
padding: 5px; }
|
||||
|
||||
.QI_padding {
|
||||
padding: 10px; }
|
||||
|
||||
.QI_table_alternate_alt1 tr:nth-child(odd) {
|
||||
background-color: #ebf4fa; }
|
||||
|
||||
.QI_background_resize {
|
||||
background-position: center center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: contain;
|
||||
-moz-background-size: contain;
|
||||
-webkit-background-size: contain; }
|
||||
|
||||
.QI_box_shadow {
|
||||
-webkit-box-shadow: #AFAFAF 0px 0px 5px;
|
||||
-moz-box-shadow: #AFAFAF 0px 0px 5px;
|
||||
box-shadow: #AFAFAF 0px 0px 5px; }
|
||||
|
||||
.QI_font_alt1 {
|
||||
font-family: Georgia; }
|
||||
|
||||
.QI_font {
|
||||
font-family: Lucida grande; }
|
||||
|
||||
.QI_color_white {
|
||||
color: white; }
|
||||
|
||||
|
||||
|
||||
.bar_transparent_dark{
|
||||
background:rgba(0,0,0,0.8);
|
||||
|
||||
height:34px;
|
||||
|
||||
}
|
||||
|
||||
.position_absolute_bottom{
|
||||
position:absolute;
|
||||
bottom:0px;
|
||||
right:0px;
|
||||
left:0px;
|
||||
|
||||
}
|
110
app/controllers/admin/admins_controller.rb
Normal file
110
app/controllers/admin/admins_controller.rb
Normal file
@ -0,0 +1,110 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Admin::AdminsController < ApplicationController
|
||||
before_filter :authenticate_admin!
|
||||
layout "admin"
|
||||
|
||||
navigation :admins
|
||||
|
||||
|
||||
def index
|
||||
|
||||
|
||||
@breadcrumb = ["liste des administrateurs"]
|
||||
|
||||
@order = magick_order("email", "DESC")
|
||||
|
||||
@admins = Admin.order(@order).page(magick_page()).per(magick_per_page())
|
||||
|
||||
if @admins.num_pages.to_i < magick_page().to_i
|
||||
params[:page] = @admins.num_pages
|
||||
@admins = Admin.order(@order).page(magick_page()).per(magick_per_page())
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
@admin = Admin.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def new
|
||||
@breadcrumb = [["liste des administrateurs", admin_admins_path],"Ajouter un administrateur"]
|
||||
@admin = Admin.new
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@breadcrumb = [["liste des administrateurs", admin_admins_path],"Modifier un administrateur"]
|
||||
@admin = Admin.find(params[:id])
|
||||
end
|
||||
|
||||
|
||||
def create
|
||||
@admin = Admin.new(params[:admin])
|
||||
|
||||
respond_to do |format|
|
||||
if @admin.save
|
||||
flash[:notice] = "L'administrateur "+@admin.email.to_s+" à été ajouté avec succès."
|
||||
format.html { redirect_to(admin_admins_path) }
|
||||
format.js
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.js { render :action => "new" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@breadcrumb = [["liste des administrateurs", admin_admins_path],"Modifier un administrateur"]
|
||||
|
||||
@admin = Admin.find(params[:id])
|
||||
|
||||
if params[:admin][:password] == ""
|
||||
params[:admin].delete(:password)
|
||||
params[:admin].delete(:password_confirmation)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
if @admin.update_attributes(params[:admin])
|
||||
|
||||
flash[:notice] = "L'administrateur "+@admin.email.to_s+" à été modifié avec succès."
|
||||
format.html { redirect_to(admin_admins_path) }
|
||||
format.js
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.js { render :action => "edit" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
@admin = Admin.find(params[:id])
|
||||
|
||||
if @admin == current_admin
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to(admin_admins_url, :alert => "Vous ne pouvez pas supprimer l'administrateur actuellement connecté.")
|
||||
}
|
||||
end
|
||||
else
|
||||
@admin.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to(admin_admins_url, :notice => "L'utilisateur "+@admin.email.to_s+" à bien été supprimé.")
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
49
app/controllers/admin/albums_controller.rb
Normal file
49
app/controllers/admin/albums_controller.rb
Normal file
@ -0,0 +1,49 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Admin::AlbumsController < ApplicationController
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
@albums = Album.all(:order => :name)
|
||||
end
|
||||
|
||||
def new
|
||||
@album = Album.new()
|
||||
end
|
||||
|
||||
def create
|
||||
@album = Album.new(params[:album])
|
||||
@album_create = true
|
||||
|
||||
if @album.save
|
||||
@albums = Album.all(:order => :name)
|
||||
else
|
||||
render :action => :new
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@album = Album.find(params[:id])
|
||||
end
|
||||
|
||||
def update
|
||||
@album = Album.find(params[:id])
|
||||
@album_update = true
|
||||
|
||||
if @album.update_attributes(params[:album])
|
||||
@albums = Album.all(:order => :name)
|
||||
flash[:notice] = "L'album a bien été renomé."
|
||||
else
|
||||
render :action => :edit
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@album = Album.find(params[:id])
|
||||
if @album.id != 1
|
||||
@album.delete
|
||||
end
|
||||
end
|
||||
|
||||
end
|
56
app/controllers/admin/blocks_controller.rb
Normal file
56
app/controllers/admin/blocks_controller.rb
Normal file
@ -0,0 +1,56 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Admin::BlocksController < ApplicationController
|
||||
before_filter :authenticate_admin!
|
||||
load_and_authorize_resource
|
||||
|
||||
layout "admin"
|
||||
|
||||
|
||||
def index
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def edit
|
||||
@block = Block.find(params[:id])
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
@block = Block.find(params[:id])
|
||||
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
19
app/controllers/admin/cibles_controller.rb
Normal file
19
app/controllers/admin/cibles_controller.rb
Normal file
@ -0,0 +1,19 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Admin::CiblesController < ApplicationController
|
||||
before_filter :authenticate_admin!
|
||||
|
||||
|
||||
def new
|
||||
@resource = params[:resource_type].to_s.constantize.new()
|
||||
|
||||
@resource.cible = params[:cible_type].to_s.constantize.new()
|
||||
|
||||
if params[:resource_type] == "LinkContent"
|
||||
@namespace = :portlet
|
||||
else
|
||||
@namespace = :admin
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
12
app/controllers/admin/dashboard_controller.rb
Normal file
12
app/controllers/admin/dashboard_controller.rb
Normal file
@ -0,0 +1,12 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Admin::DashboardController < ApplicationController
|
||||
navigation :dahsboard
|
||||
before_filter :authenticate_admin!
|
||||
|
||||
|
||||
layout "admin"
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
end
|
60
app/controllers/admin/data_files_controller.rb
Normal file
60
app/controllers/admin/data_files_controller.rb
Normal file
@ -0,0 +1,60 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Admin::DataFilesController < ApplicationController
|
||||
before_filter :authenticate_admin!
|
||||
# load_and_authorize_resource
|
||||
|
||||
layout "admin"
|
||||
navigation :data_files
|
||||
def index
|
||||
params[:file_folder_id] = params[:file_folder_id] || 1
|
||||
|
||||
@file_folder = FileFolder.find(params[:file_folder_id])
|
||||
@file_folders = FileFolder.all(:order => :name)
|
||||
@data_files = DataFile.all(:order => "created_at DESC", :conditions => {:file_folder_id => @file_folder.id})
|
||||
@data_file = DataFile.new(:file_folder_id => @file_folder.id)
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def create
|
||||
@data_file_create = true
|
||||
@data_file = DataFile.new(:name => params[:data_file][:name], :file_folder_id => params[:data_file][:file_folder_id], :file =>params[:data_file][:file][0])
|
||||
|
||||
if @data_file.save
|
||||
|
||||
else
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@data_file = DataFile.find(params[:id])
|
||||
if @data_file.update_attributes(params[:data_file])
|
||||
|
||||
else
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@data_file = DataFile.find(params[:id])
|
||||
@data_file.destroy
|
||||
|
||||
flash[:notice] = "Le fichier à bien été supprimée."
|
||||
end
|
||||
|
||||
def show
|
||||
@data_file = DataFile.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
end
|
50
app/controllers/admin/file_folders_controller.rb
Normal file
50
app/controllers/admin/file_folders_controller.rb
Normal file
@ -0,0 +1,50 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Admin::FileFoldersController < ApplicationController
|
||||
before_filter :authenticate_admin!
|
||||
load_and_authorize_resource
|
||||
|
||||
|
||||
def index
|
||||
@file_folders = FileFolder.all(:order => :name)
|
||||
end
|
||||
|
||||
def new
|
||||
@file_folder = FileFolder.new()
|
||||
end
|
||||
|
||||
def create
|
||||
@file_folder = FileFolder.new(params[:file_folder])
|
||||
@file_folder_create = true
|
||||
|
||||
if @file_folder.save
|
||||
@file_folders = FileFolder.all(:order => :name)
|
||||
else
|
||||
render :action => :new
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@file_folder = FileFolder.find(params[:id])
|
||||
end
|
||||
|
||||
def update
|
||||
@file_folder = FileFolder.find(params[:id])
|
||||
@file_folder_update = true
|
||||
|
||||
if @file_folder.update_attributes(params[:file_folder])
|
||||
@file_folders = FileFolder.all(:order => :name)
|
||||
else
|
||||
render :action => :edit
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@file_folder = FileFolder.find(params[:id])
|
||||
if @file_folder.id != 1
|
||||
@file_folder.delete
|
||||
end
|
||||
end
|
||||
|
||||
end
|
80
app/controllers/admin/folders_controller.rb
Normal file
80
app/controllers/admin/folders_controller.rb
Normal file
@ -0,0 +1,80 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Admin::FoldersController < ApplicationController
|
||||
before_filter :authenticate_admin!
|
||||
load_and_authorize_resource
|
||||
|
||||
layout "admin"
|
||||
|
||||
navigation :folders
|
||||
|
||||
|
||||
def index
|
||||
@folders = Folder.all
|
||||
end
|
||||
|
||||
def new
|
||||
current_navigation :new_folders
|
||||
@folder = Folder.new
|
||||
end
|
||||
|
||||
def create
|
||||
current_navigation :new_folders
|
||||
|
||||
@folder = Folder.new(params[:folder])
|
||||
|
||||
if @folder.save
|
||||
@folders = Folder.all
|
||||
flash[:notice] = "Le dossier à bien été créé."
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(admin_folders_path()) }
|
||||
format.js
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render :action => :new}
|
||||
format.js { render :action => :new}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def edit
|
||||
current_navigation :edit_folders
|
||||
|
||||
@folder = Folder.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
current_navigation :edit_folders
|
||||
|
||||
@folder = Folder.find(params[:id])
|
||||
|
||||
if @folder.update_attributes(params[:folder])
|
||||
flash[:notice] = "Le dossier à bien été modifié."
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(admin_folders_path()) }
|
||||
format.js
|
||||
end
|
||||
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html { render :action => :edit}
|
||||
format.js { render :action => :edit}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
@folder = Folder.find(params[:id])
|
||||
@folder.destroy
|
||||
|
||||
flash[:notice] = "Le dossier à bien été supprimé."
|
||||
end
|
||||
end
|
126
app/controllers/admin/foyers_controller.rb
Normal file
126
app/controllers/admin/foyers_controller.rb
Normal file
@ -0,0 +1,126 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
|
||||
class Admin::FoyersController < ApplicationController
|
||||
before_filter :authenticate_admin!
|
||||
|
||||
|
||||
layout "admin"
|
||||
navigation :foyers
|
||||
|
||||
|
||||
def index
|
||||
@foyers = Foyer.order('surname ASC')
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
|
||||
@foyer = Foyer.new()
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@foyers = Foyer.order('surname ASC')
|
||||
@foyer = Foyer.new(params[:foyer])
|
||||
|
||||
|
||||
if @foyer.save
|
||||
flash[:notice] = "Le foyer à bien été créé."
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
respond_to do |format|
|
||||
format.js { render :action => :new}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def edit
|
||||
|
||||
|
||||
@foyer = Foyer.find(params[:id])
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
|
||||
@foyer = Foyer.find(params[:id])
|
||||
|
||||
if @foyer.update_attributes(params[:foyer])
|
||||
flash[:notice] = "Le foyer à bien été modifié."
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(admin_foyers_path()) }
|
||||
format.js
|
||||
end
|
||||
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html { render :action => :edit}
|
||||
format.js { render :action => :edit}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
@foyer = Foyer.find(params[:id])
|
||||
@foyer.destroy
|
||||
|
||||
|
||||
flash[:notice] = "Le foyer à bien été supprimé."
|
||||
end
|
||||
def import
|
||||
if params[:dump] and params[:dump][:file]
|
||||
require 'csv'
|
||||
require 'iconv'
|
||||
|
||||
Foyer.destroy_all
|
||||
|
||||
@parsed_file=CSV.parse(Iconv.conv('utf-8', 'ISO-8859-1', params[:dump][:file].read),:col_sep => ';')
|
||||
#@parsed_file=CSV::Reader.parse(params[:dump][:file], ';')
|
||||
@parsed_file.each do |row|
|
||||
if row[19] == "LYCEE PIERRE BEGHIN"
|
||||
|
||||
|
||||
|
||||
if Foyer.find_by_fcpe_id(row[0])
|
||||
@foyer = Foyer.find_by_fcpe_id(row[0])
|
||||
else
|
||||
@foyer = Foyer.new(
|
||||
:fcpe_id => row[0],
|
||||
:surname => row[1],
|
||||
:name => row[2],
|
||||
:email => row[8],
|
||||
:city => row[6].to_s+" "+row[7].to_s
|
||||
|
||||
)
|
||||
@foyer.save
|
||||
end
|
||||
|
||||
@foyer.studients << Studient.create(:surname => row[17], :name => row[18], :classe => row[20].to_s+" "+row[21].to_s)
|
||||
|
||||
end
|
||||
end
|
||||
redirect_to :back, :alert => "Le nouveau fichier à bien été importé."
|
||||
else
|
||||
redirect_to :back, :alert => "Aucun fichier n'a été séléctionner."
|
||||
end
|
||||
end
|
||||
|
||||
def import_validation
|
||||
end
|
||||
|
||||
end
|
59
app/controllers/admin/image_files_controller.rb
Normal file
59
app/controllers/admin/image_files_controller.rb
Normal file
@ -0,0 +1,59 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Admin::ImageFilesController < ApplicationController
|
||||
before_filter :authenticate_admin!
|
||||
layout "admin"
|
||||
navigation :image_files
|
||||
|
||||
def index
|
||||
params[:album_id] = params[:album_id] || 1
|
||||
|
||||
@album = Album.find(params[:album_id])
|
||||
@albums = Album.all(:order => :name)
|
||||
@image_files = ImageFile.all(:order => "created_at DESC", :conditions => {:album_id => @album.id})
|
||||
@image_file = ImageFile.new(:album_id => @album.id)
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def create
|
||||
@image_file_create = true
|
||||
@image_file = ImageFile.new(:name => params[:image_file][:name], :album_id => params[:image_file][:album_id], :file =>params[:image_file][:file][0])
|
||||
|
||||
if @image_file.save
|
||||
|
||||
else
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@image_file = ImageFile.find(params[:id])
|
||||
if @image_file.update_attributes(params[:image_file])
|
||||
|
||||
else
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@image_file = ImageFile.find(params[:id])
|
||||
@image_file.destroy
|
||||
|
||||
flash[:notice] = "L'image à bien été supprimée."
|
||||
end
|
||||
|
||||
def show
|
||||
@image_file = ImageFile.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
end
|
15
app/controllers/admin/menu_aliases_controller.rb
Normal file
15
app/controllers/admin/menu_aliases_controller.rb
Normal file
@ -0,0 +1,15 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Admin::MenuAliasesController < ApplicationController
|
||||
|
||||
before_filter :authenticate_admin!
|
||||
load_and_authorize_resource
|
||||
|
||||
|
||||
def edit
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
|
||||
end
|
174
app/controllers/admin/menu_items_controller.rb
Normal file
174
app/controllers/admin/menu_items_controller.rb
Normal file
@ -0,0 +1,174 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Admin::MenuItemsController < ApplicationController
|
||||
before_filter :authenticate_admin!
|
||||
#load_and_authorize_resource
|
||||
|
||||
layout "admin"
|
||||
navigation :menu_items
|
||||
|
||||
|
||||
def index
|
||||
|
||||
|
||||
|
||||
if params[:menu_id] and params[:menu_id] != "" and @menu = Menu.find(params[:menu_id])
|
||||
|
||||
|
||||
params[:parent_id] = nil if !params[:parent_id]
|
||||
|
||||
@menu_parent = MenuItem.find(params[:parent_id]) if params[:parent_id]
|
||||
|
||||
|
||||
|
||||
@order = "position ASC"
|
||||
|
||||
@menu_items = @menu.menu_items.where(:parent_id => params[:parent_id]).order(@order).page(magick_page()).per(magick_per_page())
|
||||
|
||||
if @menu_items.num_pages.to_i < magick_page().to_i
|
||||
params[:page] = @menu_items.num_pages
|
||||
@menu_items = @menu.menu_items.where(:parent_id => params[:parent_id]).order(@order).page(magick_page()).per(magick_per_page())
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
else
|
||||
redirect_to admin_root_path, :alert => "Un menu doit être séléctionné."
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
current_navigation :new_menu_items
|
||||
|
||||
|
||||
@menu_item = MenuItem.new(:menu_id => params[:menu_id],:parent_id => params[:parent_id])
|
||||
|
||||
params[:menu_item_content_type] = "Page" if !params[:menu_item_content_type]
|
||||
|
||||
@content = params[:menu_item_content_type].constantize.new()
|
||||
@menu_item.menu_content = @content
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
current_navigation :new_menu_items
|
||||
params_content = params[:menu_item].delete(:menu_content_attributes)
|
||||
content_type = params[:menu_item][:menu_content_type]
|
||||
|
||||
puts params[:menu_item][:menu_content_type]
|
||||
|
||||
@menu_item= MenuItem.new(params[:menu_item])
|
||||
content = content_type.constantize.new(params_content)
|
||||
|
||||
@menu_item.menu_content = content
|
||||
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
if @menu_item.save
|
||||
MenuItem.all.each do |mi|
|
||||
mi.set_permalink
|
||||
end
|
||||
|
||||
flash[:notice] = "Le menu à été ajouté avec succès."
|
||||
format.html {
|
||||
redirect_to(admin_menu_items_path(:menu_id => @menu_item.menu_id, :parent_id => @menu_item.parent_id))
|
||||
}
|
||||
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
current_navigation :edit_menu_items
|
||||
@menu_item= MenuItem.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
current_navigation :edit_menu_items
|
||||
@menu_item= MenuItem.find(params[:id])
|
||||
|
||||
@menu = @menu_item.menu
|
||||
|
||||
if request.xhr?
|
||||
@menu_parent = @menu_item.parent if @menu_item.parent
|
||||
@menu_items = MenuItem.where(:parent_id => @menu_item.parent_id, :menu_id => @menu_item.menu_id).order(:position)
|
||||
end
|
||||
|
||||
if params[:menu_item][:parent_id] and params[:menu_item][:parent_id] == "no-menu-selected"
|
||||
@menu_item.parent_id = nil
|
||||
@menu_item.save
|
||||
params[:menu_item].delete(:parent_id)
|
||||
|
||||
end
|
||||
|
||||
@reorder = true if params[:reorder]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
if @menu_item.update_attributes(params[:menu_item])
|
||||
puts "TEST"
|
||||
MenuItem.all.each do |mi|
|
||||
mi.set_permalink
|
||||
|
||||
end
|
||||
|
||||
flash[:notice] = "Le menu à été modifié avec succès."
|
||||
format.html { redirect_to(admin_menu_items_path(:parent_id => @menu_item.parent_id, :menu_id => @menu_item.menu_id)) }
|
||||
if @reorder
|
||||
format.js {
|
||||
|
||||
render :action => "update" }
|
||||
else
|
||||
format.js {
|
||||
|
||||
render :action => "show" }
|
||||
end
|
||||
else
|
||||
|
||||
flash[:alert] = "Cet élément de menu n'a pas pu être déplacé. Vérifiez que sont lien permanent n'éxiste pas déjà dans l'élément cible."
|
||||
if @reorder
|
||||
format.js { render :action => "update_reorder_failled" }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.js { render :action => "edit" }
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def destroy
|
||||
@menu_item = MenuItem.find(params[:id])
|
||||
@menu_item.destroy
|
||||
flash[:notice] = "L'élément de menu a été supprimé avec succès."
|
||||
respond_to do |format|
|
||||
|
||||
|
||||
format.html { redirect_to(admin_menu_items_path(:menu_id => @menu_item.menu_id, :parent_id => @menu_item.parent_id)) }
|
||||
format.js
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@menu_item= MenuItem.find(params[:id])
|
||||
end
|
||||
|
||||
end
|
14
app/controllers/admin/menu_urls_controller.rb
Normal file
14
app/controllers/admin/menu_urls_controller.rb
Normal file
@ -0,0 +1,14 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Admin::MenuUrlsController < ApplicationController
|
||||
before_filter :authenticate_admin!
|
||||
load_and_authorize_resource
|
||||
|
||||
def edit
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
|
||||
end
|
80
app/controllers/admin/menus_controller.rb
Normal file
80
app/controllers/admin/menus_controller.rb
Normal file
@ -0,0 +1,80 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Admin::MenusController < ApplicationController
|
||||
before_filter :authenticate_admin!
|
||||
layout "admin"
|
||||
|
||||
before_filter :authenticate_admin!
|
||||
load_and_authorize_resource
|
||||
|
||||
|
||||
def index
|
||||
@breadcrumb = ["liste des menus"]
|
||||
|
||||
@order = magick_order("name", "ASC")
|
||||
|
||||
@menus = Menu.order(@order).page(magick_page()).per(magick_per_page())
|
||||
|
||||
if @menus.num_pages.to_i < magick_page().to_i
|
||||
params[:page] = @menus.num_pages
|
||||
@menus = Menu.order(@order).page(magick_page()).per(magick_per_page())
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def new
|
||||
@breadcrumb = [["liste des menus", admin_menus_path],"Ajouter un menu"]
|
||||
@menu = Menu.new
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
@breadcrumb = [["liste des menus", admin_menus_path],"Ajouter un menu"]
|
||||
@menu = Menu.new(params[:menu])
|
||||
|
||||
respond_to do |format|
|
||||
if @menu.save
|
||||
flash[:notice] = "Le menu à été ajouté avec succès."
|
||||
format.html { redirect_to(admin_menus_path) }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@breadcrumb = [["liste des menus", admin_menus_path],"Modifier un menu"]
|
||||
@menu = Menu.find(params[:id])
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@breadcrumb = [["liste des menus", admin_menus_path],"Modifier un menu"]
|
||||
@menu = Menu.find(params[:id])
|
||||
respond_to do |format|
|
||||
if @menu.update_attributes(params[:menu])
|
||||
|
||||
flash[:notice] = "Le menu à été modifié avec succès."
|
||||
format.html { redirect_to(admin_menus_path) }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@menu = Menu.find(params[:id])
|
||||
@menu.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to(admin_menus_url, :notice => "Le menu a bien été supprimé.")
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
140
app/controllers/admin/newsletters_controller.rb
Normal file
140
app/controllers/admin/newsletters_controller.rb
Normal file
@ -0,0 +1,140 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
|
||||
class Admin::NewslettersController < ApplicationController
|
||||
before_filter :authenticate_admin!
|
||||
|
||||
|
||||
layout "admin"
|
||||
navigation :newsletters
|
||||
|
||||
|
||||
def index
|
||||
@newsletters = Newsletter.order('subject ASC')
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
|
||||
@newsletter = Newsletter.new()
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@newsletter = Newsletter.new(params[:newsletter])
|
||||
|
||||
puts params[:newsletter][:subject]
|
||||
if @newsletter.save
|
||||
flash[:notice] = "La newsletter à bien été créé."
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html{ redirect_to admin_newsletters_path}
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
respond_to do |format|
|
||||
format.js { render :action => :new}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def edit
|
||||
|
||||
|
||||
@newsletter = Newsletter.find(params[:id])
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
|
||||
@newsletter = Newsletter.find(params[:id])
|
||||
|
||||
if @newsletter.update_attributes(params[:newsletter])
|
||||
flash[:notice] = "La newsletter à bien été modifié."
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(admin_newsletters_path()) }
|
||||
format.js
|
||||
end
|
||||
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html { render :action => :edit}
|
||||
format.js { render :action => :edit}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
@newsletter = Newsletter.find(params[:id])
|
||||
@newsletter.destroy
|
||||
|
||||
|
||||
flash[:notice] = "La newsletter à bien été supprimé."
|
||||
end
|
||||
|
||||
|
||||
def send_test
|
||||
|
||||
@newsletter = Newsletter.find(params[:id])
|
||||
@email = params[:email].to_s
|
||||
|
||||
General.send_newsletter(@email,@newsletter.subject, @newsletter.content).deliver
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
redirect_to(admin_newsletters_path, :notice => "La newsletter a bien été envoyée à l'email de test")
|
||||
end
|
||||
|
||||
def select_recipients
|
||||
@newsletter = Newsletter.find(params[:id])
|
||||
if !params[:search]
|
||||
params[:search] = {}
|
||||
params[:search][:classe_in] = ['']
|
||||
params[:search][:foyer_city_in] = ['']
|
||||
end
|
||||
params[:search].delete(:foyer_delegue_is_true) if params[:search][:foyer_delegue_is_true] and params[:search][:foyer_delegue_is_true] == 0
|
||||
@search = Studient.search(params[:search])
|
||||
@studients = @search.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
def send_newsletter
|
||||
@newsletter = Newsletter.find(params[:id])
|
||||
@i = 0
|
||||
if params[:confirmed_emails]
|
||||
|
||||
params[:confirmed_emails].uniq.each do |email|
|
||||
puts "mail envoyé à "+email.to_s
|
||||
|
||||
General.send_newsletter(email,@newsletter.subject, @newsletter.content).deliver
|
||||
@i +=1
|
||||
end
|
||||
end
|
||||
@newsletter.sended = true
|
||||
@newsletter.send_at = Time.now
|
||||
@newsletter.save
|
||||
|
||||
redirect_to(admin_newsletters_path, :notice => "La newsletter a la séléction d'emails ("+@i.to_s+" envois.)")
|
||||
end
|
||||
|
||||
|
||||
end
|
15
app/controllers/admin/pages_controller.rb
Normal file
15
app/controllers/admin/pages_controller.rb
Normal file
@ -0,0 +1,15 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Admin::PagesController < ApplicationController
|
||||
before_filter :authenticate_admin!
|
||||
load_and_authorize_resource
|
||||
|
||||
|
||||
def edit
|
||||
@page = Page.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
|
||||
end
|
86
app/controllers/admin/studients_controller.rb
Normal file
86
app/controllers/admin/studients_controller.rb
Normal file
@ -0,0 +1,86 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
|
||||
class Admin::StudientsController < ApplicationController
|
||||
before_filter :authenticate_admin!
|
||||
|
||||
|
||||
layout "admin"
|
||||
navigation :studients
|
||||
|
||||
|
||||
|
||||
|
||||
def new
|
||||
|
||||
|
||||
@studient = Studient.new(:foyer_id => params[:foyer_id])
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
|
||||
@studient = Studient.new(params[:studient])
|
||||
|
||||
@studients = @studient.foyer.studients.order('name ASC')
|
||||
|
||||
if @studient.save
|
||||
flash[:notice] = "L'étudiant à bien été créé."
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
respond_to do |format|
|
||||
format.js { render :action => :new}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def edit
|
||||
|
||||
|
||||
@studient = Studient.find(params[:id])
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
|
||||
@studient = Studient.find(params[:id])
|
||||
|
||||
if @studient.update_attributes(params[:studient])
|
||||
flash[:notice] = "L'étudiant à bien été modifié."
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(admin_studients_path()) }
|
||||
format.js
|
||||
end
|
||||
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html { render :action => :edit}
|
||||
format.js { render :action => :edit}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
@studient = Studient.find(params[:id])
|
||||
@studient.destroy
|
||||
|
||||
|
||||
flash[:notice] = "L'étudiant à bien été supprimé."
|
||||
end
|
||||
def import
|
||||
end
|
||||
|
||||
def import_validation
|
||||
end
|
||||
|
||||
end
|
17
app/controllers/admins/passwords_controller.rb
Normal file
17
app/controllers/admins/passwords_controller.rb
Normal file
@ -0,0 +1,17 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Admins::PasswordsController < ::Devise::PasswordsController
|
||||
layout "connexion"
|
||||
|
||||
def create
|
||||
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
|
||||
|
||||
if resource.errors.empty?
|
||||
set_flash_message :notice, :send_instructions
|
||||
redirect_to new_session_path(resource_name)
|
||||
else
|
||||
@flash_i= {}
|
||||
@flash_i[:alert] = "Aucun compte associé à cette adresse mail n'a été trouvé."
|
||||
render_with_scope :new
|
||||
end
|
||||
end
|
||||
end
|
5
app/controllers/admins/sessions_controller.rb
Normal file
5
app/controllers/admins/sessions_controller.rb
Normal file
@ -0,0 +1,5 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Admins::SessionsController < ::Devise::SessionsController
|
||||
layout "connexion"
|
||||
|
||||
end
|
67
app/controllers/application_controller.rb
Normal file
67
app/controllers/application_controller.rb
Normal file
@ -0,0 +1,67 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
#encoding: utf-8
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
helper_method :magick_order, :magick_search, :to_my_log
|
||||
|
||||
def magick_order(default_row, default_a_d, name="default")
|
||||
session_order_name = (params[:controller]+"/"+params[:action]).to_slug.gsub('-','_')+"_"+name+"_magick_order"
|
||||
|
||||
if params[:order]
|
||||
|
||||
session[session_order_name] = []
|
||||
|
||||
session[session_order_name][1] = params[:order]
|
||||
session[session_order_name][2] = params[:a_d]
|
||||
|
||||
|
||||
|
||||
elsif session[session_order_name]
|
||||
|
||||
params[:a_d] = session[session_order_name][2]
|
||||
params[:order] = session[session_order_name][1]
|
||||
else
|
||||
params[:order] = default_row
|
||||
params[:a_d] = default_a_d
|
||||
end
|
||||
|
||||
return params[:order]+" "+params[:a_d]
|
||||
end
|
||||
|
||||
def magick_per_page(per_page=20, name="defaut")
|
||||
session_search_name = (params[:controller]+"/"+params[:action]).to_slug.gsub('-','_')+"_"+name+"_magick_per_page"
|
||||
|
||||
if params[:per_page]
|
||||
session[session_search_name] = params[:per_page]
|
||||
elsif session[session_search_name]
|
||||
params[:per_page] = session[session_search_name]
|
||||
else
|
||||
params[:per_page] = per_page
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def magick_page(name="defaut")
|
||||
session_search_name = (params[:controller]+"/"+params[:action]).to_slug.gsub('-','_')+"_"+name+"_magick_page"
|
||||
|
||||
if params[:page]
|
||||
session[session_search_name] = params[:page]
|
||||
elsif session[session_search_name]
|
||||
params[:page] = session[session_search_name]
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def to_my_log(message)
|
||||
#current_user.user_logs.create(:message => message)
|
||||
end
|
||||
|
||||
|
||||
def current_ability
|
||||
@current_ability ||= Ability.new(current_admin)
|
||||
end
|
||||
|
||||
end
|
14
app/controllers/download_data_files_controller.rb
Normal file
14
app/controllers/download_data_files_controller.rb
Normal file
@ -0,0 +1,14 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class DownloadDataFilesController < ApplicationController
|
||||
def index
|
||||
end
|
||||
|
||||
|
||||
|
||||
def show
|
||||
@data_file = DataFile.find(params[:id])
|
||||
send_file @data_file.file.path, :filename => @data_file.abstract_file_name_slug #, :disposition => "inline"
|
||||
end
|
||||
|
||||
|
||||
end
|
111
app/controllers/portlet/block_contents_controller.rb
Normal file
111
app/controllers/portlet/block_contents_controller.rb
Normal file
@ -0,0 +1,111 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Portlet::BlockContentsController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
def new
|
||||
@block_content = BlockContent.new(:nbr_columns => 2)
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@block_content = BlockContent.new(params[:block_content])
|
||||
|
||||
respond_to do |format|
|
||||
if @block_content.save
|
||||
@block_content.nbr_columns.times do
|
||||
@block = Block.new(:block_name => "")
|
||||
@block.blockable = @block_content
|
||||
@block.save
|
||||
end
|
||||
|
||||
@portlet = Portlet.create(:position => params[:position], :block_id => params[:block_id], :content => @block_content)
|
||||
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Elément ajouté avec succès.') }
|
||||
format.js { render :template => "portlet/shared/create" }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@block_content = BlockContent.find(params[:id])
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :template => "portlet/shared/edit", :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def show
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@block_content = BlockContent.find(params[:id])
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
|
||||
respond_to do |format|
|
||||
if @block_content.update_attributes(params[:block_content])
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
|
||||
end
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Titre mis à jour.') }
|
||||
format.js { render :template => "portlet/shared/update" }
|
||||
else
|
||||
format.html { render :action => "portlet/shared/edit" }
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
@block_content = BlockContent.find(params[:id])
|
||||
@block_content.destroy
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.js { render :template => "portlet/shared/destroy" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
116
app/controllers/portlet/break_contents_controller.rb
Normal file
116
app/controllers/portlet/break_contents_controller.rb
Normal file
@ -0,0 +1,116 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Portlet::BreakContentsController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
def new
|
||||
@break_content = BreakContent.new(:line => true)
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@break_content = BreakContent.new(params[:break_content])
|
||||
|
||||
respond_to do |format|
|
||||
if @break_content.save
|
||||
|
||||
|
||||
@portlet = Portlet.create(:position => params[:position], :block_id => params[:block_id], :content => @break_content)
|
||||
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (ajout d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Elément ajouté avec succès.') }
|
||||
format.js { render :template => "portlet/shared/create" }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@break_content = BreakContent.find(params[:id])
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :template => "portlet/shared/edit", :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def show
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@break_content = BreakContent.find(params[:id])
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
|
||||
respond_to do |format|
|
||||
if @break_content.update_attributes(params[:break_content])
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (modification d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Titre mis à jour.') }
|
||||
format.js { render :template => "portlet/shared/update" }
|
||||
else
|
||||
format.html { render :action => "portlet/shared/edit" }
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
@break_content = BreakContent.find(params[:id])
|
||||
@break_content.destroy
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (suppression d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.js { render :template => "portlet/shared/destroy" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
109
app/controllers/portlet/download_contents_controller.rb
Normal file
109
app/controllers/portlet/download_contents_controller.rb
Normal file
@ -0,0 +1,109 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Portlet::DownloadContentsController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
def new
|
||||
@download_content = DownloadContent.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@download_content = DownloadContent.new(params[:download_content])
|
||||
|
||||
respond_to do |format|
|
||||
if @download_content.save
|
||||
|
||||
|
||||
@portlet = Portlet.create(:position => params[:position], :block_id => params[:block_id], :content => @download_content)
|
||||
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (ajout d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Elément ajouté avec succès.') }
|
||||
format.js { render :template => "portlet/shared/create" }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@download_content = DownloadContent.find(params[:id])
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :template => "portlet/shared/edit", :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def show
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@download_content = DownloadContent.find(params[:id])
|
||||
@portlet = @download_content.portlet
|
||||
|
||||
respond_to do |format|
|
||||
if @download_content.update_attributes(params[:download_content])
|
||||
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Titre mis à jour.') }
|
||||
format.js { render :template => "portlet/shared/update" }
|
||||
else
|
||||
format.html { render :action => "portlet/shared/edit" }
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
@download_content = DownloadContent.find(params[:id])
|
||||
@download_content.destroy
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (suppression d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.js { render :template => "portlet/shared/destroy" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
116
app/controllers/portlet/dynamic_contents_controller.rb
Normal file
116
app/controllers/portlet/dynamic_contents_controller.rb
Normal file
@ -0,0 +1,116 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Portlet::DynamicContentsController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
def new
|
||||
@dynamic_content = DynamicContent.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@dynamic_content = DynamicContent.new(params[:dynamic_content])
|
||||
|
||||
respond_to do |format|
|
||||
if @dynamic_content.save
|
||||
|
||||
|
||||
@portlet = Portlet.create(:position => params[:position], :block_id => params[:block_id], :content => @dynamic_content)
|
||||
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (ajout d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Elément ajouté avec succès.') }
|
||||
format.js { render :template => "portlet/shared/create" }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@dynamic_content = DynamicContent.find(params[:id])
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :template => "portlet/shared/edit", :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def show
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@dynamic_content = DynamicContent.find(params[:id])
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
|
||||
respond_to do |format|
|
||||
if @dynamic_content.update_attributes(params[:dynamic_content])
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (modification d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Titre mis à jour.') }
|
||||
format.js { render :template => "portlet/shared/update" }
|
||||
else
|
||||
format.html { render :action => "portlet/shared/edit" }
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
@dynamic_content = DynamicContent.find(params[:id])
|
||||
@dynamic_content.destroy
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (suppression d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.js { render :template => "portlet/shared/destroy" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
109
app/controllers/portlet/gallery_contents_controller.rb
Normal file
109
app/controllers/portlet/gallery_contents_controller.rb
Normal file
@ -0,0 +1,109 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Portlet::GalleryContentsController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
def new
|
||||
@gallery_content = GalleryContent.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def create
|
||||
@gallery_content = GalleryContent.new(params[:gallery_content])
|
||||
|
||||
respond_to do |format|
|
||||
if @gallery_content.save
|
||||
|
||||
|
||||
@portlet = Portlet.create(:position => params[:position], :block_id => params[:block_id], :content => @gallery_content)
|
||||
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (ajout d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Elément ajouté avec succès.') }
|
||||
format.js { render :template => "portlet/shared/create" }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@gallery_content = GalleryContent.find(params[:id])
|
||||
@portlet = @gallery_content.portlet
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :template => "portlet/shared/edit", :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def show
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@gallery_content = GalleryContent.find(params[:id])
|
||||
@portlet = @gallery_content.portlet
|
||||
|
||||
respond_to do |format|
|
||||
if @gallery_content.update_attributes(params[:gallery_content])
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Titre mis à jour.') }
|
||||
format.js { render :template => "portlet/shared/update" }
|
||||
else
|
||||
format.html { render :action => "portlet/shared/edit" }
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
@gallery_content = GalleryContent.find(params[:id])
|
||||
@gallery_content.destroy
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (suppression d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.js { render :template => "portlet/shared/destroy" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
82
app/controllers/portlet/gallery_images_controller.rb
Normal file
82
app/controllers/portlet/gallery_images_controller.rb
Normal file
@ -0,0 +1,82 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Portlet::GalleryImagesController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
|
||||
def reorder
|
||||
i = 0
|
||||
params[:gallery_image].each do |gallery_image_id|
|
||||
i += 1
|
||||
gallery_image = GalleryImage.find(gallery_image_id)
|
||||
gallery_image.position = i
|
||||
gallery_image.save
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@gallery_content = GalleryContent.find(params[:gallery_content_id])
|
||||
@gallery_images = []
|
||||
if params[:image_file_ids].kind_of?(Array)
|
||||
params[:image_file_ids].each do |image_file_id|
|
||||
image_file = ImageFile.find(image_file_id)
|
||||
gallery_image = GalleryImage.create(:image_file_id => image_file.id, :title => image_file.name, :description => image_file.description, :gallery_content_id => @gallery_content.id )
|
||||
|
||||
@gallery_images << gallery_image
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
format.js
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def edit
|
||||
@gallery_image = GalleryImage.find(params[:id])
|
||||
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def show
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@gallery_image = GalleryImage.find(params[:id])
|
||||
respond_to do |format|
|
||||
if @gallery_image.update_attributes(params[:gallery_image])
|
||||
|
||||
format.js
|
||||
else
|
||||
format.html { render :action => "edit", :layout => false}
|
||||
format.js { render :action => "edit" }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
||||
@gallery_image = GalleryImage.find(params[:id])
|
||||
@gallery_image.destroy
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
116
app/controllers/portlet/html_contents_controller.rb
Normal file
116
app/controllers/portlet/html_contents_controller.rb
Normal file
@ -0,0 +1,116 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Portlet::HtmlContentsController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
def new
|
||||
@html_content = HtmlContent.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@html_content = HtmlContent.new(params[:html_content])
|
||||
|
||||
respond_to do |format|
|
||||
if @html_content.save
|
||||
|
||||
|
||||
@portlet = Portlet.create(:position => params[:position], :block_id => params[:block_id], :content => @html_content)
|
||||
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (ajout d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Elément ajouté avec succès.') }
|
||||
format.js { render :template => "portlet/shared/create" }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@html_content = HtmlContent.find(params[:id])
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :template => "portlet/shared/edit", :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def show
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@html_content = HtmlContent.find(params[:id])
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
|
||||
respond_to do |format|
|
||||
if @html_content.update_attributes(params[:html_content])
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (modification d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Titre mis à jour.') }
|
||||
format.js { render :template => "portlet/shared/update" }
|
||||
else
|
||||
format.html { render :action => "portlet/shared/edit" }
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
@html_content = HtmlContent.find(params[:id])
|
||||
@html_content.destroy
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (suppression d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.js { render :template => "portlet/shared/destroy" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
100
app/controllers/portlet/image_contents_controller.rb
Normal file
100
app/controllers/portlet/image_contents_controller.rb
Normal file
@ -0,0 +1,100 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Portlet::ImageContentsController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
def new
|
||||
@image_content = ImageContent.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@image_content = ImageContent.new(params[:image_content])
|
||||
|
||||
respond_to do |format|
|
||||
if @image_content.save
|
||||
|
||||
|
||||
@portlet = Portlet.create(:content => @image_content)
|
||||
|
||||
|
||||
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Elément ajouté avec succès.') }
|
||||
format.js { render :template => "portlet/shared/create" }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@image_content = ImageContent.find(params[:id])
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :template => "portlet/shared/edit", :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def show
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@image_content = ImageContent.find(params[:id])
|
||||
@portlet = @image_content.portlet
|
||||
|
||||
respond_to do |format|
|
||||
if @image_content.update_attributes(params[:image_content])
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (modification d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Titre mis à jour.') }
|
||||
format.js { render :template => "portlet/shared/update" }
|
||||
else
|
||||
format.html { render :action => "portlet/shared/edit" }
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
@image_content = ImageContent.find(params[:id])
|
||||
@image_content.destroy
|
||||
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.js { render :template => "portlet/shared/destroy" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
131
app/controllers/portlet/link_contents_controller.rb
Normal file
131
app/controllers/portlet/link_contents_controller.rb
Normal file
@ -0,0 +1,131 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Portlet::LinkContentsController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
def new
|
||||
@link_content = LinkContent.new
|
||||
|
||||
|
||||
|
||||
params[:link_content_cible_type] = "CibleUrl" if !params[:link_content_cible_type]
|
||||
|
||||
@cible = params[:link_content_cible_type].constantize.new()
|
||||
@link_content.cible = @cible
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
|
||||
params_cible = params[:link_content].delete(:cible_attributes)
|
||||
cible_type = params[:link_content][:cible_type]
|
||||
|
||||
@link_content = LinkContent.new(params[:link_content])
|
||||
|
||||
|
||||
cible = cible_type.constantize.new(params_cible)
|
||||
|
||||
@link_content.cible = cible
|
||||
|
||||
respond_to do |format|
|
||||
if @link_content.save
|
||||
|
||||
|
||||
@portlet = Portlet.create(:content => @link_content)
|
||||
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Elément ajouté avec succès.') }
|
||||
format.js { render :template => "portlet/shared/create" }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@link_content = LinkContent.find(params[:id])
|
||||
@portlet = @link_content.portlet
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :template => "portlet/shared/edit", :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def show
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@link_content = LinkContent.find(params[:id])
|
||||
@portlet = @link_content.portlet
|
||||
|
||||
|
||||
|
||||
params_cible = params[:link_content].delete(:cible_attributes)
|
||||
cible_type = params[:link_content][:cible_type]
|
||||
|
||||
|
||||
if !(params[:link_content][:cible_id] and params[:link_content][:cible_id] != "")
|
||||
cible = cible_type.constantize.new(params_cible)
|
||||
@link_content.cible = cible
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
if @link_content.update_attributes(params[:link_content])
|
||||
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Titre mis à jour.') }
|
||||
format.js { render :template => "portlet/shared/update" }
|
||||
else
|
||||
format.html { render :action => "portlet/shared/edit" }
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
@link_content = LinkContent.find(params[:id])
|
||||
@link_content.destroy
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (suppression d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.js { render :template => "portlet/shared/destroy" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
116
app/controllers/portlet/map_contents_controller.rb
Normal file
116
app/controllers/portlet/map_contents_controller.rb
Normal file
@ -0,0 +1,116 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Portlet::MapContentsController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
def new
|
||||
@map_content = MapContent.new(:zoom => 12, :view => 1)
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@map_content = MapContent.new(params[:map_content])
|
||||
|
||||
respond_to do |format|
|
||||
if @map_content.save
|
||||
|
||||
|
||||
@portlet = Portlet.create(:position => params[:position], :block_id => params[:block_id], :content => @map_content)
|
||||
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (ajout d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Elément ajouté avec succès.') }
|
||||
format.js { render :template => "portlet/shared/create" }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@map_content = MapContent.find(params[:id])
|
||||
@portlet = @map_content.portlet
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :template => "portlet/shared/edit", :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def show
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@map_content = MapContent.find(params[:id])
|
||||
@portlet = @map_content.portlet
|
||||
|
||||
respond_to do |format|
|
||||
if @map_content.update_attributes(params[:map_content])
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (modification d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Titre mis à jour.') }
|
||||
format.js { render :template => "portlet/shared/update" }
|
||||
else
|
||||
format.html { render :action => "portlet/shared/edit" }
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
@map_content = MapContent.find(params[:id])
|
||||
@map_content.destroy
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (suppression d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.js { render :template => "portlet/shared/destroy" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
122
app/controllers/portlet/portlets_controller.rb
Normal file
122
app/controllers/portlet/portlets_controller.rb
Normal file
@ -0,0 +1,122 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Portlet::PortletsController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
|
||||
|
||||
def new
|
||||
@portlet = Portlet.new(:block_id => params[:block_id])
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
}
|
||||
format.js
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def show
|
||||
@portlet = Portlet.find(params[:id])
|
||||
end
|
||||
|
||||
|
||||
|
||||
def edit
|
||||
@portlet = Portlet.find(params[:id])
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def update
|
||||
@portlet = Portlet.find(params[:id])
|
||||
|
||||
flash[:notice] = "Le contenu à été mis à jour avec succès."
|
||||
if @portlet.update_attributes(params[:portlet])
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s)
|
||||
end
|
||||
end
|
||||
render :action => "update"
|
||||
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
def destroy
|
||||
@portlet = Portlet.find(params[:id])
|
||||
@portlet.destroy
|
||||
flash[:notice] = "Le contenu à été supprimé avec succès."
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
end
|
||||
end
|
||||
|
||||
def ajax_create
|
||||
@t = params[:type]
|
||||
if @t == "Title"
|
||||
@content = TitleContent.new()
|
||||
elsif @t == "Text"
|
||||
@content = TextContent.new()
|
||||
elsif @t == "Image"
|
||||
@content = ImageContent.new()
|
||||
elsif @t == "Gallery"
|
||||
@content = GalleryContent.new()
|
||||
elsif @t == "Link"
|
||||
@content = LinkContent.new()
|
||||
elsif @t == "Break"
|
||||
@content = BreakContent.new()
|
||||
elsif @t == "Html"
|
||||
@content = HtmlContent.new()
|
||||
elsif @t == "Download"
|
||||
@content = DownloadContent.new()
|
||||
elsif @t == "DynamicContent"
|
||||
@content = DynamicContent.new()
|
||||
end
|
||||
@portlet = Portlet.new(:block_id => params[:block_id])
|
||||
@content.portlets << @portlet
|
||||
@content.save!
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
end
|
||||
flash[:notice] = "Le contenu à été créé avec succès."
|
||||
end
|
||||
|
||||
def reorder
|
||||
|
||||
params[:blocks].each do |index, block|
|
||||
|
||||
block_id = block["block_id"].to_i
|
||||
i = 0
|
||||
if block["block_portlet_ids"].kind_of?(Array)
|
||||
block["block_portlet_ids"].each do |portlet_id|
|
||||
i += 1
|
||||
Portlet.find(portlet_id.to_i).update_attributes(:position => i, :block_id => block_id)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
render :inline => "ok"
|
||||
|
||||
end
|
||||
end
|
35
app/controllers/portlet/table_cols_controller.rb
Normal file
35
app/controllers/portlet/table_cols_controller.rb
Normal file
@ -0,0 +1,35 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Portlet::TableColsController < ApplicationController
|
||||
def create
|
||||
|
||||
@table_content = TableContent.find(params[:table_content_id])
|
||||
|
||||
@table_content.table_rows.each do |table_row|
|
||||
CelTable.create( :position => params[:position], :table_row_id => table_row.id)
|
||||
|
||||
|
||||
end
|
||||
@table_content.nbr_cols = @table_content.nbr_cols + 1
|
||||
@table_content.save
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
|
||||
def destroy
|
||||
@table_content = TableContent.find(params[:table_content_id])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CelTable.where(:table_row_id => @table_content.table_row_ids,:position => params[:id] ).each do |cel_table|
|
||||
cel_table.destroy
|
||||
|
||||
end
|
||||
|
||||
@table_content.nbr_cols = @table_content.nbr_cols - 1
|
||||
@table_content.save
|
||||
end
|
||||
|
||||
end
|
108
app/controllers/portlet/table_contents_controller.rb
Normal file
108
app/controllers/portlet/table_contents_controller.rb
Normal file
@ -0,0 +1,108 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Portlet::TableContentsController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
def new
|
||||
@table_content = TableContent.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@table_content = TableContent.new(params[:table_content])
|
||||
|
||||
respond_to do |format|
|
||||
if @table_content.save
|
||||
|
||||
|
||||
@portlet = Portlet.create(:position => params[:position], :block_id => params[:block_id], :content => @table_content)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Elément ajouté avec succès.') }
|
||||
format.js { render :template => "portlet/shared/create" }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@table_content = TableContent.find(params[:id])
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :template => "portlet/shared/edit", :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def show
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@table_content = TableContent.find(params[:id])
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
|
||||
respond_to do |format|
|
||||
if @table_content.update_attributes(params[:table_content])
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (modification d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Titre mis à jour.') }
|
||||
format.js { render :template => "portlet/shared/update" }
|
||||
else
|
||||
format.html { render :action => "portlet/shared/edit" }
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
@table_content = TableContent.find(params[:id])
|
||||
@table_content.destroy
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (suppression d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.js { render :template => "portlet/shared/destroy" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
106
app/controllers/portlet/table_rows_controller.rb
Normal file
106
app/controllers/portlet/table_rows_controller.rb
Normal file
@ -0,0 +1,106 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Portlet::TableRowsController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
def new
|
||||
@title_content = TitleContent.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@table_row = TableRow.new(params[:table_row])
|
||||
|
||||
respond_to do |format|
|
||||
if @table_row.save
|
||||
|
||||
@table = @table_row.table_content
|
||||
@table.nbr_cols.times do
|
||||
cel_table = CelTable.new
|
||||
@table_row.cel_tables << cel_table
|
||||
end
|
||||
nbr_past = @table.nbr_rows
|
||||
@table.nbr_rows = nbr_past +1
|
||||
@table.save
|
||||
|
||||
|
||||
@portlet = Portlet.find(@table.portlet.id)
|
||||
|
||||
#format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Elément ajouté avec succès.') }
|
||||
format.js
|
||||
else
|
||||
#format.html { render :action => "new" }
|
||||
#format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@title_content = TitleContent.find(params[:id])
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :template => "portlet/shared/edit", :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def show
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@title_content = TitleContent.find(params[:id])
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
|
||||
respond_to do |format|
|
||||
if @title_content.update_attributes(params[:title_content])
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (modification d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Titre mis à jour.') }
|
||||
format.js { render :template => "portlet/shared/update" }
|
||||
else
|
||||
format.html { render :action => "portlet/shared/edit" }
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
||||
@table_row = TableRow.find(params[:id])
|
||||
@table_content = @table_row.table_content
|
||||
@table_row.destroy
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
116
app/controllers/portlet/text_contents_controller.rb
Normal file
116
app/controllers/portlet/text_contents_controller.rb
Normal file
@ -0,0 +1,116 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Portlet::TextContentsController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
def new
|
||||
@text_content = TextContent.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@text_content = TextContent.new(params[:text_content])
|
||||
|
||||
respond_to do |format|
|
||||
if @text_content.save
|
||||
|
||||
|
||||
@portlet = Portlet.create(:position => params[:position], :block_id => params[:block_id], :content => @text_content)
|
||||
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (ajout d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Elément ajouté avec succès.') }
|
||||
format.js { render :template => "portlet/shared/create" }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@text_content = TextContent.find(params[:id])
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :template => "portlet/shared/edit", :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def show
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@text_content = TextContent.find(params[:id])
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
|
||||
respond_to do |format|
|
||||
if @text_content.update_attributes(params[:text_content])
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (modification d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Titre mis à jour.') }
|
||||
format.js { render :template => "portlet/shared/update" }
|
||||
else
|
||||
format.html { render :action => "portlet/shared/edit" }
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
@text_content = TextContent.find(params[:id])
|
||||
@text_content.destroy
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (suppression d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.js { render :template => "portlet/shared/destroy" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
116
app/controllers/portlet/title_contents_controller.rb
Normal file
116
app/controllers/portlet/title_contents_controller.rb
Normal file
@ -0,0 +1,116 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Portlet::TitleContentsController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
def new
|
||||
@title_content = TitleContent.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@title_content = TitleContent.new(params[:title_content])
|
||||
|
||||
respond_to do |format|
|
||||
if @title_content.save
|
||||
|
||||
|
||||
@portlet = Portlet.create(:position => params[:position], :block_id => params[:block_id], :content => @title_content)
|
||||
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (ajout d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Elément ajouté avec succès.') }
|
||||
format.js { render :template => "portlet/shared/create" }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.js { render :template => "portlet/shared/new" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@title_content = TitleContent.find(params[:id])
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if request.xhr?
|
||||
render :template => "portlet/shared/edit", :layout => false
|
||||
end
|
||||
}
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def show
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@title_content = TitleContent.find(params[:id])
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
|
||||
respond_to do |format|
|
||||
if @title_content.update_attributes(params[:title_content])
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (modification d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
format.html { redirect_to([:admin, @portlet.block.blockable], :notice => 'Titre mis à jour.') }
|
||||
format.js { render :template => "portlet/shared/update" }
|
||||
else
|
||||
format.html { render :action => "portlet/shared/edit" }
|
||||
format.js { render :template => "portlet/shared/edit" }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@portlet = Portlet.find(params[:portlet_id])
|
||||
@title_content = TitleContent.find(params[:id])
|
||||
@title_content.destroy
|
||||
|
||||
if @portlet.block and @portlet.block.blockable
|
||||
@portlet.block.blockable.updated_at = Time.now
|
||||
@portlet.block.blockable.save
|
||||
if @portlet.block.blockable_type == "Page"
|
||||
|
||||
to_my_log("[Page_"+@portlet.block.blockable.id.to_s+"] "+"Modification de la page "+@portlet.block.blockable.title.to_s+" (suppression d'un portlet)")
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.js { render :template => "portlet/shared/destroy" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
46
app/controllers/public/menu_items_controller.rb
Normal file
46
app/controllers/public/menu_items_controller.rb
Normal file
@ -0,0 +1,46 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Public::MenuItemsController < ApplicationController
|
||||
|
||||
layout "public"
|
||||
def show
|
||||
@menu_item = MenuItem.find_by_permalink(params[:url])
|
||||
if @menu_item
|
||||
|
||||
if !@menu_item.enabled
|
||||
redirect_to "/404.html"
|
||||
|
||||
elsif @menu_item.menu_content_type == "MenuAlias"
|
||||
if @menu_item.menu_content.menu_item
|
||||
redirect_to menu_item_path(:url => @menu_item.menu_content.menu_item_alias.permalink)
|
||||
else
|
||||
redirect_to "/404.html"
|
||||
end
|
||||
|
||||
|
||||
elsif @menu_item.menu_content_type == "Page"
|
||||
|
||||
|
||||
@page = @menu_item.menu_content
|
||||
|
||||
@title = @page.title
|
||||
|
||||
|
||||
end
|
||||
else
|
||||
redirect_to "/", :notice => "La page que vous demandez n'a pas pu être trouvée.<br /><br />Vous avez donc été redirigé sur notre page d'accueil"
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def home
|
||||
if MenuItem.find_by_slug("accueil")
|
||||
|
||||
redirect_to "/pages/accueil.html"
|
||||
|
||||
else
|
||||
|
||||
render :file => "#{Rails.root}/public/404.html", :status => :not_found, :layout => false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
2
app/helpers/admin/adherents_helper.rb
Normal file
2
app/helpers/admin/adherents_helper.rb
Normal file
@ -0,0 +1,2 @@
|
||||
module Admin::AdherentsHelper
|
||||
end
|
35
app/helpers/admin/auto_load_div_helper.rb
Normal file
35
app/helpers/admin/auto_load_div_helper.rb
Normal file
@ -0,0 +1,35 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
module Admin::AutoLoadDivHelper
|
||||
|
||||
def auto_load_div(url,div=nil)
|
||||
|
||||
r = ""
|
||||
|
||||
|
||||
rand = (rand(99999999999999))
|
||||
|
||||
|
||||
|
||||
|
||||
content = content_tag(:div, "", :id => rand.to_s)
|
||||
|
||||
|
||||
content += content_tag(:div, image_tag('/quartz_admin/icons/load.gif'), :class => "loading")
|
||||
content += content_tag(:div, "", :class => "ajax_load_content")
|
||||
|
||||
javascript = "<script type='text/javascript'>"
|
||||
javascript += "\n//<![CDATA["
|
||||
javascript += "\n"
|
||||
javascript += 'auto_load_div($("#'+rand.to_s+'").parent());'
|
||||
|
||||
javascript += "\n //]]>"
|
||||
javascript += "\n</script>"
|
||||
|
||||
content += raw(javascript)
|
||||
|
||||
content_tag(:div, content, :"data-load" => true, :"data-url" => url, :id => div.to_s)
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
19
app/helpers/admin/icon_helper.rb
Normal file
19
app/helpers/admin/icon_helper.rb
Normal file
@ -0,0 +1,19 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
module Admin::IconHelper
|
||||
|
||||
|
||||
def i(name,color=:gray_dark, size=16)
|
||||
|
||||
image_tag(i_path(name,color,size))
|
||||
end
|
||||
|
||||
def i_path(name,color=:gray_dark, size=16)
|
||||
if size.kind_of?(Integer)
|
||||
s = size.to_s+"x"+size.to_s
|
||||
else
|
||||
s = size.to_s
|
||||
end
|
||||
"/iconic/"+color.to_s+"/"+name.to_s+"_"+s+".png"
|
||||
end
|
||||
|
||||
end
|
28
app/helpers/admin/javascripts_helper.rb
Normal file
28
app/helpers/admin/javascripts_helper.rb
Normal file
@ -0,0 +1,28 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
module Admin::JavascriptsHelper
|
||||
|
||||
def flash_notice()
|
||||
if flash[:notice]
|
||||
text = flash[:notice]
|
||||
flash[:notice] = nil
|
||||
return raw('flash_notice("'+escape_javascript(text)+'");')
|
||||
end
|
||||
end
|
||||
|
||||
def flash_alert()
|
||||
if flash[:alert]
|
||||
text = flash[:alert]
|
||||
flash[:alert] = nil
|
||||
return raw('flash_alert("'+escape_javascript(text)+'");')
|
||||
end
|
||||
end
|
||||
|
||||
def flashs()
|
||||
r= flash_notice().to_s
|
||||
r+= flash_alert().to_s
|
||||
|
||||
return raw(r)
|
||||
end
|
||||
|
||||
|
||||
end
|
36
app/helpers/admin/magick_order_helper.rb
Normal file
36
app/helpers/admin/magick_order_helper.rb
Normal file
@ -0,0 +1,36 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
module Admin::MagickOrderHelper
|
||||
|
||||
|
||||
def a_d(test=params[:a_d])
|
||||
if test == "DESC"
|
||||
"ASC"
|
||||
else
|
||||
"DESC"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
def link_to_sort_results(text, row)
|
||||
|
||||
new_params = {}
|
||||
|
||||
|
||||
new_params[:order] = row
|
||||
new_params[:a_d] = a_d
|
||||
params.each do |p|
|
||||
new_params[p[0].to_sym] = p[1]
|
||||
end
|
||||
new_params[:order] = row
|
||||
new_params[:a_d] = a_d
|
||||
#:page => (params[:page] if params[:page])
|
||||
|
||||
link_to( text, url_for(new_params ), :remote => true, :style => ("font-weight:bold" if row == params[:order]))
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
40
app/helpers/admin/pagination_helper.rb
Normal file
40
app/helpers/admin/pagination_helper.rb
Normal file
@ -0,0 +1,40 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
module Admin::PaginationHelper
|
||||
|
||||
|
||||
def per_page_link(per_page)
|
||||
new_params = {}
|
||||
new_params.merge!(params)
|
||||
new_params["per_page"] = per_page
|
||||
link_to per_page, new_params, :remote => true
|
||||
|
||||
end
|
||||
|
||||
def per_page_links(per_page, items)
|
||||
to_r = ""
|
||||
|
||||
|
||||
nbrs = [5, 10, 20, 50 ]
|
||||
|
||||
|
||||
max = ((items.to_i.to_f / 10).to_i*10)+10
|
||||
nbrs << max if !nbrs.include?(max)
|
||||
nbrs_to_show = nbrs
|
||||
nbrs_to_show.delete(per_page.to_i)
|
||||
nbrs.sort.each do |nbr|
|
||||
to_r += per_page_link(nbr)
|
||||
end
|
||||
to_r += "<em>"
|
||||
to_r += per_page.to_s
|
||||
to_r += "</em>"
|
||||
to_r += " lignes/pages"
|
||||
|
||||
raw(to_r)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
3
app/helpers/application_helper.rb
Normal file
3
app/helpers/application_helper.rb
Normal file
@ -0,0 +1,3 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
module ApplicationHelper
|
||||
end
|
20
app/helpers/public/menu_items_helper.rb
Normal file
20
app/helpers/public/menu_items_helper.rb
Normal file
@ -0,0 +1,20 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
module Public::MenuItemsHelper
|
||||
def menu_item_link(menu_item)
|
||||
link_to menu_item.name, menu_item_path(:url => menu_item.url), :class => ('active' if @menu_item and (@menu_item.id == menu_item.id or @menu_item.ancestors.include?(menu_item)))
|
||||
end
|
||||
|
||||
def lien_bouton(nbr,slug)
|
||||
menu_item = MenuItem.find_by_slug( slug)
|
||||
if menu_item
|
||||
link_to "", menu_item_path(:url => menu_item.url) , :id => "button-"+nbr.to_s, :class => "digibutton", :"data-text" => menu_item.name
|
||||
end
|
||||
# page = Page.find_by_permanent_slug("bouton"+nbr.to_s) || nil
|
||||
# if page
|
||||
# link_to "", permalink(page) , :id => "button-"+nbr.to_s, :class => "digibutton", :"data-text" => page.title
|
||||
# else
|
||||
# link_to "", "" , :id => "button-"+nbr.to_s, :class => "digibutton", :"data-text" => ""
|
||||
# end
|
||||
end
|
||||
|
||||
end
|
0
app/mailers/.gitkeep
Normal file
0
app/mailers/.gitkeep
Normal file
15
app/mailers/general.rb
Normal file
15
app/mailers/general.rb
Normal file
@ -0,0 +1,15 @@
|
||||
class General < ActionMailer::Base
|
||||
default :from => "secretaire@fcpe-lycee-moirans.fr"
|
||||
self.default_url_options = {:host => HOSTNAME}
|
||||
|
||||
|
||||
def send_newsletter(email,subject, newsletter)
|
||||
@newsletter = newsletter
|
||||
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.html { render :action => "send_newsletter"}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
0
app/models/.gitkeep
Normal file
0
app/models/.gitkeep
Normal file
50
app/models/ability.rb
Normal file
50
app/models/ability.rb
Normal file
@ -0,0 +1,50 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Ability
|
||||
include CanCan::Ability
|
||||
|
||||
def initialize(admin)
|
||||
admin ||= Admin.new # guest user
|
||||
can :manage, :all
|
||||
|
||||
#if admin.super_admin?
|
||||
# can :manage, :all
|
||||
|
||||
#else
|
||||
# puts "TESTs"
|
||||
#
|
||||
# if admin.is? :cms
|
||||
# can :manage, [Article,Album,Block,Cible,DataFile,FileFolder,Folder,HomeBlock,Home,ImageFile,MenuAlias,MenuItem,MenuUrl,Menu,Page,Promotion,Slider,Slide]
|
||||
# end
|
||||
# if admin.is? :pharmacien
|
||||
#
|
||||
# can :manage, [Prescription]
|
||||
#
|
||||
# end
|
||||
# end
|
||||
|
||||
|
||||
|
||||
# Define abilities for the passed in user here. For example:
|
||||
#
|
||||
# user ||= User.new # guest user (not logged in)
|
||||
# if user.admin?
|
||||
# can :manage, :all
|
||||
# else
|
||||
# can :read, :all
|
||||
# end
|
||||
#
|
||||
# The first argument to `can` is the action you are giving the user permission to do.
|
||||
# If you pass :manage it will apply to every action. Other common actions here are
|
||||
# :read, :create, :update and :destroy.
|
||||
#
|
||||
# The second argument is the resource the user can perform the action on. If you pass
|
||||
# :all it will apply to every resource. Otherwise pass a Ruby class of the resource.
|
||||
#
|
||||
# The third argument is an optional hash of conditions to further filter the objects.
|
||||
# For example, here the user can only update published articles.
|
||||
#
|
||||
# can :update, Article, :published => true
|
||||
#
|
||||
# See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities
|
||||
end
|
||||
end
|
2
app/models/adherent.rb
Normal file
2
app/models/adherent.rb
Normal file
@ -0,0 +1,2 @@
|
||||
class Adherent < ActiveRecord::Base
|
||||
end
|
43
app/models/authentification_admin/admin.rb
Normal file
43
app/models/authentification_admin/admin.rb
Normal file
@ -0,0 +1,43 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Admin < ActiveRecord::Base
|
||||
|
||||
|
||||
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
attr_accessor :login
|
||||
|
||||
attr_accessible :login, :username, :surname, :firstname, :email, :password, :password_confirmation, :roles_mask, :roles, :super_admin
|
||||
|
||||
|
||||
validates :username, :presence => true, :uniqueness => true
|
||||
|
||||
ROLES = %w[SuperAdmin]
|
||||
|
||||
def super_admin?
|
||||
true if self.is? :SuperAdmin
|
||||
end
|
||||
|
||||
|
||||
def roles=(roles)
|
||||
self.roles_mask = (roles & ROLES).map { |r| 2**ROLES.index(r) }.sum
|
||||
end
|
||||
|
||||
def roles
|
||||
ROLES.reject do |r|
|
||||
((roles_mask || 0) & 2**ROLES.index(r)).zero?
|
||||
end
|
||||
end
|
||||
|
||||
def is?(role)
|
||||
roles.include?(role.to_s)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def self.find_for_database_authentication(warden_conditions)
|
||||
conditions = warden_conditions.dup
|
||||
login = conditions.delete(:login)
|
||||
where(conditions).where(["username = :value OR email = :value", { :value => login }]).first
|
||||
end
|
||||
|
||||
end
|
19
app/models/cible/cible_alias.rb
Normal file
19
app/models/cible/cible_alias.rb
Normal file
@ -0,0 +1,19 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class CibleAlias < ActiveRecord::Base
|
||||
include Rails.application.routes.url_helpers
|
||||
belongs_to :menu_item
|
||||
|
||||
|
||||
validates :menu_item_id, :presence => true
|
||||
#has_one :link_content, :as => :cible
|
||||
has_one :cibleable, :as => :cible
|
||||
|
||||
|
||||
def url
|
||||
if self.menu_item
|
||||
menu_item_path(:url => self.menu_item.permalink)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
14
app/models/cible/cible_article.rb
Normal file
14
app/models/cible/cible_article.rb
Normal file
@ -0,0 +1,14 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class CibleArticle < ActiveRecord::Base
|
||||
include Rails.application.routes.url_helpers
|
||||
belongs_to :article
|
||||
|
||||
|
||||
def url
|
||||
if self.article and self.article.folder
|
||||
article_path(:slug => self.article.slug, :folder_slug => self.article.folder.slug)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
13
app/models/cible/cible_folder.rb
Normal file
13
app/models/cible/cible_folder.rb
Normal file
@ -0,0 +1,13 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class CibleFolder < ActiveRecord::Base
|
||||
include Rails.application.routes.url_helpers
|
||||
belongs_to :folder
|
||||
|
||||
|
||||
def url
|
||||
if self.folder
|
||||
folder_path(:slug => self.folder.slug)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
3
app/models/cible/cible_type.rb
Normal file
3
app/models/cible/cible_type.rb
Normal file
@ -0,0 +1,3 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class CibleType < ActiveRecord::Base
|
||||
end
|
5
app/models/cible/cible_url.rb
Normal file
5
app/models/cible/cible_url.rb
Normal file
@ -0,0 +1,5 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class CibleUrl < ActiveRecord::Base
|
||||
validates :url, :presence => true
|
||||
|
||||
end
|
5
app/models/cms/allowed_block_content.rb
Normal file
5
app/models/cms/allowed_block_content.rb
Normal file
@ -0,0 +1,5 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class AllowedBlockContent < ActiveRecord::Base
|
||||
belongs_to :block
|
||||
belongs_to :content_type
|
||||
end
|
14
app/models/cms/block.rb
Normal file
14
app/models/cms/block.rb
Normal file
@ -0,0 +1,14 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Block < ActiveRecord::Base
|
||||
|
||||
|
||||
belongs_to :blockable, :polymorphic => true
|
||||
|
||||
has_many :portlets, :order => :position, :dependent => :destroy
|
||||
accepts_nested_attributes_for :portlets
|
||||
|
||||
|
||||
has_many :allowed_block_contents
|
||||
|
||||
has_many :content_types, :through => :allowed_block_contents
|
||||
end
|
3
app/models/cms/content_type.rb
Normal file
3
app/models/cms/content_type.rb
Normal file
@ -0,0 +1,3 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class ContentType < ActiveRecord::Base
|
||||
end
|
28
app/models/cms/page.rb
Normal file
28
app/models/cms/page.rb
Normal file
@ -0,0 +1,28 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Page < ActiveRecord::Base
|
||||
|
||||
|
||||
has_one :menu_item, :as => :menu_content
|
||||
|
||||
has_many :blocks, :as => :blockable, :dependent => :destroy
|
||||
|
||||
|
||||
validates :title, :presence => true
|
||||
|
||||
HUMAN_NAME = "Page"
|
||||
|
||||
after_create :after_creation
|
||||
|
||||
def after_creation
|
||||
@block = Block.new(:block_name => "general")
|
||||
@block.blockable = self
|
||||
@block.save
|
||||
|
||||
ContentType.all.each do |content_type|
|
||||
@block.content_types << content_type
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
30
app/models/cms/portlet.rb
Normal file
30
app/models/cms/portlet.rb
Normal file
@ -0,0 +1,30 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Portlet < ActiveRecord::Base
|
||||
belongs_to :block
|
||||
belongs_to :content, :polymorphic => true
|
||||
accepts_nested_attributes_for :content
|
||||
|
||||
attr_accessor :skip_before_update
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
before_create do
|
||||
|
||||
end
|
||||
|
||||
before_update do
|
||||
|
||||
end
|
||||
|
||||
before_destroy do
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
7
app/models/cms/tag.rb
Normal file
7
app/models/cms/tag.rb
Normal file
@ -0,0 +1,7 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Tag < ActiveRecord::Base
|
||||
|
||||
before_validation do
|
||||
self.slug = self.name.to_slug
|
||||
end
|
||||
end
|
4
app/models/foyer.rb
Normal file
4
app/models/foyer.rb
Normal file
@ -0,0 +1,4 @@
|
||||
class Foyer < ActiveRecord::Base
|
||||
|
||||
has_many :studients, :dependent => :destroy
|
||||
end
|
5
app/models/manager/album.rb
Normal file
5
app/models/manager/album.rb
Normal file
@ -0,0 +1,5 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Album < ActiveRecord::Base
|
||||
validates :name, :presence => true, :uniqueness => true
|
||||
|
||||
end
|
33
app/models/manager/data_file.rb
Normal file
33
app/models/manager/data_file.rb
Normal file
@ -0,0 +1,33 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class DataFile < ActiveRecord::Base
|
||||
belongs_to :file_folder
|
||||
|
||||
|
||||
mount_uploader :file, FileUploader
|
||||
|
||||
before_save do
|
||||
if !self.name?
|
||||
self.name = File.basename(self.file.filename, File.extname(self.file.filename)).to_s if self.file?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
def file_type
|
||||
|
||||
|
||||
mime = `file --mime -br "#{self.file.path}"`.strip.split(';')[0]
|
||||
mime
|
||||
|
||||
end
|
||||
|
||||
def abstract_file_name
|
||||
self.name+File.extname(self.file.to_s)
|
||||
end
|
||||
|
||||
def abstract_file_name_slug
|
||||
self.name.to_slug+File.extname(self.file.to_s)
|
||||
end
|
||||
|
||||
end
|
3
app/models/manager/file_folder.rb
Normal file
3
app/models/manager/file_folder.rb
Normal file
@ -0,0 +1,3 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class FileFolder < ActiveRecord::Base
|
||||
end
|
29
app/models/manager/image_file.rb
Normal file
29
app/models/manager/image_file.rb
Normal file
@ -0,0 +1,29 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class ImageFile < ActiveRecord::Base
|
||||
mount_uploader :file, ImageUploader
|
||||
|
||||
before_save do
|
||||
if !self.name?
|
||||
self.name = File.basename(self.file.filename, File.extname(self.file.filename)).to_s if self.file?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
before_validation do
|
||||
if self.tags?
|
||||
self.tags = self.tags.gsub(/ +?,/, ',')
|
||||
self.tags = self.tags.gsub(/, +?/, ',')
|
||||
self.tags = self.tags.gsub(/,/, ', ')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
after_save do
|
||||
tags_to_save = self.tags.to_s.split(',')
|
||||
tags_to_save.each do |t|
|
||||
name = t.to_s.strip
|
||||
|
||||
Tag.find_or_create_by_name(t.to_s.strip) if name.size > 0
|
||||
end
|
||||
end
|
||||
end
|
15
app/models/menus/menu.rb
Normal file
15
app/models/menus/menu.rb
Normal file
@ -0,0 +1,15 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Menu < ActiveRecord::Base
|
||||
|
||||
|
||||
#field :name, :type => String
|
||||
#field :max_levels, :type => Integer
|
||||
has_many :menu_items
|
||||
|
||||
|
||||
validates_presence_of :name, :max_levels
|
||||
validates_uniqueness_of :name
|
||||
|
||||
# references_many :menu_items
|
||||
|
||||
end
|
13
app/models/menus/menu_alias.rb
Normal file
13
app/models/menus/menu_alias.rb
Normal file
@ -0,0 +1,13 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class MenuAlias < ActiveRecord::Base
|
||||
belongs_to :menu_item_alias, :foreign_key => :menu_item_id, :class_name => "MenuItem"
|
||||
|
||||
has_one :menu_item, :as => :menu_content
|
||||
|
||||
validates :menu_item_id, :presence => true
|
||||
|
||||
HUMAN_NAME = "Alias"
|
||||
|
||||
|
||||
|
||||
end
|
10
app/models/menus/menu_article.rb
Normal file
10
app/models/menus/menu_article.rb
Normal file
@ -0,0 +1,10 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class MenuArticle < ActiveRecord::Base
|
||||
belongs_to :article
|
||||
|
||||
|
||||
|
||||
HUMAN_NAME = "Article"
|
||||
|
||||
|
||||
end
|
8
app/models/menus/menu_folder.rb
Normal file
8
app/models/menus/menu_folder.rb
Normal file
@ -0,0 +1,8 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class MenuFolder < ActiveRecord::Base
|
||||
belongs_to :folder
|
||||
|
||||
HUMAN_NAME = "Dossier"
|
||||
|
||||
|
||||
end
|
180
app/models/menus/menu_item.rb
Normal file
180
app/models/menus/menu_item.rb
Normal file
@ -0,0 +1,180 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class MenuItem < ActiveRecord::Base
|
||||
|
||||
belongs_to :menu_content, :polymorphic => true
|
||||
belongs_to :menu
|
||||
validates :name, :presence => true
|
||||
validates :slug, :presence => true
|
||||
|
||||
|
||||
attr_accessor :skip_before_update, :skip_permalink
|
||||
|
||||
|
||||
accepts_nested_attributes_for :menu_content
|
||||
|
||||
acts_as_tree
|
||||
|
||||
def url
|
||||
if menu_content
|
||||
self.permalink
|
||||
|
||||
else
|
||||
"/404.html"
|
||||
end
|
||||
end
|
||||
|
||||
before_validation do
|
||||
self.slug = self.slug.to_slug
|
||||
|
||||
end
|
||||
|
||||
before_save do
|
||||
#self.set_permalink
|
||||
end
|
||||
|
||||
def generate_permalink
|
||||
r = ""
|
||||
|
||||
node, ancestors = self, []
|
||||
ancestors << node = MenuItem.find(node.parent_id) while node.parent_id?
|
||||
|
||||
|
||||
|
||||
ancestors.reverse.each do |ancestor|
|
||||
r += ancestor.slug.to_s
|
||||
r+= "/"
|
||||
end
|
||||
r+= self.slug.to_s
|
||||
end
|
||||
|
||||
def set_permalink
|
||||
|
||||
|
||||
if !skip_permalink
|
||||
|
||||
self.permalink = self.generate_permalink
|
||||
self.skip_permalink = true
|
||||
self.skip_before_update = true
|
||||
|
||||
|
||||
|
||||
self.save
|
||||
|
||||
|
||||
# self.children.each do |child|
|
||||
# child.save
|
||||
# end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
def validate
|
||||
self.parent_id = nil if self.parent_id == 0
|
||||
errors.add(:parent_id, 'doit être différent de la page actuelle') if parent_id == id and id != nil
|
||||
|
||||
if self.id
|
||||
errors.add(:parent_id, 'attention la page parente à pour page parente celle-ci = boucle') if self.parent_id and self.id == MenuItem.find(self.parent_id).parent_id
|
||||
end
|
||||
|
||||
conditions = ["menu_id = ? and parent_id "+(self.parent_id ? "=" : "IS")+" ? and slug = ? "+("and id != ?" if self.id).to_s, self.menu_id,self.parent_id ,self.slug]
|
||||
conditions << self.id if self.id
|
||||
if MenuItem.where(conditions).first
|
||||
errors.add(:slug, 'est déjà utilisé')
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
before_create do
|
||||
if !position
|
||||
top = MenuItem.find(:first, :conditions =>{ :parent_id => self.parent_id, :menu_id => self.menu_id}, :order => "position DESC")
|
||||
if top
|
||||
self.position = top.position.to_i + 1
|
||||
else
|
||||
self.position = 1
|
||||
end
|
||||
end
|
||||
if position
|
||||
MenuItem.find(:all, :conditions => ["menu_id = ? and position >= ? and parent_id "+(self.parent_id ? "=" : "IS")+" ?",self.menu_id,self.position,self.parent_id]).each do |portlet|
|
||||
portlet.position = portlet.position + 1
|
||||
portlet.skip_before_update = true
|
||||
portlet.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
before_update do
|
||||
if !skip_before_update
|
||||
if self.parent_id_changed?
|
||||
|
||||
MenuItem.find(:all, :conditions => ["menu_id = ? and position > ? and parent_id "+(self.changes['parent_id'][0] ? "=" : "IS")+" ?",self.menu_id,self.position,self.changes['parent_id'][0]]).each do |portlet|
|
||||
portlet.position = portlet.position - 1
|
||||
portlet.skip_before_update = true
|
||||
portlet.save!
|
||||
end
|
||||
|
||||
self.position = 1
|
||||
|
||||
MenuItem.find(:all, :conditions => ["menu_id = ? and parent_id "+(self.parent_id ? "=" : "IS")+" ?",self.menu_id,self.parent_id]).each do |portlet|
|
||||
portlet.position = portlet.position + 1
|
||||
portlet.skip_before_update = true
|
||||
portlet.save!
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
elsif self.position_changed?
|
||||
|
||||
top = MenuItem.find(:first, :conditions =>{ :parent_id => self.parent_id, :menu_id => self.menu_id}, :order => "position DESC")
|
||||
|
||||
if self.changes['position'][1] > self.changes['position'][0]
|
||||
self.position = self.position - 1
|
||||
self.changes['position'][1] = self.changes['position'][1] - 1
|
||||
|
||||
MenuItem.find(:all, :conditions => ["menu_id = ? and position > ? and position <= ? and parent_id "+(self.parent_id ? "=" : "IS")+" ?",self.menu_id,self.changes['position'][0],self.changes['position'][1],self.parent_id]).each do |portlet|
|
||||
portlet.position = portlet.position - 1
|
||||
portlet.skip_before_update = true
|
||||
portlet.save!
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
#si la position est plus petite que l'ancienne.
|
||||
elsif self.changes['position'][1] < self.changes['position'][0]
|
||||
MenuItem.find(:all, :conditions => ["menu_id = ? and position >= ? and position < ? and parent_id "+(self.parent_id ? "=" : "IS")+" ?",self.menu_id,self.changes['position'][1],self.changes['position'][0],self.parent_id]).each do |portlet|
|
||||
portlet.position = portlet.position + 1
|
||||
portlet.skip_before_update = true
|
||||
portlet.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
before_destroy do
|
||||
MenuItem.find(:all, :conditions => ["menu_id = ? and position > ? and parent_id "+(self.parent_id ? "=" : "IS")+" ?",self.menu_id,self.position,self.parent_id]).each do |portlet|
|
||||
portlet.position = portlet.position - 1
|
||||
portlet.skip_before_update = true
|
||||
portlet.save!
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
3
app/models/menus/menu_item_content_type.rb
Normal file
3
app/models/menus/menu_item_content_type.rb
Normal file
@ -0,0 +1,3 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class MenuItemContentType < ActiveRecord::Base
|
||||
end
|
9
app/models/menus/menu_url.rb
Normal file
9
app/models/menus/menu_url.rb
Normal file
@ -0,0 +1,9 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class MenuUrl < ActiveRecord::Base
|
||||
has_one :menu_item, :as => :menu_content
|
||||
|
||||
validates :url, :presence => true
|
||||
|
||||
HUMAN_NAME = "Lien externe"
|
||||
|
||||
end
|
2
app/models/newsletter.rb
Normal file
2
app/models/newsletter.rb
Normal file
@ -0,0 +1,2 @@
|
||||
class Newsletter < ActiveRecord::Base
|
||||
end
|
9
app/models/portlets/block_content.rb
Normal file
9
app/models/portlets/block_content.rb
Normal file
@ -0,0 +1,9 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class BlockContent < ActiveRecord::Base
|
||||
has_many :portlets, :as => :content, :dependent => :destroy
|
||||
has_many :blocks, :as => :blockable, :dependent => :destroy
|
||||
|
||||
validates :nbr_columns, :presence => true
|
||||
|
||||
STYLES = []#[["Style 1",1], ["Style 2",2]]
|
||||
end
|
6
app/models/portlets/break_content.rb
Normal file
6
app/models/portlets/break_content.rb
Normal file
@ -0,0 +1,6 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class BreakContent < ActiveRecord::Base
|
||||
has_many :portlets, :as => :content, :dependent => :destroy
|
||||
|
||||
STYLES = []#[["Style 1",1], ["Style 2",2]]
|
||||
end
|
67
app/models/portlets/cel_table.rb
Normal file
67
app/models/portlets/cel_table.rb
Normal file
@ -0,0 +1,67 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class CelTable < ActiveRecord::Base
|
||||
belongs_to :table_row
|
||||
#belongs_to :table_content possible
|
||||
|
||||
has_one :block, :as => :blockable, :dependent => :destroy
|
||||
|
||||
attr_accessor :skip_before_update
|
||||
|
||||
|
||||
|
||||
|
||||
before_create do
|
||||
if !position
|
||||
self.position = 1
|
||||
end
|
||||
if position
|
||||
CelTable.find(:all, :conditions => ["position >= ? and table_row_id = ?",self.position,self.table_row_id]).each do |cel_table|
|
||||
cel_table.position = cel_table.position + 1
|
||||
cel_table.skip_before_update = true
|
||||
cel_table.save!
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
after_create do
|
||||
block = Block.create()
|
||||
puts "CREATION DU BLOCK "+block.id.to_s
|
||||
self.block = block
|
||||
end
|
||||
|
||||
before_update do
|
||||
if !skip_before_update
|
||||
if self.position_changed?
|
||||
#si la position est plus grande que l'ancienne
|
||||
if self.changes['position'][1] > self.changes['position'][0]
|
||||
CelTable.find(:all, :conditions => ["position > ? and position <= ? and table_row_id = ?",self.changes['position'][0],self.changes['position'][1],self.table_row_id]).each do |cel_table|
|
||||
cel_table.position = cel_table.position - 1
|
||||
cel_table.skip_before_update = true
|
||||
cel_table.save!
|
||||
end
|
||||
end
|
||||
#si la position est plus petite que l'ancienne.
|
||||
if self.changes['position'][1] < self.changes['position'][0]
|
||||
CelTable.find(:all, :conditions => ["position >= ? and position < ? and table_row_id = ?",self.changes['position'][1],self.changes['position'][0],self.table_row_id]).each do |cel_table|
|
||||
cel_table.position = cel_table.position + 1
|
||||
cel_table.skip_before_update = true
|
||||
cel_table.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
before_destroy do
|
||||
CelTable.find(:all, :conditions => ["position > ? and table_row_id = ?",self.position,self.table_row_id]).each do |cel_table|
|
||||
cel_table.position = cel_table.position - 1
|
||||
cel_table.skip_before_update = true
|
||||
cel_table.save!
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
9
app/models/portlets/download_content.rb
Normal file
9
app/models/portlets/download_content.rb
Normal file
@ -0,0 +1,9 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class DownloadContent < ActiveRecord::Base
|
||||
belongs_to :data_file
|
||||
|
||||
has_one :portlet, :as => :content, :dependent => :destroy
|
||||
|
||||
STYLES = []#[["Medium","1"], ["Small","2"], ["Square","3"], ["Thumb","4"]]
|
||||
|
||||
end
|
9
app/models/portlets/dynamic_content.rb
Normal file
9
app/models/portlets/dynamic_content.rb
Normal file
@ -0,0 +1,9 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class DynamicContent < ActiveRecord::Base
|
||||
has_many :portlets, :as => :content, :dependent => :destroy
|
||||
|
||||
belongs_to :item
|
||||
|
||||
NAMES = {"formulaire_ordonnances" => "Formulaire dépôt ordonnances", "folder_list" => "Liste des dossiers", "promotions-list" => "Liste des promotions"}
|
||||
|
||||
end
|
8
app/models/portlets/gallery_content.rb
Normal file
8
app/models/portlets/gallery_content.rb
Normal file
@ -0,0 +1,8 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class GalleryContent < ActiveRecord::Base
|
||||
has_many :gallery_images, :order => :position
|
||||
|
||||
has_one :portlet, :as => :content, :dependent => :destroy
|
||||
|
||||
STYLES = []#[["Style 1",1], ["Style 2",2]]
|
||||
end
|
7
app/models/portlets/gallery_image.rb
Normal file
7
app/models/portlets/gallery_image.rb
Normal file
@ -0,0 +1,7 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class GalleryImage < ActiveRecord::Base
|
||||
belongs_to :image_file, :dependent => :destroy
|
||||
belongs_to :gallery
|
||||
|
||||
validates :title, :presence => true
|
||||
end
|
6
app/models/portlets/html_content.rb
Normal file
6
app/models/portlets/html_content.rb
Normal file
@ -0,0 +1,6 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class HtmlContent < ActiveRecord::Base
|
||||
has_many :portlets, :as => :content, :dependent => :destroy
|
||||
|
||||
STYLES = []#[["Style 1",1], ["Style 2",2]]
|
||||
end
|
8
app/models/portlets/image_content.rb
Normal file
8
app/models/portlets/image_content.rb
Normal file
@ -0,0 +1,8 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class ImageContent < ActiveRecord::Base
|
||||
belongs_to :image_file
|
||||
|
||||
has_one :portlet, :as => :content, :dependent => :destroy
|
||||
STYLES = [["Taille moyenne","1"], ["Petite taille","2"], ["Petit carré","3"], ["Miniature","4"]]
|
||||
ALIGNS = ["center", "left", "right"]
|
||||
end
|
24
app/models/portlets/link_content.rb
Normal file
24
app/models/portlets/link_content.rb
Normal file
@ -0,0 +1,24 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class LinkContent < ActiveRecord::Base
|
||||
belongs_to :item
|
||||
|
||||
belongs_to :cible, :polymorphic => true
|
||||
|
||||
has_one :portlet, :as => :content, :dependent => :destroy
|
||||
|
||||
validates :name, :presence => true
|
||||
|
||||
accepts_nested_attributes_for :cible
|
||||
|
||||
def url
|
||||
|
||||
if self.cible
|
||||
cible.url
|
||||
else
|
||||
""
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
STYLES = [["Style 1",1], ["Style 2",2]]
|
||||
end
|
12
app/models/portlets/map_content.rb
Normal file
12
app/models/portlets/map_content.rb
Normal file
@ -0,0 +1,12 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class MapContent < ActiveRecord::Base
|
||||
|
||||
has_one :portlet, :as => :content, :dependent => :destroy
|
||||
|
||||
validates :address, :presence => true
|
||||
|
||||
VIEWS = [["Plan",1], ["Mixte",2], ["Satelite",3]]
|
||||
|
||||
ZOOMS = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]
|
||||
|
||||
end
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user