From adeb3acd79f848609e1f6e19d8a99777a4918bac Mon Sep 17 00:00:00 2001 From: Du Peng Date: Thu, 12 Dec 2024 12:10:45 +0100 Subject: [PATCH 1/3] (feat) default order for the spaces/trainings list is set to descending by created_at --- CHANGELOG.md | 2 ++ app/controllers/api/spaces_controller.rb | 2 +- app/services/training_service.rb | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb4b2587d..641d47789 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Next release +- Improvement: default order for the spaces/trainings list is set to descending by created_at + ## v6.3.35 2024 November 13 - Fix a bug: unable to run rails db:migrate if the database is empty diff --git a/app/controllers/api/spaces_controller.rb b/app/controllers/api/spaces_controller.rb index d6a2ea8ae..ba9e84993 100644 --- a/app/controllers/api/spaces_controller.rb +++ b/app/controllers/api/spaces_controller.rb @@ -7,7 +7,7 @@ class API::SpacesController < API::APIController respond_to :json def index - @spaces = Space.includes(:space_image, :machines).where(deleted_at: nil) + @spaces = Space.includes(:space_image, :machines).where(deleted_at: nil).order(:created_at) @spaces_indexed_with_parent = @spaces.index_with { |space| @spaces.find { |s| s.id == space.parent_id } } @spaces_grouped_by_parent_id = @spaces.group_by(&:parent_id) end diff --git a/app/services/training_service.rb b/app/services/training_service.rb index ec9bfc434..690e681cb 100644 --- a/app/services/training_service.rb +++ b/app/services/training_service.rb @@ -5,7 +5,7 @@ class TrainingService class << self # @param filters [ActionController::Parameters] def list(filters) - trainings = Training.includes(:training_image, :plans, :machines) + trainings = Training.includes(:training_image, :plans, :machines).order(:created_at) trainings = filter_by_disabled(trainings, filters) trainings = filter_by_public_page(trainings, filters) From 362cdc4fc497629b5d2ef931324cf499944ed12f Mon Sep 17 00:00:00 2001 From: Du Peng Date: Thu, 12 Dec 2024 14:17:49 +0100 Subject: [PATCH 2/3] (feat) members cannot see training deactivated in the list --- CHANGELOG.md | 1 + app/controllers/api/trainings_controller.rb | 1 + app/policies/training_policy.rb | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 641d47789..e2b2f9038 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Next release - Improvement: default order for the spaces/trainings list is set to descending by created_at +- Improvement: members cannot see training deactivated in the list ## v6.3.35 2024 November 13 diff --git a/app/controllers/api/trainings_controller.rb b/app/controllers/api/trainings_controller.rb index 286ef7bf8..e912fc807 100644 --- a/app/controllers/api/trainings_controller.rb +++ b/app/controllers/api/trainings_controller.rb @@ -14,6 +14,7 @@ class API::TrainingsController < API::APIController def show @training = Training.friendly.find(params[:id]) + authorize @training end def create diff --git a/app/policies/training_policy.rb b/app/policies/training_policy.rb index 6fb3d1215..18b66f89c 100644 --- a/app/policies/training_policy.rb +++ b/app/policies/training_policy.rb @@ -8,6 +8,10 @@ class TrainingPolicy < ApplicationPolicy end end + def show? + !record.disabled? || user.admin? || user.manager? + end + def create? user.admin? end From d7d81e3bcede2caf94104cb377225ec0027b06f8 Mon Sep 17 00:00:00 2001 From: Du Peng Date: Thu, 12 Dec 2024 14:20:12 +0100 Subject: [PATCH 3/3] Version 6.3.36 --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2b2f9038..78adb7a98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Next release +## v6.3.36 2024 December 12 + - Improvement: default order for the spaces/trainings list is set to descending by created_at - Improvement: members cannot see training deactivated in the list diff --git a/package.json b/package.json index 7fd79467f..4c3406432 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fab-manager", - "version": "6.3.35", + "version": "6.3.36", "description": "Fab-manager is the FabLab management solution. It provides a comprehensive, web-based, open-source tool to simplify your administrative tasks and your marker's projects.", "keywords": [ "fablab",