The moderator creation should be finalised

This commit is contained in:
echarp 2019-05-11 15:01:10 +02:00
parent 129bf02113
commit 37225e0691
8 changed files with 26 additions and 12 deletions

View File

@ -21,15 +21,22 @@ ActiveAdmin.register User do
f.input :email
f.input :firstname
f.input :lastname
f.input :password
f.input :password_confirmation
end
f.actions
end
controller do
def permitted_params
params.permit admin_user: %i[login email firstname lastname password
password_confirmation]
params.permit user: %i[login email firstname lastname]
end
end
before_create do |user|
user.password = Devise.friendly_token.first(8)
end
after_create do |user|
logger.info 'Sending initialisation mail to moderator'
user.send_reset_password_instructions
end
end

View File

@ -1,7 +1,7 @@
# The top level controller, where can be centralised almost everything
class ApplicationController < ActionController::Base
before_action :set_paper_trail_whodunnit, :set_locale, :discard
before_action :set_mailer_host, if: :devise_controller?
before_action :set_paper_trail_whodunnit, :set_locale, :discard,
:set_mailer_host
before_action :configure_permitted_parameters, if: :devise_controller?
# Prevent CSRF attacks by raising an exception.

View File

@ -9,7 +9,6 @@ class EventsController < ApplicationController
before_action :set_event, except: %i[index new preview_create create]
before_action :set_create_event, only: %i[new preview_create create]
before_action :check_secret, only: %i[edit preview update destroy]
before_action :set_mailer_host, only: %i[create update destroy]
rescue_from ActiveRecord::StaleObjectError, with: :locked
def index

View File

@ -4,7 +4,7 @@ class ModerationsController < ApplicationController
has_scope :near, type: :hash, using: %i[location distance]
before_action :authenticate_user!
before_action :set_moderation, :set_mailer_host, only:
before_action :set_moderation, only:
%i[show edit preview update validate accept refuse destroy]
before_action :generate_destroy_reason, only: :destroy
rescue_from ActiveRecord::StaleObjectError, with: :locked
@ -14,6 +14,14 @@ class ModerationsController < ApplicationController
@orgas = Orga.unmoderated
end
def show; end
def edit; end
def validate; end
def refuse; end
def preview
@moderation.attributes = moderation_params
@moderation.valid?

View File

@ -1,7 +1,7 @@
# Events, particulary during moderation, can have notes associated to them
class NotesController < ApplicationController
before_action :set_event, only: %i[new create]
before_action :create_note, :set_mailer_host, only: %i[create]
before_action :create_note, only: %i[create]
# GET /moderations/id/new
def new

View File

@ -5,7 +5,6 @@ class OrgasController < ApplicationController
has_scope :active, type: :boolean, default: true, allow_blank: true
before_action :set_orga, except: %i[index new create]
before_action :set_mailer_host
before_action :authenticate_user!, except: %i[index new create show],
unless: :check_secret

View File

@ -3,7 +3,7 @@
.field.login
= f.label :login
%br/
= f.email_field :login, autofocus: true, autocomplete: "login"
= f.text_field :login, autofocus: true, autocomplete: "login"
.field.password
= f.label :password
%br/

View File

@ -43,7 +43,8 @@ Rails.application.routes.draw do
devise_for :users, skip: [:registrations]
as :user do
get 'users/edit' => 'devise/registrations#edit', as: 'edit_user_registration'
get 'users/edit' => 'devise/registrations#edit',
as: 'edit_user_registration'
put 'users' => 'devise/registrations#update', as: 'user_registration'
end
devise_for :admin_users, ActiveAdmin::Devise.config