It is now possible to associate tags to organisations. Refs #21

recurrent
echarp 7 years ago
parent 60aad71488
commit 454d74c831

@ -9,12 +9,12 @@ $(document).ready ->
elt.select2 tags: tags, separator: [' '], tokenSeparators: [' ']
# Manage the tags label so it points the proper select2 input
$('label[for=event_tags]').attr 'for', 's2id_autogen1'
$('#event_start_time').change ->
if $('#event_start_time').val() >= $('#event_end_time').val()
$('#event_end_time').val($('#event_start_time').val())
$('#event_end_time').change ->
if $('#event_start_time').val() >= $('#event_end_time').val()
$('#event_start_time').val($('#event_end_time').val())
# Manage the tags label so it points the proper select2 input
$('label[for=event_tags]').attr 'for', 's2id_autogen1'

@ -0,0 +1,13 @@
$(document).ready ->
# Manage orga tags edition
$('#orga_tags').each ->
elt = $(this)
$.ajax
url: '/tags/orgas.json'
.done (data) ->
tags = jQuery.map data, (n) -> n[0]
elt.select2 tags: tags, separator: [' '], tokenSeparators: [' ']
# Manage the tags label so it points the proper select2 input
$('label[for=orga_tags]').attr 'for', 's2id_autogen1'

@ -92,7 +92,7 @@ class OrgasController < ApplicationController
def orga_params
params.require(:orga)
.permit :lock_version, :kind_id, :name, :description, :city, :department,
:region_id, :url, :feed, :contact, :submitter, :active
:region_id, :url, :feed, :contact, :submitter, :tags, :active
end
# Check that you can only edit an existing event if you know its secret

@ -22,4 +22,18 @@ class TagsController < InheritedResources::Base
@events_future = apply_scopes(Event).moderated.future
@events_past = apply_scopes(Event).moderated.past
end
def orgas
@tags = apply_scopes(Orga.moderated)
.pluck(:tags).map(&:split).flatten
.group_by { |i| i }
.map { |k, v| [k, v.size] }
.reject { |_k, v| v <= 3 }
.sort
respond_to do |format|
format.html
format.json { render json: @tags }
end
end
end

@ -58,6 +58,14 @@
#{t '.submitter_helper'}
= f.label :submitter
= f.email_field :submitter
.field.tags
.helper
:markdown
#{t '.tags_helper'}
= f.label :tags
= f.text_field :tags
.field.active
= f.label :active
= f.check_box :active

@ -1,7 +1,7 @@
= search_form_for @search || Orga.search(params[:q]) do |f|
= f.label :search, t('.label')
%em.fa.fa-users
= f.search_field :name_or_city_or_department_or_region_name_or_url_cont_any,
= f.search_field :name_or_city_or_department_or_region_name_or_url_or_tags_cont_any,
id: :q_search, size: 16,
placeholder: t('.title', entity: Orga.model_name.human)
= f.button class: :search do

@ -12,6 +12,7 @@
%th= sort_link @search, :city
%th= sort_link @search, :department
%th= sort_link @search, :region_name, Orga.human_attribute_name(:region)
%th= sort_link @search, :tags, Orga.human_attribute_name(:tags)
%th= sort_link @search, :updated_at, Orga.human_attribute_name(:updated_at)
%th/
%th/
@ -31,6 +32,7 @@
%td= orga.city
%td= orga.department
%td= orga.region
%td= orga.tags
%td
- if orga.updated_at.present?
= l orga.updated_at.to_date

@ -96,6 +96,11 @@
%dd= mail_to @orga.contact, nil,
encode: (request.format == 'text/html' ? :javascript : nil),
replace_at: ' CHEZ ', replace_dot: ' POINT '
- if @orga.tags?
%dt
%em.fa.fa-tags
= Event.human_attribute_name :tags
%dd= @orga.tags
%dt
%em.fa.fa-heartbeat
= Orga.human_attribute_name :active

@ -8,6 +8,7 @@
#{Orga.human_attribute_name(:feed).concat(':').ljust 12 } #{@orga.feed}
#{Orga.human_attribute_name(:contact).concat(':').ljust 12 } #{@orga.contact}
#{Orga.human_attribute_name(:submitter).concat(':').ljust 12 } #{@orga.submitter}
#{Orga.human_attribute_name(:tags).concat(':').ljust 12 } #{@orga.tags}
- if @orga.active.present?
#{Orga.human_attribute_name(:active).concat(':').ljust 12 } #{t @orga.active.to_s}
- unless @orga.description.blank?

@ -264,6 +264,8 @@ description."
inform about her acceptation or rejection. If this address is
present, this organisation will only be editable by the submitter, who
will receive a secret edition link...
tags_helper: Separated with spaces, they can only contain lower case
letters, numbers and hyphens
save: Save
validate:
ok: Yes

@ -264,6 +264,8 @@ description plus complète."
Utilisée par les modérateurs pour informer de sa validation ou de son
rejet. Si cette adresse est présente, l'organisation ne sera modifiable
que par le soumetteur, qui recevra un lien secret d'édition...
tags_helper: Séparés par des espaces, ils ne peuvent contenir que des
lettres minuscules, des chiffres et des tirets
save: Envoyer
validate:
ok: Oui

@ -18,6 +18,7 @@ Rails.application.routes.draw do
end
resources :digests, only: [:index, :show]
resources :regions, only: [:index]
get 'tags/orgas', to: 'tags#orgas'
resources :tags, only: [:index, :show]
resources :maps, only: [:index]
resources :orgas do

@ -0,0 +1,6 @@
# Adding keywords to organisations
class AddTagsToOrga < ActiveRecord::Migration
def change
add_column :orgas, :tags, :text, null: true, default: ''
end
end

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160102152958) do
ActiveRecord::Schema.define(version: 20160103141244) do
create_table "active_admin_comments", force: :cascade do |t|
t.string "namespace", limit: 255
@ -24,9 +24,9 @@ ActiveRecord::Schema.define(version: 20160102152958) do
t.datetime "updated_at"
end
add_index "active_admin_comments", ["author_type", "author_id"], name: "index_active_admin_comments_on_author_type_and_author_id", using: :btree
add_index "active_admin_comments", ["namespace"], name: "index_active_admin_comments_on_namespace", using: :btree
add_index "active_admin_comments", ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource_type_and_resource_id", using: :btree
add_index "active_admin_comments", ["author_type", "author_id"], name: "index_active_admin_comments_on_author_type_and_author_id"
add_index "active_admin_comments", ["namespace"], name: "index_active_admin_comments_on_namespace"
add_index "active_admin_comments", ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource_type_and_resource_id"
create_table "admin_users", force: :cascade do |t|
t.string "email", limit: 255, default: "", null: false
@ -43,8 +43,8 @@ ActiveRecord::Schema.define(version: 20160102152958) do
t.datetime "updated_at"
end
add_index "admin_users", ["email"], name: "index_admin_users_on_email", unique: true, using: :btree
add_index "admin_users", ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true, using: :btree
add_index "admin_users", ["email"], name: "index_admin_users_on_email", unique: true
add_index "admin_users", ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true
create_table "cities", force: :cascade do |t|
t.string "name", limit: 255, default: "", null: false
@ -56,7 +56,7 @@ ActiveRecord::Schema.define(version: 20160102152958) do
t.float "longitude", limit: 24
end
add_index "cities", ["name"], name: "cities_name", using: :btree
add_index "cities", ["name"], name: "cities_name"
create_table "events", force: :cascade do |t|
t.string "title", limit: 255, default: "", null: false
@ -72,8 +72,8 @@ ActiveRecord::Schema.define(version: 20160102152958) do
t.integer "moderated", limit: 4, default: 0, null: false
t.string "tags", limit: 255, default: "", null: false
t.string "secret", limit: 255, default: "", null: false
t.datetime "decision_time", null: false
t.datetime "submission_time", null: false
t.datetime "decision_time"
t.datetime "submission_time"
t.string "moderator_mail_id", limit: 32
t.string "submitter_mail_id", limit: 32
t.text "address", limit: 65535
@ -83,7 +83,7 @@ ActiveRecord::Schema.define(version: 20160102152958) do
t.string "place_name", limit: 255
end
add_index "events", ["start_time", "end_time"], name: "events_date", using: :btree
add_index "events", ["start_time", "end_time"], name: "events_date"
create_table "kinds", force: :cascade do |t|
t.string "name", limit: 255, null: false
@ -100,38 +100,60 @@ ActiveRecord::Schema.define(version: 20160102152958) do
end
create_table "orgas", force: :cascade do |t|
t.integer "region_id", limit: 4, default: 0, null: false
t.string "department", limit: 255
t.string "name", limit: 255, default: "", null: false
t.string "url", limit: 255, default: "", null: false
t.string "city", limit: 255, default: "", null: false
t.integer "region_id", limit: 4, default: 0, null: false
t.string "department", limit: 4, default: "0", null: false
t.string "name", limit: 255, default: "", null: false
t.string "url", limit: 255, default: "", null: false
t.string "city", limit: 255, default: "", null: false
t.integer "kind_id", limit: 4
t.string "feed", limit: 255
t.string "contact", limit: 255
t.string "submitter", limit: 255
t.boolean "moderated", default: false
t.boolean "moderated", limit: 1, default: false
t.datetime "submission_time"
t.datetime "decision_time"
t.string "secret", limit: 255
t.boolean "deleted", default: false, null: false
t.boolean "active", default: true, null: false
t.text "description", limit: 65535
t.boolean "deleted", limit: 1, default: false, null: false
t.boolean "active", default: true, null: false
t.text "description"
t.datetime "created_at"
t.datetime "updated_at"
t.text "tag"
t.text "tags", default: ""
end
add_index "orgas", ["kind_id"], name: "index_orgas_on_kind_id", using: :btree
add_index "orgas", ["kind_id"], name: "index_orgas_on_kind_id"
create_table "regions", force: :cascade do |t|
t.string "name", limit: 255, default: "", null: false
end
create_table "taggings", force: :cascade do |t|
t.integer "tag_id"
t.integer "taggable_id"
t.string "taggable_type", limit: 255
t.integer "tagger_id"
t.string "tagger_type", limit: 255
t.string "context", limit: 128
t.datetime "created_at"
end
add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true
add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context"
create_table "tags", force: :cascade do |t|
t.string "name", limit: 255
t.integer "taggings_count", default: 0
end
add_index "tags", ["name"], name: "index_tags_on_name", unique: true
create_table "translations", force: :cascade do |t|
t.string "locale", limit: 255
t.string "key", limit: 255
t.text "value", limit: 65535
t.text "interpolations", limit: 65535
t.boolean "is_proc", default: false
t.boolean "is_proc", limit: 1, default: false
end
create_table "users", force: :cascade do |t|
@ -143,14 +165,14 @@ ActiveRecord::Schema.define(version: 20160102152958) do
end
create_table "versions", force: :cascade do |t|
t.string "item_type", limit: 255, null: false
t.integer "item_id", limit: 4, null: false
t.string "event", limit: 255, null: false
t.string "whodunnit", limit: 255
t.text "object", limit: 65535
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.text "object"
t.datetime "created_at"
end
add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id", using: :btree
add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id"
end

Loading…
Cancel
Save