From fc79b2b84aef76fdf173b3d44953c83d4304897b Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Fri, 21 Dec 2018 15:20:49 +0100 Subject: [PATCH 1/4] Fix a typo in the README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0918d2786..75288b252 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ Une fois `overmind` lancé, et un breakpoint `byebug` inséré dans le code, il ### Linting -Le projet utilise plusieurs linters pour vérifier la lisibilité et la qualité code. +Le projet utilise plusieurs linters pour vérifier la lisibilité et la qualité du code. - Faire tourner tous les linters : `bin/rake lint` - [AccessLint](http://accesslint.com/) tourne automatiquement sur les PRs From 324b65b7ad5897af5a8fce3d65d8c4d82c48eae7 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Fri, 21 Dec 2018 15:20:34 +0100 Subject: [PATCH 2/4] Improve the admin tasks --- lib/tasks/admin.rake | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/lib/tasks/admin.rake b/lib/tasks/admin.rake index 01dd504e6..e74c1054f 100644 --- a/lib/tasks/admin.rake +++ b/lib/tasks/admin.rake @@ -1,22 +1,33 @@ namespace :admin do - task :create_admin, [:email] => :environment do |_t, args| - email = args[:email] - puts "Creating Administration for #{email}" - a = Administration.new(email: email, password: Devise.friendly_token[0, 20]) - if a.save - puts "#{a.email} created" - else - puts "An error occured : #{a.errors.full_messages}" - end - end - + desc <<~EOD + List all super-admins + EOD task list: :environment do - puts "All Administrations :" + puts "All Administrations:" Administration.all.pluck(:email).each do |a| puts a end end + desc <<~EOD + Create a new super-admin account with the #EMAIL email address. + EOD + task :create_admin, [:email] => :environment do |_t, args| + email = args[:email] + + puts "Creating Administration for #{email}" + a = Administration.new(email: email, password: Devise.friendly_token[0, 20]) + + if a.save + puts "#{a.email} created" + else + puts "An error occured: #{a.errors.full_messages}" + end + end + + desc <<~EOD + Delete the #EMAIL super-admin account + EOD task :delete_admin, [:email] => :environment do |_t, args| email = args[:email] puts "Deleting Administration for #{email}" From 0e6db7106ca924f32c458a0e7e62b902aee6fa1c Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Fri, 21 Dec 2018 15:19:24 +0100 Subject: [PATCH 3/4] =?UTF-8?q?admin=20=E2=86=92=20superadmin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/{admin.rake => superadmin.rake} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename lib/tasks/{admin.rake => superadmin.rake} (84%) diff --git a/lib/tasks/admin.rake b/lib/tasks/superadmin.rake similarity index 84% rename from lib/tasks/admin.rake rename to lib/tasks/superadmin.rake index e74c1054f..67c2dabbf 100644 --- a/lib/tasks/admin.rake +++ b/lib/tasks/superadmin.rake @@ -1,4 +1,4 @@ -namespace :admin do +namespace :superadmin do desc <<~EOD List all super-admins EOD @@ -12,7 +12,7 @@ namespace :admin do desc <<~EOD Create a new super-admin account with the #EMAIL email address. EOD - task :create_admin, [:email] => :environment do |_t, args| + task :create, [:email] => :environment do |_t, args| email = args[:email] puts "Creating Administration for #{email}" @@ -28,7 +28,7 @@ namespace :admin do desc <<~EOD Delete the #EMAIL super-admin account EOD - task :delete_admin, [:email] => :environment do |_t, args| + task :delete, [:email] => :environment do |_t, args| email = args[:email] puts "Deleting Administration for #{email}" a = Administration.find_by(email: email) From b3ae737a35eaec203cd87a5f732a926bcbda81b8 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Fri, 21 Dec 2018 15:20:43 +0100 Subject: [PATCH 4/4] Improve the superadmin tasks part of the README --- README.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 75288b252..996958ed5 100644 --- a/README.md +++ b/README.md @@ -121,16 +121,10 @@ Le projet utilise plusieurs linters pour vérifier la lisibilité et la qualité ## Tâches courantes -### Tâches Super Admin +### Tâches de gestion des comptes super-admin -- ajouter un compte super admin : - `bin/rake admin:create_admin[email-du-compte-github@exemple.com]` - -- lister les comptes super admin : - `bin/rake admin:list` - -- supprimer un compte super admin : - `bin/rake admin:delete_admin[email-du-compte-github@exemple.com]` +Des tâches de gestion des comptes super-admin sont prévues dans le namespace `superadmin`. +Pour les lister : `bin/rake -D superadmin:`. ### Tâches d’aide au support