Table lugs renamed to orgas

This commit is contained in:
echarp 2015-02-15 17:10:17 +01:00
parent 5ab067edf2
commit ef7df97949
33 changed files with 162 additions and 156 deletions

View File

@ -1,4 +1,4 @@
ActiveAdmin.register Lug do
ActiveAdmin.register Orga do
permit_params :name, :url, :city, :department, :region
index do

View File

@ -23,7 +23,7 @@ html
margin: 0
padding: 0
background-color: transparent
h2, nav, .region_selector, .lug_search, .formats, #banner
h2, nav, .region_selector, .orga_search, .formats, #banner
display: none
body

View File

@ -116,7 +116,7 @@ body.events.show main
h2
margin-top: 1em
aside#lug-list
aside#orga-list
float: right
width: 16em
border: 1px solid #96CFFF

View File

@ -14,7 +14,7 @@
&.event
height: 20em
.tags, .lugs
.tags, .orgas
#map
width: 40%
height: 60em

View File

@ -4,7 +4,7 @@
body
font-size: larger
aside#lug-list
aside#orga-list
width: auto
#advises
@ -14,7 +14,7 @@
body.events.index table
width: 100%
form#lug_search
form#orga_search
right: 0
.formats, a#banner
margin: 0.6em auto
@ -40,7 +40,7 @@
main ul
margin-left: 0
form#lug_search
form#orga_search
font-size: smaller
/* For small screen width */
@ -59,7 +59,7 @@
h2
font-size: initial
form#lug_search
form#orga_search
display: none
body.events.index table

View File

@ -5,7 +5,7 @@ img.favicon
vertical-align: middle
+border-radius(3px)
form#lug_search
form#orga_search
right: 5%
width: 12em
position: absolute
@ -40,8 +40,8 @@ form#lug_search
span.label
display: none
body.show
body.show main
dl, iframe, fieldset
min-width: 30em
vertical-align: top
+inline-block()
vertical-align: top

View File

@ -1,24 +0,0 @@
# Groups life cycle
class LugsController < ApplicationController
before_action :set_lug, only: [:show]
def index
@search = Lug.search params[:q]
@search.sorts = 'name' if @search.sorts.empty?
@lugs = @search.result.page params[:page]
end
def show
@search = Lug.search params[:q]
@events_future = Event.moderated.future.tag @lug.name
@events_past = Event.moderated.past.tag @lug.name
end
private
# Use callbacks to share common setup or constraints between actions.
def set_lug
@lug = Lug.find params[:id]
end
end

View File

@ -0,0 +1,24 @@
# Groups life cycle
class OrgasController < ApplicationController
before_action :set_orga, only: [:show]
def index
@search = Orga.search params[:q]
@search.sorts = 'name' if @search.sorts.empty?
@orgas = @search.result.page params[:page]
end
def show
@search = Orga.search params[:q]
@events_future = Event.moderated.future.tag @orga.name
@events_past = Event.moderated.past.tag @orga.name
end
private
# Use callbacks to share common setup or constraints between actions.
def set_orga
@orga = Orga.find params[:id]
end
end

View File

@ -1,14 +0,0 @@
# Helper for the lug views
module LugsHelper
def set_lug_meta
set_meta_tags \
description: @lug.url,
DC: { title: @lug.name },
geo: {
region: @lug.region,
placename: @lug.city,
position: "#{@lug.city.try :latitude};" \
+ "#{@lug.city.try :longitude}"
}
end
end

View File

@ -0,0 +1,14 @@
# Helper for the orga views
module OrgasHelper
def set_orga_meta
set_meta_tags \
description: @orga.url,
DC: { title: @orga.name },
geo: {
region: @orga.region,
placename: @orga.city,
position: "#{@orga.city.try :latitude};" \
+ "#{@orga.city.try :longitude}"
}
end
end

View File

@ -1,8 +1,8 @@
# This class is linked to events and lugs
# This class is linked to events and organisations
#
# It is mainly used to manage coordinates
#
class City < ActiveRecord::Base
has_many :events, foreign_key: :city, primary_key: :name
has_many :lugs, foreign_key: :city, primary_key: :name
has_many :orgas, foreign_key: :city, primary_key: :name
end

View File

@ -1,4 +1,4 @@
# Groups related to this agenda
class Lug < ActiveRecord::Base
class Orga < ActiveRecord::Base
belongs_to :region
end

View File

@ -1,6 +1,6 @@
# This is mostly to group events around a region
class Region < ActiveRecord::Base
has_many :lugs
has_many :orgas
has_many :events
default_scope { order :name }

View File

@ -1,4 +1,4 @@
= render '/lugs/search'
= render '/orgas/search'
= render '/regions/selector'
- if params[:year]

View File

@ -9,19 +9,19 @@
= title @event.title
- if controller.controller_name == 'events' && controller.action_name == 'show'
%aside#lug-list
- if @event.region.present? && @event.region.lugs.present?
%aside#orga-list
- if @event.region.present? && @event.region.orgas.present?
%h1
%em.fa.fa-users
= t '.lug-list'
= t '.orga-list'
- if @event.region
%ul
- @event.region.lugs.order(department: :asc).each do |lug|
- @event.region.orgas.order(department: :asc).each do |orga|
%li
= link_to lug.name, lug
(#{lug.department})
= link_to lug.url do
= image_tag lug.url + '/favicon.ico', alt: '', class: :favicon
= link_to orga.name, orga
(#{orga.department})
= link_to orga.url do
= image_tag orga.url + '/favicon.ico', alt: '', class: :favicon
%h1
%em.fa.fa-wrench

View File

@ -53,9 +53,9 @@
= link_to tags_path do
%em.fa.fa-tags
= t '.tags'
= link_to lugs_path do
= link_to orgas_path do
%em.fa.fa-users
= Lug.model_name.human.pluralize
= Orga.model_name.human.pluralize
= link_to application_infos_path do
%em.fa.fa-info
= t '.infos'

View File

@ -1,36 +0,0 @@
%h2
%em.fa.fa-users
= title t 'lugs.search.title', entity: Lug.model_name.human
= render 'search'
%table.list.autopagerize_page_element
%thead
%th= sort_link @search, :name
%th= sort_link @search, :city
%th= sort_link @search, :department
%th= sort_link @search, :region_name, Lug.human_attribute_name(:region)
%th= sort_link @search, :url
%th/
%tbody
- @lugs.each do |lug|
%tr
%td
- if lug.url =~ /^http/
= image_tag lug.url + '/favicon.ico', alt: '', class: :favicon
= lug.name
%td
= lug.city
%td
= lug.department
%td
= lug.region
%td
= link_to lug.url, lug.url
%td
= link_to t('show'),
lug_path(lug, q: params[:q], page: params[:page]),
class: :view_link
= paginate @lugs

View File

@ -1,9 +1,9 @@
= search_form_for @search || Lug.search(params[:q]) do |f|
= 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,
id: :q_search, size: 16,
placeholder: t('.title', entity: Lug.model_name.human)
placeholder: t('.title', entity: Orga.model_name.human)
= f.button class: :search do
%em.fa.fa-search
%span.label=t '.label'
%span.label= t '.label'

View File

@ -0,0 +1,36 @@
%h2
%em.fa.fa-users
= title t 'orgas.search.title', entity: Orga.model_name.human
= render 'search'
%table.list.autopagerize_page_element
%thead
%th= sort_link @search, :name
%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, :url
%th/
%tbody
- @orgas.each do |orga|
%tr
%td
- if orga.url =~ /^http/
= image_tag orga.url + '/favicon.ico', alt: '', class: :favicon
= orga.name
%td
= orga.city
%td
= orga.department
%td
= orga.region
%td
= link_to orga.url, orga.url
%td
= link_to t('show'),
orga_path(orga, q: params[:q], page: params[:page]),
class: :view_link
= paginate @orgas

View File

@ -1,52 +1,52 @@
- set_lug_meta
- set_orga_meta
= render 'search'
%h2
= image_tag @lug.url + '/favicon.ico', alt: '', class: :favicon
= title @lug.name
= image_tag @orga.url + '/favicon.ico', alt: '', class: :favicon
= title @orga.name
%nav
= link_to lugs_path(q: params[:q], page: params[:page]), class: :back do
= link_to orgas_path(q: params[:q], page: params[:page]), class: :back do
%em.fa.fa-arrow-left
= Lug.model_name.human.pluralize
= Orga.model_name.human.pluralize
\/
= link_to events_path tag: @lug.name do
= link_to events_path tag: @orga.name do
%em.fa.fa-calendar
Agenda
\/
= link_to events_path format: :rss, tag: @lug.name do
= link_to events_path format: :rss, tag: @orga.name do
%em.fa.fa-rss
RSS
\/
= link_to events_path format: :ics, tag: @lug.name do
= link_to events_path format: :ics, tag: @orga.name do
%em.fa.fa-th-list
iCal
\/
= link_to maps_path tag: @lug.name do
= link_to maps_path tag: @orga.name do
%em.fa.fa-map-marker
OpenStreetMap
\/
= link_to maps_path format: :json, tag: @lug.name do
= link_to maps_path format: :json, tag: @orga.name do
%em.fa.fa-dot-circle-o
GeoJSON
%dl
- if @lug.city.present?
%dt= Lug.human_attribute_name :city
%dd= @lug.city
- if @lug.department.present?
%dt= Lug.human_attribute_name :department
%dd= @lug.department
- if @lug.region.present?
%dt= Lug.human_attribute_name :region
%dd= @lug.region
- if @lug.url.present?
%dt= Lug.human_attribute_name :url
%dd= link_to @lug.url, @lug.url
- if @orga.city.present?
%dt= Orga.human_attribute_name :city
%dd= @orga.city
- if @orga.department.present?
%dt= Orga.human_attribute_name :department
%dd= @orga.department
- if @orga.region.present?
%dt= Orga.human_attribute_name :region
%dd= @orga.region
- if @orga.url.present?
%dt= Orga.human_attribute_name :url
%dd= link_to @orga.url, @orga.url
%iframe(src="#{@lug.url}" width='1280' height='300' frameborder='none'
allowTransparency='true')
%iframe{ src: @orga.url, width: '1280', height: '300', frameborder: 'none',
allowTransparency: 'true' }
- if @events_future.any? || @events_past.any?
%fieldset
@ -82,4 +82,4 @@
= event.title
.date= display_date event
.events#map(data-url="#{ maps_path format: :json, tag: @lug.name }")
.events#map{ data: { url: maps_path(format: :json, tag: @orga.name) } }

View File

@ -15,7 +15,7 @@ en:
models:
event: Event
user: Modérator
lug: Asso
orga: Asso
city: City
region: Region
admin_user: Admin
@ -32,7 +32,7 @@ en:
postalcode: Zip code
inseecode: INSEE code
regioncode: Region code
lug:
orga:
region: Region
department: Department
url: Web address

View File

@ -15,7 +15,7 @@ fr:
models:
event: Événement
user: Modérateur
lug: Asso
orga: Asso
city: Ville
region: Région
admin_user: Admin
@ -32,7 +32,7 @@ fr:
postalcode: Code postal
inseecode: Code INSEE
regioncode: Code région
lug:
orga:
city: Ville
department: Département
region: Région

View File

@ -42,7 +42,7 @@ en:
calendar_in: This calendar in %{rss}, %{webcal} or %{ical}
nb_events: "%{count} events"
show:
lug-list: Region's associations
orga-list: Region's associations
add_to_calendar: Add to my calendar
copy: Duplicate event
at: At
@ -234,11 +234,11 @@ description."
index:
title: Events map
events: Events
lugs: Association
orgas: Association
users:
sign_in:
title: Authentication
lugs:
orgas:
search:
title: Find your %{entity}!
label: Search

View File

@ -42,7 +42,7 @@ fr:
calendar_in: Ce calendrier en %{rss}, %{webcal} ou %{ical}
nb_events: "%{count} événements"
show:
lug-list: Asso de la région
orga-list: Asso de la région
add_to_calendar: Ajouter à mon calendrier
copy: Dupliquer événement
at: À
@ -236,11 +236,11 @@ description plus complète."
index:
title: Carte des événements
events: Événements
lugs: Asso
orgas: Asso
users:
sign_in:
title: Identification
lugs:
orgas:
search:
title: Trouve ton %{entity}!
label: Recherche

View File

@ -19,7 +19,7 @@ Rails.application.routes.draw do
resources :regions, only: [:index]
resources :tags, only: [:index, :show]
resources :maps, only: [:index]
resources :lugs, only: [:index, :show]
resources :orgas, only: [:index, :show]
# Manage former php pages
get 'showevent.php', to: redirect { |_, req| "events/#{req.params[:id]}" }

View File

@ -0,0 +1,6 @@
# Generalisation of the LUG concept to one of event's organiser
class RenameTableLug < ActiveRecord::Migration
def change
rename_table :lugs, :orgas
end
end

View File

@ -12,7 +12,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150215121248) do
ActiveRecord::Schema.define(version: 20150215151059) do
create_table "active_admin_comments", force: :cascade do |t|
t.string "namespace", limit: 255
@ -85,14 +85,6 @@ ActiveRecord::Schema.define(version: 20150215121248) do
add_index "events", ["start_time", "end_time"], name: "events_date"
create_table "lugs", force: :cascade do |t|
t.integer "region_id", default: 0, null: false
t.integer "department", 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
end
create_table "notes", force: :cascade do |t|
t.text "contents", null: false
t.datetime "date", null: false
@ -100,6 +92,14 @@ ActiveRecord::Schema.define(version: 20150215121248) do
t.integer "author_id"
end
create_table "orgas", force: :cascade do |t|
t.integer "region_id", default: 0, null: false
t.integer "department", 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
end
create_table "regions", force: :cascade do |t|
t.string "name", limit: 255, default: "", null: false
end

BIN
db/schema_cache.dump Normal file

Binary file not shown.

View File

@ -1,9 +1,9 @@
require 'test_helper'
# Free Software groups life cycle
class LugsControllerTest < ActionController::TestCase
class OrgasControllerTest < ActionController::TestCase
setup do
@lug = lugs :one
@orga = orgas :one
end
test 'should get index' do
@ -12,7 +12,7 @@ class LugsControllerTest < ActionController::TestCase
end
test 'should get show' do
get :show, id: @lug
get :show, id: @orga
assert_response :success
end
end

View File

@ -1,4 +0,0 @@
require 'test_helper'
class LugsHelperTest < ActionView::TestCase
end

View File

@ -0,0 +1,4 @@
require 'test_helper'
class OrgasHelperTest < ActionView::TestCase
end

View File

@ -1,6 +1,6 @@
require 'test_helper'
class LugTest < ActiveSupport::TestCase
class OrgaTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end