Commit 381b5da5 authored by David F.'s avatar David F.
Browse files

Merge branch '51-liste-admin-adhesions' into 'master'

Resolve "[Admin] Lister les adhérents de tous les membres"

See merge request !54
parents 84632ac3 5058f603
# 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-2016 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/>.
#
class PlatformController < ApplicationController
before_action :authorize
def index
@collaborating_clubs = Member.of_member_groups(settings.platform_collaborating_clubs).by_name
end
end
......@@ -6,6 +6,7 @@ class Subscription < ApplicationRecord
has_many :performances, through: :performance_subscriptions
scope :for_performances, ->(performance_ids) { joins(:performances).where(performance_subscriptions: {performance_id: performance_ids}).distinct }
scope :by_adherent_name, -> { joins(:adherent).order('adherents.first_name','adherents.last_name') }
def performances_list
"#{performances.to_a.map(&:title_for_subscriptions_list).join(', ')}"
......
......@@ -30,6 +30,7 @@
<li><%= link_to "Membres", members_path, :class => 'action_link' %></li>
<li><%= link_to "Newsletters", newsletters_path, :class => 'action_link' %></li>
<li><%= link_to "Partenaires", partners_path, :class => 'action_link' %></li>
<li><%= link_to "Plateforme", platform_path, :class => 'action_link' %></li>
<li><%= link_to "Paramètres", edit_settings_path, :class => 'action_link' %></li>
</ul>
</nav>
\ No newline at end of file
</nav>
<%
# 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-2017 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 "Plateforme Sports et Troubles psychiques" %>
<div class="tabs">
<ul>
<li><a href="#subscriptions">Adhésions</a></li>
</ul>
<div id="subscriptions">
<h2>Liste des adhésions</h2>
<%- @collaborating_clubs.each do |club| %>
<h3><%= club.name %></h3>
<ul id="member-<%= club.id %>">
<%- club.subscriptions.by_adherent_name.each do |subscription| %>
<li>
<%- if admin? %>
<%= custom_edit_link edit_member_subscription_path(club, subscription), :short, class: %w(tight) %>
<%= custom_delete_link member_subscription_path(club, subscription), :short, class: %w(tight) %>
<%- end %>
<%= internal_subscription_label(subscription) %>
</li>
<%- end %>
</ul>
<%- end %>
</div>
</div>
......@@ -101,5 +101,7 @@ Rails.application.routes.draw do
get '/sitemap' => 'sitemap#index', :as => :sitemap
get '/platform' => 'platform#index', as: :platform
root :to => 'novels#public_index'
end
......@@ -70,6 +70,47 @@ feature "Manage subscriptions" do
expect(page).to have_content "Jean Dupond"
end
end
scenario "I can list all susbscriptions" do
collaborating_clubs_mg = create :member_group
usg = create :member, name: "USG", member_groups: [collaborating_clubs_mg]
mouettes = create :member, name: "Les Mouettes", member_groups: [collaborating_clubs_mg]
athle = create :activity, title: "Athlétisme"
jean_dupont = build :adherent, last_name: "Dupont", first_name: "Jean"
arthur_latrouille = build :adherent, last_name: "Latrouille", first_name: "Arthur"
pascal_durand = build :adherent, last_name: "Durand", first_name: "Pascal"
perf_usg = create :performance, member: usg, activity: athle
perf_mouettes = create :performance, member: mouettes, activity: athle
create :subscription, adherent: jean_dupont, performances: [perf_usg], member_id: usg.id
create :subscription, adherent: arthur_latrouille, performances: [perf_usg], member_id: usg.id
create :subscription, adherent: pascal_durand, performances: [perf_mouettes], member_id: mouettes.id
@settings.platform_collaborating_clubs << collaborating_clubs_mg
visit root_path
within "nav#admin_links" do
click_link "Plateforme"
end
click_link "Adhésions"
expect(page).to have_selector("h2", text: "Liste des adhésions")
lists = all("#subscriptions > ul")
expect(lists.length).to eq 2
expect(lists[0]['id']).to eq "member-#{mouettes.id}"
expect(lists[1]['id']).to eq "member-#{usg.id}"
expect(page).to have_selector "h3", text: "USG"
expect(page).to have_selector "h3", text: "Les Mouettes"
within "ul#member-#{usg.id}" do
items = all("li")
expect(items.length).to eq 2
expect(items[0]).to have_content "Arthur Latrouille"
expect(items[1]).to have_content "Jean Dupont"
end
within "ul#member-#{mouettes.id}" do
items = all("li")
expect(items.length).to eq 1
expect(items[0]).to have_content "Pascal Durand"
end
end
end
context "as a collaborating club" do
......
......@@ -26,6 +26,19 @@ RSpec.describe Subscription, type: :model do
subscription2 = create :subscription, adherent: adherent2, performances: [perf2], member_id: member2.id
expect(Subscription.for_performances([perf1,perf3].map(&:id))).to eq [subscription1]
end
it ".by_adherent_name returns susbscriptions ordered by ascending adherent name" do
member = create :member
activity = create :activity
perf = create :performance, member: member, activity: activity
jean_dupont = build :adherent, first_name: "Jean", last_name: "Dupont"
arthur_latrouille = build :adherent, first_name: "Arthur", last_name: "Latrouille"
jean_dupond = build :adherent, first_name: "Jean", last_name: "Dupond"
adh_jean_dupont = create :subscription, adherent: jean_dupont, performances: [perf], member_id: member.id
adh_arthur_latrouille = create :subscription, adherent: arthur_latrouille, performances: [perf], member_id: member.id
adh_jean_dupond = create :subscription, adherent: jean_dupond, performances: [perf], member_id: member.id
expect(Subscription.by_adherent_name).to eq [adh_arthur_latrouille,adh_jean_dupond,adh_jean_dupont]
end
end
describe "behaviors" do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment