Commit 1e765070 authored by David F.'s avatar David F.
Browse files

Merge branch '100-infos-clubs' into 'master'

Resolve "Infos des clubs Sport Adapté Girondins"

See merge request CDSA33/OLIGAA!100
parents 231051d5 9ae7df7e
......@@ -22,7 +22,7 @@
#
source 'https://rubygems.org'
gem 'rails', '5.1.6'
gem 'rails', '5.1.7'
gem 'sass-rails'
gem 'uglifier'
gem 'coffee-rails'
......
......@@ -46,39 +46,39 @@ GEM
remote: https://rubygems.org/
specs:
RedCloth (4.3.2)
actioncable (5.1.6)
actionpack (= 5.1.6)
actioncable (5.1.7)
actionpack (= 5.1.7)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.1.6)
actionpack (= 5.1.6)
actionview (= 5.1.6)
activejob (= 5.1.6)
actionmailer (5.1.7)
actionpack (= 5.1.7)
actionview (= 5.1.7)
activejob (= 5.1.7)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.1.6)
actionview (= 5.1.6)
activesupport (= 5.1.6)
actionpack (5.1.7)
actionview (= 5.1.7)
activesupport (= 5.1.7)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.1.6)
activesupport (= 5.1.6)
actionview (5.1.7)
activesupport (= 5.1.7)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.1.6)
activesupport (= 5.1.6)
activejob (5.1.7)
activesupport (= 5.1.7)
globalid (>= 0.3.6)
activemodel (5.1.6)
activesupport (= 5.1.6)
activerecord (5.1.6)
activemodel (= 5.1.6)
activesupport (= 5.1.6)
activemodel (5.1.7)
activesupport (= 5.1.7)
activerecord (5.1.7)
activemodel (= 5.1.7)
activesupport (= 5.1.7)
arel (~> 8.0)
activesupport (5.1.6)
activesupport (5.1.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
......@@ -132,7 +132,7 @@ GEM
compass (~> 1.0.0)
sass-rails (< 5.1)
sprockets (< 4.0)
concurrent-ruby (1.0.5)
concurrent-ruby (1.1.5)
crack (0.4.3)
safe_yaml (~> 1.0.0)
crass (1.0.4)
......@@ -149,7 +149,7 @@ GEM
dotenv-rails (2.2.1)
dotenv (= 2.2.1)
railties (>= 3.2, < 5.2)
erubi (1.7.1)
erubi (1.8.0)
execjs (2.7.0)
extlib (0.9.16)
factory_girl (4.8.0)
......@@ -174,7 +174,7 @@ GEM
rspec-core (~> 3.0)
ruby-progressbar (~> 1.4)
geocoder (1.4.9)
globalid (0.4.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
google-api-client (0.8.6)
activesupport (>= 3.2)
......@@ -223,28 +223,28 @@ GEM
logging (2.2.2)
little-plugger (~> 1.1)
multi_json (~> 1.10)
loofah (2.2.2)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
mail (2.7.1)
mini_mime (>= 0.1.1)
memoist (0.16.0)
method_source (0.9.0)
method_source (0.9.2)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mimemagic (0.3.2)
mini_mime (1.0.1)
mini_portile2 (2.3.0)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.11.3)
momentjs-rails (2.17.1)
railties (>= 3.1)
multi_json (1.12.2)
multipart-post (2.0.0)
nested_form (0.3.2)
nio4r (2.3.1)
nokogiri (1.8.4)
mini_portile2 (~> 2.3.0)
nio4r (2.4.0)
nokogiri (1.10.4)
mini_portile2 (~> 2.4.0)
os (0.9.6)
paperclip (5.1.0)
activemodel (>= 4.2.0)
......@@ -261,33 +261,33 @@ GEM
uglifier
public_suffix (3.0.3)
puma (3.10.0)
rack (2.0.5)
rack (2.0.7)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.1.6)
actioncable (= 5.1.6)
actionmailer (= 5.1.6)
actionpack (= 5.1.6)
actionview (= 5.1.6)
activejob (= 5.1.6)
activemodel (= 5.1.6)
activerecord (= 5.1.6)
activesupport (= 5.1.6)
rails (5.1.7)
actioncable (= 5.1.7)
actionmailer (= 5.1.7)
actionpack (= 5.1.7)
actionview (= 5.1.7)
activejob (= 5.1.7)
activemodel (= 5.1.7)
activerecord (= 5.1.7)
activesupport (= 5.1.7)
bundler (>= 1.3.0)
railties (= 5.1.6)
railties (= 5.1.7)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
rails-html-sanitizer (1.2.0)
loofah (~> 2.2, >= 2.2.2)
railties (5.1.6)
actionpack (= 5.1.6)
activesupport (= 5.1.6)
railties (5.1.7)
actionpack (= 5.1.7)
activesupport (= 5.1.7)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.3.1)
rake (12.3.3)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
......@@ -345,7 +345,7 @@ GEM
sass (>= 3.3.0, < 3.5)
test-unit (3.2.5)
power_assert
thor (0.20.0)
thor (0.20.3)
thread_safe (0.3.6)
tilt (2.0.8)
timecop (0.8.1)
......@@ -368,7 +368,7 @@ GEM
crack (>= 0.3.2)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
websocket-extensions (0.1.4)
will_paginate (3.1.6)
xpath (3.1.0)
nokogiri (~> 1.8)
......@@ -415,7 +415,7 @@ DEPENDENCIES
piwik_analytics!
prettyphoto-rails
puma
rails (= 5.1.6)
rails (= 5.1.7)
rdoc
rspec-rails
sass-rails
......@@ -435,4 +435,4 @@ DEPENDENCIES
will_paginate
BUNDLED WITH
1.16.1
2.0.1
......@@ -66,6 +66,7 @@
@import "partners";
@import "events";
@import "platform";
@import "club_novels";
.danger {
color: $oligaa-red;
......
#page #columns #content section#club_novels {
ul {
list-style-type: none;
margin: 0;
padding: 0;
li.club_novel {
@extend .card-block-narrow;
@include clearfix;
div.description {
@include span-columns(5,6);
text-align: justify;
h2 {
font-size: 110%;
}
h3 {
color: $oligaa-yellow;
}
div.attached_files {
}
&.pushed {
@include push(1);
}
}
div.aside {
@include span-columns(1 omega,6);
ul.gallery {
list-style-type: none;
margin: 0;
padding: 0;
li {
display: none;
&:first-of-type {
display: block;
}
img {
width: 100%;
}
}
}
span.images-number {
text-align: center;
}
ul.activities {
list-style-type: none;
margin: 0;
padding: 0;
img {
width: 50%;
display: block;
margin: auto;
}
}
}
}
}
ul#unpublished > li {
background: rgba(100%, 0, 0, 0.1);
}
div.pagination {
padding: 1em 0;
text-align: center;
}
}
class ClubNovelsController < ApplicationController
before_action :authorize, except: [:index]
def index
@title = Menu.find_by(uid: 'club_novels')&.title
@unpublished_club_novels = ClubNovel.unpublished.paginate(page: params[:page])
@published_club_novels = ClubNovel.published.ordered.paginate(page: params[:page])
end
def new
@club_novel = ClubNovel.new
end
def create
@club_novel = ClubNovel.new(club_novel_params)
sanitize_publication
if @club_novel.save
flash[:notice] = 'Info club créée avec succès.'
redirect_to club_novels_path
else
render :new
end
end
def edit
@club_novel = ClubNovel.find(params[:id])
end
def update
@club_novel = ClubNovel.find(params[:id])
sanitize_publication
if @club_novel.update_attributes(club_novel_params)
flash[:notice] = 'Info club modifiée avec succès.'
redirect_to club_novels_path
else
render :edit
end
end
def destroy
ClubNovel.find(params[:id]).destroy
flash[:notice] = 'Info club supprimée avec succès.'
redirect_to club_novels_path
end
private
def club_novel_params
params.require(:club_novel).permit(:title, :content, :published_at, activity_ids: [],
attached_files_attributes: attached_file_permitted_attributes,
images_attributes: image_permitted_attributes)
end
def sanitize_publication
@club_novel.published_at = (params[:club_novel][:published] == "true" ? Time.zone.now : nil)
params[:club_novel].delete(:published)
end
end
class ClubNovel < ApplicationRecord
has_and_belongs_to_many :activities
has_many :attached_files, :as => :attachable, :dependent => :destroy
accepts_nested_attributes_for :attached_files, :allow_destroy => true
has_many :images, :as => :imageable, :dependent => :destroy
accepts_nested_attributes_for :images, :allow_destroy => true
scope :published, -> { where.not(published_at: nil) }
scope :unpublished, -> { where(published_at: nil) }
scope :ordered, -> { order(published_at: :desc)}
def self.per_page
4
end
def published
published_at.present?
end
end
<li class="club_novel">
<div class="description">
<h2>
<% if admin? %>
<span class="no_print">
<%= custom_edit_link edit_club_novel_path(club_novel), :short, class: %w(tight) %>
<%= custom_delete_link club_novel, :short, class: %w(tight) %>
</span>
<% end -%>
<%= raw textilize_without_paragraph club_novel.title %>
</h2>
<%= textilize raw club_novel.content %>
<% unless club_novel.attached_files.empty? %>
<h3>Pièces jointes</h3>
<dl class="attachments">
<%= render partial: 'attachment', collection: club_novel.attached_files %>
</dl>
<% end -%>
</div>
<div class="aside">
<ul class="activities">
<% club_novel.activities.each do |activity| %>
<li>
<% if activity.poster? %>
<%= image_tag activity.poster.url(:standard), title: activity.title %>
<% else %>
<%= activity.title %>
<% end %>
</li>
<% end %>
</ul>
<ul class="gallery">
<% club_novel.images.each do |img| %>
<li>
<%= link_to image_tag(img.img_file.url(:thumb), alt: img.title, class: "photo"), img.img_file.url(:large), rel: "prettyPhoto[gallery-#{club_novel.id.to_s}]" %>
</li>
<% end %>
</ul>
<% unless club_novel.images.empty? %>
<span class="images-number"><%= club_novel.images.length %> image(s)</span>
<% end %>
</div>
</li>
<%
# OLIGAA - Stands for "Outil en Ligne d'Information et de Gestion des Activités
# des Associations" which is an online tool for associations to manage news,
# actors and activities.
# Copyright (C) 2010-2018 Comité Départemental du Sport Adapté de la Gironde (CDSA
# 33) <contact@cdsa33.org>
#
# This file is part of OLIGAA.
#
# OLIGAA is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# OLIGAA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with OLIGAA. If not, see <http://www.gnu.org/licenses/>.
%>
<p><%= redcloth_help %></p>
<%= simple_nested_form_for @club_novel do |f| %>
<div class="tabs">
<ul>
<li><a href="#general">Général</a></li>
<li><a href="#activities">Activités</a></li>
<li><a href="#images">Images</a></li>
<li><a href="#attachments">Pièces jointes</a></li>
</ul>
<div id="general">
<%= f.input :title, input_html: {class: "small_text"} %>
<%= f.input :content %>
<%= f.input :published, as: :boolean, checked_value: true, unchecked_value: false %>
</div>
<div id="activities">
<%= f.association :activities, as: :check_boxes %>
</div>
<div id="attachments">
<%= render 'attached_files_form', f: f %>
</div>
<div id="images">
<%= render 'images_form', f: f %>
</div>
</div>
<p><%= f.button :submit %></p>
<% end %>
<%
# OLIGAA - Stands for "Outil en Ligne d'Information et de Gestion des Activités
# des Associations" which is an online tool for associations to manage news,
# actors and activities.
# Copyright (C) 2010-2018 Comité Départemental du Sport Adapté de la Gironde (CDSA
# 33) <contact@cdsa33.org>
#
# This file is part of OLIGAA.
#
# OLIGAA is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# OLIGAA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with OLIGAA. If not, see <http://www.gnu.org/licenses/>.
%>
<% title "Edition d'une info club" %>
<div class="card-block">
<h1><%= yield :title %></h1>
<p class="AdminCard-globalActions">
<%= custom_show_link @club_novel, 'Afficher' %>
<%= custom_list_link club_novels_path %>
</p>
<%= render :partial => 'form' %>
</div>
<% title @title %>
<div class="card-block">
<h1><%= yield :title %></h1>
<% if admin? %>
<p class="AdminCard-globalActions">
<%= custom_add_link 'Nouvelle info club', new_club_novel_path %>
</p>
<% end -%>
</div>
<section id="club_novels">
<% if admin? && !@unpublished_club_novels.empty? %>
<ul id="unpublished">
<%= render partial: 'club_novel', collection: @unpublished_club_novels %>
</ul>
<%= will_paginate @unpublished_club_novels %>
<% end %>
<% unless @published_club_novels.empty? %>
<ul id="published">
<%= render partial: 'club_novel', collection: @published_club_novels %>
</ul>
<%= will_paginate @published_club_novels %>
<% end %>
</section>
<%
# OLIGAA - Stands for "Outil en Ligne d'Information et de Gestion des Activités
# des Associations" which is an online tool for associations to manage news,
# actors and activities.
# Copyright (C) 2010-2018 Comité Départemental du Sport Adapté de la Gironde (CDSA
# 33) <contact@cdsa33.org>
#
# This file is part of OLIGAA.
#
# OLIGAA is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# OLIGAA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with OLIGAA. If not, see <http://www.gnu.org/licenses/>.
%>
<% title 'Nouvelle info club' %>
<div class="card-block">
<h1><%= yield :title %></h1>
<p class="AdminCard-globalActions">
<%= custom_list_link club_novels_path %>
</p>
<%= render 'form' %>
</div>
......@@ -61,6 +61,8 @@
</ul>
</li>
<% end %>
<% when "club_novels" %>
<%= menu_to menu.title, club_novels_path, class: 'menu_item' %>
<% when "member_zone" %>
<li class="menu_item">
<span class="menu_title"><%= menu.title %></span>
......
......@@ -211,6 +211,14 @@ fr:
other_medicosocial_org: "Autre structure médico-sociale"
subscription:
performances: "Séances"
club_novel:
title: "Intitulé"
content: "Contenu"
published: "Publiée"
attached_files:
<<: *attached_file_labels
images:
<<: *image_labels
helpers:
submit:
create: "Créer"
......
......@@ -91,6 +91,7 @@ Rails.application.routes.draw do
patch :move_down
end
end
resources :club_novels, except: :show
patch '/newsletter_items/:id/move_up' => 'newsletter_items#move_up', as: 'move_up_item'
patch '/newsletter_items/:id/move_down' => 'newsletter_items#move_down', as: 'move_down_item'
......
class AddClubNovelsMenu < ActiveRecord::Migration[5.1]
def up
Menu.find_or_create_by(uid: 'club_novels') do |menu|
menu.title = "Info des clubs Sport Adapté Girondins"
end
end
def down
Menu.find_by(uid: 'club_novels').destroy
end