Sha256: 89450ad977d49c95d539695ea137b6cff8229f39b0ff40a983a7e72341c3c964
Contents?: true
Size: 1.95 KB
Versions: 12
Compression:
Stored size: 1.95 KB
Contents
# frozen_string_literal: true module Decidim module Admin # Controller that allows managing the user organization. # class OrganizationController < Decidim::Admin::ApplicationController layout "decidim/admin/settings" def edit enforce_permission_to :update, :organization, organization: current_organization @form = form(OrganizationForm).from_model(current_organization) end def update enforce_permission_to :update, :organization, organization: current_organization @form = form(OrganizationForm).from_params(params) @form.id = current_organization.id UpdateOrganization.call(current_organization, @form) do on(:ok) do flash[:notice] = I18n.t("organization.update.success", scope: "decidim.admin") redirect_to edit_organization_path end on(:invalid) do flash.now[:alert] = I18n.t("organization.update.error", scope: "decidim.admin") render :edit end end end def users search(current_organization.users.available) end def user_entities search(current_organization.user_entities.available) end private def search(relation) respond_to do |format| format.json do if (term = params[:term].to_s).present? query = relation.order(name: :asc) query = if term.start_with?("@") query.where("nickname ILIKE ?", "#{term.delete("@")}%") else query.where("name ILIKE ?", "%#{term}%").or( query.where("email ILIKE ?", "%#{term}%") ) end render json: query.all.collect { |u| { value: u.id, label: "#{u.name} (@#{u.nickname})" } } else render json: [] end end end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems