Commit c2fb96f7 authored by Alexandre Friquet's avatar Alexandre Friquet

Collaborating member can print licence cards: refs #50.

parent 425c976b
......@@ -58,7 +58,6 @@ gem 'fitvidsjs_rails'
gem 'font-awesome-rails'
gem 'jquery-minicolors-rails'
gem 'prettyphoto-rails'
gem 'jquery-modal-rails-assets'
group :development, :test do
gem "sqlite3"
......
......@@ -197,7 +197,6 @@ GEM
jquery-minicolors-rails (2.2.6.0)
jquery-rails
rails (>= 3.2.8)
jquery-modal-rails-assets (0.9.1)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
......@@ -393,7 +392,6 @@ DEPENDENCIES
gretel-trails!
hirb
jquery-minicolors-rails
jquery-modal-rails-assets
jquery-rails
jquery-ui-rails
launchy
......
This diff is collapsed.
......@@ -50,7 +50,6 @@
//= require novels
//= require clipboard
//= require subscriptions
//= require jquery.modal
//= require_self
$(document).ready(function() {
......
......@@ -32,7 +32,6 @@
*= require prettyphoto-rails
*= require fullcalendar
*= require jquery.minicolors
*= require jquery.modal
*= require_self
*/
......
This diff is collapsed.
......@@ -25,7 +25,7 @@ class SubscriptionsController < ApplicationController
before_action :set_member
before_action :set_subscription, only: [:edit, :update, :destroy, :card, :toggle_billing]
before_action :authorize_member, except: [:destroy, :toggle_billing]
before_action :authorize_member, except: [:destroy, :toggle_billing, :card]
before_action :authorize, only: [:destroy, :toggle_billing]
before_action :set_medico_social_orgs, except: [:destroy, :card, :toggle_billing]
before_action :set_available_performances, except: [:destroy, :card, :toggle_billing]
......@@ -103,8 +103,8 @@ class SubscriptionsController < ApplicationController
render :card, layout: false
end
format.pdf do
pdf = PDFKit.new(card_member_subscription_url(@member, @subscription)).to_pdf
send_data pdf, filename: "Carte adhésion #{@subscription.adherent.name}.pdf", type: 'application/pdf'
pdf = PDFKit.new(card_member_subscription_url(@member, @subscription), margin_left: 3, margin_right: 3).to_pdf
send_data pdf, filename: "Carte adhésion #{@subscription.adherent.name} - #{@subscription.season.label}.pdf", type: 'application/pdf'
expires_now
end
end
......
......@@ -107,13 +107,13 @@ module LinksHelper
custom_link 'fa-files-o', 'Dupliquer', path, version, options
end
def custom_show_card_link(path, version = :normal, options = {})
def custom_print_card_link(path, version = :normal, options = {})
options[:class] ||= []
options[:class] << 'primary'
custom_link 'fa-id-card-o', 'Afficher carte', path, version, options
custom_link 'fa-id-card-o', 'Imprimer carte', path, version, options
end
def custom_bill_link(path, version = :normal, options = {})
options[:class] ||= []
options[:method] = :patch
......
......@@ -28,4 +28,13 @@ module SubscriptionsHelper
def external_subscription_label(subscription, member)
"#{subscription.adherent.name} (#{subscription.member.name}) → #{subscription.performances.for_member(member).to_a.map(&:full_title).join(', ')}"
end
def card_header(subscription)
label = (subscription.multipass? ? "Pass' Multi-Activités" : "Mono-Activité")
header = ""
4.times do
header << content_tag(:span, label)
end
header.html_safe
end
end
......@@ -35,7 +35,7 @@
<ul id="internal">
<% @internal_subscriptions.each do |subscription| %>
<li>
<%= custom_show_card_link card_member_subscription_path(@member, subscription), :short, class: %w(tight) %>
<%= custom_print_card_link card_member_subscription_path(@member, subscription, format: :pdf), :short, class: %w(tight) %>
<%- if admin? %>
<%= custom_edit_link edit_member_subscription_path(@member, subscription), :short, class: %w(tight) %>
<%= custom_delete_link member_subscription_path(@member, subscription), :short, class: %w(tight) %>
......
......@@ -2,7 +2,7 @@
# 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
# Copyright (C) 2010-2018 Comité Départemental du Sport Adapté de la Gironde (CDSA
# 33) <contact@cdsa33.org>
#
# This file is part of OLIGAA.
......@@ -20,8 +20,16 @@
# You should have received a copy of the GNU Affero General Public License
# along with OLIGAA. If not, see <http://www.gnu.org/licenses/>.
%>
<div class="subscription_card">
<h1>Pass Multi'Activités</h1>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<%= stylesheet_link_tag "subscription-card", media: :all %>
</head>
<body class="subscription_card">
<header>
<h1><%= card_header(@subscription) %></h1>
</header>
<section id="data">
<img class="photo">
<dl>
......@@ -29,19 +37,22 @@
<dd><%= @subscription.adherent.last_name %></dd>
<dt>Prénom</dt>
<dd><%= @subscription.adherent.first_name %></dd>
<dt>Numéro de licence FFSA</dt>
<dd><%= @subscription.adherent.permit_number %></dd>
<dt>Numéro d'adhérent plateforme</dt>
<dd><%= @subscription.platform_number %></dd>
<dt>Club d'origine</dt>
<dd><%= @member.name %></dd>
<dt>Structure médico-sociale</dt>
<dd><%= @subscription.adherent.medico_social_org_name %></dd>
<dt>Numéro de licence FFSA</dt>
<dd><%= @subscription.adherent.permit_number %></dd>
<dt>Numéro d'adhérent plateforme</dt>
<dd><%= @subscription.platform_number %></dd>
</dl>
</section>
<section id="cover">
<span>PLATEFORME</span>
<span>SPORTS & TROUBLES PSYCHIQUES</span>
<span><%= @subscription.season.label.upcase %></span>
<div>
<%= image_tag "ffsa-hands.svg" %>
<span class="blue">PLATEFORME</span>
<span class="red">SPORTS & TROUBLES PSYCHIQUES</span>
<span class="blue"><%= @subscription.season.label.upcase %></span>
</div>
</section>
</div>
</body>
......@@ -32,4 +32,4 @@ Rails.application.config.assets.paths << Rails.root.join('node_modules')
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
Rails.application.config.assets.precompile += %w( print.scss emails.js )
Rails.application.config.assets.precompile += %w( print.scss emails.js subscription-card.scss)
......@@ -463,12 +463,7 @@ feature "Manage subscriptions" do
perf2 = create :performance, member: @member, activity: foot
subscription = create :subscription, adherent: adherent, performances: [perf1, perf2], member_id: @member.id, created_at: Date.new(2017,9,19)
visit member_path(@member)
within "aside#subscriptions li", text: "Jean Dupont" do
click_link "Afficher carte"
end
expect(current_path).to eq card_member_subscription_path(@member, subscription)
visit card_member_subscription_path(@member, subscription)
within "section#data" do
expect(page).to have_selector("dd", text: "Dupont")
expect(page).to have_selector("dd", text: "Jean")
......@@ -481,9 +476,10 @@ feature "Manage subscriptions" do
expect(page).to have_content "SAISON 2017-2018"
end
pending "print to pdf"
click_link "Imprimer"
expect(response.content_type).to eq "application/pdf"
visit member_path(@member)
within "aside#subscriptions li", text: "Jean Dupont" do
expect(page).to have_link "Imprimer carte"
end
end
scenario "I can read the number of mono and multi activities ones" 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