Organisation can now be organised in kinds, and easily modified by moderators

This commit is contained in:
echarp 2015-02-28 17:28:05 +01:00
parent ef7df97949
commit 0333a1ad68
34 changed files with 630 additions and 276 deletions

View File

@ -57,7 +57,7 @@ gem 'i18n-active_record',
gem 'http_accept_language' gem 'http_accept_language'
# A superb font to use as icons # A superb font to use as icons
gem 'font-awesome-rails' gem 'font-awesome-sass'
# Validate mails submitted # Validate mails submitted
gem 'email_validator' gem 'email_validator'
# Email address obfuscation # Email address obfuscation

View File

@ -146,8 +146,8 @@ GEM
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
fastercsv (1.5.5) fastercsv (1.5.5)
ffi (1.9.6) ffi (1.9.6)
font-awesome-rails (4.3.0.0) font-awesome-sass (4.3.1)
railties (>= 3.2, < 5.0) sass (~> 3.2)
formatador (0.2.5) formatador (0.2.5)
formtastic (3.1.3) formtastic (3.1.3)
actionpack (>= 3.2.13) actionpack (>= 3.2.13)
@ -426,7 +426,7 @@ DEPENDENCIES
devise-i18n devise-i18n
differ differ
email_validator email_validator
font-awesome-rails font-awesome-sass
geocoder geocoder
guard-brakeman guard-brakeman
guard-bundler guard-bundler

View File

@ -1,42 +0,0 @@
// Mixins
// --------------------------
@mixin fa-icon-rotate($degrees, $rotation) {
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=#{$rotation});
-webkit-transform: rotate($degrees);
-moz-transform: rotate($degrees);
-ms-transform: rotate($degrees);
-o-transform: rotate($degrees);
transform: rotate($degrees);
}
@mixin fa-icon-flip($horiz, $vert, $rotation) {
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=#{$rotation});
-webkit-transform: scale($horiz, $vert);
-moz-transform: scale($horiz, $vert);
-ms-transform: scale($horiz, $vert);
-o-transform: scale($horiz, $vert);
transform: scale($horiz, $vert);
}
@mixin fa-icon-base() {
&:before {
display: inline-block;
font-family: FontAwesome;
font-style: normal;
font-weight: normal;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
margin-right: 5px;
}
}
@mixin fa-icon($icon-char) {
@include fa-icon-base();
&:before {
@if($icon-char != null) {
content: $icon-char;
}
}
}

View File

@ -1,4 +1,5 @@
@import compass @import compass
@import font-awesome-sprockets
@import font-awesome @import font-awesome
* *
@ -134,6 +135,28 @@ main, body.mce-content-body
min-height: 100% min-height: 100%
font-family: Palatino, 'URW Palladio L', 'dejavu serif', georgia, serif font-family: Palatino, 'URW Palladio L', 'dejavu serif', georgia, serif
aside
float: right
width: 16em
border: 1px solid #96CFFF
margin: 0 1.2em
padding: 5px
font-size: 0.7em
margin-right: -4em
background-color: #D6ECFF
+box-shadow(4px 4px 1em gray)
+border-radius(10px)
h1
font-weight: normal
border-bottom: 1px black solid
padding-bottom: 0.3em
h2
margin: 0
font-size: larger
a
padding: 0.5em 0
display: block
iframe iframe
border: none border: none
max-width: 100% max-width: 100%

View File

@ -14,17 +14,22 @@
*= require_tree . *= require_tree .
*/ */
@import 'awesome_mixins' @import font-awesome-sprockets
@import font-awesome
body.application body.application
&.infos h4 &.infos h4
text-align: left text-align: left
&.infos main h2:first-child &.infos, &.contact, &.rules
+fa-icon('') main h2:first-child:before
+fa-icon()
margin-right: 0.4em
&.infos main h2:first-child:before
content: $fa-var-info
&.contact main h2:first-child &.contact main h2:first-child:before
+fa-icon('') content: $fa-var-envelope
&.rules main h2:first-child &.rules main h2:first-child:before
+fa-icon('') content: $fa-var-gavel

View File

@ -1,5 +1,4 @@
@import compass @import compass
@import awesome_mixins
header.calendar-header header.calendar-header
font-size: 1.5em font-size: 1.5em
@ -116,28 +115,6 @@ body.events.show main
h2 h2
margin-top: 1em margin-top: 1em
aside#orga-list
float: right
width: 16em
border: 1px solid #96CFFF
margin: 0 1.2em
padding: 5px
font-size: 0.7em
margin-right: -4em
background-color: #D6ECFF
+box-shadow(4px 4px 1em gray)
+border-radius(10px)
h1
font-weight: normal
border-bottom: 1px black solid
padding-bottom: 0.3em
h2
margin: 0
font-size: larger
a
padding: 0.5em 0
display: block
#advises #advises
border: 1px solid #FFB578 border: 1px solid #FFB578
padding-left: 10px padding-left: 10px
@ -150,80 +127,6 @@ aside#orga-list
a a
color: #8F4900 color: #8F4900
.events form, .moderations form
.field, .actions
max-width: 70em
text-align: left
margin-left: auto
margin-right: auto
*
vertical-align: middle
.helper p
color: gray
margin: 0
font-style: italic
margin-left: 8em
padding-left: 0.4em
label
width: 8em
+inline-block()
input, select, .select2-container ul
+border-top-left-radius(0)
+border-bottom-left-radius(0)
input[type=radio] + label
width: 20em
&:after
content: ''
input[type=text], input[type=url], input[type=email],
.select2-container, .select2-container ul, .mce-tinymce
min-width: 22em
.mce-tinymce
font-size: inherit
font-family: inherit
+inline-block()
+border-radius(0.4em)
+border-top-left-radius(0)
+border-bottom-left-radius(0)
.mce-container-body
.mce-panel.mce-first
+border-top-right-radius(0.4em)
.mce-panel.mce-last
+border-bottom-right-radius(0.4em)
.field label:before
color: gray
.field.title label
+fa-icon('')
.field.start_time label
+fa-icon('')
.field.end_time label
+fa-icon('')
.field.description label
+fa-icon('')
.field.address label
+fa-icon('')
.field.city label
+fa-icon('')
.field.region label
+fa-icon('')
.field.locality label
+fa-icon('')
.field.contact label
+fa-icon('')
.field.submitter label
+fa-icon('')
.field.url label
+fa-icon('')
.field.tags label
+fa-icon('')
.actions
text-align: center
input
font-size: x-large
.description, body.mce-content-body .description, body.mce-content-body
img img
margin-left: 1% margin-left: 1%

View File

@ -0,0 +1,97 @@
@import compass
@import font-awesome-sprockets
@import font-awesome
.events form, .moderations form, .orgas form
.field, .actions
max-width: 70em
text-align: left
margin-left: auto
margin-right: auto
.helper p
color: gray
margin: 0
font-style: italic
margin-left: 8em
padding-left: 0.4em
label
width: 8em
+inline-block()
input, select, .select2-container ul
+border-top-left-radius(0)
+border-bottom-left-radius(0)
input[type=radio] + label
width: 20em
&:after
content: ''
input[type=text], input[type=url], input[type=email],
.select2-container, .select2-container ul, .mce-tinymce
min-width: 22em
.mce-tinymce
font-size: inherit
font-family: inherit
+inline-block()
+border-radius(0.4em)
+border-top-left-radius(0)
+border-bottom-left-radius(0)
.mce-container-body
.mce-panel.mce-first
+border-top-right-radius(0.4em)
.mce-panel.mce-last
+border-bottom-right-radius(0.4em)
.field label:before
color: gray
margin-right: 0.4em
+fa-icon()
.field.title label:before
content: $fa-var-newspaper-o
.field.start_time label:before
content: $fa-var-toggle-on
.field.end_time label:before
content: $fa-var-toggle-off
.field.description label:before
content: $fa-var-pencil-square-o
.field.address label:before
content: $fa-var-map-marker
.field.city label:before
content: $fa-var-compress
.field.region label:before
content: $fa-var-shield
.field.locality > label:before
content: $fa-var-expand
.field.contact label:before
content: $fa-var-envelope
.field.submitter label:before
content: $fa-var-envelope-o
.field.url label:before
content: $fa-var-external-link
.field.tags label:before
content: $fa-var-tags
.field.kind > label:before
content: $fa-var-cubes
.field.feed label:before
content: $fa-var-rss
.field .radios label
width: auto !important
margin-right: 1em
[type=radio]
display: none
[type=radio] + label:before
color: black
content: $fa-var-circle-o
font-size: larger
[type=radio]:checked + label:before
color: black
content: $fa-var-dot-circle-o
+text-shadow(0 0 1px gray)
.actions
text-align: center
input
font-size: x-large

View File

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

View File

@ -40,7 +40,9 @@ form#orga_search
span.label span.label
display: none display: none
body.show main body.orgas.show main
fieldset.orga
min-width: 60em
dl, iframe, fieldset dl, iframe, fieldset
min-width: 30em min-width: 30em
+inline-block() +inline-block()

View File

@ -20,7 +20,7 @@ class EventsController < ApplicationController
end end
end end
# GET /users/new # GET /events/new
def new def new
@event = Event.new start_time: Time.now.change(min: 0) + 1.day + 1.hour, @event = Event.new start_time: Time.now.change(min: 0) + 1.day + 1.hour,
end_time: Time.now.change(min: 0) + 1.day + 2.hour end_time: Time.now.change(min: 0) + 1.day + 2.hour

View File

@ -1,6 +1,7 @@
# Groups life cycle # Groups life cycle
class OrgasController < ApplicationController class OrgasController < ApplicationController
before_action :set_orga, only: [:show] before_action :authenticate_user!, only: [:new, :edit, :update, :destroy]
before_action :set_orga, except: [:index, :new, :create]
def index def index
@search = Orga.search params[:q] @search = Orga.search params[:q]
@ -8,6 +9,28 @@ class OrgasController < ApplicationController
@orgas = @search.result.page params[:page] @orgas = @search.result.page params[:page]
end end
# GET /orgas/new
def new
@orga = Orga.new
end
# POST /orgas
# POST /orgas.json
def create
@orga = Orga.new orga_params
respond_to do |format|
if @orga.save # && send_creation_mails
format.html { redirect_to :root, notice: t('.ok') }
# 201 means :created
format.json { render action: 'show', status: 201, location: @orga }
else
format.html { render action: 'new' }
# 422 means :unprocessable_entity
format.json { render json: @orga.errors, status: 422 }
end
end
end
def show def show
@search = Orga.search params[:q] @search = Orga.search params[:q]
@ -15,10 +38,33 @@ class OrgasController < ApplicationController
@events_past = Event.moderated.past.tag @orga.name @events_past = Event.moderated.past.tag @orga.name
end end
# PATCH/PUT /orgas/1
# PATCH/PUT /orgas/1.json
def update
respond_to do |format|
if @orga.update(orga_params) # && send_update_mails
format.html { redirect_to @orga, notice: t('.ok') }
format.json { head :no_content }
else
format.html { render action: 'edit' }
# 422 means :unprocessable_entity
format.json { render json: @orga.errors, status: 422 }
end
end
end
private private
# Use callbacks to share common setup or constraints between actions. # Use callbacks to share common setup or constraints between actions.
def set_orga def set_orga
@orga = Orga.find params[:id] @orga = Orga.find params[:id]
end end
# Never trust parameters from the scary internet, only allow the white list
# through
def orga_params
params.require(:orga)
.permit :lock_version, :kind_id, :name, :city, :department, :region_id,
:url, :feed, :contact, :submitter
end
end end

4
app/models/kind.rb Normal file
View File

@ -0,0 +1,4 @@
# Gives the possibility to organise organisations! :)
class Kind < ActiveRecord::Base
has_many :orgas
end

View File

@ -1,4 +1,21 @@
# Groups related to this agenda # Groups related to this agenda
class Orga < ActiveRecord::Base class Orga < ActiveRecord::Base
belongs_to :region belongs_to :region
belongs_to :kind
validates :kind, presence: true
validates :name, presence: true
validates :region, presence: true
validates :url, format: %r{\Ahttps?:\/\/.*\..*\z}
validates :feed, allow_blank: true, format: %r{\Ahttps?:\/\/.*\..*\z}
validates :contact, allow_blank: true, email: true
validates :submitter, allow_blank: true, email: true
before_validation on: :create do
self.submission_time = DateTime.now
self.decision_time = DateTime.now
# Populate submitter using contact info if absent
self.submitter ||= contact
end
end end

View File

@ -43,14 +43,18 @@
%option= city %option= city
.field.region .field.region
= f.label :region = f.label :region
= f.select :region_id, = f.collection_select :region_id, Region.all, :id, :name
options_from_collection_for_select(Region.all, 'id', 'name',
@event.region_id)
.field.locality .field.locality
= f.label :locality = f.label :locality
= f.select :locality, %span.radios
options_for_select([[t('attributes.locality_0'), 0], = f.radio_button :locality, 0
[t('attributes.locality_1'), 1]], @event.locality) = f.label 'locality_0' do
%em.fa.fa-shield
= t 'attributes.locality_0'
= f.radio_button :locality, 1
= f.label 'locality_1' do
%em.fa.fa-globe
= t 'attributes.locality_1'
.field.url .field.url
.helper .helper

View File

@ -19,6 +19,6 @@
%fieldset %fieldset
%legend %legend
%em.fa.fa-pencil %em.fa.fa-plus
=t '.edit' =t '.edit'
= render 'form' = render 'form'

View File

@ -14,11 +14,14 @@
%h1 %h1
%em.fa.fa-users %em.fa.fa-users
= t '.orga-list' = t '.orga-list'
- if @event.region %ul.fa-ul
%ul - @event.region.orgas.each do |orga|
- @event.region.orgas.order(department: :asc).each do |orga| %li
%li = link_to orga do
= link_to orga.name, orga - if orga.kind
%em.fa.fa-li{ class: "fa-#{orga.kind.icon}",
title: Kind.human_attribute_name("name_#{orga.kind.name}") }
= orga.name
(#{orga.department}) (#{orga.department})
= link_to orga.url do = link_to orga.url do
= image_tag orga.url + '/favicon.ico', alt: '', class: :favicon = image_tag orga.url + '/favicon.ico', alt: '', class: :favicon
@ -84,11 +87,15 @@
tags: %w(p h1 h2 h3 h4 br table tr th td ul ol li a strong b em i img), tags: %w(p h1 h2 h3 h4 br table tr th td ul ol li a strong b em i img),
attributes: %w(href src width height style) attributes: %w(href src width height style)
%h3= t '.infos' %h3
%em.fa.fa-info-circle
= t '.infos'
%p %p
%em.fa.fa-external-link
%span.label= Event.human_attribute_name :url %span.label= Event.human_attribute_name :url
= link_to @event.url, @event.url = link_to @event.url, @event.url
%p %p
%em.fa.fa-envelope
%span.label= Event.human_attribute_name :contact %span.label= Event.human_attribute_name :contact
= mail_to @event.contact, nil, = mail_to @event.contact, nil,
encode: (request.format == 'text/html' ? :javascript : nil), encode: (request.format == 'text/html' ? :javascript : nil),
@ -96,6 +103,7 @@
- if @event.tags && @event.tags.present? - if @event.tags && @event.tags.present?
%p.tags %p.tags
%em.fa.fa-tags
%span.label= Event.human_attribute_name :tags %span.label= Event.human_attribute_name :tags
- @event.tags.split.each do |tag| - @event.tags.split.each do |tag|
= link_to tag, tag_path(tag), rel: :tag = link_to tag, tag_path(tag), rel: :tag

View File

@ -0,0 +1,59 @@
= form_for @orga do |f|
- if @orga.errors.any?
#flash_messages
- @orga.errors.full_messages.each do |msg|
%p.flash.alert= msg
.field.kind
= f.label :kind
%span.radios
- Kind.all.each do |kind|
= f.radio_button :kind_id, kind.id
= f.label "kind_id_#{kind.id}" do
%em.fa{ class: "fa-#{kind.icon}" }
= Kind.human_attribute_name "name_#{kind.name}"
.field.name
= f.label :name
= f.text_field :name, required: true
.field.city
= f.label :city
= f.text_field :city, list: :cities
%datalist#cities
- Event.group(:city).order('count(city) desc').pluck(:city).each do |city|
%option= city
.field.department
= f.label :department
= f.text_field :department
.field.region
= f.label :region
= f.collection_select :region_id, Region.all, :id, :name
.field.url
.helper
:markdown
#{t '.url_helper'}
= f.label :url
= f.url_field :url, placeholder: 'Ex: http://april.org'
.field.feed
.helper
:markdown
#{t '.feed_helper'}
= f.label :feed
= f.url_field :feed, placeholder: 'Ex: http://april.org/index.rss'
.field.contact
.helper
:markdown
#{t '.contact_helper'}
= f.label :contact
= f.email_field :contact
.field.submitter
.helper
:markdown
#{t '.submitter_helper'}
= f.label :submitter
= f.email_field :submitter
.actions
= f.button do
%em.fa.fa-check
= t '.save'

View File

@ -0,0 +1,9 @@
%h2
%em.fa.fa-users
= title t '.title'
%fieldset
%legend
%em.fa.fa-pencil
= t '.edit'
= render 'form'

View File

@ -6,6 +6,7 @@
%table.list.autopagerize_page_element %table.list.autopagerize_page_element
%thead %thead
%th= sort_link @search, :kind_name, Orga.human_attribute_name(:kind)
%th= sort_link @search, :name %th= sort_link @search, :name
%th= sort_link @search, :city %th= sort_link @search, :city
%th= sort_link @search, :department %th= sort_link @search, :department
@ -17,9 +18,13 @@
- @orgas.each do |orga| - @orgas.each do |orga|
%tr %tr
%td %td
- if orga.kind
%em.fa{ class: "fa-#{orga.kind.icon}",
title: Kind.human_attribute_name("name_#{orga.kind.name}") }
%td
= orga.name
- if orga.url =~ /^http/ - if orga.url =~ /^http/
= image_tag orga.url + '/favicon.ico', alt: '', class: :favicon = image_tag orga.url + '/favicon.ico', alt: '', class: :favicon
= orga.name
%td %td
= orga.city = orga.city
%td %td

View File

@ -0,0 +1,9 @@
%h2
%em.fa.fa-users
= title t '.title'
%fieldset
%legend
%em.fa.fa-pencil
= t '.edit'
= render 'form'

View File

@ -2,84 +2,97 @@
= render 'search' = render 'search'
%h2
= image_tag @orga.url + '/favicon.ico', alt: '', class: :favicon
= title @orga.name
%nav %nav
= link_to orgas_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 %em.fa.fa-arrow-left
= Orga.model_name.human.pluralize = Orga.model_name.human.pluralize
\/
= link_to events_path tag: @orga.name do
%em.fa.fa-calendar
Agenda
\/
= link_to events_path format: :rss, tag: @orga.name do
%em.fa.fa-rss
RSS
\/
= link_to events_path format: :ics, tag: @orga.name do
%em.fa.fa-th-list
iCal
\/
= link_to maps_path tag: @orga.name do
%em.fa.fa-map-marker
OpenStreetMap
\/
= link_to maps_path format: :json, tag: @orga.name do
%em.fa.fa-dot-circle-o
GeoJSON
%dl %fieldset.orga
- if @orga.city.present? %aside
%dt= Orga.human_attribute_name :city %h1
%dd= @orga.city %em.fa.fa-link
- if @orga.department.present? = t '.links'
%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: @orga.url, width: '1280', height: '300', frameborder: 'none', %ul.fa-ul
allowTransparency: 'true' } %li
= link_to events_path tag: @orga.name do
%em.fa.fa-li.fa-calendar
Agenda
- if @events_future.any? || @events_past.any? %li
%fieldset = link_to events_path format: :rss, tag: @orga.name do
%legend %em.fa.fa-li.fa-rss
%em.fa.fa-calendar RSS
= Event.model_name.human.pluralize
%li
= link_to events_path format: :ics, tag: @orga.name do
%em.fa.fa-li.fa-th-list
iCal
%li
= link_to maps_path tag: @orga.name do
%em.fa.fa-li.fa-map-marker
OpenStreetMap
%li
= link_to maps_path format: :json, tag: @orga.name do
%em.fa.fa-li.fa-dot-circle-o
GeoJSON
- if user_signed_in?
%h1
%em.fa.fa-wrench
= t '.actions'
%h2
= link_to edit_orga_path @orga do
%em.fa.fa-lg.fa-pencil
= t '.edit'
%h2
- if @orga.kind
%em.fa{ class: "fa-#{@orga.kind.icon}",
title: Kind.human_attribute_name("name_#{@orga.kind.name}") }
= title @orga.name
= image_tag @orga.url + '/favicon.ico', alt: '', class: :favicon
%dl
- if @orga.city.present?
%dt
%em.fa.fa-compress
= 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
%em.fa.fa-shield
= Orga.human_attribute_name :region
%dd= @orga.region
- if @orga.url.present?
%dt
%em.fa.fa-external-link
= Orga.human_attribute_name :url
%dd= link_to @orga.url, @orga.url
- if @orga.feed.present?
%dt
%em.fa.fa-rss
= Orga.human_attribute_name :feed
%dd= link_to @orga.feed, @orga.feed
- if @orga.contact.present?
%dt
%em.fa.fa-envelope
= Event.human_attribute_name :contact
%dd= mail_to @orga.contact, nil,
encode: (request.format == 'text/html' ? :javascript : nil),
replace_at: ' CHEZ ', replace_dot: ' POINT '
- if @events_future.any? - if @events_future.any?
%h3= raw t 'future', count: @events_future.count %dt= t '.future'
%ul.fa-ul %dd= t '.count', count: @events_future.count
- @events_future.order('start_time asc').each do |event|
%li
= link_to event do
- if event.locality?
%em.locality.fa-li.fa.fa-globe(title="#{Event.human_attribute_name :locality} #{t 'attributes.locality_1'}")
- else
%em.locality.fa-li.fa.fa-shield(title="#{Event.human_attribute_name :locality} #{t 'attributes.locality_0'}")
%em.city= event.city
= event.title
.date= display_date event
- if @events_past.any? - if @events_past.any?
%h3= raw t 'past', count: @events_past.count %dt= t '.past'
%ul.fa-ul %dd= t '.count', count: @events_past.count
- @events_past.order('start_time desc').each do |event|
%li
= link_to event do
- if event.locality?
%em.locality.fa-li.fa.fa-globe(title="#{Event.human_attribute_name :locality} #{t 'attributes.locality_1'}")
- else
%em.locality.fa-li.fa.fa-shield(title="#{Event.human_attribute_name :locality} #{t 'attributes.locality_0'}")
%em.city= event.city
= event.title
.date= display_date event
.events#map{ data: { url: maps_path(format: :json, tag: @orga.name) } } .events#map{ data: { url: maps_path(format: :json, tag: @orga.name,
future: false) } }

View File

@ -33,10 +33,22 @@ en:
inseecode: INSEE code inseecode: INSEE code
regioncode: Region code regioncode: Region code
orga: orga:
region: Region kind: Type
department: Department name: Name
url: Web address
city: City city: City
department: Department
region: Region
url: Web address
feed: Syndication
contact: Contact
submitter: Soumetteur
submission_time: En attente depuis
kind:
name_association: Association
name_enterprise: Enterprise
name_lug: LUG
name_provider: ISP
name_institution: Institution
event: event:
title: Title title: Title
start_time: Start start_time: Start

View File

@ -16,6 +16,7 @@ fr:
event: Événement event: Événement
user: Modérateur user: Modérateur
orga: Asso orga: Asso
kind: Type
city: Ville city: Ville
region: Région region: Région
admin_user: Admin admin_user: Admin
@ -33,10 +34,22 @@ fr:
inseecode: Code INSEE inseecode: Code INSEE
regioncode: Code région regioncode: Code région
orga: orga:
kind: Type
name: Nom
city: Ville city: Ville
department: Département department: Département
region: Région region: Région
url: Adresse web url: Adresse web
feed: Syndication
contact: Contact
submitter: Soumetteur
submission_time: En attente depuis
kind:
name_association: Association
name_enterprise: Entreprise
name_lug: GUL
name_provider: FAI
name_institution: Institution
event: event:
title: Titre title: Titre
start_time: Début start_time: Début

View File

@ -9,14 +9,6 @@ en:
logout: Disconnect logout: Disconnect
staleObjectError: Sorry, your modification was rejected because someone else staleObjectError: Sorry, your modification was rejected because someone else
already intervened already intervened
future:
zero:
one: "<strong>In the future</strong>, %{count} event:"
other: "<strong>In the future</strong>, %{count} evens:"
past:
zero:
one: "<strong>In the past</strong>, %{count} event:"
other: "<strong>In the past</strong>, %{count} events:"
# Translatings screens # Translatings screens
layouts: layouts:
@ -42,7 +34,7 @@ en:
calendar_in: This calendar in %{rss}, %{webcal} or %{ical} calendar_in: This calendar in %{rss}, %{webcal} or %{ical}
nb_events: "%{count} events" nb_events: "%{count} events"
show: show:
orga-list: Region's associations orga-list: Region's orgas
add_to_calendar: Add to my calendar add_to_calendar: Add to my calendar
copy: Duplicate event copy: Duplicate event
at: At at: At
@ -76,7 +68,7 @@ telegraphic style.
it more readable or agreable. it more readable or agreable.
" "
preview: Previsualisation preview: Previsualisation
edit: Edition edit: Creation
create: create:
ok: Your event was added to the lists of events waiting for moderation. ok: Your event was added to the lists of events waiting for moderation.
It will appear online as soon as a moderator validates it. It will appear online as soon as a moderator validates it.
@ -242,6 +234,32 @@ description."
search: search:
title: Find your %{entity}! title: Find your %{entity}!
label: Search label: Search
show:
links: Links
actions: Actions
edit: Edit
future: Coming
past: In the past
count:
zero:
one: one event
other: "%{count} events"
new:
title: Organisation
edit: Creation
edit:
title: Organisation
edit: Edition
form:
url_helper: Link toe the organisation's website
feed_helper: "**Direct** link to a syndication feed, RSS or atom"
contact_helper: Contact's email address, obfuscated so that spammers
won't understand it
submitter_helper: Submitter's email address. It will only be used by the
moderators to contact the person who proposed the event, to inform her
about her acceptation or rejection. If this address is absent, the
contact's will be used
save: Save
devise: devise:
sessions: sessions:

View File

@ -9,14 +9,6 @@ fr:
logout: Se déconnecter logout: Se déconnecter
staleObjectError: Désolé, votre modification est rejetée car une autre staleObjectError: Désolé, votre modification est rejetée car une autre
personne est déjà intervenue personne est déjà intervenue
future:
zero:
one: "<strong>Prochainement</strong>, %{count} événement:"
other: "<strong>Prochainement</strong>, %{count} événements:"
past:
zero:
one: "<strong>Dans le passé</strong>, %{count} événement:"
other: "<strong>Dans le passé</strong>, %{count} événements:"
# Traductions des écrans # Traductions des écrans
layouts: layouts:
@ -42,7 +34,7 @@ fr:
calendar_in: Ce calendrier en %{rss}, %{webcal} ou %{ical} calendar_in: Ce calendrier en %{rss}, %{webcal} ou %{ical}
nb_events: "%{count} événements" nb_events: "%{count} événements"
show: show:
orga-list: Asso de la région orga-list: Orgas de la région
add_to_calendar: Ajouter à mon calendrier add_to_calendar: Ajouter à mon calendrier
copy: Dupliquer événement copy: Dupliquer événement
at: À at: À
@ -60,14 +52,14 @@ fr:
description: Description description: Description
infos: Informations infos: Informations
new: new:
title: Soumettre un événement title: Proposer un événement
subtitle: Cette page permet de soumettre un événement dans l'Agenda du subtitle: Cette page permet de soumettre un événement dans l'Agenda du
Libre. Celui-ci n'apparaîtra pas automatiquement dans l'Agenda, il sera Libre. Celui-ci n'apparaîtra pas automatiquement dans l'Agenda, il sera
tout d'abord validé par un modérateur. Un courrier électronique sera tout d'abord validé par un modérateur. Un courrier électronique sera
envoyé à l'adresse e-mail du soumetteur donnée ci-dessous lorsque envoyé à l'adresse e-mail du soumetteur donnée ci-dessous lorsque
l'événement aura été modéré. l'événement aura été modéré.
preview: Prévisualisation preview: Prévisualisation
edit: Édition edit: Création
create: create:
ok: Votre événement a bien été ajouté à la liste des événements en ok: Votre événement a bien été ajouté à la liste des événements en
attente de modération. Il apparaîtra en ligne dès qu'un modérateur attente de modération. Il apparaîtra en ligne dès qu'un modérateur
@ -244,6 +236,32 @@ description plus complète."
search: search:
title: Trouve ton %{entity}! title: Trouve ton %{entity}!
label: Recherche label: Recherche
show:
links: Liens
actions: Actions
edit: Éditer
future: Prochainement
past: Dans le passé
count:
zero:
one: Un événement
other: "%{count} événements"
new:
title: Organisation
edit: Création
edit:
title: Organisation
edit: Édition
form:
url_helper: Lien vers le site web de l'organisation
feed_helper: Lien **direct** vers un flux de syndication, type RSS ou atom
contact_helper: Adresse e-mail de contact, affichée de manière peu
compréhensible par les spammeurs
submitter_helper: Adresse e-mail du soumetteur de l'organisation.
Utilisée par les modérateurs pour informer de sa validation ou de son
rejet. Si cette adresse n'est pas présente, l'adresse de contact sera
utilisée
save: Envoyer
devise: devise:
sessions: sessions:

View File

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

View File

@ -0,0 +1,18 @@
# Setting up organisations' kinds
class CreateKinds < ActiveRecord::Migration
def change
create_table :kinds do |t|
t.string :name, unique: true, null: false
t.string :icon
t.timestamps null: false
end
# Create the relevant organisation kinds
Kind.create name: 'association', icon: 'sitemap'
Kind.create name: 'enterprise', icon: 'building'
Kind.create name: 'lug', icon: 'support'
Kind.create name: 'provider', icon: 'tty'
Kind.create name: 'institution', icon: 'institution'
end
end

View File

@ -0,0 +1,15 @@
# The relation between orga and their kind
class AddDataToOrgas < ActiveRecord::Migration
def change
add_reference :orgas, :kind, index: true
add_foreign_key :orgas, :kinds
add_column :orgas, :feed, :string
add_column :orgas, :contact, :string
add_column :orgas, :submitter, :string
add_column :orgas, :moderated, :boolean, default: false
add_column :orgas, :submission_time, :datetime
add_column :orgas, :decision_time, :datetime
add_column :orgas, :secret, :string
add_column :orgas, :deleted, :boolean, default: false, null: false
end
end

View File

@ -1,5 +1,4 @@
# encoding: UTF-8 # encoding: UTF-8
# rubocop:disable all
# This file is auto-generated from the current state of the database. Instead # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to # of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition. # incrementally modify your database, and then regenerate this schema definition.
@ -12,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150215151059) do ActiveRecord::Schema.define(version: 20150215172739) do
create_table "active_admin_comments", force: :cascade do |t| create_table "active_admin_comments", force: :cascade do |t|
t.string "namespace", limit: 255 t.string "namespace", limit: 255
@ -85,6 +84,13 @@ ActiveRecord::Schema.define(version: 20150215151059) do
add_index "events", ["start_time", "end_time"], name: "events_date" add_index "events", ["start_time", "end_time"], name: "events_date"
create_table "kinds", force: :cascade do |t|
t.string "name", null: false
t.string "icon"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "notes", force: :cascade do |t| create_table "notes", force: :cascade do |t|
t.text "contents", null: false t.text "contents", null: false
t.datetime "date", null: false t.datetime "date", null: false
@ -93,13 +99,28 @@ ActiveRecord::Schema.define(version: 20150215151059) do
end end
create_table "orgas", force: :cascade do |t| create_table "orgas", force: :cascade do |t|
t.integer "region_id", default: 0, null: false t.integer "region_id", default: 0, null: false
t.integer "department", default: 0, null: false t.integer "department", default: 0, null: false
t.string "name", limit: 255, default: "", null: false t.string "name", limit: 255, default: "", null: false
t.string "url", limit: 255, default: "", null: false t.string "url", limit: 255, default: "", null: false
t.string "city", limit: 255, default: "", null: false t.string "city", limit: 255, default: "", null: false
t.string "place"
t.string "address"
t.integer "orga_kind_id"
t.integer "kind_id"
t.string "feed"
t.string "contact"
t.string "submitter"
t.boolean "moderated", default: false
t.datetime "submission_time"
t.datetime "decision_time"
t.string "secret"
t.boolean "deleted", default: false, null: false
end end
add_index "orgas", ["kind_id"], name: "index_orgas_on_kind_id"
add_index "orgas", ["orga_kind_id"], name: "index_orgas_on_orga_kind_id"
create_table "regions", force: :cascade do |t| create_table "regions", force: :cascade do |t|
t.string "name", limit: 255, default: "", null: false t.string "name", limit: 255, default: "", null: false
end end

View File

@ -18,6 +18,12 @@ User.create login: 'admin@example.com', email: 'admin@example.com',
AdminUser.create email: 'admin@example.com', password: 'password' AdminUser.create email: 'admin@example.com', password: 'password'
Kind.create name: 'association', icon: 'sitemap'
Kind.create name: 'enterprise', icon: 'building'
Kind.create name: 'lug', icon: 'support'
Kind.create name: 'provider', icon: 'tty'
Kind.create name: 'institution', icon: 'institution'
# rubocop:disable Metrics/LineLength # rubocop:disable Metrics/LineLength
I18n::Backend::ActiveRecord::Translation.create([ I18n::Backend::ActiveRecord::Translation.create([
{ locale: 'fr', key: 'mail_suffix', value: '[AdL] ' }, { locale: 'fr', key: 'mail_suffix', value: '[AdL] ' },

View File

@ -2,6 +2,7 @@ require 'test_helper'
# Free Software groups life cycle # Free Software groups life cycle
class OrgasControllerTest < ActionController::TestCase class OrgasControllerTest < ActionController::TestCase
include Devise::TestHelpers
setup do setup do
@orga = orgas :one @orga = orgas :one
end end
@ -11,6 +12,40 @@ class OrgasControllerTest < ActionController::TestCase
assert_response :success assert_response :success
end end
test 'should get new' do
sign_in users(:one)
get :new
assert_response :success
end
test 'should create orga' do
sign_in users(:one)
assert_difference 'Orga.count' do
post :create, orga: {
kind_id: @orga.kind_id,
name: @orga.name,
city: @orga.city,
region_id: @orga.region.id,
url: @orga.url,
feed: @orga.feed,
contact: @orga.contact
}
assert_empty assigns(:orga).errors.messages
end
assert_redirected_to :root
end
test 'should not create orga' do
sign_in users(:one)
assert_no_difference 'Orga.count' do
post :create, orga: { url: @orga.url }
assert_not_empty assigns(:orga).errors.messages
end
end
test 'should get show' do test 'should get show' do
get :show, id: @orga get :show, id: @orga
assert_response :success assert_response :success

21
test/fixtures/kinds.yml vendored Normal file
View File

@ -0,0 +1,21 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
name: Association
icon: sitemap
two:
name: Enterprise
icon: building
lug:
name: Lug
icon: support
provider:
name: Provider
icon: tty
institution:
name: Institution
icon: institution

View File

@ -1,15 +1,23 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one: one:
region: region_one kind: lug
name: MyString
city: Jolie ville city: Jolie ville
department: 1 department: 1
name: MyString region: region_one
url: MyString url: http://april.org
feed: http://april.org/index.rss
contact: test@exemple.com
submitter: test@exemple.com
two: two:
region: region_two kind: provider
name: MyString
city: Jolie ville city: Jolie ville
department: 1 department: 1
name: MyString region: region_two
url: MyString url: http://april.org
feed: http://april.org/index.rss
contact: test@exemple.com
submitter: test@exemple.com

7
test/models/kind_test.rb Normal file
View File

@ -0,0 +1,7 @@
require 'test_helper'
class KindTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end