",
+ subject: t('note_mailer.create.subject', subject: note.event.title)
end
end
diff --git a/app/models/admin_user.rb b/app/models/admin_user.rb
index 318ec397..a7a554e0 100644
--- a/app/models/admin_user.rb
+++ b/app/models/admin_user.rb
@@ -1,6 +1,7 @@
+# The new agenda moderators, from active_admin
class AdminUser < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
- devise :database_authenticatable,
+ devise :database_authenticatable,
:recoverable, :rememberable, :trackable, :validatable
end
diff --git a/app/models/event.rb b/app/models/event.rb
index b75a72d7..cea67143 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -1,43 +1,52 @@
+# This is the central ADL class, where are managed all events
class Event < ActiveRecord::Base
extend SimpleCalendar
belongs_to :related_region, foreign_key: 'region', class_name: Region
has_many :notes, dependent: :destroy
- has_one :related_city, foreign_key: :name, primary_key: :city, class_name: City
+ has_one :related_city, foreign_key: :name, primary_key: :city,
+ class_name: City
- validates_presence_of :title, :description, :city, :related_region, :url, :contact
- validates_format_of :url, with: /\Ahttps?:\/\/.*\z/
+ validates :title, presence: true
+ validates :description, presence: true
+ validates :city, presence: true
+ validates :related_region, presence: true
+ validates :url, presence: true, format: %r{\Ahttps?:\/\/.*\z}
+ validates :contact, presence: true
validates :contact, email: true
validates :submitter, email: true
-
scope :moderated, -> { where moderated: true }
- scope :past, -> { where('end_time < ?', DateTime.now).order(start_time: :desc) }
- scope :future, -> { where('end_time >= ?', DateTime.now).order(start_time: :asc) }
- scope :future_30, -> {
+ scope :unmoderated, -> { where moderated: false }
+ scope :last_year, -> { where 'start_time >= ?', 360.days.ago }
+ scope :past, (lambda do
+ where('end_time < ?', DateTime.now).order start_time: :desc
+ end)
+ scope :future, (lambda do
+ where('end_time >= ?', DateTime.now).order start_time: :asc
+ end)
+ scope :future_30, (lambda do
where('start_time >= ? and end_time <= ?', DateTime.now, 30.days.from_now)
.order :start_time
- }
- scope :year, -> year {
+ end)
+ scope :year, (lambda do |year|
where '? <= end_time and start_time <= ?',
- Date.new(year, 1, 1).beginning_of_week, Date.new(year, 12, 31).end_of_week
- }
- scope :month, -> start_date {
+ Date.new(year, 1, 1).beginning_of_week, Date.new(year, 12, 31)
+ .end_of_week
+ end)
+ scope :month, (lambda do |start_date|
where '? <= end_time and start_time <= ?',
- start_date.beginning_of_week,
- start_date.next_month.end_of_week
- }
+ start_date.beginning_of_month.beginning_of_week,
+ start_date.beginning_of_month.next_month.end_of_week
+ end)
scope :region, -> region { where 'region = ? or locality', region }
scope :tag, -> tag { where 'tags like ?', "%#{tag}%" }
-
before_validation on: :create do
self.submission_time = DateTime.now
self.decision_time = DateTime.now
- if self.submitter.empty?
- self.submitter = self.contact
- end
+ self.submitter = contact if submitter.empty?
end
before_create do
@@ -47,7 +56,7 @@ class Event < ActiveRecord::Base
end
before_update do
- if moderated? and moderated_was != moderated
+ if moderated? && moderated_was != moderated
self.decision_time = DateTime.now
end
end
@@ -55,4 +64,17 @@ class Event < ActiveRecord::Base
def same_day?
start_time.to_date == end_time.to_date
end
+
+ def to_json
+ { type: 'Feature', properties: {
+ name: title,
+ popupContent: "#{city}: #{title}"
+ },
+ geometry: {
+ type: 'Point',
+ coordinates: [related_city.longitude, related_city.latitude]
+ }
+ }
+ end
end
diff --git a/app/models/lug.rb b/app/models/lug.rb
index 7adafbc2..8d8f9c27 100644
--- a/app/models/lug.rb
+++ b/app/models/lug.rb
@@ -1,4 +1,6 @@
+# Groups related to this agenda
class Lug < ActiveRecord::Base
belongs_to :related_region, foreign_key: 'region', class_name: Region
- has_one :related_city, foreign_key: :name, primary_key: :city, class_name: City
+ has_one :related_city, foreign_key: :name, primary_key: :city,
+ class_name: City
end
diff --git a/app/models/note.rb b/app/models/note.rb
index 8565d50f..f0d58286 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -1,3 +1,4 @@
+# Manages data related to events' moderation
class Note < ActiveRecord::Base
belongs_to :event
belongs_to :author, class_name: User
diff --git a/app/models/region.rb b/app/models/region.rb
index c6371c00..153d3229 100644
--- a/app/models/region.rb
+++ b/app/models/region.rb
@@ -1,3 +1,4 @@
+# This is mostly to group events around a region
class Region < ActiveRecord::Base
has_many :lugs, foreign_key: :region
diff --git a/app/models/user.rb b/app/models/user.rb
index 33eda7e7..418efe8f 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,25 +1,28 @@
require 'digest/md5'
+# Moderators, but using a failed pwd mechanism
+# TODO, migrate to full active_admin
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, authentication_keys: [:login]
- #, :registerable, :validatable
+ # :registerable, :validatable
has_many :notes
def encrypted_password=(pass)
- write_attribute :password, pass
+ self[:password] = pass
end
def encrypted_password
- read_attribute :password
+ self[:password]
end
def self.find_first_by_auth_conditions(warden_conditions)
conditions = warden_conditions.dup
- if login = conditions.delete(:login)
- where(conditions).where(["login = :value", { value: login }]).first
+ login = conditions.delete(:login)
+ if login.present?
+ where(conditions).where(['login = :value', { value: login }]).first
else
where(conditions).first
end
@@ -34,7 +37,8 @@ class User < ActiveRecord::Base
end
protected
- def password_digest(password)
- Digest::MD5.hexdigest password
- end
+
+ def password_digest(password)
+ Digest::MD5.hexdigest password
+ end
end
diff --git a/app/views/events/index.html.haml b/app/views/events/index.html.haml
index 5df8c5b9..6305684f 100644
--- a/app/views/events/index.html.haml
+++ b/app/views/events/index.html.haml
@@ -1,3 +1,5 @@
+- set_events_meta
+
= render '/lugs/search' unless controller.controller_name == 'lugs'
-# Seems necessary, for the time being, to ensure calendar is changing days correctly
diff --git a/app/views/events/show.html.haml b/app/views/events/show.html.haml
index 7508dfe1..aaa74d42 100644
--- a/app/views/events/show.html.haml
+++ b/app/views/events/show.html.haml
@@ -1,6 +1,8 @@
+- set_event_meta
+
%h2
%em.city= @event.city
- = @event.title
+ = title @event.title
- if @event.persisted? && request.format == 'text/html' && controller.controller_name == 'events' && controller.action_name == 'show'
%sidebar#lug-list
@@ -47,7 +49,7 @@
%h3=t '.description'
.description
- markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, tables: true)
- = sanitize markdown.render(@event.description),
+ = description sanitize markdown.render(@event.description),
tags: %w(p br table tr th td ul ol li a strong b em i img),
attributes: %w(href src width height)
diff --git a/app/views/lugs/show.html.haml b/app/views/lugs/show.html.haml
index 0ebe7774..aac22bd2 100644
--- a/app/views/lugs/show.html.haml
+++ b/app/views/lugs/show.html.haml
@@ -1,6 +1,8 @@
+- set_lug_meta
+
%h2
%em.fa.fa-users
- = title t 'lugs.search.title', entity: Lug.model_name.human
+ = t 'lugs.search.title', entity: Lug.model_name.human
= render 'search'
@@ -9,7 +11,7 @@
%dd
%h3
= image_tag @lug.url+'/favicon.ico', alt: '', class: :favicon
- = @lug.name
+ = title @lug.name
- if @lug.city.present?
%dt= Lug.human_attribute_name :city
%dd= @lug.city
diff --git a/app/views/moderation_mailer/update.text.haml b/app/views/moderation_mailer/update.text.haml
index e575bfe9..1f226a8c 100644
--- a/app/views/moderation_mailer/update.text.haml
+++ b/app/views/moderation_mailer/update.text.haml
@@ -5,7 +5,7 @@
- new = render file: '/events/show'
- former = @event
-- @event = @olderEvent
+- @event = @older_event
- prev = render file: '/events/show'
- @event = former
diff --git a/app/views/tags/show.html.haml b/app/views/tags/show.html.haml
index dfc9c733..7ddc5c63 100644
--- a/app/views/tags/show.html.haml
+++ b/app/views/tags/show.html.haml
@@ -2,9 +2,9 @@
=t '.title'
%em= params[:id]
-%p=raw t '.future', count: @eventsFuture.count
+%p=raw t '.future', count: @events_future.count
%ul
- - @eventsFuture.each do |event|
+ - @events_future.each do |event|
%li
%div= link_to event.title, event
- if event.same_day?
@@ -18,9 +18,9 @@
à
= event.city
-%p=raw t '.past', count: @eventsPast.count
+%p=raw t '.past', count: @events_past.count
%ul
- - @eventsPast.each do |event|
+ - @events_past.each do |event|
%li
%div= link_to event.title, event
- if event.same_day?
diff --git a/config/application.rb b/config/application.rb
index 04256983..f581cdf0 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -7,17 +7,23 @@ require 'rails/all'
Bundler.require(*Rails.groups)
module AgendaDuLibreRails
+ # All the specific configuraton for ADL
class Application < Rails::Application
- # Settings in config/environments/* take precedence over those specified here.
+ # Settings in config/environments/* take precedence over those specified
+ # here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+ # Set Time.zone default to the specified zone and make Active Record
+ # auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names.
+ # Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
+ # The default locale is :en and all translations from
+ # config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path +=
+ # Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.i18n.default_locale = :fr
@@ -28,6 +34,6 @@ module AgendaDuLibreRails
to: 'moderateurs@agendadulibre.org'
}
- #config.quiet_assets = false
+ # config.quiet_assets = false
end
end
diff --git a/config/environments/development.rb b/config/environments/development.rb
index ddf0e90c..103e1c54 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -1,5 +1,6 @@
Rails.application.configure do
- # Settings specified here will take precedence over those in config/application.rb.
+ # Settings specified here will take precedence over those in
+ # config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
diff --git a/config/environments/production.rb b/config/environments/production.rb
index b269b326..daca57cb 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -1,5 +1,6 @@
Rails.application.configure do
- # Settings specified here will take precedence over those in config/application.rb.
+ # Settings specified here will take precedence over those in
+ # config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
@@ -16,7 +17,8 @@ Rails.application.configure do
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
- # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
+ # For large-scale production use, consider using a caching reverse proxy like
+ # nginx, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this).
@@ -39,7 +41,8 @@ Rails.application.configure do
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
- # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+ # Force all access to the app over SSL, use Strict-Transport-Security, and
+ # use secure cookies.
# config.force_ssl = true
# Set to :debug to see everything in the log.
@@ -56,14 +59,16 @@ Rails.application.configure do
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com"
- config.action_controller.asset_host = "http://assets%d.agendadulibre.org"
+ config.action_controller.asset_host = 'http://assets%d.agendadulibre.org'
# Precompile additional assets.
- # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
+ # application.js, application.css, and all non-JS/CSS in app/assets folder
+ # are already added.
# config.assets.precompile += %w( search.js )
# Ignore bad email addresses and do not raise email delivery errors.
- # Set this to true and configure the email server for immediate delivery to raise delivery errors.
+ # Set this to true and configure the email server for immediate delivery to
+ # raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
config.action_mailer.smtp_settings = { openssl_verify_mode: 'none' }
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 053f5b66..fc0e8f12 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -1,5 +1,6 @@
Rails.application.configure do
- # Settings specified here will take precedence over those in config/application.rb.
+ # Settings specified here will take precedence over those in
+ # config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
diff --git a/config/initializers/active_admin.rb b/config/initializers/active_admin.rb
index b34977d1..7f64a2d8 100644
--- a/config/initializers/active_admin.rb
+++ b/config/initializers/active_admin.rb
@@ -5,7 +5,7 @@ ActiveAdmin.setup do |config|
# Set the title that is displayed on the main layout
# for each of the active admin pages.
#
- config.site_title = "Agenda Du Libre"
+ config.site_title = 'Agenda Du Libre'
# Set the link url for the title. For example, to take
# users to your main site. Defaults to no link.
@@ -84,7 +84,6 @@ ActiveAdmin.setup do |config|
# to return the currently logged in user.
config.current_user_method = :current_admin_user
-
# == Logging Out
#
# Active Admin displays a logout link on each screen. These
@@ -103,7 +102,6 @@ ActiveAdmin.setup do |config|
# Default:
# config.logout_link_method = :get
-
# == Root
#
# Set the action to call for the root path. You can set different
@@ -112,10 +110,10 @@ ActiveAdmin.setup do |config|
# Default:
# config.root_to = 'dashboard#index'
-
# == Admin Comments
#
- # This allows your users to comment on any resource registered with Active Admin.
+ # This allows your users to comment on any resource registered with Active
+ # Admin.
#
# You can completely disable comments:
# config.allow_comments = false
@@ -126,27 +124,23 @@ ActiveAdmin.setup do |config|
# You can change the name under which comments are registered:
# config.comments_registration_name = 'AdminComment'
-
# == Batch Actions
#
# Enable and disable Batch Actions
#
config.batch_actions = true
-
# == Controller Filters
#
# You can add before, after and around filters to all of your
# Active Admin resources and pages from here.
#
# config.before_filter :do_something_awesome
-
-
+
# == Setting a Favicon
#
# config.favicon = '/assets/favicon.ico'
-
# == Register Stylesheets & Javascripts
#
# We recommend using the built in Active Admin layout and loading
@@ -156,13 +150,13 @@ ActiveAdmin.setup do |config|
# To load a stylesheet:
# config.register_stylesheet 'my_stylesheet.css'
#
- # You can provide an options hash for more control, which is passed along to stylesheet_link_tag():
+ # You can provide an options hash for more control, which is passed along to
+ # stylesheet_link_tag():
# config.register_stylesheet 'my_print_stylesheet.css', :media => :print
#
# To load a javascript file:
# config.register_javascript 'my_javascript.js'
-
# == CSV options
#
# Set the CSV builder separator
@@ -171,16 +165,19 @@ ActiveAdmin.setup do |config|
# Force the use of quotes
# config.csv_options = { :force_quotes => true }
-
# == Menu System
#
- # You can add a navigation menu to be used in your application, or configure a provided menu
+ # You can add a navigation menu to be used in your application, or configure
+ # a provided menu
#
- # To change the default utility navigation to show a link to your website & a logout btn
+ # To change the default utility navigation to show a link to your website & a
+ # logout btn
#
# config.namespace :admin do |admin|
# admin.build_menu :utility_navigation do |menu|
- # menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank }
+ # menu.add label: "My Great Website",
+ # url: "http://www.mygreatwebsite.com",
+ # html_options: { target: :blank }
# admin.add_logout_button_to_menu menu
# end
# end
@@ -189,11 +186,12 @@ ActiveAdmin.setup do |config|
#
# config.namespace :admin do |admin|
# admin.build_menu :default do |menu|
- # menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank }
+ # menu.add label: "My Great Website",
+ # url: "http://www.mygreatwebsite.com",
+ # html_options: { target: :blank }
# end
# end
-
# == Download Links
#
# You can disable download links on resource listing pages,
@@ -215,7 +213,6 @@ ActiveAdmin.setup do |config|
#
# end
-
# == Pagination
#
# Pagination is enabled by default for all resources.
@@ -223,11 +220,10 @@ ActiveAdmin.setup do |config|
#
# config.default_per_page = 30
-
# == Filters
#
- # By default the index screen includes a “Filters” sidebar on the right
- # hand side with a filter for each attribute of the registered model.
+ # By default the index screen includes a "Filters" sidebar on the right hand
+ # side with a filter for each attribute of the registered model.
# You can enable or disable them for all resources here.
#
# config.filters = true
diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb
index 59385cdf..cf74fe3d 100644
--- a/config/initializers/backtrace_silencers.rb
+++ b/config/initializers/backtrace_silencers.rb
@@ -1,7 +1,9 @@
# Be sure to restart your server when you modify this file.
-# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# You can add backtrace silencers for libraries that you're using but don't
+# wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
-# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# You can also remove all the silencers if you're trying to debug a problem
+# that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!
diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb
index 7a06a89f..7f70458d 100644
--- a/config/initializers/cookies_serializer.rb
+++ b/config/initializers/cookies_serializer.rb
@@ -1,3 +1,3 @@
# Be sure to restart your server when you modify this file.
-Rails.application.config.action_dispatch.cookies_serializer = :json
\ No newline at end of file
+Rails.application.config.action_dispatch.cookies_serializer = :json
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
index 27272085..1e68b9c9 100644
--- a/config/initializers/devise.rb
+++ b/config/initializers/devise.rb
@@ -4,13 +4,15 @@ Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmation, reset password and unlock tokens in the database.
- config.secret_key = 'a462883bde2ce796fa8aa481d8946a500ac8a4141ccc5f2fb1988bed8f3595b9cbd713abdca92b2d276d339a4e342768173e1b13b7a45956f6d3bda4653b14b6'
+ config.secret_key = 'a462883bde2ce796fa8aa481d8946a500ac8a4141ccc5f2fb1988b' \
+ + 'ed8f3595b9cbd713abdca92b2d276d339a4e342768173e1b13b7a45956f6d3bda4653b' \
+ + '14b6'
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class
# with default "from" parameter.
- config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
+ config.mailer_sender = 'moderateurs@agendadulibre.org'
# Configure the class responsible to send e-mails.
# config.mailer = 'Devise::Mailer'
@@ -26,39 +28,45 @@ Devise.setup do |config|
# just :email. You can configure it to use [:username, :subdomain], so for
# authenticating a user, both parameters are required. Remember that those
# parameters are used only when authenticating and not when retrieving from
- # session. If you need permissions, you should implement that in a before filter.
+ # session. If you need permissions, you should implement that in a before
+ # filter.
# You can also supply a hash where the value is a boolean determining whether
# or not authentication should be aborted when the value is not present.
# config.authentication_keys = [ :email ]
- # Configure parameters from the request object used for authentication. Each entry
- # given should be a request method and it will automatically be passed to the
- # find_for_authentication method and considered in your model lookup. For instance,
- # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
- # The same considerations mentioned for authentication_keys also apply to request_keys.
+ # Configure parameters from the request object used for authentication. Each
+ # entry given should be a request method and it will automatically be passed
+ # to the find_for_authentication method and considered in your model lookup.
+ # For instance, if you set :request_keys to [:subdomain], :subdomain will be
+ # used on authentication.
+ # The same considerations mentioned for authentication_keys also apply to
+ # request_keys.
# config.request_keys = []
# Configure which authentication keys should be case-insensitive.
# These keys will be downcased upon creating or modifying a user and when used
# to authenticate or find a user. Default is :email.
- config.case_insensitive_keys = [ :email ]
+ config.case_insensitive_keys = [:email]
# Configure which authentication keys should have whitespace stripped.
# These keys will have whitespace before and after removed upon creating or
- # modifying a user and when used to authenticate or find a user. Default is :email.
- config.strip_whitespace_keys = [ :email ]
+ # modifying a user and when used to authenticate or find a user. Default is
+ # :email.
+ config.strip_whitespace_keys = [:email]
# Tell if authentication through request.params is enabled. True by default.
- # It can be set to an array that will enable params authentication only for the
- # given strategies, for example, `config.params_authenticatable = [:database]` will
- # enable it only for database (email + password) authentication.
+ # It can be set to an array that will enable params authentication only for
+ # the given strategies, for example, `config.params_authenticatable =
+ # [:database]` will enable it only for database (email + password)
+ # authentication.
# config.params_authenticatable = true
# Tell if authentication through HTTP Auth is enabled. False by default.
# It can be set to an array that will enable http authentication only for the
- # given strategies, for example, `config.http_authenticatable = [:database]` will
- # enable it only for database authentication. The supported strategies are:
- # :database = Support basic authentication with authentication key + password
+ # given strategies, for example, `config.http_authenticatable = [:database]`
+ # will enable it only for database authentication. The supported strategies
+ # are:
+ # :database = Support basic authentication with authentication key + password
# config.http_authenticatable = false
# If http headers should be returned for AJAX requests. True by default.
@@ -87,15 +95,17 @@ Devise.setup do |config|
# ==> Configuration for :database_authenticatable
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
- # using other encryptors, it sets how many times you want the password re-encrypted.
+ # using other encryptors, it sets how many times you want the password
+ # re-encrypted.
#
- # Limiting the stretches to just one in testing will increase the performance of
- # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
- # a value less than 10 in other environments.
+ # Limiting the stretches to just one in testing will increase the performance
+ # of your test suite dramatically. However, it is STRONGLY RECOMMENDED to not
+ # use a value less than 10 in other environments.
config.stretches = Rails.env.test? ? 1 : 10
# Setup a pepper to generate the encrypted password.
- # config.pepper = 'a5d405c1f73d70b39798058c401d3aedbcea8e19d953ee0d2b038ff093abe0ea94b255d75905563e0d16c4944297f0755481b1f125461f23fda56ee123085b09'
+ # config.pepper =
+ # 'a5d405c1f73d70b39798058c401d3aedbcea8e19d953ee0d2b038ff093abe0ea94b255d759'
# ==> Configuration for :confirmable
# A period that the user is allowed to access the website even without
@@ -114,9 +124,10 @@ Devise.setup do |config|
# config.confirm_within = 3.days
# If true, requires any email changes to be confirmed (exactly the same way as
- # initial account confirmation) to be applied. Requires additional unconfirmed_email
- # db field (see migrations). Until confirmed new email is stored in
- # unconfirmed email column, and copied to email column on successful confirmation.
+ # initial account confirmation) to be applied. Requires additional
+ # unconfirmed_email db field (see migrations). Until confirmed new email is
+ # stored in unconfirmed email column, and copied to email column on
+ # successful confirmation.
config.reconfirmable = true
# Defines which key will be used when confirming an account
@@ -152,7 +163,8 @@ Devise.setup do |config|
# ==> Configuration for :lockable
# Defines which strategy will be used to lock an account.
- # :failed_attempts = Locks an account after a number of failed attempts to sign in.
+ # :failed_attempts = Locks an account after a number of failed attempts to
+ # sign in.
# :none = No lock strategy. You should handle locking by yourself.
# config.lock_strategy = :failed_attempts
@@ -161,7 +173,8 @@ Devise.setup do |config|
# Defines which strategy will be used to unlock an account.
# :email = Sends an unlock link to the user email
- # :time = Re-enables login after a certain amount of time (see :unlock_in below)
+ # :time = Re-enables login after a certain amount of time (see :unlock_in
+ # below)
# :both = Enables both strategies
# :none = No unlock strategy. You should handle unlocking by yourself.
# config.unlock_strategy = :both
@@ -187,19 +200,19 @@ Devise.setup do |config|
config.reset_password_within = 6.hours
# ==> Configuration for :encryptable
- # Allow you to use another encryption algorithm besides bcrypt (default). You can use
- # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
- # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
- # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
- # REST_AUTH_SITE_KEY to pepper).
+ # Allow you to use another encryption algorithm besides bcrypt (default). You
+ # can use :sha1, :sha512 or encryptors from others authentication tools as
+ # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to
+ # 20 for default behavior) and :restful_authentication_sha1 (then you should
+ # set stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
#
# Require the `devise-encryptable` gem when using anything other than bcrypt
# config.encryptor = :sha512
# ==> Scopes configuration
- # Turn scoped views on. Before rendering "sessions/new", it will first check for
- # "users/sessions/new". It's turned off by default because it's slower if you
- # are using only default views.
+ # Turn scoped views on. Before rendering "sessions/new", it will first check
+ # for "users/sessions/new". It's turned off by default because it's slower if
+ # you are using only default views.
# config.scoped_views = false
# Configure the default scope given to Warden. By default it's the first
@@ -227,20 +240,24 @@ Devise.setup do |config|
# ==> OmniAuth
# Add a new OmniAuth provider. Check the wiki for more information on setting
# up on your models and hooks.
- # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET',
+ # :scope => 'user,public_repo'
# ==> Warden configuration
# If you want to use other strategies, that are not supported by Devise, or
- # change the failure app, you can configure them inside the config.warden block.
+ # change the failure app, you can configure them inside the config.warden
+ # block.
#
# config.warden do |manager|
# manager.intercept_401 = false
- # manager.default_strategies(:scope => :user).unshift :some_external_strategy
+ # manager.default_strategies(:scope => :user).unshift
+ # :some_external_strategy
# end
# ==> Mountable engine configurations
- # When using Devise inside an engine, let's call it `MyEngine`, and this engine
- # is mountable, there are some extra configurations to be taken into account.
+ # When using Devise inside an engine, let's call it `MyEngine`, and this
+ # engine is mountable, there are some extra configurations to be taken into
+ # account.
# The following options are available, assuming the engine is mounted as:
#
# mount MyEngine, at: '/my_engine'
diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb
index 1713c24f..b9984427 100644
--- a/config/initializers/mime_types.rb
+++ b/config/initializers/mime_types.rb
@@ -1,5 +1,5 @@
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
-# Mime::Type.register "text/richtext", :rtf
-Mime::Type.register "text/calendar", :ics, [], %w(ical)
+# Mime::Type.register 'text/richtext', :rtf
+Mime::Type.register 'text/calendar', :ics, [], %w(ical)
diff --git a/config/initializers/override_mail_recipient.rb b/config/initializers/override_mail_recipient.rb
index 886dc0ef..ec502e63 100644
--- a/config/initializers/override_mail_recipient.rb
+++ b/config/initializers/override_mail_recipient.rb
@@ -1,5 +1,6 @@
# config/initializers/override_mail_recipient.rb
if Rails.env.development?
+ # During development, we don't really send mails to the outside world
class OverrideMailRecipient
def self.delivering_email(mail)
mail.to = 'manu@localhost'
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb
index e57304ea..d68b842e 100644
--- a/config/initializers/session_store.rb
+++ b/config/initializers/session_store.rb
@@ -1,3 +1,4 @@
# Be sure to restart your server when you modify this file.
-Rails.application.config.session_store :cookie_store, key: '_agenda_du_libre_rails_session'
+Rails.application.config.session_store :cookie_store,
+ key: '_agenda_du_libre_rails_session'
diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb
index 33725e95..6fffb713 100644
--- a/config/initializers/wrap_parameters.rb
+++ b/config/initializers/wrap_parameters.rb
@@ -3,7 +3,8 @@
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
-# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+# Enable parameter wrapping for JSON. You can disable this by setting :format
+# to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
end
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index d843eec2..03f8a00a 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -130,11 +130,14 @@ fr:
new:
title: Soumettre un événement
create:
- 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 l'aura validé.
+ 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
+ l'aura validé.
edit:
title: Éditer un événement
preview: Prévisualisation de l'événement
- warning: Attention, cet événement est déjà modéré. Toute modification sera immédiatement visible sur le site.
+ warning: Attention, cet événement est déjà modéré. Toute modification
+ sera immédiatement visible sur le site.
forbidden: Vous n'êtes pas authorisé à modifier cet événement
edit: Édition de l'événement
update:
@@ -144,7 +147,8 @@ fr:
visualise: Visualiser
cancel:
title: Annulation de l'événement
- already_moderated: Attention, cet événement est déjà modéré. Cette annulation le fera disparaître de l'Agenda du Libre.
+ already_moderated: Attention, cet événement est déjà modéré. Cette
+ annulation le fera disparaître de l'Agenda du Libre.
confirm: Confirmez-vous l'annulation de cet événement?
preview: Visualisation de l'événement
ok: Oui
@@ -154,7 +158,11 @@ fr:
regions:
index:
title: Liste des flux
- quick: Chaque flux liste les évènements pour les 30 prochains jours en cours dans une région donnée. En vous abonnant à un flux régional, vous recevrez des informations sur les évènements de votre région à portée locale, mais également les évènements à portée nationale comme les RMLL.
+ quick: Chaque flux liste les évènements pour les 30 prochains jours en
+ cours dans une région donnée. En vous abonnant à un flux régional, vous
+ recevrez des informations sur les évènements de votre région à portée
+ locale, mais également les évènements à portée nationale comme les
+ RMLL.
help: "Quelques fonctionnalités intéressantes:\n
\n
* Vous pouvez limiter les évènements à un certain tag, en passant le paramètre `tag`. Cela permet par exemple de récupérer un flux des évènements organisés uniquement par votre association, à partir du moment où vous pensez à marquer tous vos évènements avec un tag précis. \n
@@ -167,10 +175,14 @@ Exemple: `%{daylimit}`"
allModeration: Événements en cours de modération
regional: Par région
city: Par ville
- city_conditions: Seules les villes où plus de trois événements ont été organisés sont mentionnées.
+ city_conditions: Seules les villes où plus de trois événements ont été
+ organisés sont mentionnées.
dates: Par date
web: Statistiques Web
- webalizer: Des statistiques Web générées par Webalizer [sont disponibles](http://agendadulibre.org/stats/). Elles sont protégées par le login *stats*, mot de passe *Cuntipshaf6* pour éviter le *spam de referers*
+ webalizer: Des statistiques Web générées par Webalizer [sont
+ disponibles](http://agendadulibre.org/stats/). Elles sont protégées par
+ le login *stats*, mot de passe *Cuntipshaf6* pour éviter le *spam de
+ referers*
tags:
index:
title: Tags
@@ -187,7 +199,8 @@ Exemple: `%{daylimit}`"
moderations:
index:
title: Événements à modérer
- rules: Modérateurs, merci de lire et de tenir compte des [recommandations de modération](/application/rules).
+ rules: Modérateurs, merci de lire et de tenir compte des [recommandations
+ de modération](/application/rules).
actions: Actions
posted_by: Posté par %{author} le %{date}
date: Date
@@ -196,7 +209,8 @@ Exemple: `%{daylimit}`"
edit:
moderation: Modération
preview: Prévisualisation de l'événement
- warning: Attention, cet événement est déjà modéré. Toute modification sera immédiatement visible sur le site.
+ warning: Attention, cet événement est déjà modéré. Toute modification
+ sera immédiatement visible sur le site.
edit: Édition de l'événement
update:
ok: Événement mis à jour
@@ -217,9 +231,26 @@ Exemple: `%{daylimit}`"
reason_r_2: Pas assez d'informations
reason_r_3: Événement déjà enregistré
reason_r_4: Raison spécifique (précisez)
- reason_r_1_long: Toutefois, l'événement proposé n'a pour l'instant pas retenu l'attention des modérateurs. En effet, l'événement proposé ne concerne pas le Logiciel Libre, ou bien le lien avec le Logiciel Libre n'est pas évident dans la formulation actuelle, ou alors il s'agit d'un événement ou d'une formation payante et coûteuse. Si l'événement concerne vraiment le Logiciel Libre et qu'il ne s'agit pas d'une formation payante, n'hésitez pas à le soumettre à nouveau avec une description plus claire.
- reason_r_2_long: Votre événement a tout à fait sa place dans l'Agenda du Libre, mais les modérateurs trouvent que la description de celui-ci n'est pas assez complète pour être validée.\n\nLa description doit être compréhensible par un nouveau venu dans le monde du Libre, et doit donc préciser le principe de la rencontre, le public visé, la rôle du ou des Logiciels Libres qui seront exposés, la date et le lieu précis de la rencontre. Même si il s'agit d'une rencontre régulière, n'hésitez pas à répéter à chaque fois ces informations, elles sont importantes.\n\nNous vous invitons donc vivement à soumettre à nouveau cet événement avec une description plus complète.
- reason_r_3_long: Votre événement a tout à fait sa place dans l'Agenda du Libre, mais il est déjà enregistré dans celui-ci.
+ reason_r_1_long: Toutefois, l'événement proposé n'a pour l'instant pas
+ retenu l'attention des modérateurs. En effet, l'événement proposé ne
+ concerne pas le Logiciel Libre, ou bien le lien avec le Logiciel Libre
+ n'est pas évident dans la formulation actuelle, ou alors il s'agit d'un
+ événement ou d'une formation payante et coûteuse. Si l'événement
+ concerne vraiment le Logiciel Libre et qu'il ne s'agit pas d'une
+ formation payante, n'hésitez pas à le soumettre à nouveau avec une
+ description plus claire.
+ reason_r_2_long: Votre événement a tout à fait sa place dans l'Agenda du
+ Libre, mais les modérateurs trouvent que la description de celui-ci
+ n'est pas assez complète pour être validée.\n\nLa description doit être
+ compréhensible par un nouveau venu dans le monde du Libre, et doit donc
+ préciser le principe de la rencontre, le public visé, la rôle du ou des
+ Logiciels Libres qui seront exposés, la date et le lieu précis de la
+ rencontre. Même si il s'agit d'une rencontre régulière, n'hésitez pas à
+ répéter à chaque fois ces informations, elles sont importantes.\n\nNous
+ vous invitons donc vivement à soumettre à nouveau cet événement avec
+ une description plus complète.
+ reason_r_3_long: Votre événement a tout à fait sa place dans l'Agenda du
+ Libre, mais il est déjà enregistré dans celui-ci.
reason: Votre raison
destroy:
ok: Événement rejeté
@@ -228,7 +259,8 @@ Exemple: `%{daylimit}`"
back: Modération
title: Ajout d'une note de modération
create:
- sendByMailWrap: "Demande d'informations complémentaires:
%{contents}
"
+ sendByMailWrap: "Demande d'informations complémentaires:
+ %{contents}
"
ok: La note a bien été ajoutée, merci!
form:
title: Rédaction du message
@@ -255,28 +287,38 @@ Exemple: `%{daylimit}`"
event_mailer:
create:
- subject: "[Agenda du Libre] Votre événement: '%{subject}' est en attente de modération"
+ subject: "[Agenda du Libre] Votre événement: '%{subject}' est en attente
+ de modération"
title: Bonjour,
body: "Votre événement intitulé '%{subject}',
-\nqui aura lieu le '%{start_time}' a bien été enregistré dans l'Agenda du Libre.
+\nqui aura lieu le '%{start_time}' a bien été enregistré dans l'Agenda du
+Libre.
\n\nL'équipe de modération le prendra en charge très prochainement.
-\n\nPendant la modération et après celle-ci si votre événement est validé, vous pouvez éditer votre événement à l'adresse:"
+\n\nPendant la modération et après celle-ci si votre événement est validé, vous
+pouvez éditer votre événement à l'adresse:"
delete_link: "et vous pouvez l'annuler en utilisant l'adresse:"
signature: "Merci de votre participation!\n\n-- \nAgenda du Libre"
accept:
subject: "[Agenda du Libre] Événement '%{subject}' modéré"
title: Bonjour,
- body: "L'événement que vous avez soumis a été modéré par %{moderator}. Il est maintenant visible dans l'Agenda à l'adresse:"
- edit_link: "Vous pouvez modifier cet événement ultérieurement pour y ajouter des précisions en vous rendant à l'adresse:"
- delete_link: "Vous pouvez également l'annuler en vous rendant à l'adresse:"
- signature: "Merci de votre contribution à l'Agenda du Libre et à bientôt!\n\n-- \nL'équipe de modération"
+ body: "L'événement que vous avez soumis a été modéré par %{moderator}. Il
+ est maintenant visible dans l'Agenda à l'adresse:"
+ edit_link: "Vous pouvez modifier cet événement ultérieurement pour y
+ ajouter des précisions en vous rendant à l'adresse:"
+ delete_link: "Vous pouvez également l'annuler en vous rendant à
+ l'adresse:"
+ signature: "Merci de votre contribution à l'Agenda du Libre et à
+ bientôt!\n\n-- \nL'équipe de modération"
destroy:
subject: "[Agenda du Libre] Événement '%{subject}' refusé"
title: Bonjour,
- body: Vous avez soumis l'événement suivant dans l'Agenda du Libre, et nous vous remercions de cette contribution.
+ body: Vous avez soumis l'événement suivant dans l'Agenda du Libre, et
+ nous vous remercions de cette contribution.
reminder: "Pour rappel, voici le contenu de votre événement:"
- reclamation: Pour toute réclamation, n'hésitez pas à contacter l'équipe de modérateurs.
- signature: "Avec tous nos remerciements pour votre contribution,\n\n-- \nL'équipe de modération"
+ reclamation: Pour toute réclamation, n'hésitez pas à contacter l'équipe
+ de modérateurs.
+ signature: "Avec tous nos remerciements pour votre contribution,\n\n--
+ \nL'équipe de modération"
moderation_mailer:
create:
subject: "[Agenda du Libre] Nouvel événement à modérer: '%{subject}'"
@@ -286,7 +328,8 @@ Exemple: `%{daylimit}`"
update:
subject: "[Agenda du Libre] Édition de l'événement '%{subject}'"
title: Bonjour,
- body: "L'événement '%{subject}' a été modifié par %{author}.\n\nModifications apportées:"
+ body: "L'événement '%{subject}' a été modifié par
+ %{author}.\n\nModifications apportées:"
submitter: le soumetteur
signature: "Bonne journée\n\n-- \nL'équipe de modération"
accept:
@@ -297,7 +340,8 @@ Exemple: `%{daylimit}`"
destroy:
subject: "[Agenda du Libre] Événement '%{subject}' refusé"
title: Bonjour,
- body: "L'événement '%{subject}' a été rejeté par %{author} pour la raison suivante:\n\n"
+ body: "L'événement '%{subject}' a été rejeté par %{author} pour la raison
+ suivante:\n\n"
reminder: "Pour rappel, l'événement:"
signature: "-- \nL'équipe des modérateurs de l'Agenda du Libre"
note_mailer:
@@ -310,7 +354,8 @@ Exemple: `%{daylimit}`"
\ncomplémentaires sur cet événement:"
edit_link: "Nous vous invitons à ajouter ces informations en éditant directement
\nl'événement à l'adresse suivante:"
- signature: "Avec tous nos remerciements pour votre contribution,\n\n-- \nL'équipe des modérateurs de l'Agenda du Libre"
+ signature: "Avec tous nos remerciements pour votre contribution,\n\n--
+ \nL'équipe des modérateurs de l'Agenda du Libre"
create:
subject: "[Agenda du Libre] Une note a été rajoutée à l'événement '%{subject}'"
title: Bonjour,
diff --git a/config/locales/kaminari.fr.yml b/config/locales/kaminari.fr.yml
index 5c88bb18..84245996 100644
--- a/config/locales/kaminari.fr.yml
+++ b/config/locales/kaminari.fr.yml
@@ -1,9 +1,9 @@
fr:
views:
pagination:
- first: "«"
- last: "»"
- previous: "‹"
- next: "›"
- truncate: "..."
+ first: '«'
+ last: '»'
+ previous: '‹'
+ next: '›'
+ truncate: '...'
diff --git a/config/routes.rb b/config/routes.rb
index 8227969b..5e2c6a4a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -12,30 +12,35 @@ Rails.application.routes.draw do
get :validate, :refuse, on: :member
put :accept, on: :member
end
- resources :regions, only: [ :index ] do
+ resources :regions, only: [:index] do
get 'stats', on: :collection
end
- resources :tags, only: [ :index, :show ]
+ resources :tags, only: [:index, :show]
resources :maps, only: [:index]
resources :lugs, only: [:index, :show]
# Manage former php pages
- get 'showevent.php', to: redirect { |params, request| "events/#{request.params[:id]}" }
- get 'listevents.php', to: redirect { |params, request| "events?#{request.query_string}" }
+ get 'showevent.php', to: redirect { |_, req| "events/#{req.params[:id]}" }
+ get 'listevents.php', to: redirect { |_, req| "events?#{req.query_string}" }
# A mechanism to list "all" events
- get '(:format)listevents.php', to: redirect { |params, request| "events.#{request.format.to_sym}?#{request.query_string}" }
+ get '(:format)listevents.php',
+ to: redirect { |_, r| "events.#{r.format.to_sym}?#{r.query_string}" }
# Respond to rss and ical calls
- get '(:format)event.php', to: redirect { |params, request| "events.#{request.format.to_sym}?#{request.query_string}" }
+ get '(:format)event.php',
+ to: redirect { |_, r| "events.#{r.format.to_sym}?#{r.query_string}" }
# Respond to rss and ical calls
- get '(:format).php', to: redirect { |params, request| "events.#{request.format.to_sym}?#{request.query_string}" }
+ get '(:format).php',
+ to: redirect { |_, r| "events.#{r.format.to_sym}?#{r.query_string}" }
- devise_for :users, path: '', path_names: {sign_in: 'login', sign_out: 'logout'}
+ devise_for :users,
+ path: '', path_names: { sign_in: 'login', sign_out: 'logout' }
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
root to: 'events#index'
- # The priority is based upon order of creation: first created -> highest priority.
+ # The priority is based upon order of creation:
+ # first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
@@ -47,7 +52,8 @@ Rails.application.routes.draw do
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
- # Example resource route (maps HTTP verbs to controller actions automatically):
+ # Example resource route (maps HTTP verbs to controller actions
+ # automatically):
# resources :products
# Example resource route with options:
diff --git a/db/migrate/20131114103118_devise_create_admin_users.rb b/db/migrate/20131114103118_devise_create_admin_users.rb
index 649b269d..3a34b16f 100644
--- a/db/migrate/20131114103118_devise_create_admin_users.rb
+++ b/db/migrate/20131114103118_devise_create_admin_users.rb
@@ -1,29 +1,32 @@
+# Generate tables for active_admin users and associated auth mechanisms
class DeviseCreateAdminUsers < ActiveRecord::Migration
def migrate(direction)
super
# Create a default user
- AdminUser.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password') if direction == :up
+ AdminUser.create!(email: 'admin@example.com', password: 'password',
+ password_confirmation: 'password') if direction == :up
end
+ # rubocop:disable Style/MethodLength
def change
create_table(:admin_users) do |t|
## Database authenticatable
- t.string :email, :null => false, :default => ""
- t.string :encrypted_password, :null => false, :default => ""
+ t.string :email, null: false, default: ''
+ t.string :encrypted_password, null: false, default: ''
## Recoverable
- t.string :reset_password_token
+ t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
- t.integer :sign_in_count, :default => 0, :null => false
+ t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
- t.string :current_sign_in_ip
- t.string :last_sign_in_ip
+ t.string :current_sign_in_ip
+ t.string :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
@@ -32,16 +35,16 @@ class DeviseCreateAdminUsers < ActiveRecord::Migration
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
- # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
+ # Only if lock strategy is :failed_attempts
+ # t.integer :failed_attempts, :default => 0, :null => false
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
-
t.timestamps
end
- add_index :admin_users, :email, :unique => true
- add_index :admin_users, :reset_password_token, :unique => true
+ add_index :admin_users, :email, unique: true
+ add_index :admin_users, :reset_password_token, unique: true
# add_index :admin_users, :confirmation_token, :unique => true
# add_index :admin_users, :unlock_token, :unique => true
end
diff --git a/db/migrate/20131114103121_create_active_admin_comments.rb b/db/migrate/20131114103121_create_active_admin_comments.rb
index 90ed7b93..69a993bd 100644
--- a/db/migrate/20131114103121_create_active_admin_comments.rb
+++ b/db/migrate/20131114103121_create_active_admin_comments.rb
@@ -1,11 +1,13 @@
+# Add comments for administrators to internally share about any item
class CreateActiveAdminComments < ActiveRecord::Migration
+ # rubocop:disable Style/MethodLength
def self.up
create_table :active_admin_comments do |t|
t.string :namespace
- t.text :body
- t.string :resource_id, :null => false
- t.string :resource_type, :null => false
- t.references :author, :polymorphic => true
+ t.text :body
+ t.string :resource_id, null: false
+ t.string :resource_type, null: false
+ t.references :author, polymorphic: true
t.timestamps
end
add_index :active_admin_comments, [:namespace]
diff --git a/db/migrate/20140403204748_create_translation.rb b/db/migrate/20140403204748_create_translation.rb
index 697a0fcb..820b9dcb 100644
--- a/db/migrate/20140403204748_create_translation.rb
+++ b/db/migrate/20140403204748_create_translation.rb
@@ -1,3 +1,4 @@
+# Add a translations table, to mange many texts from the database
class CreateTranslation < ActiveRecord::Migration
def change
create_table :translations do |t|
diff --git a/db/schema.rb b/db/schema.rb
index ccfd9968..aeefdea6 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -1,4 +1,5 @@
# encoding: UTF-8
+# rubocop:disable all
# 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
# incrementally modify your database, and then regenerate this schema definition.
@@ -12,7 +13,6 @@
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140403204748) do
-
create_table "active_admin_comments", force: true do |t|
t.string "namespace"
t.text "body"
@@ -114,5 +114,4 @@ ActiveRecord::Schema.define(version: 20140403204748) do
t.string "lastname", default: "", null: false
t.string "firstname", default: "", null: false
end
-
end
diff --git a/db/seeds.rb b/db/seeds.rb
index d8d060c6..be9ba398 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -1,7 +1,9 @@
# encoding: utf-8
-# This file should contain all the record creation needed to seed the database with its default values.
-# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
+# This file should contain all the record creation needed to seed the database
+# with its default values.
+# The data can then be loaded with the rake db:seed (or created alongside the
+# db with db:setup).
#
# Examples:
#
@@ -11,9 +13,12 @@
City.create name: 'Rennes'
Region.create name: 'Bretagne'
Region.create name: 'Ma première région'
-User.create login: 'admin@example.com', email: 'admin@example.com', password: 'password'
+User.create login: 'admin@example.com', email: 'admin@example.com',
+ password: 'password'
AdminUser.create email: 'admin@example.com', password: 'password'
+# rubocop:disable all
+# rubocop:disable Metrics/LineLength, Style/StringLiterals
I18n::Backend::ActiveRecord::Translation.create([
{ locale: 'fr', key: 'layouts.application.subtitle',
value: 'L\'agenda des événements du Logiciel Libre en France' },
@@ -64,7 +69,7 @@ Si vous soumettez souvent un événement régulier dans l'Agenda du Libre, vous
{ locale: 'fr', key: 'events.form.tags_helper',
value: "*Tags pour l'événement. Les tags sont séparés par des espaces. Un tag ne peut contenir que des lettres minuscules, des chiffres et des tirets.*
-
+
*Dans les tags, indiquez le nom de la ou des associations organisatrices. N'indiquez pas le nom de la ville ou de la région.*" },
{ locale: 'fr', key: 'application.infos.content',
diff --git a/deploy/before_restart b/deploy/before_restart
index 8f75b7f5..9fe8a96c 100755
--- a/deploy/before_restart
+++ b/deploy/before_restart
@@ -2,7 +2,7 @@
oldrev, newrev = ARGV
def run(cmd)
- exit($?.exitstatus) unless system "umask 002 && #{cmd}"
+ exit($CHILD_STATUS.exitstatus) unless system "umask 002 && #{cmd}"
end
RAILS_ENV = ENV['RAILS_ENV'] || 'production'
@@ -21,19 +21,22 @@ end
if File.file? 'Rakefile'
tasks = []
- num_migrations = `git diff #{oldrev} #{newrev} --diff-filter=A --name-only -z db/migrate`.split("\0").size
+ num_migrations =
+ `git diff #{oldrev} #{newrev} --diff-filter=A --name-only -z db/migrate`
+ .split("\0").size
# run migrations if new ones have been added
- tasks << "db:migrate" if num_migrations > 0
+ tasks << 'db:migrate' if num_migrations > 0
# precompile assets
- changed_assets = `git diff #{oldrev} #{newrev} --name-only -z app/assets`.split("\0")
- tasks << "assets:precompile" if changed_assets.size > 0
+ changed_assets = `git diff #{oldrev} #{newrev} --name-only -z app/assets`
+ .split("\0")
+ tasks << 'assets:precompile' if changed_assets.size > 0
run "#{rake_cmd} #{tasks.join(' ')} RAILS_ENV=#{RAILS_ENV}" if tasks.any?
end
# clear cached assets (unversioned/ignored files)
-run "git clean -x -f -- public/stylesheets public/javascripts"
+run 'git clean -x -f -- public/stylesheets public/javascripts'
# clean unversioned files from vendor/plugins (e.g. old submodules)
-run "git clean -d -f -- vendor/plugins"
+run 'git clean -d -f -- vendor/plugins'
diff --git a/test/controllers/events_controller_test.rb b/test/controllers/events_controller_test.rb
index 8141d124..f4515c29 100644
--- a/test/controllers/events_controller_test.rb
+++ b/test/controllers/events_controller_test.rb
@@ -1,5 +1,6 @@
require 'test_helper'
+# Event life cycle
class EventsControllerTest < ActionController::TestCase
include Devise::TestHelpers
diff --git a/test/controllers/lugs_controller_test.rb b/test/controllers/lugs_controller_test.rb
index 4ae99e5b..0407ee0e 100644
--- a/test/controllers/lugs_controller_test.rb
+++ b/test/controllers/lugs_controller_test.rb
@@ -1,16 +1,17 @@
require 'test_helper'
+# Free Software groups life cycle
class LugsControllerTest < ActionController::TestCase
setup do
@lug = lugs :one
end
- test "should get index" do
+ test 'should get index' do
get :index
assert_response :success
end
- test "should get show" do
+ test 'should get show' do
get :show, id: @lug
assert_response :success
end
diff --git a/test/controllers/maps_controller_test.rb b/test/controllers/maps_controller_test.rb
index 7972cdc7..d0293a27 100644
--- a/test/controllers/maps_controller_test.rb
+++ b/test/controllers/maps_controller_test.rb
@@ -1,9 +1,9 @@
require 'test_helper'
+# Test the geocoding life cycle
class MapsControllerTest < ActionController::TestCase
- test "should get index" do
+ test 'should get index' do
get :index
assert_response :success
end
-
end
diff --git a/test/controllers/moderations_controller_test.rb b/test/controllers/moderations_controller_test.rb
index 78a7c4f4..7d29020a 100644
--- a/test/controllers/moderations_controller_test.rb
+++ b/test/controllers/moderations_controller_test.rb
@@ -1,5 +1,7 @@
require 'test_helper'
+# Event management, moderation means refusal, acceptation or demands for more
+# information
class ModerationsControllerTest < ActionController::TestCase
include Devise::TestHelpers
diff --git a/test/controllers/notes_controller_test.rb b/test/controllers/notes_controller_test.rb
index 5cabf28d..24e824b2 100644
--- a/test/controllers/notes_controller_test.rb
+++ b/test/controllers/notes_controller_test.rb
@@ -1,5 +1,6 @@
require 'test_helper'
+# Test the notes life cycle
class NotesControllerTest < ActionController::TestCase
include Devise::TestHelpers
@@ -9,12 +10,12 @@ class NotesControllerTest < ActionController::TestCase
sign_in users(:one)
end
- test "should get new" do
+ test 'should get new' do
get :new, moderation_id: @note.event.id
assert_response :success
end
- test "should create note" do
+ test 'should create note' do
assert_difference('Note.count') do
post :create, moderation_id: @note.event.id, note: {
author: @note.author,
diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb
index 820101e0..9c1918ae 100644
--- a/test/controllers/users_controller_test.rb
+++ b/test/controllers/users_controller_test.rb
@@ -1,5 +1,6 @@
require 'test_helper'
+# Test moderator management controller
class UsersControllerTest < ActionController::TestCase
include Devise::TestHelpers
@@ -9,18 +10,18 @@ class UsersControllerTest < ActionController::TestCase
sign_in users(:one)
end
- test "should get index" do
+ test 'should get index' do
get :index
assert_response :success
assert_not_nil assigns(:users)
end
- test "should get new" do
+ test 'should get new' do
get :new
assert_response :success
end
- test "should create user" do
+ test 'should create user' do
assert_difference('User.count') do
post :create, user: {
email: 'original@example.com',
@@ -34,17 +35,17 @@ class UsersControllerTest < ActionController::TestCase
assert_redirected_to user_path(assigns(:user))
end
- test "should show user" do
+ test 'should show user' do
get :show, id: @user
assert_response :success
end
- test "should get edit" do
+ test 'should get edit' do
get :edit, id: @user
assert_response :success
end
- test "should update user" do
+ test 'should update user' do
patch :update, id: @user, user: {
email: @user.email,
firstname: @user.firstname,
@@ -54,7 +55,7 @@ class UsersControllerTest < ActionController::TestCase
assert_redirected_to user_path(assigns(:user))
end
- test "should destroy user" do
+ test 'should destroy user' do
assert_difference('User.count', -1) do
delete :destroy, id: @user
end
diff --git a/test/mailers/event_mailer_test.rb b/test/mailers/event_mailer_test.rb
index 54339771..0cd0cc35 100644
--- a/test/mailers/event_mailer_test.rb
+++ b/test/mailers/event_mailer_test.rb
@@ -1,5 +1,6 @@
require 'test_helper'
+# Test mails related to event life cycle
class EventMailerTest < ActionMailer::TestCase
setup do
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
@@ -7,7 +8,8 @@ class EventMailerTest < ActionMailer::TestCase
test 'create' do
mail = EventMailer.create Event.last
- assert_match(/\[Agenda du Libre\] Votre événement: .* est en attente de modération/, mail.subject)
+ assert_match(/Votre événement: .* est en attente de modération/,
+ mail.subject)
assert_equal [Event.last.contact], mail.to
assert_equal ['moderateurs@agendadulibre.org'], mail.from
assert_match(/Bonjour.*/, mail.body.encoded)
@@ -15,14 +17,14 @@ class EventMailerTest < ActionMailer::TestCase
test 'accept' do
mail = EventMailer.accept Event.last, User.last
- assert_match(/\[Agenda du Libre\] Événement .* modéré/, mail.subject)
+ assert_match(/Événement .* modéré/, mail.subject)
assert_equal [Event.last.contact], mail.to
assert_equal ['moderateurs@agendadulibre.org'], mail.from
end
test 'destroy' do
mail = EventMailer.destroy Event.last, User.last, 'hello world'
- assert_match(/\[Agenda du Libre\] Événement .* refusé/, mail.subject)
+ assert_match(/Événement .* refusé/, mail.subject)
assert_equal [Event.last.contact], mail.to
assert_equal ['moderateurs@agendadulibre.org'], mail.from
end
diff --git a/test/mailers/moderation_mailer_test.rb b/test/mailers/moderation_mailer_test.rb
index 84acfd47..ef1cdac9 100644
--- a/test/mailers/moderation_mailer_test.rb
+++ b/test/mailers/moderation_mailer_test.rb
@@ -1,5 +1,6 @@
require 'test_helper'
+# Test mails sent related to event moderation
class ModerationMailerTest < ActionMailer::TestCase
setup do
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
@@ -7,21 +8,22 @@ class ModerationMailerTest < ActionMailer::TestCase
test 'create' do
mail = ModerationMailer.create Event.unscoped.last
- assert_match(/\[Agenda du Libre\] Nouvel événement à modérer: .*/, mail.subject)
+ assert_match(/\[Agenda du Libre\] Nouvel événement à modérer: .*/,
+ mail.subject)
assert_equal ['moderateurs@agendadulibre.org'], mail.to
assert_equal ['moderateurs@agendadulibre.org'], mail.from
end
test 'update' do
event = Event.last
- olderEvent = Event.new event.attributes
+ older_event = Event.new event.attributes
event.tags += ', ho'
event.start_time += 1.day
event.description = event.description + '
hello world'
- mail = ModerationMailer.update olderEvent, event, User.last
+ mail = ModerationMailer.update older_event, event, User.last
assert_match(/\[Agenda du Libre\] Édition de l'événement .*/, mail.subject)
assert_equal ['moderateurs@agendadulibre.org'], mail.to
assert_equal ['moderateurs@agendadulibre.org'], mail.from
@@ -36,7 +38,8 @@ hello world'
end
test 'destroy' do
- mail = ModerationMailer.destroy Event.unscoped.last, User.last, 'hello world'
+ mail = ModerationMailer.destroy Event.unscoped.last, User.last,
+ 'hello world'
assert_match(/\[Agenda du Libre\] Événement .* refusé/, mail.subject)
assert_equal ['moderateurs@agendadulibre.org'], mail.to
assert_equal ['moderateurs@agendadulibre.org'], mail.from
diff --git a/test/mailers/note_mailer_test.rb b/test/mailers/note_mailer_test.rb
index 196572c6..96892b1b 100644
--- a/test/mailers/note_mailer_test.rb
+++ b/test/mailers/note_mailer_test.rb
@@ -1,5 +1,7 @@
require 'test_helper'
+# Test that some information is sent to submitter and moderators when notes are
+# added to events
class NoteMailerTest < ActionMailer::TestCase
setup do
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
@@ -7,15 +9,17 @@ class NoteMailerTest < ActionMailer::TestCase
test 'notify' do
mail = NoteMailer.notify Note.last
- assert_match(/\[Agenda du Libre\] Demande d'informations sur l'événement .*/, mail.subject)
+ assert_match(/\[Agenda du Libre\] Demande d'informations sur l'événement.*/,
+ mail.subject)
assert_equal [Note.last.event.contact], mail.to
- assert_equal ["moderateurs@agendadulibre.org"], mail.from
+ assert_equal ['moderateurs@agendadulibre.org'], mail.from
end
test 'create' do
mail = NoteMailer.create Note.last
- assert_match(/\[Agenda du Libre\] Une note a été rajoutée à l'événement .*/, mail.subject)
+ assert_match(/\[Agenda du Libre\] Une note a été rajoutée à l'événement.*/,
+ mail.subject)
assert_not_equal [Note.last.event.contact], mail.to
- assert_equal ["moderateurs@agendadulibre.org"], mail.from
+ assert_equal ['moderateurs@agendadulibre.org'], mail.from
end
end
diff --git a/test/mailers/previews/event_mailer_preview.rb b/test/mailers/previews/event_mailer_preview.rb
index 197bc894..6b593713 100644
--- a/test/mailers/previews/event_mailer_preview.rb
+++ b/test/mailers/previews/event_mailer_preview.rb
@@ -1,6 +1,5 @@
# Preview all emails at http://localhost:3000/rails/mailers/event_mailer
class EventMailerPreview < ActionMailer::Preview
-
# Preview this email at http://localhost:3000/rails/mailers/event_mailer/create
def create
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
diff --git a/test/mailers/previews/moderation_mailer_preview.rb b/test/mailers/previews/moderation_mailer_preview.rb
index c68e4eb0..5ff66e26 100644
--- a/test/mailers/previews/moderation_mailer_preview.rb
+++ b/test/mailers/previews/moderation_mailer_preview.rb
@@ -12,14 +12,14 @@ class ModerationMailerPreview < ActionMailer::Preview
def update
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
event = Event.last
- olderEvent = Event.new event.attributes
+ older_event = Event.new event.attributes
event.tags += ', ho'
event.start_time += 1.day
event.description = event.description + '
hello world'
- ModerationMailer.update olderEvent, event, nil
+ ModerationMailer.update older_event, event, nil
end
# Preview this email at http://localhost:3000/rails/mailers/moderation_mailer/accept
diff --git a/test/models/event_test.rb b/test/models/event_test.rb
index 5c7d059d..31eb693f 100644
--- a/test/models/event_test.rb
+++ b/test/models/event_test.rb
@@ -1,33 +1,34 @@
require 'test_helper'
+# Test events, which are the application central part
class EventTest < ActiveSupport::TestCase
test 'basic event' do
@event = Event.new(
title: 'hello world',
- start_time: Time.new(),
- end_time: Time.new() + 1,
+ start_time: Time.new,
+ end_time: Time.new + 1,
description: 'et hop!',
- city: City.first(),
- related_region: Region.first(),
+ city: City.first,
+ related_region: Region.first,
url: 'http://example.com',
contact: 'contact@example.com',
submitter: 'submitter@example.com'
)
- assert @event.save(), @event.errors.messages
+ assert @event.save, @event.errors.messages
- assert_equal 32, @event.secret.size()
- assert_equal 32, @event.moderator_mail_id.size()
- assert_equal 32, @event.submitter_mail_id.size()
+ assert_equal 32, @event.secret.size
+ assert_equal 32, @event.moderator_mail_id.size
+ assert_equal 32, @event.submitter_mail_id.size
end
test 'validations' do
@event = Event.new(
title: 'hello world',
- start_time: Time.new(),
- end_time: Time.new() + 1,
+ start_time: Time.new,
+ end_time: Time.new + 1,
description: 'et hop!',
- city: City.first(),
- related_region: Region.first(),
+ city: City.first,
+ related_region: Region.first,
url: 'http://example.com',
contact: 'contact@example.com'
)
@@ -52,16 +53,16 @@ class EventTest < ActiveSupport::TestCase
test 'moderation' do
@event = Event.new(
title: 'hello world',
- start_time: Time.new(),
- end_time: Time.new() + 1,
+ start_time: Time.new,
+ end_time: Time.new + 1,
description: 'et hop!',
- city: City.first(),
- related_region: Region.first(),
+ city: City.first,
+ related_region: Region.first,
url: 'http://example.com',
contact: 'contact@example.com'
)
- assert @event.save(), @event.errors.messages
+ assert @event.save, @event.errors.messages
assert !@event.moderated?
@event.update(moderated: 1)
diff --git a/test/models/user_test.rb b/test/models/user_test.rb
index 3b9c137b..3bdc7373 100644
--- a/test/models/user_test.rb
+++ b/test/models/user_test.rb
@@ -1,7 +1,8 @@
require 'test_helper'
+# Some tests for moderators
class UserTest < ActiveSupport::TestCase
- test "basic user" do
+ test 'basic user' do
@user = User.new(
email: 'original@example.com',
firstname: 'first',
@@ -13,7 +14,7 @@ class UserTest < ActiveSupport::TestCase
assert_equal 'c3fcd3d76192e4007dfb496cca67e13b', @user.encrypted_password
end
- test "the password" do
+ test 'the password' do
@user = User.new(
email: 'original@example.com',
firstname: 'first',
diff --git a/test/test_helper.rb b/test/test_helper.rb
index bc7e05d7..043e8d3f 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -1,15 +1,20 @@
-ENV["RAILS_ENV"] ||= "test"
+ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
-class ActiveSupport::TestCase
- ActiveRecord::Migration.check_pending!
+module ActiveSupport
+ # Standard helper class for almost all tests
+ class TestCase
+ ActiveRecord::Migration.check_pending!
- # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
- #
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
- # -- they do not yet inherit this setting
- fixtures :all
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical
+ # order.
+ #
+ # Note: You'll currently still have to declare fixtures explicitly in
+ # integration tests
+ # -- they do not yet inherit this setting
+ fixtures :all
- # Add more helper methods to be used by all tests here...
+ # Add more helper methods to be used by all tests here...
+ end
end