Sha256: 3062176ee6d2db77cc63cee55563dfac3f4f415f43487895a4f3695b613bee32

Contents?: true

Size: 671 Bytes

Versions: 19

Compression:

Stored size: 671 Bytes

Contents

# frozen_string_literal: true

require "csv"

module Decidim
  module Admin
    # A form object used to upload CSV to batch participatory space private users.
    #
    class ParticipatorySpacePrivateUserCsvImportForm < Form
      include Decidim::HasUploadValidations

      attribute :file
      attribute :user_name, String
      attribute :email, String

      validates :file, presence: true
      validate :validate_csv

      def validate_csv
        return if file.blank?

        CSV.foreach(file.path) do |_email, user_name|
          errors.add(:user_name, :invalid) unless user_name.match?(UserBaseEntity::REGEXP_NAME)
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
decidim-admin-0.26.10 app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb
decidim-admin-0.26.9 app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb
decidim-admin-0.26.8 app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb
decidim-admin-0.26.7 app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb
decidim-admin-0.26.5 app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb
decidim-admin-0.26.4 app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb
decidim-admin-0.26.3 app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb
decidim-admin-0.26.2 app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb
decidim-admin-0.26.1 app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb
decidim-admin-0.26.0 app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb
decidim-admin-0.26.0.rc2 app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb
decidim-admin-0.26.0.rc1 app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb
decidim-admin-0.25.2 app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb
decidim-admin-0.25.1 app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb
decidim-admin-0.25.0 app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb
decidim-admin-0.25.0.rc4 app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb
decidim-admin-0.25.0.rc3 app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb
decidim-admin-0.25.0.rc2 app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb
decidim-admin-0.25.0.rc1 app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb