diff --git a/README.md b/README.md index 3d778b6a6..29e1e7edc 100644 --- a/README.md +++ b/README.md @@ -499,9 +499,16 @@ Default is **UTC**. Configure the first day of the week in your locale zone (generally monday or sunday). D3_DATE_FORMAT + Date format for dates displayed in statistics charts. See https://github.com/mbostock/d3/wiki/Time-Formatting#format for available formats. + UIB_DATE_FORMAT + +Date format for dates displayed and parsed in date pickers. +See https://angular-ui.github.io/bootstrap/#uibdateparser-s-format-codes for a list available formats. + +**BEWARE**: years format with less than 4 digits will result in problems because the system won't be able to distinct dates with the same less significant digits, eg. 50 could mean 1950 or 2050. #### Applying changes diff --git a/app/assets/javascripts/controllers/admin/events.coffee b/app/assets/javascripts/controllers/admin/events.coffee index 50503beb0..ae48804bf 100644 --- a/app/assets/javascripts/controllers/admin/events.coffee +++ b/app/assets/javascripts/controllers/admin/events.coffee @@ -23,7 +23,7 @@ # - $state (Ui-Router) [ 'app.public.events_list' ] ## class EventsController - constructor: ($scope, $state, $locale, Event, Category) -> + constructor: ($scope, $state, Event, Category) -> ## Retrieve the list of categories from the server (stage, atelier, ...) Category.query().$promise.then (data)-> @@ -33,7 +33,7 @@ class EventsController ## default parameters for AngularUI-Bootstrap datepicker $scope.datePicker = - format: $locale.DATETIME_FORMATS.shortDate + format: Fablab.uibDateFormat startOpened: false # default: datePicker is not shown endOpened: false recurrenceEndOpened: false @@ -242,7 +242,7 @@ Application.Controllers.controller "NewEventController", ["$scope", "$state", "$ $scope.currencySymbol = $locale.NUMBER_FORMATS.CURRENCY_SYM; ## Using the EventsController - new EventsController($scope, $state, $locale, Event, Category) + new EventsController($scope, $state, Event, Category) ] @@ -286,7 +286,7 @@ Application.Controllers.controller "EditEventController", ["$scope", "$state", " $scope.event.end_date = moment($scope.event.end_date).toDate() ## Using the EventsController - new EventsController($scope, $state, $locale, Event, Category) + new EventsController($scope, $state, Event, Category) diff --git a/app/assets/javascripts/controllers/admin/graphs.coffee b/app/assets/javascripts/controllers/admin/graphs.coffee index 03a7b542b..529cbf7b4 100644 --- a/app/assets/javascripts/controllers/admin/graphs.coffee +++ b/app/assets/javascripts/controllers/admin/graphs.coffee @@ -1,7 +1,7 @@ 'use strict' -Application.Controllers.controller "GraphsController", ["$scope", "$state", '$locale', "$rootScope", 'es', 'Statistics', '_t' -, ($scope, $state, $locale, $rootScope, es, Statistics, _t) -> +Application.Controllers.controller "GraphsController", ["$scope", "$state", "$rootScope", 'es', 'Statistics', '_t' +, ($scope, $state, $rootScope, es, Statistics, _t) -> @@ -50,7 +50,7 @@ Application.Controllers.controller "GraphsController", ["$scope", "$state", '$lo ## datePicker parameters for interval beginning $scope.datePickerStart = - format: $locale.DATETIME_FORMATS.shortDate + format: Fablab.uibDateFormat opened: false # default: datePicker is not shown minDate: null maxDate: moment().subtract(1, 'day').toDate() @@ -60,7 +60,7 @@ Application.Controllers.controller "GraphsController", ["$scope", "$state", '$lo ## datePicker parameters for interval ending $scope.datePickerEnd = - format: $locale.DATETIME_FORMATS.shortDate + format: Fablab.uibDateFormat opened: false # default: datePicker is not shown minDate: null maxDate: moment().subtract(1, 'day').toDate() diff --git a/app/assets/javascripts/controllers/admin/invoices.coffee.erb b/app/assets/javascripts/controllers/admin/invoices.coffee.erb index 21727dfe7..ce723d05b 100644 --- a/app/assets/javascripts/controllers/admin/invoices.coffee.erb +++ b/app/assets/javascripts/controllers/admin/invoices.coffee.erb @@ -390,8 +390,8 @@ Application.Controllers.controller "InvoicesController", ["$scope", "$state", 'I ## # Controller used in the invoice refunding modal window ## -Application.Controllers.controller 'AvoirModalController', ["$scope", "$uibModalInstance", '$locale', "invoice", "Invoice", "growl", '_t' -, ($scope, $uibModalInstance, $locale, invoice, Invoice, growl, _t) -> +Application.Controllers.controller 'AvoirModalController', ["$scope", "$uibModalInstance", "invoice", "Invoice", "growl", '_t' +, ($scope, $uibModalInstance, invoice, Invoice, growl, _t) -> @@ -424,7 +424,7 @@ Application.Controllers.controller 'AvoirModalController', ["$scope", "$uibModal ## AngularUI-Bootstrap datepicker parameters to define when to refund $scope.datePicker = - format: $locale.DATETIME_FORMATS.shortDate + format: Fablab.uibDateFormat opened: false # default: datePicker is not shown options: startingDay: Fablab.weekStartingDay diff --git a/app/assets/javascripts/controllers/admin/members.coffee.erb b/app/assets/javascripts/controllers/admin/members.coffee.erb index 6571e0d7f..a6e48519f 100644 --- a/app/assets/javascripts/controllers/admin/members.coffee.erb +++ b/app/assets/javascripts/controllers/admin/members.coffee.erb @@ -21,7 +21,7 @@ # - $state (Ui-Router) [ 'app.admin.members' ] ## class MembersController - constructor: ($scope, $state, $locale, Group, Training) -> + constructor: ($scope, $state, Group, Training) -> ## Retrieve the profiles groups (eg. students ...) Group.query (groups) -> @@ -35,7 +35,7 @@ class MembersController ## Default parameters for AngularUI-Bootstrap datepicker $scope.datePicker = - format: $locale.DATETIME_FORMATS.shortDate + format: Fablab.uibDateFormat opened: false # default: datePicker is not shown subscription_date_opened: false options: @@ -188,8 +188,8 @@ Application.Controllers.controller "AdminMembersController", ["$scope", 'members ## # Controller used in the member edition page ## -Application.Controllers.controller "EditMemberController", ["$scope", "$state", "$stateParams", '$locale', "Member", 'Training', 'dialogs', 'growl', 'Group', 'Subscription', 'CSRF', 'memberPromise', 'tagsPromise', '$uibModal', 'Plan', '$filter', '_t' -, ($scope, $state, $stateParams, $locale, Member, Training, dialogs, growl, Group, Subscription, CSRF, memberPromise, tagsPromise, $uibModal, Plan, $filter, _t) -> +Application.Controllers.controller "EditMemberController", ["$scope", "$state", "$stateParams", "Member", 'Training', 'dialogs', 'growl', 'Group', 'Subscription', 'CSRF', 'memberPromise', 'tagsPromise', '$uibModal', 'Plan', '$filter', '_t' +, ($scope, $state, $stateParams, Member, Training, dialogs, growl, Group, Subscription, CSRF, memberPromise, tagsPromise, $uibModal, Plan, $filter, _t) -> @@ -245,7 +245,7 @@ Application.Controllers.controller "EditMemberController", ["$scope", "$state", $scope.free = free $scope.datePicker = opened: false - format: $locale.DATETIME_FORMATS.shortDate + format: Fablab.uibDateFormat options: startingDay: Fablab.weekStartingDay minDate: new Date @@ -349,7 +349,7 @@ Application.Controllers.controller "EditMemberController", ["$scope", "$state", plan.nameToDisplay = "#{plan.base_name} - #{plan.interval}" # Using the MembersController - new MembersController($scope, $state, $locale, Group, Training) + new MembersController($scope, $state, Group, Training) @@ -362,8 +362,8 @@ Application.Controllers.controller "EditMemberController", ["$scope", "$state", ## # Controller used in the member's creation page (admin view) ## -Application.Controllers.controller "NewMemberController", ["$scope", "$state", "$locale", "$stateParams", "Member", 'Training', 'Group', 'CSRF' -, ($scope, $state, $locale, $stateParams, Member, Training, Group, CSRF) -> +Application.Controllers.controller "NewMemberController", ["$scope", "$state", "$stateParams", "Member", 'Training', 'Group', 'CSRF' +, ($scope, $state, $stateParams, Member, Training, Group, CSRF) -> CSRF.setMetaTags() @@ -386,7 +386,7 @@ Application.Controllers.controller "NewMemberController", ["$scope", "$state", " ## Using the MembersController - new MembersController($scope, $state, $locale, Group, Training) + new MembersController($scope, $state, Group, Training) ] @@ -394,7 +394,7 @@ Application.Controllers.controller "NewMemberController", ["$scope", "$state", " ## # Controller used in the admin's creation page (admin view) ## -Application.Controllers.controller 'NewAdminController', ['$state', '$scope', '$locale', 'Admin', 'growl', ($state, $scope, $locale, Admin, growl)-> +Application.Controllers.controller 'NewAdminController', ['$state', '$scope', 'Admin', 'growl', ($state, $scope, Admin, growl)-> ## default admin profile $scope.admin = @@ -403,7 +403,7 @@ Application.Controllers.controller 'NewAdminController', ['$state', '$scope', '$ ## Default parameters for AngularUI-Bootstrap datepicker $scope.datePicker = - format: $locale.DATETIME_FORMATS.shortDate + format: Fablab.uibDateFormat opened: false options: startingDay: Fablab.weekStartingDay diff --git a/app/assets/javascripts/controllers/admin/statistics.coffee b/app/assets/javascripts/controllers/admin/statistics.coffee index db22fc55e..85d515fa2 100644 --- a/app/assets/javascripts/controllers/admin/statistics.coffee +++ b/app/assets/javascripts/controllers/admin/statistics.coffee @@ -1,7 +1,7 @@ 'use strict' -Application.Controllers.controller "StatisticsController", ["$scope", "$state", "$rootScope", "$locale", "Statistics", "es", "Member", '_t' -, ($scope, $state, $rootScope, $locale, Statistics, es, Member, _t) -> +Application.Controllers.controller "StatisticsController", ["$scope", "$state", "$rootScope", "Statistics", "es", "Member", '_t' +, ($scope, $state, $rootScope, Statistics, es, Member, _t) -> @@ -53,7 +53,7 @@ Application.Controllers.controller "StatisticsController", ["$scope", "$state", value : null exclude: false datePicker: - format: $locale.DATETIME_FORMATS.shortDate + format: Fablab.uibDateFormat opened: false # default: datePicker is not shown minDate: null maxDate: moment().toDate() @@ -69,7 +69,7 @@ Application.Controllers.controller "StatisticsController", ["$scope", "$state", ## datePicker parameters for interval beginning $scope.datePickerStart = - format: $locale.DATETIME_FORMATS.shortDate + format: Fablab.uibDateFormat opened: false # default: datePicker is not shown minDate: null maxDate: moment().subtract(1, 'day').toDate() @@ -79,7 +79,7 @@ Application.Controllers.controller "StatisticsController", ["$scope", "$state", ## datePicker parameters for interval ending $scope.datePickerEnd = - format: $locale.DATETIME_FORMATS.shortDate + format: Fablab.uibDateFormat opened: false # default: datePicker is not shown minDate: null maxDate: moment().subtract(1, 'day').toDate() diff --git a/app/assets/javascripts/controllers/application.coffee.erb b/app/assets/javascripts/controllers/application.coffee.erb index 604310e0c..d9b12e334 100644 --- a/app/assets/javascripts/controllers/application.coffee.erb +++ b/app/assets/javascripts/controllers/application.coffee.erb @@ -1,7 +1,7 @@ 'use strict' -Application.Controllers.controller 'ApplicationController', ["$rootScope", "$scope", "$window", "Session", "AuthService", "Auth", "$uibModal", "$state", 'growl', 'Notification', '$interval', "Setting", '$locale', '_t' -, ($rootScope, $scope, $window, Session, AuthService, Auth, $uibModal, $state, growl, Notification, $interval, Setting, $locale, _t) -> +Application.Controllers.controller 'ApplicationController', ["$rootScope", "$scope", "$window", "Session", "AuthService", "Auth", "$uibModal", "$state", 'growl', 'Notification', '$interval', "Setting", '_t' +, ($rootScope, $scope, $window, Session, AuthService, Auth, $uibModal, $state, growl, Notification, $interval, Setting, _t) -> @@ -66,7 +66,7 @@ Application.Controllers.controller 'ApplicationController', ["$rootScope", "$sco controller: ['$scope', '$uibModalInstance', 'Group', 'CustomAsset', ($scope, $uibModalInstance, Group, CustomAsset) -> # default parameters for the date picker in the account creation modal $scope.datePicker = - format: $locale.DATETIME_FORMATS.shortDate + format: Fablab.uibDateFormat opened: false options: startingDay: Fablab.weekStartingDay diff --git a/app/assets/javascripts/controllers/members.coffee b/app/assets/javascripts/controllers/members.coffee index 8417cc2fd..f101165be 100644 --- a/app/assets/javascripts/controllers/members.coffee +++ b/app/assets/javascripts/controllers/members.coffee @@ -15,8 +15,8 @@ Application.Controllers.controller "MembersController", ["$scope", 'membersPromi ## # Controller used when editing the current user's profile ## -Application.Controllers.controller "EditProfileController", ["$scope", "$rootScope", "$state", "$window", '$locale', "Member", "Auth", "Session", "activeProviderPromise", 'growl', 'dialogs', 'CSRF', 'memberPromise', 'groups', '_t' -, ($scope, $rootScope, $state, $window, $locale, Member, Auth, Session, activeProviderPromise, growl, dialogs, CSRF, memberPromise, groups, _t) -> +Application.Controllers.controller "EditProfileController", ["$scope", "$rootScope", "$state", "$window", "Member", "Auth", "Session", "activeProviderPromise", 'growl', 'dialogs', 'CSRF', 'memberPromise', 'groups', '_t' +, ($scope, $rootScope, $state, $window, Member, Auth, Session, activeProviderPromise, growl, dialogs, CSRF, memberPromise, groups, _t) -> @@ -56,7 +56,7 @@ Application.Controllers.controller "EditProfileController", ["$scope", "$rootSco ## Angular-Bootstrap datepicker configuration for birthday $scope.datePicker = - format: $locale.DATETIME_FORMATS.shortDate + format: Fablab.uibDateFormat opened: false # default: datePicker is not shown options: startingDay: Fablab.weekStartingDay diff --git a/app/assets/javascripts/controllers/profile.coffee b/app/assets/javascripts/controllers/profile.coffee index 9162f4d28..a19968e18 100644 --- a/app/assets/javascripts/controllers/profile.coffee +++ b/app/assets/javascripts/controllers/profile.coffee @@ -1,8 +1,8 @@ 'use strict' -Application.Controllers.controller "CompleteProfileController", ["$scope", "$rootScope", "$state", "_t", "$locale", "growl", "CSRF", "Auth", "Member", "settingsPromise", "activeProviderPromise", "groupsPromise", "cguFile", "memberPromise" -, ($scope, $rootScope, $state, _t, $locale, growl, CSRF, Auth, Member, settingsPromise, activeProviderPromise, groupsPromise, cguFile, memberPromise) -> +Application.Controllers.controller "CompleteProfileController", ["$scope", "$rootScope", "$state", "_t", "growl", "CSRF", "Auth", "Member", "settingsPromise", "activeProviderPromise", "groupsPromise", "cguFile", "memberPromise" +, ($scope, $rootScope, $state, _t, growl, CSRF, Auth, Member, settingsPromise, activeProviderPromise, groupsPromise, cguFile, memberPromise) -> @@ -40,7 +40,7 @@ Application.Controllers.controller "CompleteProfileController", ["$scope", "$roo ## Angular-Bootstrap datepicker configuration for birthday $scope.datePicker = - format: $locale.DATETIME_FORMATS.shortDate + format: Fablab.uibDateFormat opened: false # default: datePicker is not shown options: startingDay: Fablab.weekStartingDay diff --git a/app/assets/javascripts/controllers/trainings.coffee.erb b/app/assets/javascripts/controllers/trainings.coffee.erb index ee1f678f4..98a061f3a 100644 --- a/app/assets/javascripts/controllers/trainings.coffee.erb +++ b/app/assets/javascripts/controllers/trainings.coffee.erb @@ -447,7 +447,6 @@ Application.Controllers.controller "ReserveTrainingController", ["$scope", "$sta element.attr( 'uib-popover': event.training.description 'popover-trigger': 'mouseenter' - 'popover-append-to-body': true ) $compile(element)($scope) diff --git a/app/assets/javascripts/filters/filters.coffee b/app/assets/javascripts/filters/filters.coffee index 686d9e40b..9b6334d91 100644 --- a/app/assets/javascripts/filters/filters.coffee +++ b/app/assets/javascripts/filters/filters.coffee @@ -210,4 +210,11 @@ Application.Filters.filter 'toArray', [ -> if angular.isObject(val) Object.defineProperty(val, '$key', {__proto__: null, value: key}) +] + +Application.Filters.filter 'toIsoDate', [ -> + (date) -> + return date unless (date instanceof Date || moment.isMoment(date)) + moment(date).format('YYYY-MM-DD') + ] \ No newline at end of file diff --git a/app/assets/templates/machines/_form.html.erb b/app/assets/templates/machines/_form.html.erb index 5eec4d43d..0aa424824 100644 --- a/app/assets/templates/machines/_form.html.erb +++ b/app/assets/templates/machines/_form.html.erb @@ -30,7 +30,7 @@ {{ 'add_an_illustration' | translate }} {{ 'change' }} + diff --git a/app/assets/templates/shared/_member_form.html.erb b/app/assets/templates/shared/_member_form.html.erb index 1a4e3f6cc..a62e0cf64 100644 --- a/app/assets/templates/shared/_member_form.html.erb +++ b/app/assets/templates/shared/_member_form.html.erb @@ -168,7 +168,6 @@ + {{ 'date_of_birth_is_required' }} diff --git a/app/mailers/notifications_mailer.rb b/app/mailers/notifications_mailer.rb index e7d51e96a..f30a17535 100644 --- a/app/mailers/notifications_mailer.rb +++ b/app/mailers/notifications_mailer.rb @@ -28,12 +28,12 @@ class NotificationsMailer < NotifyWith::NotificationsMailer end def notify_user_when_invoice_ready - attachments['facture.pdf'] = File.read(@attached_object.file) + attachments[@attached_object.filename] = File.read(@attached_object.file) mail(to: @recipient.email, subject: t('notifications_mailer.notify_member_invoice_ready.subject'), template_name: 'notify_member_invoice_ready') end def notify_user_when_avoir_ready - attachments['avoir.pdf'] = File.read(@attached_object.file) + attachments[@attached_object.filename] = File.read(@attached_object.file) mail(to: @recipient.email, subject: t('notifications_mailer.notify_member_avoir_ready.subject'), template_name: 'notify_member_avoir_ready') end end diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 6c0c252eb..0421c364d 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -18,7 +18,11 @@ class Invoice < ActiveRecord::Base # create directories if they doesn't exists (invoice & user_id) FileUtils::mkdir_p dir - "#{dir}/#{ENV['INVOICE_PREFIX']}-#{self.id}_#{self.created_at.strftime('%d%m%Y')}.pdf" + "#{dir}/#{self.filename}" + end + + def filename + "#{ENV['INVOICE_PREFIX']}-#{self.id}_#{self.created_at.strftime('%d%m%Y')}.pdf" end diff --git a/app/views/application/index.html.erb b/app/views/application/index.html.erb index b913c884f..c6fad0b2a 100644 --- a/app/views/application/index.html.erb +++ b/app/views/application/index.html.erb @@ -23,11 +23,7 @@ var Fablab = Fablab || {}; - if ('<%= Rails.application.secrets.fablab_without_plans %>' == 'true'){ - Fablab.withoutPlans = true; - } else { - Fablab.withoutPlans = false; - } + Fablab.withoutPlans = ('<%= Rails.application.secrets.fablab_without_plans %>' == 'true'); Fablab.disqusShortname = "<%= Rails.application.secrets.disqus_shortname %>"; Fablab.defaultHost = "<%= ENV['DEFAULT_HOST'] %>"; Fablab.gaId = "<%= ENV['GA_ID'] %>"; @@ -48,6 +44,7 @@ }; Fablab.weekStartingDay = <%= Date.parse(Rails.application.secrets.week_starting_day).strftime('%w') %>; Fablab.d3DateFormat = "<%= Rails.application.secrets.d3_date_format %>"; + Fablab.uibDateFormat = "<%= Rails.application.secrets.uib_date_format %>"; <%= stylesheet_link_tag 'application', media: 'all' %> diff --git a/config/application.yml.default b/config/application.yml.default index 1281d4e80..0807bb263 100644 --- a/config/application.yml.default +++ b/config/application.yml.default @@ -46,3 +46,4 @@ ELASTICSEARCH_LANGUAGE_ANALYZER: 'french' TIME_ZONE: 'Paris' WEEK_STARTING_DAY: 'monday' D3_DATE_FORMAT: '%d/%m/%y' +UIB_DATE_FORMAT: 'dd/MM/yyyy' diff --git a/config/locales/app.shared.en.yml b/config/locales/app.shared.en.yml index c97a750c5..50a5057a3 100644 --- a/config/locales/app.shared.en.yml +++ b/config/locales/app.shared.en.yml @@ -53,7 +53,7 @@ en: _subscription: "subscription" confirm_and_pay: "Confirm and pay" your_invoice_will_be_available_soon_from_your_: "Your invoice will be available soon form your" - add_an_event: "Add ane event" + add_an_event: "Add an event" load_the_next_courses_and_workshops: "Load the next courses and workshops..." dates: "Dates:" thank_you_your_payment_has_been_successfully_registered: "Thank you. Your payment has been successfully registered !" diff --git a/config/secrets.yml b/config/secrets.yml index db40b5980..ce1b803dc 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -20,6 +20,7 @@ development: time_zone: <%= ENV["TIME_ZONE"] %> week_starting_day: <%= ENV["WEEK_STARTING_DAY"] %> d3_date_format: <%= ENV["D3_DATE_FORMAT"].dump %> # .dump is needed as the value may start by a '%', see https://github.com/tenderlove/psych/issues/75 + uib_date_format: <%= ENV["UIB_DATE_FORMAT"] %> rails_locale: <%= ENV["RAILS_LOCALE"] %> moment_locale: <%= ENV["MOMENT_LOCALE"] %> summernote_locale: <%= ENV["SUMMERNOTE_LOCALE"] %> @@ -38,6 +39,7 @@ test: time_zone: <%= ENV["TIME_ZONE"] %> week_starting_day: <%= ENV["WEEK_STARTING_DAY"] %> d3_date_format: <%= ENV["D3_DATE_FORMAT"].dump %> + uib_date_format: <%= ENV["UIB_DATE_FORMAT"] %> rails_locale: <%= ENV["RAILS_LOCALE"] %> moment_locale: <%= ENV["MOMENT_LOCALE"] %> summernote_locale: <%= ENV["SUMMERNOTE_LOCALE"] %> @@ -64,6 +66,7 @@ staging: time_zone: <%= ENV["TIME_ZONE"] %> week_starting_day: <%= ENV["WEEK_STARTING_DAY"] %> d3_date_format: <%= ENV["D3_DATE_FORMAT"].dump %> + uib_date_format: <%= ENV["UIB_DATE_FORMAT"] %> rails_locale: <%= ENV["RAILS_LOCALE"] %> moment_locale: <%= ENV["MOMENT_LOCALE"] %> summernote_locale: <%= ENV["SUMMERNOTE_LOCALE"] %> @@ -91,6 +94,7 @@ production: time_zone: <%= ENV["TIME_ZONE"] %> week_starting_day: <%= ENV["WEEK_STARTING_DAY"] %> d3_date_format: <%= ENV["D3_DATE_FORMAT"].dump %> + uib_date_format: <%= ENV["UIB_DATE_FORMAT"] %> rails_locale: <%= ENV["RAILS_LOCALE"] %> moment_locale: <%= ENV["MOMENT_LOCALE"] %> summernote_locale: <%= ENV["SUMMERNOTE_LOCALE"] %>