A calendar management project, for events and activities related to communities fighting for freedoms.
This can be related to software, art, data, hardware, content, commons, internet.
https://www.agendadulibre.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

44 lines
1.2 KiB

# Manage event and organisation tags
class TagsController < InheritedResources::Base
has_scope :region, :locality, :daylimit
has_scope :tag, as: :id
before_action :set_orgas, if: -> { params[:id].present? }
def index
@tags = ActsAsTaggableOn::Tag.where('taggings_count > ?',
Rails.configuration.cloud_threshold)
if params[:term]
# Used to autocomplete tags
@tags = @tags.select(:id, :name, 'name AS label')
.where('name LIKE ?', "#{params[:term]}%")
end
respond_to do |format|
format.html
format.json { render json: @tags }
end
end
def show
@events_future = apply_scopes Event.moderated.future
@events_past = apply_scopes Event.moderated.past
respond_to do |format|
format.html
format.json { render json: @events_future + @events_past }
end
end
private
# Splits, groups, rejects the less used
def set_orgas
@orgas = (apply_scopes(Orga.moderated.active) +
Orga.moderated.active
.where(
'lower(orgas.name) like lower(?)',
"%#{params[:id].tr '-', '%'}%"
)
).uniq
end
end