مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2026-01-17 13:39:46 +00:00
style(rubocop): fix all safe auto correctable offenses
هذا الالتزام موجود في:
@@ -1,6 +1,6 @@
|
||||
class OrganizationsController < ApplicationController
|
||||
|
||||
before_action :admin_required, :only => [:new, :create, :delete, :destroy]
|
||||
before_action :admin_required, only: [:new, :create, :delete, :destroy]
|
||||
|
||||
def index
|
||||
if current_user.admin?
|
||||
@@ -17,48 +17,48 @@ class OrganizationsController < ApplicationController
|
||||
@organization = Organization.new
|
||||
end
|
||||
|
||||
def edit
|
||||
@organization_obj = current_user.organizations_scope.find(organization.id)
|
||||
end
|
||||
|
||||
def create
|
||||
@organization = Organization.new(params.require(:organization).permit(:name, :permalink))
|
||||
@organization.owner = current_user
|
||||
if @organization.save
|
||||
redirect_to_with_json organization_root_path(@organization)
|
||||
else
|
||||
render_form_errors 'new', @organization
|
||||
render_form_errors "new", @organization
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@organization_obj = current_user.organizations_scope.find(organization.id)
|
||||
end
|
||||
|
||||
def update
|
||||
@organization_obj = current_user.organizations_scope.find(organization.id)
|
||||
if @organization_obj.update(params.require(:organization).permit(:name, :time_zone))
|
||||
redirect_to_with_json organization_settings_path(@organization_obj), :notice => "Settings for #{@organization_obj.name} have been saved successfully."
|
||||
redirect_to_with_json organization_settings_path(@organization_obj), notice: "Settings for #{@organization_obj.name} have been saved successfully."
|
||||
else
|
||||
render_form_errors 'edit', @organization_obj
|
||||
render_form_errors "edit", @organization_obj
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
unless current_user.authenticate(params[:password])
|
||||
respond_to do |wants|
|
||||
wants.html { redirect_to organization_delete_path(@organization), :alert => "The password you entered was not valid. Please check and try again." }
|
||||
wants.json { render :json => {:alert => "The password you entered was invalid. Please check and try again."} }
|
||||
wants.html { redirect_to organization_delete_path(@organization), alert: "The password you entered was not valid. Please check and try again." }
|
||||
wants.json { render json: { alert: "The password you entered was invalid. Please check and try again." } }
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
organization.soft_destroy
|
||||
redirect_to_with_json root_path(:nrd => 1), :notice => "#{@organization.name} has been removed successfully."
|
||||
redirect_to_with_json root_path(nrd: 1), notice: "#{@organization.name} has been removed successfully."
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def organization
|
||||
if [:edit, :update, :delete, :destroy].include?(action_name.to_sym)
|
||||
@organization ||= params[:org_permalink] ? current_user.organizations_scope.find_by_permalink!(params[:org_permalink]) : nil
|
||||
end
|
||||
return unless [:edit, :update, :delete, :destroy].include?(action_name.to_sym)
|
||||
|
||||
@organization ||= params[:org_permalink] ? current_user.organizations_scope.find_by_permalink!(params[:org_permalink]) : nil
|
||||
end
|
||||
helper_method :organization
|
||||
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم