Skip to content
Extraits de code Groupes Projets
Valider 811b4bc0 rédigé par echarp's avatar echarp
Parcourir les fichiers

Slightly reworked cloud tag and tag page, to display organisation with similar name

parent 769ba823
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
class DigestsController < ApplicationController class DigestsController < ApplicationController
has_scope :region, :locality, :tag has_scope :region, :locality, :tag
has_scope :near, type: :hash, using: %i[location distance] has_scope :near, type: :hash, using: %i[location distance]
has_scope :moderated, default: nil, allow_blank: true
has_scope :period, allow_blank: true, type: :hash, using: %i[year week], has_scope :period, allow_blank: true, type: :hash, using: %i[year week],
default: ( default: (
lambda do lambda do
...@@ -28,6 +27,6 @@ class DigestsController < ApplicationController ...@@ -28,6 +27,6 @@ class DigestsController < ApplicationController
def set_events def set_events
@week ||= Time.zone.today + 7.days @week ||= Time.zone.today + 7.days
@events = apply_scopes Event @events = apply_scopes Event.moderated
end end
end end
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
class TagsController < InheritedResources::Base class TagsController < InheritedResources::Base
has_scope :region, :locality, :daylimit has_scope :region, :locality, :daylimit
has_scope :tag, as: :id has_scope :tag, as: :id
before_action :set_orgas, if: -> { params[:id].present? }
def index def index
@tags = ActsAsTaggableOn::Tag.where('taggings_count > ?', @tags = ActsAsTaggableOn::Tag.where('taggings_count > ?',
...@@ -21,7 +22,6 @@ class TagsController < InheritedResources::Base ...@@ -21,7 +22,6 @@ class TagsController < InheritedResources::Base
def show def show
@events_future = apply_scopes Event.moderated.future @events_future = apply_scopes Event.moderated.future
@events_past = apply_scopes Event.moderated.past @events_past = apply_scopes Event.moderated.past
@orgas = apply_scopes Orga.moderated.active
respond_to do |format| respond_to do |format|
format.html format.html
...@@ -29,23 +29,16 @@ class TagsController < InheritedResources::Base ...@@ -29,23 +29,16 @@ class TagsController < InheritedResources::Base
end end
end end
def orgas
@tags = organise_tags apply_scopes(Orga.moderated)
respond_to do |format|
format.html
format.json { render json: @tags }
end
end
private private
# Splits, groups, rejects the less used # Splits, groups, rejects the less used
def organise_tags(tags) def set_orgas
tags.where.not(tags: '').pluck(:tags).map(&:split).flatten @orgas = (apply_scopes(Orga.moderated.active) +
.group_by { |i| i } Orga.moderated.active
.map { |k, v| [k, v.size] } .where(
.reject { |_k, v| v <= 3 } 'lower(name) like lower(?)',
.sort { |t| -t[1] } "%#{params[:id].tr '-', '%'}%"
)
).uniq
end end
end end
...@@ -49,6 +49,6 @@ module AgendaDuLibreRails ...@@ -49,6 +49,6 @@ module AgendaDuLibreRails
# TODO # TODO
config.action_controller.per_form_csrf_tokens = false config.action_controller.per_form_csrf_tokens = false
config.cloud_threshold = 3 config.cloud_threshold = 5
end end
end end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter