Attention ! Gitlab fournissant maintenant nativement des certificats Let’s Encrypt aux domaines personnalisés des Gitlab Pages, nous avons coupé notre service qui le faisait automatiquement pour vous.

Il est impératif, pour que votre domaine personnalisé continue à avoir un certificat Let’s Encrypt à jour, d’activer la fonctionnalité native dans les paramètres de votre projet. Cette activation remplacera votre certificat actuel par un nouveau certificat Let’s Encrypt géré par Gitlab.

Voir les détails sur https://docs.framasoft.org/fr/gitlab/gitlab-pages-le.html

Commit 4fa1e02d authored by David F.'s avatar David F.

Merge branch '4-gestion-des-saisons' into 'master'

Resolve "[Admin] Gestion des saisons"

See merge request !91
parents 0386e004 f6769c68
......@@ -25,6 +25,7 @@ class EventsController < ApplicationController
def index
@passed_events = Event.reverse_chronology.visible.passed
@seasoned_passed_events = Season.all_for(@passed_events)
@current_events = Event.reverse_chronology.visible.current
@events_to_come = Event.chronology.visible.to_come
@unscheduled_events = Event.visible.unscheduled
......
......@@ -21,6 +21,8 @@
# along with OLIGAA. If not, see <http://www.gnu.org/licenses/>.
#
class Activity < ApplicationRecord
include SeasonedEventsConcern
has_and_belongs_to_many :activity_categories, :join_table => :activities_cats
has_and_belongs_to_many :events
has_and_belongs_to_many :members
......@@ -42,18 +44,4 @@ class Activity < ApplicationRecord
def self.uncategorized
all.reject { |act| !act.activity_categories.blank? }
end
def seasoned_events
result = {}
self.events.visible.chronology.each do |event|
year = event.begin_at.year
if event.begin_at >= Season.birthdate.change(year: year)
(result["Saison #{year.to_s}-#{(year+1).to_s}"] ||= []) << event
else
(result["Saison #{(year-1).to_s}-#{year.to_s}"] ||= []) << event
end
end
result.sort.reverse
end
end
module SeasonedEventsConcern
extend ActiveSupport::Concern
included do
def seasoned_events
Season.all_for(self.events.with_dates.visible.reverse_chronology)
end
end
end
......@@ -21,6 +21,8 @@
# along with OLIGAA. If not, see <http://www.gnu.org/licenses/>.
#
class EventType < ApplicationRecord
include SeasonedEventsConcern
has_many :events
validates_presence_of :title
......@@ -52,18 +54,4 @@ class EventType < ApplicationRecord
def ga_cal
GoogleAgenda::Calendar.find_by_id_or_create(self.ga_cal_id)
end
def seasoned_events
result = {}
self.events.with_dates.visible.reverse_chronology.each do |event|
year = event.begin_at.year
if event.begin_at >= Season.birthdate.change(year: year)
(result["Saison #{year.to_s}-#{(year+1).to_s}"] ||= []) << event
else
(result["Saison #{(year-1).to_s}-#{year.to_s}"] ||= []) << event
end
end
result.sort.reverse
end
end
......@@ -32,6 +32,19 @@ class Season
Settings.instance.reload.season_birthdate || self.default_birthdate
end
def self.all_for(items)
result = {}
items.each do |item|
year = item.begin_at.year
if item.begin_at >= Season.birthdate.change(year: year)
(result["Saison #{year.to_s}-#{(year+1).to_s}"] ||= []) << item
else
(result["Saison #{(year-1).to_s}-#{year.to_s}"] ||= []) << item
end
end
result.sort.reverse
end
def initialize(date)
year = (date < Season.birthdate.change(year: date.year) ? date.year-1 : date.year)
@begining = Season.birthdate.change(year: year)
......
......@@ -67,7 +67,15 @@
<%= toggle_link "Passés (#{@passed_events.count})", '#time-elapsed' %>
</h2>
<div id="time-elapsed" style="display:none;">
<%= render :partial => 'event', :collection => @passed_events %>
<%- @seasoned_passed_events.each do |season, events| %>
<div>
<% season_label = season.downcase.gsub(/\s/, '_') %>
<%= toggle_link "#{ season } (#{ events.length })", "##{season_label}" %>
<div id="<%= season_label %>" style="display:none;">
<%= render :partial => 'event', :collection => events %>
</div>
</div>
<%- end %>
</div>
</li>
<% end %>
......
......@@ -69,13 +69,6 @@ describe Activity do
end
describe "behaviors" do
it "#seasoned_events returns associated events by season" do
activity = create :activity
event1 = create :event, begin_at: "01/08/2013", activities: [activity]
event2 = create :event, begin_at: "01/09/2013", activities: [activity]
event3 = create :event, begin_at: "02/09/2013", activities: [activity], goto_trash: true
expected = [["Saison 2013-2014", [event2]], ["Saison 2012-2013", [event1]]]
expect(activity.seasoned_events).to eq expected
end
it_behaves_like "seasoned_events"
end
end
......@@ -35,16 +35,8 @@ describe EventType do
end
describe "behaviors" do
it "#seasoned_events returns seasons with corresponding events" do
et = create :event_type
ev1 = create :event, begin_at: nil, end_at: nil
ev2 = create :event, begin_at: "02/07/2013 09:00", end_at: "02/07/2013 11:00"
ev3 = create :event, begin_at: "02/07/2012 09:00", end_at: "02/07/2012 11:00"
ev4 = create :event, begin_at: "02/01/2012 09:00", end_at: "02/01/2012 11:00"
et.events << [ev1, ev2, ev3, ev4]
expected = [["Saison 2012-2013", [ev2]], ["Saison 2011-2012", [ev3, ev4]]]
expect(et.seasoned_events).to eq expected
end
it_behaves_like "seasoned_events"
describe '.ga_cal' do
......
......@@ -53,6 +53,23 @@ RSpec.describe Season, type: :model do
expect(result).to eq first_of_september
end
end
it ".all_for returns items arranged by season" do
# Given
allow(Settings).to receive_message_chain(:instance, :reload, :season_birthdate).and_return(Date.new(1970,9,1))
Item = Struct.new(:begin_at)
item1 = Item.new(Date.new(2018,8,31))
item2 = Item.new(Date.new(2018,9,1))
item3 = Item.new(Date.new(2018,9,2))
expected = [
["Saison 2018-2019", [item2, item3]],
["Saison 2017-2018", [item1]]
]
# When
result = Season.all_for([ item1, item2, item3 ])
# Then
expect(result).to eq expected
end
end
context "regarding initialization" do
......
require 'rails_helper'
shared_examples_for "seasoned_events" do
let(:factory) { described_class.name.underscore.to_sym }
it "#seasoned_events returns seasons with corresponding events" do
model = create factory
ev1 = create :event, begin_at: nil, end_at: nil
ev2 = create :event, begin_at: "02/07/2013 09:00", end_at: "02/07/2013 11:00"
ev3 = create :event, begin_at: "02/07/2012 09:00", end_at: "02/07/2012 11:00"
ev4 = create :event, begin_at: "02/01/2012 09:00", end_at: "02/01/2012 11:00"
model.events << [ev1, ev2, ev3, ev4]
expected = [["Saison 2012-2013", [ev2]], ["Saison 2011-2012", [ev3, ev4]]]
expect(model.seasoned_events).to eq expected
end
end
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