Browse Source

Administration de cités, régions, lugs et contributeurs en place

recurrent
echarp 8 years ago
parent
commit
4761dc8bf6
  1. 13
      app/admin/dashboard.rb
  2. 3
      app/admin/lug.rb
  3. 3
      app/assets/javascripts/cities.js.coffee
  4. 3
      app/assets/javascripts/regions.js.coffee
  5. 6
      app/assets/stylesheets/all.css.sass
  6. 3
      app/assets/stylesheets/cities.css.sass
  7. 3
      app/assets/stylesheets/regions.css.sass
  8. 69
      app/assets/stylesheets/scaffolds.css.scss
  9. 7
      app/controllers/cities_controller.rb
  10. 2
      app/controllers/regions_controller.rb
  11. 2
      app/helpers/lugs_helper.rb
  12. 5
      app/models/city.rb
  13. 3
      app/models/lug.rb
  14. 31
      app/views/cities/_form.html.haml
  15. 7
      app/views/cities/edit.html.haml
  16. 31
      app/views/cities/index.html.haml
  17. 4
      app/views/cities/index.json.jbuilder
  18. 5
      app/views/cities/new.html.haml
  19. 27
      app/views/cities/show.html.haml
  20. 1
      app/views/cities/show.json.jbuilder
  21. 32
      app/views/layouts/application.html.haml
  22. 13
      app/views/regions/_form.html.haml
  23. 7
      app/views/regions/edit.html.haml
  24. 19
      app/views/regions/index.html.haml
  25. 4
      app/views/regions/index.json.jbuilder
  26. 5
      app/views/regions/new.html.haml
  27. 9
      app/views/regions/show.html.haml
  28. 1
      app/views/regions/show.json.jbuilder
  29. 26
      config/locales/fr.yml
  30. 1
      config/routes.rb
  31. 49
      test/controllers/cities_controller_test.rb
  32. 49
      test/controllers/regions_controller_test.rb
  33. 15
      test/fixtures/lugs.yml
  34. 4
      test/fixtures/regions.yml
  35. 1
      test/fixtures/users.yml
  36. 4
      test/helpers/lugs_helper_test.rb
  37. 7
      test/models/lug_test.rb

13
app/admin/dashboard.rb

@ -1,24 +1,23 @@
ActiveAdmin.register_page "Dashboard" do
menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }
menu :priority => 1, :label => proc{ I18n.t("active_admin.dashboard") }
content :title => proc{ I18n.t("active_admin.dashboard") } do
content title: proc{ I18n.t("active_admin.dashboard") } do
columns do
column do
panel "Contributeurs" do
ul do
User.all.map do |user|
li link_to(user, user)
li link_to("#{user.firstname} #{user.lastname} (#{user.login})", user)
end
end
end
end
column do
panel "Contributeurs" do
panel "Commentaires" do
ul do
User.all.map do |user|
li link_to(user.login, user)
ActiveAdmin::Comment.all.map do |comment|
li link_to(comment.author.email, admin_admin_user_path(comment.author))
end
end
end

3
app/admin/lug.rb

@ -0,0 +1,3 @@
ActiveAdmin.register Lug do
permit_params :name, :department, :url, :city
end

3
app/assets/javascripts/cities.js.coffee

@ -1,3 +0,0 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

3
app/assets/javascripts/regions.js.coffee

@ -1,3 +0,0 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

6
app/assets/stylesheets/all.css.sass

@ -54,3 +54,9 @@ header.top
main h1
margin-top: 1em
footer.bottom nav
font-size: smaller
a + a:before
color: black
content: '- '

3
app/assets/stylesheets/cities.css.sass

@ -1,3 +0,0 @@
// Place all the styles related to the cities controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

3
app/assets/stylesheets/regions.css.sass

@ -1,3 +0,0 @@
// Place all the styles related to the regions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

69
app/assets/stylesheets/scaffolds.css.scss

@ -0,0 +1,69 @@
body {
background-color: #fff;
color: #333;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px;
}
p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px;
}
pre {
background-color: #eee;
padding: 10px;
font-size: 11px;
}
a {
color: #000;
&:visited {
color: #666;
}
&:hover {
color: #fff;
background-color: #000;
}
}
div {
&.field, &.actions {
margin-bottom: 10px;
}
}
#notice {
color: green;
}
.field_with_errors {
padding: 2px;
background-color: red;
display: table;
}
#error_explanation {
width: 450px;
border: 2px solid red;
padding: 7px;
padding-bottom: 0;
margin-bottom: 20px;
background-color: #f0f0f0;
h2 {
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px;
margin-bottom: 0px;
background-color: #c00;
color: #fff;
}
ul li {
font-size: 12px;
list-style: square;
}
}

7
app/controllers/cities_controller.rb

@ -1,7 +0,0 @@
class CitiesController < InheritedResources::Base
protected
# Never trust parameters from the scary internet, only allow the white list through.
def permitted_params
params.permit city: [:name, :majname, :postalcode, :inseecode, :regioncode, :latitude, :longitude]
end
end

2
app/controllers/regions_controller.rb

@ -1,2 +0,0 @@
class RegionsController < InheritedResources::Base
end

2
app/helpers/lugs_helper.rb

@ -0,0 +1,2 @@
module LugsHelper
end

5
app/models/city.rb

@ -1,2 +1,7 @@
class City < ActiveRecord::Base
end
#
# def permitted_params
# params.permit city: [:name, :majname, :postalcode, :inseecode, :regioncode, :latitude, :longitude]
# end

3
app/models/lug.rb

@ -0,0 +1,3 @@
class Lug < ActiveRecord::Base
belongs_to :region, foreign_key: 'region'
end

31
app/views/cities/_form.html.haml

@ -1,31 +0,0 @@
= form_for @city do |f|
- if @city.errors.any?
#error_explanation
%h2= "#{pluralize(@city.errors.count, "error")} prohibited this city from being saved:"
%ul
- @city.errors.full_messages.each do |msg|
%li= msg
.field
= f.label :name
= f.text_field :name
.field
= f.label :majname
= f.text_field :majname
.field
= f.label :postalcode
= f.number_field :postalcode
.field
= f.label :inseecode
= f.number_field :inseecode
.field
= f.label :regioncode
= f.number_field :regioncode
.field
= f.label :latitude
= f.text_field :latitude
.field
= f.label :longitude
= f.text_field :longitude
.actions
= f.submit 'Save'

7
app/views/cities/edit.html.haml

@ -1,7 +0,0 @@
%h1 Editing city
= render 'form'
= link_to 'Show', @city
\|
= link_to 'Back', cities_path

31
app/views/cities/index.html.haml

@ -1,31 +0,0 @@
%h1 Listing cities
%table
%tr
%th Name
%th Majname
%th Postalcode
%th Inseecode
%th Regioncode
%th Latitude
%th Longitude
%th
%th
%th
- @cities.each do |city|
%tr
%td= city.name
%td= city.majname
%td= city.postalcode
%td= city.inseecode
%td= city.regioncode
%td= city.latitude
%td= city.longitude
%td= link_to 'Show', city
%td= link_to 'Edit', edit_city_path(city)
%td= link_to 'Destroy', city, :method => :delete, :data => { :confirm => 'Are you sure?' }
%br
= link_to 'New City', new_city_path

4
app/views/cities/index.json.jbuilder

@ -1,4 +0,0 @@
json.array!(@cities) do |city|
json.extract! city, :name, :majname, :postalcode, :inseecode, :regioncode, :latitude, :longitude
json.url city_url(city, format: :json)
end

5
app/views/cities/new.html.haml

@ -1,5 +0,0 @@
%h1 New city
= render 'form'
= link_to 'Back', cities_path

27
app/views/cities/show.html.haml

@ -1,27 +0,0 @@
%p#notice= notice
%p
%b Name:
= @city.name
%p
%b Majname:
= @city.majname
%p
%b Postalcode:
= @city.postalcode
%p
%b Inseecode:
= @city.inseecode
%p
%b Regioncode:
= @city.regioncode
%p
%b Latitude:
= @city.latitude
%p
%b Longitude:
= @city.longitude
= link_to t('Edit'), edit_city_path(@city)
\|
= link_to t('Back'), cities_path

1
app/views/cities/show.json.jbuilder

@ -1 +0,0 @@
json.extract! @city, :name, :majname, :postalcode, :inseecode, :regioncode, :latitude, :longitude, :created_at, :updated_at

32
app/views/layouts/application.html.haml

@ -2,18 +2,18 @@
/[if IE]
%html(lang="#{I18n.locale}")
%head
%title L'Agenda du Libre
%title=t '.title'
%meta(http-equiv='Content-Type' content='text/html; charset=utf-8')
%meta(name='description' content='Parlement, a mix between direct and representative democracy, in the shape of a website. A mailing list, forum, chat. Democratic mailing list and forum')
%meta(name='description' content='Agende du Libre. Free Software Calendar')
%meta(name='author' content='Emmanuel Charpentier')
%meta(name='robots' content='index, follow')
%meta(name='keywords' content='collaborative writing, democracy, direct democracy, representative democracy, forum, mailing list, chat, Ruby on Rails, PostgreSQL')
%meta(name='keywords' content='calendar, agenda, date')
%meta(name='dcterms.title' content='Parlement' lang='en')
%meta(name='dcterms.title' content='Parlement' lang='fr')
%meta(name='dcterms.subject' content='Parlement, democratic mailing list and forum')
%meta(name='dcterms.title' content='Free Calendar' lang='en')
%meta(name='dcterms.title' content='Agenda du Libre' lang='fr')
%meta(name='dcterms.subject' content='agenda')
-#%link(rel='shortcut icon' href='/assets/favicon.ico')
%link(rel='icon' type='image/png' href='/assets/world.png')
@ -33,16 +33,22 @@
= render 'layouts/flash', flash: flash if flash.present?
%header.top
%h1= link_to "L'Agenda du Libre", root_url
%h2 L'agenda des évènements du Logiciel Libre en France
%h1= link_to t('.title'), root_url
%h2=t '.subtitle'
%main
= yield
%footer.bottom
%nav
= link_to User.model_name.human.capitalize.pluralize, users_url
= link_to 'Forge', 'http://rubyforge.org/projects/parlement'
= link_to 'AGPL', 'http://www.gnu.org/licenses/agpl.html'
= link_to 'fr', '/fr', class: 'fr'
%span.version=t :version, version: 1.99
= link_to t('.propose'), users_url
= link_to t('.rss'), users_url
= link_to t('.ical'), users_url
= link_to t('.map'), users_url
= link_to t('.tags'), users_url
= link_to t('.infos'), users_url
= link_to t('.stats'), users_url
= link_to t('.contact'), users_url
= link_to t('.moderation'), users_url
= link_to t('.forge'), 'http://rubyforge.org/projects/parlement'
= link_to t('.agpl'), 'http://www.gnu.org/licenses/agpl.html'

13
app/views/regions/_form.html.haml

@ -1,13 +0,0 @@
= form_for @region do |f|
- if @region.errors.any?
#error_explanation
%h2= "#{pluralize(@region.errors.count, "error")} prohibited this region from being saved:"
%ul
- @region.errors.full_messages.each do |msg|
%li= msg
.field
= f.label :name
= f.text_field :name
.actions
= f.submit 'Save'

7
app/views/regions/edit.html.haml

@ -1,7 +0,0 @@
%h1 Editing region
= render 'form'
= link_to 'Show', @region
\|
= link_to 'Back', regions_path

19
app/views/regions/index.html.haml

@ -1,19 +0,0 @@
%h1 Listing regions
%table
%tr
%th Name
%th
%th
%th
- @regions.each do |region|
%tr
%td= region.name
%td= link_to 'Show', region
%td= link_to 'Edit', edit_region_path(region)
%td= link_to 'Destroy', region, :method => :delete, :data => { :confirm => 'Are you sure?' }
%br
= link_to 'New Region', new_region_path

4
app/views/regions/index.json.jbuilder

@ -1,4 +0,0 @@
json.array!(@regions) do |region|
json.extract! region, :name
json.url region_url(region, format: :json)
end

5
app/views/regions/new.html.haml

@ -1,5 +0,0 @@
%h1 New region
= render 'form'
= link_to 'Back', regions_path

9
app/views/regions/show.html.haml

@ -1,9 +0,0 @@
%p#notice= notice
%p
%b Name:
= @region.name
= link_to 'Edit', edit_region_path(@region)
\|
= link_to 'Back', regions_path

1
app/views/regions/show.json.jbuilder

@ -1 +0,0 @@
json.extract! @region, :name, :created_at, :updated_at

26
config/locales/fr.yml

@ -4,6 +4,9 @@ fr:
destroy: Supprimer
attributes:
id: ID
name: Nom
email: Email
created_at: Créé le
updated_at: Modifié le
created: Créé il y a %{date}
@ -16,13 +19,23 @@ fr:
user: Contributeur
city: Cité
region: Région
lug: Gull
attributes:
user:
login: Identifiant
email: Email
password: Mot de passe
lastname: Nom
firstname: Prénom
city:
majname: Nom majuscules
postalcode: Code postal
inseecode: Code INSEE
regioncode: Code région
lug:
region: Région
department: Département
url: Adresse web
city: Cité
helpers:
submit:
@ -32,3 +45,14 @@ fr:
layouts:
application:
login: Authentication
title: L'Agenda du Libre
subtitle: L'agenda des évènements du Logiciel Libre en France
propose: Proposer un évènement
rss: Flux RSS
ical: Calendriers iCal
map: Carte
tags: Tags
infos: Informations
stats: Statistiques
contact: Contact
moderation: Modération

1
config/routes.rb

@ -1,4 +1,5 @@
AgendaDuLibreRails::Application.routes.draw do
resources :lugs
resources :cities
resources :regions
resources :users

49
test/controllers/cities_controller_test.rb

@ -1,49 +0,0 @@
require 'test_helper'
class CitiesControllerTest < ActionController::TestCase
setup do
@city = cities(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:cities)
end
test "should get new" do
get :new
assert_response :success
end
test "should create city" do
assert_difference('City.count') do
post :create, city: { inseecode: @city.inseecode, latitude: @city.latitude, longitude: @city.longitude, majname: @city.majname, name: @city.name, postalcode: @city.postalcode, regioncode: @city.regioncode }
end
assert_redirected_to city_path(assigns(:city))
end
test "should show city" do
get :show, id: @city
assert_response :success
end
test "should get edit" do
get :edit, id: @city
assert_response :success
end
test "should update city" do
patch :update, id: @city, city: { inseecode: @city.inseecode, latitude: @city.latitude, longitude: @city.longitude, majname: @city.majname, name: @city.name, postalcode: @city.postalcode, regioncode: @city.regioncode }
assert_redirected_to city_path(assigns(:city))
end
test "should destroy city" do
assert_difference('City.count', -1) do
delete :destroy, id: @city
end
assert_redirected_to cities_path
end
end

49
test/controllers/regions_controller_test.rb

@ -1,49 +0,0 @@
require 'test_helper'
class RegionsControllerTest < ActionController::TestCase
setup do
@region = regions(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:regions)
end
test "should get new" do
get :new
assert_response :success
end
test "should create region" do
assert_difference('Region.count') do
post :create, region: { name: @region.name }
end
assert_redirected_to region_path(assigns(:region))
end
test "should show region" do
get :show, id: @region
assert_response :success
end
test "should get edit" do
get :edit, id: @region
assert_response :success
end
test "should update region" do
patch :update, id: @region, region: { name: @region.name }
assert_redirected_to region_path(assigns(:region))
end
test "should destroy region" do
assert_difference('Region.count', -1) do
delete :destroy, id: @region
end
assert_redirected_to regions_path
end
end

15
test/fixtures/lugs.yml

@ -0,0 +1,15 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
region: region_one
department: 1
name: MyString
url: MyString
city: MyString
two:
region: region_one
department: 1
name: MyString
url: MyString
city: MyString

4
test/fixtures/regions.yml

@ -1,7 +1,7 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
region_one:
name: MyString
two:
region_two:
name: MyString

1
test/fixtures/users.yml

@ -6,6 +6,5 @@
one:
email: one@example.com
two:
email: two@example.com

4
test/helpers/lugs_helper_test.rb

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

7
test/models/lug_test.rb

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