Sha256: be2e607b3d1e1217bf50f98c002ca18c3f856025f31f27581469a036c00c4a37

Contents?: true

Size: 812 Bytes

Versions: 42

Compression:

Stored size: 812 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Assemblies
    module Admin
      # A form object used to create assembly user roles from the admin dashboard.
      #
      class AssemblyUserRoleForm < Form
        mimic :assembly_user_role

        attribute :name, String
        attribute :email, String
        attribute :role, String

        validates :name, :email, :role, presence: true
        validates :role, inclusion: { in: Decidim::AssemblyUserRole::ROLES }

        validates :name, format: { with: UserBaseEntity::REGEXP_NAME }

        def roles
          Decidim::AssemblyUserRole::ROLES.map do |role|
            [
              I18n.t(role, scope: "decidim.admin.models.assembly_user_role.roles"),
              role
            ]
          end
        end
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
decidim-assemblies-0.27.9 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb
decidim-assemblies-0.27.8 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb
decidim-assemblies-0.27.7 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb
decidim-assemblies-0.27.6 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb
decidim-assemblies-0.26.10 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb
decidim-assemblies-0.26.9 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb
decidim-assemblies-0.27.5 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb
decidim-assemblies-0.26.8 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb
decidim-assemblies-0.27.4 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb
decidim-assemblies-0.27.3 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb
decidim-assemblies-0.26.7 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb
decidim-assemblies-0.26.5 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb
decidim-assemblies-0.27.2 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb
decidim-assemblies-0.27.1 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb
decidim-assemblies-0.26.4 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb
decidim-assemblies-0.27.0 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb
decidim-assemblies-0.26.3 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb
decidim-assemblies-0.27.0.rc2 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb
decidim-assemblies-0.27.0.rc1 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb
decidim-assemblies-0.26.2 app/forms/decidim/assemblies/admin/assembly_user_role_form.rb