Browse Source

Organisations can now be managed as are managed events: propose, accept or refuse

recurrent
echarp 7 years ago
parent
commit
e0d6415865
  1. 9
      Gemfile
  2. 164
      Gemfile.lock
  3. 2
      app/assets/stylesheets/events.css.sass
  4. 1
      app/controllers/moderations_controller.rb
  5. 26
      app/controllers/orgas_controller.rb
  6. 4
      app/mailers/application_mailer.rb
  7. 2
      app/mailers/event_mailer.rb
  8. 2
      app/mailers/moderation_mailer.rb
  9. 2
      app/mailers/note_mailer.rb
  10. 66
      app/mailers/orga_mailer.rb
  11. 1
      app/models/event.rb
  12. 27
      app/models/orga.rb
  13. 10
      app/views/event_mailer/accept.text.haml
  14. 9
      app/views/event_mailer/create.text.haml
  15. 10
      app/views/event_mailer/destroy.text.haml
  16. 8
      app/views/events/cancel.html.haml
  17. 3
      app/views/layouts/mailer.html.haml
  18. 5
      app/views/layouts/mailer.text.haml
  19. 8
      app/views/moderation_mailer/accept.text.haml
  20. 7
      app/views/moderation_mailer/create.text.haml
  21. 8
      app/views/moderation_mailer/destroy.text.haml
  22. 21
      app/views/moderation_mailer/update.text.haml
  23. 123
      app/views/moderations/index.html.haml
  24. 8
      app/views/orga_mailer/accept.text.haml
  25. 7
      app/views/orga_mailer/create.text.haml
  26. 10
      app/views/orga_mailer/destroy.text.haml
  27. 8
      app/views/orga_mailer/update.text.haml
  28. 3
      app/views/orgas/_form.html.haml
  29. 18
      app/views/orgas/cancel.html.haml
  30. 104
      app/views/orgas/show.html.haml
  31. 9
      app/views/orgas/show.text.haml
  32. 18
      app/views/orgas/validate.html.haml
  33. 30
      app/views/stats/index.html.haml
  34. 2
      config/application.rb
  35. 143
      config/locales/views/en.yml
  36. 142
      config/locales/views/fr.yml
  37. 5
      config/routes.rb
  38. 14
      db/migrate/20150711164423_create_versions.rb
  39. 50
      db/schema.rb
  40. 6
      test/controllers/notes_controller_test.rb
  41. 1
      test/controllers/orgas_controller_test.rb
  42. 4
      test/fixtures/notes.yml
  43. 3
      test/fixtures/orgas.yml
  44. 4
      test/fixtures/users.yml
  45. 47
      test/mailers/orga_mailer_test.rb
  46. 5
      test/mailers/previews/note_mailer_preview.rb
  47. 26
      test/mailers/previews/orga_mailer_preview.rb
  48. 54
      test/models/orga_test.rb

9
Gemfile

@ -55,6 +55,10 @@ gem 'i18n-active_record',
github: 'svenfuchs/i18n-active_record',
require: 'i18n/active_record'
gem 'http_accept_language'
# Remove leading and trailing white spaces
gem 'strip_attributes'
# Track changes to models' data
gem 'paper_trail', '~> 4.0.0.rc'
# A superb font to use as icons
gem 'font-awesome-sass'
@ -66,7 +70,7 @@ gem 'actionview-encoded_mail_to'
gem 'differ'
# A generic library to administrate the tool
gem 'activeadmin', github: 'activeadmin'
gem 'activeadmin', '~> 1.0.0.pre1'
# A nicer markdown editor in active admin
gem 'activeadmin_pagedown'
@ -85,9 +89,6 @@ gem 'geocoder'
gem 'tinymce-rails'
gem 'tinymce-rails-langs'
# Remove leading and trailing white spaces
gem 'strip_attributes'
# SEO optimisations
gem 'meta-tags'

164
Gemfile.lock

@ -1,21 +1,3 @@
GIT
remote: git://github.com/activeadmin/activeadmin.git
revision: 0b4b22871fd332c94daec3c5138c0cf9a5b95451
specs:
activeadmin (1.0.0.pre1)
arbre (~> 1.0, >= 1.0.2)
bourbon
coffee-rails
formtastic (~> 3.1)
formtastic_i18n
inherited_resources (~> 1.6)
jquery-rails
jquery-ui-rails (~> 5.0)
kaminari (~> 0.15)
rails (>= 3.2, < 5.0)
ransack (~> 1.3)
sass-rails
GIT
remote: git://github.com/cubus/jquery-sparkline-rails.git
revision: c5b531f51e3e734710c7561b06c2c829107f9b38
@ -34,40 +16,53 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.1)
actionpack (= 4.2.1)
actionview (= 4.2.1)
activejob (= 4.2.1)
actionmailer (4.2.3)
actionpack (= 4.2.3)
actionview (= 4.2.3)
activejob (= 4.2.3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.1)
actionview (= 4.2.1)
activesupport (= 4.2.1)
actionpack (4.2.3)
actionview (= 4.2.3)
activesupport (= 4.2.3)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.1)
actionview (4.2.1)
activesupport (= 4.2.1)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.3)
activesupport (= 4.2.3)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.1)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview-encoded_mail_to (1.0.6)
rails
activeadmin (1.0.0.pre1)
arbre (~> 1.0, >= 1.0.2)
bourbon
coffee-rails
formtastic (~> 3.1)
formtastic_i18n
inherited_resources (~> 1.6)
jquery-rails
jquery-ui-rails (~> 5.0)
kaminari (~> 0.15)
rails (>= 3.2, < 5.0)
ransack (~> 1.3)
sass-rails
activeadmin_pagedown (0.0.2)
activeadmin (>= 0.5.0)
activejob (4.2.1)
activesupport (= 4.2.1)
activejob (4.2.3)
activesupport (= 4.2.3)
globalid (>= 0.3.0)
activemodel (4.2.1)
activesupport (= 4.2.1)
activemodel (4.2.3)
activesupport (= 4.2.3)
builder (~> 3.1)
activerecord (4.2.1)
activemodel (= 4.2.1)
activesupport (= 4.2.1)
activerecord (4.2.3)
activemodel (= 4.2.3)
activesupport (= 4.2.3)
arel (~> 6.0)
activesupport (4.2.1)
activesupport (4.2.3)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
@ -76,32 +71,30 @@ GEM
addressable (2.3.8)
arbre (1.0.3)
activesupport (>= 3.0.0)
arel (6.0.0)
arel (6.0.2)
ast (2.0.0)
astrolabe (1.3.0)
parser (>= 2.2.0.pre.3, < 3.0)
astrolabe (1.3.1)
parser (~> 2.2)
bcrypt (3.1.10)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
bourbon (4.2.3)
sass (~> 3.4)
thor
brakeman (3.0.3)
brakeman (3.0.5)
erubis (~> 2.6)
fastercsv (~> 1.5)
haml (>= 3.0, < 5.0)
highline (~> 1.6.20)
multi_json (~> 1.2)
ruby2ruby (~> 2.1.1)
ruby_parser (~> 3.6.2)
ruby_parser (~> 3.7.0)
sass (~> 3.0)
terminal-table (~> 1.4)
buftok (0.2.0)
builder (3.2.2)
byebug (5.0.0)
columnize (= 0.9.0)
celluloid (0.16.0)
timers (~> 4.0.0)
chunky_png (1.3.4)
coderay (1.1.0)
coffee-rails (4.1.0)
@ -136,7 +129,7 @@ GEM
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
devise-i18n (0.12.0)
devise-i18n (0.12.1)
differ (0.1.2)
docile (1.1.5)
em-websocket (0.5.1)
@ -151,7 +144,7 @@ GEM
faraday (0.9.1)
multipart-post (>= 1.2, < 3)
fastercsv (1.5.5)
ffi (1.9.8)
ffi (1.9.10)
font-awesome-sass (4.3.2.1)
sass (~> 3.2)
formatador (0.2.5)
@ -161,9 +154,9 @@ GEM
geocoder (1.2.9)
globalid (0.3.5)
activesupport (>= 4.1.0)
guard (2.12.6)
guard (2.12.9)
formatador (>= 0.2.4)
listen (~> 2.7)
listen (>= 2.7, <= 4.0)
lumberjack (~> 1.0)
nenv (~> 0.1)
notiffany (~> 0.0)
@ -209,7 +202,6 @@ GEM
activesupport (>= 3.2, < 5)
highline (1.6.21)
hike (1.2.3)
hitimes (1.2.2)
html2haml (2.0.0)
erubis (~> 2.7.0)
haml (~> 4.0.0)
@ -225,10 +217,10 @@ GEM
has_scope (~> 0.6.0.rc)
railties (>= 3.2, < 5)
responders
jbuilder (2.2.16)
jbuilder (2.3.1)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jquery-rails (4.0.3)
jquery-rails (4.0.4)
rails-dom-testing (~> 1.0)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
@ -244,9 +236,8 @@ GEM
leaflet-markercluster-rails (0.7.0)
railties (>= 3.1)
leaflet-rails (0.7.4)
libv8 (3.16.14.7)
listen (2.10.0)
celluloid (~> 0.16.0)
libv8 (3.16.14.11)
listen (3.0.3)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
loofah (2.0.2)
@ -263,7 +254,7 @@ GEM
mini_portile (0.6.2)
minitest (5.7.0)
modernizr-rails (2.7.1)
multi_json (1.11.1)
multi_json (1.11.2)
multipart-post (2.0.0)
mysql2 (0.3.18)
naught (1.0.0)
@ -274,7 +265,11 @@ GEM
nenv (~> 0.1)
shellany (~> 0.0)
orm_adapter (0.5.0)
parser (2.3.0.pre.1)
paper_trail (4.0.0.rc2)
activerecord (>= 3.0, < 6.0)
activesupport (>= 3.0, < 6.0)
request_store (~> 1.1)
parser (2.2.2.6)
ast (>= 1.1, < 3.0)
polyamorous (1.2.0)
activerecord (>= 3.0)
@ -285,19 +280,19 @@ GEM
slop (~> 3.4)
quiet_assets (1.1.0)
railties (>= 3.1, < 5.0)
rack (1.6.1)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.1)
actionmailer (= 4.2.1)
actionpack (= 4.2.1)
actionview (= 4.2.1)
activejob (= 4.2.1)
activemodel (= 4.2.1)
activerecord (= 4.2.1)
activesupport (= 4.2.1)
rails (4.2.3)
actionmailer (= 4.2.3)
actionpack (= 4.2.3)
actionview (= 4.2.3)
activejob (= 4.2.3)
activemodel (= 4.2.3)
activerecord (= 4.2.3)
activesupport (= 4.2.3)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.1)
railties (= 4.2.3)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
@ -310,9 +305,9 @@ GEM
rails-i18n (4.0.4)
i18n (~> 0.6)
railties (~> 4.0)
railties (4.2.1)
actionpack (= 4.2.1)
activesupport (= 4.2.1)
railties (4.2.3)
actionpack (= 4.2.3)
activesupport (= 4.2.3)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.0.0)
@ -328,11 +323,12 @@ GEM
ffi (>= 0.5.0)
rdoc (4.2.0)
json (~> 1.4)
redcarpet (3.3.1)
ref (1.0.5)
redcarpet (3.3.2)
ref (2.0.0)
request_store (1.2.0)
responders (2.1.0)
railties (>= 4.2.0, < 5)
rubocop (0.32.0)
rubocop (0.32.1)
astrolabe (~> 1.3)
parser (>= 2.2.2.5, < 3.0)
powerpack (~> 0.1)
@ -342,9 +338,9 @@ GEM
ruby2ruby (2.1.4)
ruby_parser (~> 3.1)
sexp_processor (~> 4.0)
ruby_parser (3.6.6)
ruby_parser (3.7.0)
sexp_processor (~> 4.1)
sass (3.4.14)
sass (3.4.16)
sass-rails (5.0.1)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
@ -368,12 +364,12 @@ GEM
simplecov-html (0.10.0)
slop (3.6.0)
spring (1.3.6)
sprockets (2.12.3)
sprockets (2.12.4)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.3.1)
sprockets-rails (2.3.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
@ -381,16 +377,14 @@ GEM
strip_attributes (1.7.0)
activemodel (>= 3.0, < 5.0)
sysexits (1.2.0)
terminal-table (1.4.5)
terminal-table (1.5.2)
therubyracer (0.12.2)
libv8 (~> 3.16.14.0)
ref
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
timers (4.0.1)
hitimes
tinymce-rails (4.1.6)
tinymce-rails (4.2.2)
railties (>= 3.1.1)
tinymce-rails-langs (4.20140129)
tinymce-rails (~> 4.0)
@ -414,13 +408,13 @@ GEM
json (>= 1.8.0)
warden (1.2.3)
rack (>= 1.0)
web-console (2.1.2)
web-console (2.2.1)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
webrick (1.3.1)
webshims-rails (1.15.6.4)
webshims-rails (1.15.8)
rails (> 3.1.0)
PLATFORMS
@ -428,7 +422,7 @@ PLATFORMS
DEPENDENCIES
actionview-encoded_mail_to
activeadmin!
activeadmin (~> 1.0.0.pre1)
activeadmin_pagedown
brakeman
byebug
@ -460,6 +454,7 @@ DEPENDENCIES
meta-tags
modernizr-rails
mysql2
paper_trail (~> 4.0.0.rc)
quiet_assets
rails
rails-i18n
@ -481,3 +476,6 @@ DEPENDENCIES
web-console (~> 2.0)
webrick (>= 1.3.1)
webshims-rails
BUNDLED WITH
1.10.5

2
app/assets/stylesheets/events.css.sass

@ -107,7 +107,7 @@ a#banner
margin-left: 5%
padding-left: 2px
body.events.show main
body.events.show main, body.orgas.show main
padding: 1em
max-width: 60em
+box-shadow(1px 1px 5px gray)

1
app/controllers/moderations_controller.rb

@ -8,6 +8,7 @@ class ModerationsController < ApplicationController
def index
@events = Event.unmoderated
@orgas = Orga.unmoderated
end
def preview

26
app/controllers/orgas_controller.rb

@ -1,11 +1,13 @@
# Groups life cycle
class OrgasController < ApplicationController
before_action :set_orga, except: [:index, :new, :create]
before_action :authenticate_user!, only: [:edit, :update, :destroy],
before_action :set_mailer_host
before_action :authenticate_user!, only: [:edit, :update, :cancel, :destroy],
unless: :check_secret
before_action :authenticate_user!, only: [:validate, :accept]
def index
@search = Orga.search params[:q]
@search = Orga.moderated.search params[:q]
@search.sorts = 'name' if @search.sorts.empty?
@orgas = @search.result.page params[:page]
end
@ -54,6 +56,26 @@ class OrgasController < ApplicationController
end
end
# PATCH/PUT /accept/1
# PATCH/PUT /accept/1.json
def accept
@orga.update moderated: true
respond_to do |format|
format.html { redirect_to :orgas, notice: t('.ok') }
format.json { head :no_content }
end
end
# DELETE /orgas/1
# DELETE /orgas/1.json
def destroy
@orga.destroy
respond_to do |format|
format.html { redirect_to :root, notice: t('.ok') }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.

4
app/mailers/application_mailer.rb

@ -0,0 +1,4 @@
# Top mailer class, from which all others are inheritors
class ApplicationMailer < ActionMailer::Base
layout 'mailer'
end

2
app/mailers/event_mailer.rb

@ -1,5 +1,5 @@
# Sending mails related to events life cycle
class EventMailer < ActionMailer::Base
class EventMailer < ApplicationMailer
helper :events
def create(event)

2
app/mailers/moderation_mailer.rb

@ -1,5 +1,5 @@
# Sending mails related to events' moderation
class ModerationMailer < ActionMailer::Base
class ModerationMailer < ApplicationMailer
helper :events
def create(event)

2
app/mailers/note_mailer.rb

@ -1,5 +1,5 @@
# Sending mails related to events' notes
class NoteMailer < ActionMailer::Base
class NoteMailer < ApplicationMailer
helper :events
def notify(note)

66
app/mailers/orga_mailer.rb

@ -0,0 +1,66 @@
# Send mails to check on organisations life cycle
class OrgaMailer < ApplicationMailer
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.orga_mailer.create.subject
#
def create(orga)
@orga = orga
mail 'Message-ID' =>
"<orga-#{orga.id}@#{ActionMailer::Base.default_url_options[:host]}>",
to: orga.submitter,
subject: "#{t 'mail_prefix'}#{t 'orga_mailer.create.subject',
subject: orga.name}"
end
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.orga_mailer.update.subject
#
def update(orga)
@orga = orga
@current_user = User.find_by id: orga.paper_trail_originator
mail 'Message-ID' =>
"<orga-#{orga.id}@#{ActionMailer::Base.default_url_options[:host]}>",
to: orga.submitter,
subject: "#{t 'mail_prefix'}#{t 'orga_mailer.update.subject',
subject: orga.name}"
end
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.orga_mailer.accept.subject
#
def accept(orga)
@orga = orga
@current_user = User.find_by id: orga.paper_trail_originator
mail 'In-Reply-To' =>
"<orga-#{orga.id}@#{ActionMailer::Base.default_url_options[:host]}>",
to: orga.submitter,
subject: "#{t 'mail_prefix'}#{t 'orga_mailer.accept.subject',
subject: orga.name}"
end
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.orga_mailer.destroy.subject
#
def destroy(orga, reason = '')
@orga = orga
@current_user = User.find_by id: orga.paper_trail_originator
@reason = reason
mail 'In-Reply-To' =>
"<orga-#{orga.id}@#{ActionMailer::Base.default_url_options[:host]}>",
to: orga.submitter,
subject: "#{t 'mail_prefix'}#{t 'orga_mailer.destroy.subject',
subject: orga.name}"
end
end

1
app/models/event.rb

@ -4,6 +4,7 @@
class Event < ActiveRecord::Base
extend SimpleCalendar
strip_attributes
has_paper_trail
belongs_to :region
has_many :notes, dependent: :destroy

27
app/models/orga.rb

@ -1,5 +1,7 @@
# Groups related to this agenda
class Orga < ActiveRecord::Base
has_paper_trail
belongs_to :region
belongs_to :kind
@ -11,6 +13,9 @@ class Orga < ActiveRecord::Base
validates :contact, presence: true, email: true
validates :submitter, allow_blank: true, email: true
scope :moderated, -> { where moderated: true }
scope :unmoderated, -> { where moderated: false }
before_validation do
self.secret ||= SecureRandom.urlsafe_base64(32)[0...32]
self.submission_time ||= Time.zone.now
@ -18,4 +23,26 @@ class Orga < ActiveRecord::Base
# Populate submitter using contact info if absent
self.submitter ||= contact
end
after_create do
send_secret
end
before_update do
send_secret if secret_changed?
if moderated_changed?
OrgaMailer.accept(self).deliver_now!
elsif previous_changes
OrgaMailer.update(self).deliver_now!
end
end
before_destroy do
OrgaMailer.destroy(self).deliver_now!
end
def send_secret
OrgaMailer.create(self).deliver_now!
end
end

10
app/views/event_mailer/accept.text.haml

@ -1,14 +1,12 @@
=t '.title'
\
=t '.body', moderator: @current_user
= t '.body', moderator: @current_user
= event_url @event
\
=t '.edit_link'
= t '.edit_link'
= edit_event_url @event, secret: @event.secret
\
=t '.delete_link'
= t '.delete_link'
= cancel_event_url @event, secret: @event.secret
\
= render file: '/events/show'
\
=t '.signature'
= t '.signature'

9
app/views/event_mailer/create.text.haml

@ -1,9 +1,8 @@
=t '.title'
\
=t '.body', subject: @event.title, start_time: l(@event.start_time, format: :at)
= t '.body', subject: @event.title,
start_time: l(@event.start_time, format: :at)
= edit_event_url @event, secret: @event.secret
\
=t '.delete_link'
= t '.delete_link'
= cancel_event_url @event, secret: @event.secret
\
=t '.signature'
= t '.signature'

10
app/views/event_mailer/destroy.text.haml

@ -1,12 +1,10 @@
=t '.title'
\
=t '.body', author: @current_user
= t '.body', author: @current_user
\
= @reason
\
=t '.reclamation'
= t '.reclamation'
\
=t '.reminder'
= t '.reminder'
= render file: '/events/show'
\
=t '.signature'
= t '.signature'

8
app/views/events/cancel.html.haml

@ -1,18 +1,18 @@
%h2
%em.fa.fa-trash-o
=t '.title'
= t '.title'
- if @event.moderated?
%h3.warning=t '.already_moderated'
%h3.warning= t '.already_moderated'
%fieldset
= form_for @event, method: :delete do |f|
= hidden_field_tag :secret, params[:secret]
%h2=t '.confirm'
%h2= t '.confirm'
= f.submit t('.ok'), name: :yes
= link_to t('.ko'), @event, class: :button
%fieldset
%legend=Event.model_name.human
%legend= Event.model_name.human
= render file: '/events/show'

3
app/views/layouts/mailer.html.haml

@ -0,0 +1,3 @@
%hmtl
%body
= yield

5
app/views/layouts/mailer.text.haml

@ -0,0 +1,5 @@
= t '.title'
\
= yield
\--
= t 'layouts.application.title'

8
app/views/moderation_mailer/accept.text.haml

@ -1,10 +1,8 @@
=t '.title'
\
=t '.body', author: @current_user
= t '.body', author: @current_user
\
= render file: '/events/show'
\
=t '.access'
= t '.access'
= event_url @event
\
=t '.signature'
= t '.signature'

7
app/views/moderation_mailer/create.text.haml

@ -1,8 +1,7 @@
=t '.title'
\
=t '.body', subject: @event.title, start_time: l(@event.start_time, format: :at)
= t '.body', subject: @event.title, start_time: l(@event.start_time,
format: :at)
= moderations_url
\
= render file: '/events/show'
\
=t '.signature'
= t '.signature'

8
app/views/moderation_mailer/destroy.text.haml

@ -1,10 +1,8 @@
=t '.title'
\
=t '.body', subject: @event.title, author: @current_user
= t '.body', subject: @event.title, author: @current_user
\
= @reason
\
=t '.reminder'
= t '.reminder'
= render file: '/events/show'
\
=t '.signature'
= t '.signature'

21
app/views/moderation_mailer/update.text.haml

@ -1,17 +1,16 @@
=t '.title'
\
=t '.body', subject: @event.title, author: @current_user||t('.submitter')
= t '.body', subject: @event.title, author: @current_user || t('.submitter')
- new = render file: '/events/show'
:ruby
new = render file: '/events/show'
- former = @event
- @event = @older_event
former = @event
@event = @older_event
- prev = render file: '/events/show'
- @event = former
prev = render file: '/events/show'
@event = former
- require 'differ/format/patch'
- Differ.format = Differ::Format::Patch
require 'differ/format/patch'
Differ.format = Differ::Format::Patch
= Differ.diff new, prev
\
- if @current_user
@ -19,4 +18,4 @@
- else
= edit_event_url @event, secret: @event.secret
\
=t '.signature'
= t '.signature'

123
app/views/moderations/index.html.haml

@ -5,57 +5,88 @@
:markdown
#### #{t '.rules'}
%table.list
%thead
%tr
%th= Event.human_attribute_name :title
%th
= Event.human_attribute_name :start_time
\-
= Event.human_attribute_name :end_time
%th= Event.human_attribute_name :city
%th= Event.human_attribute_name :region
%th= Event.human_attribute_name :submission_time
%th= t '.actions'
- if @orgas.present?
%table.list
%thead
%tr
%th= Orga.human_attribute_name :name
%th= Orga.human_attribute_name :city
%th= Orga.human_attribute_name :region
%th= Orga.human_attribute_name :submission_time
%th= t '.actions'
%tbody
- @orgas.each do |orga|
%tr
%td= orga.name
%td= orga.city
%td= orga.region
%td= time_ago_in_words orga.submission_time
%th.actions
= link_to edit_orga_path orga do
%em.fa.fa-pencil
= t 'edit'
\-
= link_to validate_orga_path orga do
%em.fa.fa-thumbs-up
= t 'validate'
\-
= link_to cancel_orga_path orga do
%em.fa.fa-thumbs-down
= t 'refuse'
%tbody
- @events.each do |event|
- if @events.present?
%table.list
%thead
%tr
%td= event.title
%td= display_date event
%td= event.city
%td= event.region.name
%td= time_ago_in_words event.submission_time
%th.actions
= link_to edit_moderation_path event do
%em.fa.fa-pencil
= t 'edit'
\-
= link_to validate_moderation_path event do
%em.fa.fa-thumbs-up
= t 'validate'
%th= Event.human_attribute_name :title
%th
= Event.human_attribute_name :start_time
\-
= link_to refuse_moderation_path event do
%em.fa.fa-thumbs-down
= t 'refuse'
\-
= link_to new_moderation_note_path event, envoiParMail: :oui do
%em.fa.fa-bullhorn
= t '.askInfos'
\-
= link_to new_moderation_note_path event do
%em.fa.fa-paperclip
= t '.createNote'
= Event.human_attribute_name :end_time
%th= Event.human_attribute_name :city
%th= Event.human_attribute_name :region
%th= Event.human_attribute_name :submission_time
%th= t '.actions'
- event.notes.each do |note|
%tbody
- @events.each do |event|
%tr
%td.empty/
%td.note(colspan="5")
= raw note.contents
%em.author
= t '.posted_by',
author: "#{note.author.firstname} #{note.author.lastname}",
date: l(note.date, format: :at) rescue nil
%td= event.title
%td= display_date event
%td= event.city
%td= event.region.name
%td= time_ago_in_words event.submission_time
%th.actions
= link_to edit_moderation_path event do
%em.fa.fa-pencil
= t 'edit'
\-
= link_to validate_moderation_path event do
%em.fa.fa-thumbs-up
= t 'validate'
\-
= link_to refuse_moderation_path event do
%em.fa.fa-thumbs-down
= t 'refuse'
\-
= link_to new_moderation_note_path event, envoiParMail: :oui do
%em.fa.fa-bullhorn
= t '.askInfos'
\-
= link_to new_moderation_note_path event do
%em.fa.fa-paperclip
= t '.createNote'
- event.notes.each do |note|
%tr
%td.empty/
%td.note(colspan="5")
= raw note.contents
%em.author
= t '.posted_by',
author: "#{note.author.firstname} #{note.author.lastname}",
date: l(note.date, format: :at) rescue nil
.logout
= link_to destroy_user_session_path, method: :delete do

8
app/views/orga_mailer/accept.text.haml

@ -0,0 +1,8 @@
= t '.body', author: @current_user
\
= render file: '/orgas/show'
\
= t '.access'
= orga_url @orga
\
= t '.signature'

7
app/views/orga_mailer/create.text.haml

@ -0,0 +1,7 @@
= t '.body', subject: @orga.name
= edit_orga_url @orga, secret: @orga.secret
\
= t '.delete_link'
= cancel_orga_url @orga, secret: @orga.secret
\
= t '.signature'

10
app/views/orga_mailer/destroy.text.haml

@ -0,0 +1,10 @@
= t '.body', author: @current_user
\
= @reason
\
= t '.reclamation'
\
= t '.reminder'
= render file: '/orgas/show'
\
= t '.signature'

8
app/views/orga_mailer/update.text.haml

@ -0,0 +1,8 @@
= t '.body', subject: @orga.name, author: @current_user || t('.submitter')
\
= render file: '/orgas/show'
\
= t '.access'
= orga_url @orga
\
= t '.signature'

3
app/views/orgas/_form.html.haml

@ -1,4 +1,7 @@
= form_for @orga do |f|
- if @orga.persisted?
= hidden_field_tag :secret, params[:secret]
- if @orga.errors.any?
#flash_messages
- @orga.errors.full_messages.each do |msg|

18
app/views/orgas/cancel.html.haml

@ -0,0 +1,18 @@
%h2
%em.fa.fa-trash-o
= t '.title'
- if @orga.moderated?
%h3.warning= t '.already_moderated'
%fieldset
= form_for @orga, method: :delete do |f|
= hidden_field_tag :secret, params[:secret]
%h2= t '.confirm'
= f.submit t('.ok'), name: :yes
= link_to t('.ko'), @orga, class: :button
%fieldset
%legend= Orga.model_name.human
= render file: '/orgas/show'

104
app/views/orgas/show.html.haml

@ -1,19 +1,24 @@
- set_orga_meta
= render 'search'
%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
%nav
= link_to orgas_path(q: params[:q], page: params[:page]), class: :back do
%em.fa.fa-arrow-left
= Orga.model_name.human.pluralize
%fieldset.orga
- if controller.controller_name == 'orgas' && controller.action_name == 'show'
%aside
%h1
%em.fa.fa-link
= t '.links'
%ul.fa-ul
%li
= link_to orgas_path(q: params[:q], page: params[:page]),
class: :back do
%em.fa.fa-li.fa-arrow-left
= Orga.model_name.human.pluralize
%li
= link_to events_path tag: @orga.name do
%em.fa.fa-li.fa-calendar
@ -47,52 +52,49 @@
= link_to edit_orga_path @orga do
%em.fa.fa-lg.fa-pencil
= t '.edit'
%h2
= link_to cancel_orga_path @orga do
%em.fa.fa-lg.fa-thumbs-down
= t '.cancel'
%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 '
%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?
%dt= t '.future'
%dd= t '.count', count: @events_future.count
- if @events_past.any?
%dt= t '.past'
%dd= t '.count', count: @events_past.count
- if @events_future && @events_future.any?
%dt= t '.future'
%dd= t '.count', count: @events_future.count
- if @events_future && @events_past.any?
%dt= t '.past'
%dd= t '.count', count: @events_past.count
.events#map{ data: { url: maps_path(format: :json, tag: @orga.name,
future: false) } }

9
app/views/orgas/show.text.haml

@ -0,0 +1,9 @@
=====================================================
#{Orga.human_attribute_name(:kind).concat(':').ljust 12 } #{@orga.kind.name}
#{Orga.human_attribute_name(:name).concat(':').ljust 12 } #{@orga.name}
#{Orga.human_attribute_name(:region).concat(':').ljust 12 } #{@orga.region}
#{Orga.human_attribute_name(:url).concat(':').ljust 12 } #{@orga.url}
#{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}
=====================================================

18
app/views/orgas/validate.html.haml

@ -0,0 +1,18 @@
%h2
%em.fa.fa-exclamation-triangle
= t '.title'
= form_for @orga, url: { action: :accept }, html: { method: :put } do |f|
= link_to moderations_path do
%em.fa.fa-arrow-left
= t '.ko'
= f.button do
%em.fa.fa-thumbs-up
= t '.ok'
%fieldset
%legend
%em.fa.fa-calendar
= Orga.model_name.human
= render file: '/orgas/show'

30
app/views/stats/index.html.haml

@ -3,15 +3,21 @@
= title t '.title'
%dl
%dt=t '.all'
%dd.quantity= number_with_delimiter Event.count
%dt= t '.allEvents'
%dd.quantity= number_with_delimiter Event.moderated.count
%dt=t '.allModeration'
%dd.quantity= number_with_delimiter Event.unscoped.where(moderated: 0).count
%dt= t '.awaitingModeration'
%dd.quantity= number_with_delimiter Event.unmoderated.count
%dt= t '.allOrgas'
%dd.quantity= number_with_delimiter Orga.moderated.count
%dt= t '.awaitingModeration'
%dd.quantity= number_with_delimiter Orga.unmoderated.count
%h3
%em.fa.fa-calendar
=t '.dates'
= t '.dates'
%table.list.dates
%thead
@ -33,17 +39,17 @@
%tfoot
%tr
%th=t '.total'
%th= t '.total'
- @years.each do |year|
%th.quantity= number_with_delimiter year[1]
%tr
%th/
%td.sparkline(colspan="#{@years.size}")/
%td.sparkline{ colspan: @years.size }
%h3
%em.fa.fa-shield
=t '.regional'
= t '.regional'
%table.list.dates
%thead
@ -51,7 +57,7 @@
%th/
- @years.each do |year|
%th= year[0]
%th=t '.total'
%th= t '.total'
%th/
%tbody
- Region.all.each do |region|
@ -66,16 +72,16 @@
%th.quantity.total= number_with_delimiter total
%td.sparkline/
%h3=t '.city'
%h3= t '.city'
%p=t '.city_conditions'
%p= t '.city_conditions'
%dl
- @city_events.each do |city|
%dt.item= city[0]
%dd.quantity= number_with_delimiter city[1]
%h3=t '.web'
%h3= t '.web'
:markdown
#{t '.webalizer'}

2
config/application.rb

@ -40,5 +40,7 @@ module AgendaDuLibreRails
config.action_dispatch.default_headers
.merge! 'X-Frame-Options' => 'ALLOWALL'
config.active_record.raise_in_transactional_callbacks = true
end
end

143
config/locales/views/en.yml

@ -53,10 +53,10 @@ en:
infos: Informations
new:
title: Propose an event
subtitle: This page lets you submit an event in the Agenda du Libre. It
will not appear automatically in the Agenda, it will first be validated
by a moderator. An electronic mail will be sent to the submitter's
email when the event will be moderated.
subtitle: This page lets you submit an event. It will not appear
automatically, it will first be validated by a moderator. An electronic
mail will be sent to the submitter's email when the event will be
moderated.
advises: "# Important recommandations
\n
\n* The event must relate to **Free Software**. The agenda is not intended for
@ -106,7 +106,7 @@ it more readable or agreable.
cancel:
title: Cancel event
already_moderated: 'Event already moderated: this cancellation will
remove it from Agenda du Libre'
delete it'
confirm: Do you confirm this event cancellation?
preview: Event visualisation
ok: Yes
@ -132,8 +132,9 @@ it more readable or agreable.
stats:
index:
title: Statistics
all: Validated events
allModeration: Waiting for validation
allEvents: Validated events
allOrgas: Validated organisations
awaitingModeration: Waiting for validation
dates: Per date
regional: Per region
city: Per city
@ -193,8 +194,8 @@ it more readable or agreable.
about an expensive event or formation. If the event does relate to Free
Software and this is not a paying formation, do not hesitate to submit
it again with a clearer description.
reason_r_2_long: "Your event is relevant to the Agenda du Libre, but
moderators think its description is not complete enough to be validated.
reason_r_2_long: "Your event is relevant, but moderators think its
description is not complete enough to be validated.
\n
\nDescription must be comprehensible by a newcomer to Free Software, and must
thus detail the meeting cause, the targeted audience, the role of the presented
@ -203,8 +204,7 @@ don't hesitate to repeat each time these informations, they are important.
\n
\nWe strongly invite you to submit again this event with a more complete
description."
reason_r_3_long: Your event is relevant to the Agenda du Libre, but is
already present there.
reason_r_3_long: Your event is relevant, but has already been submitted.
reason: Your reason
destroy:
ok: Event rejected
@ -266,6 +266,20 @@ description."
about her acceptation or rejection. If this address is absent, the
contact's will be used
save: Save
validate:
ok: Yes
ko: Moderation
accept:
ok: Organisation accepted
cancel:
title: Delete organisation
already_moderated: 'Organisation already moderated: this will delete it'
confirm: Do you confirm this event cancellation?
preview: Organisation
ok: Yes
ko: No
destroy:
ok: Organisation was deleted
devise:
sessions:
@ -276,98 +290,107 @@ description."
event_mailer:
create:
subject: "Your event: '%{subject}' is waiting for moderation"
title: Hello,
body: "Your event titled '%{subject}',
\nwhich will take place on the '%{start_time}' has been recorded in the Agenda
du Libre.
\nwhich will take place on the '%{start_time}' has been recorded.
\n
\nThe moderation team will take charge of it very soon.
\n
\nMeanwhile, and later if your event is accepted, you can edit it the address:"
\nMeanwhile, and later if your event is accepted, you can edit it at the
\nfollowing address:"
delete_link: "and you can cancel it using the address:"
signature: "Thanks for your participation!
\n
\n--
\nAgenda du Libre"
signature: Thanks for your participation!
accept:
subject: "Event '%{subject}' moderated"
title: Hello,
body: "The event you submitted was moderated by %{moderator}. It is now
visible in the Agenda at the address:"
visible at the address:"
edit_link: "You can modify this event later to add details at the
address:"
delete_link: "You can can also cancel it at the address:"
signature: "Thank you for your contribution at the Agenda du Libre and
see you soon!
\n
\n--
\nThe moderation team"
signature: Thank you for your contribution and see you soon!
destroy:
subject: "Event '%{subject}' refused"
title: Hello,
body: You have submitted the following event in the Agenda du Libre, and
we thank you for this contribution.
reminder: "Reminder, here is your event's content:"
body: You have submitted the following event, and we thank you for this
contribution.
reclamation: For any reclamation, don't hesitate to contact the
moderation team.
signature: "With all our thanks for your contribution,
\n
\n--
\nThe moderation team"
reminder: "Reminder, here is your event's content:"
signature: With all our thanks for your contribution
moderation_mailer:
create:
subject: "New event to moderate: '%{subject}'"
title: Hello,
body: A new event is to be moderated on
signature: "Thank you!
\n
\n--
\nAgenda du Libre"
signature: Thank you!
update:
subject: "Event '%{subject}' edition"
title: Hello,
body: "Event '%{subject}' has been modified by
%{author}.
\n
\nModifications:"
submitter: the submitter
signature: "Have a good day
\n
\n--
\nThe moderation team"
signature: Have a good day
accept:
subject: "Event '%{subject}' moderated"
title: Hello,
body: The event has been moderated by %{author}.
access: "You can consult it here:"
signature: "--
\nThe moderation team"
signature: Thanks for your contribution!
destroy:
subject: "Event '%{subject}' refused"
title: Hello,
body: "The event '%{subject}' was rejected by %{author} for the following
reason:
\n
\n"
reminder: "The event:"
signature: "--
\nThe Agenda du Libre moderation team"
signature: Thank you for your contribution
note_mailer:
notify:
subject: "Demand for more information on event '%{subject}'"
title: Hello,
body: "We have received your event proposal '%{subject}',
\nit is relevant to the Agenda du Libre. Nonetheless, before acceptation we
\nneed some supplementary informations:"
\nit is relevant. Nonetheless, before acceptation we need some complementary
\ninformations:"
edit_link: "We invite you to directly add these informations to the
\nevent at the following address:"
<