Sha256: b3722b95034b5ae55f10516002b3d32b933152c7a063111e2c22bf0c0ff79611

Contents?: true

Size: 694 Bytes

Versions: 22

Compression:

Stored size: 694 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # A form object used to upload CSV to batch verify user groups.
    #
    class UserGroupCsvVerificationForm < Form
      include Decidim::HasUploadValidations
      include Decidim::ProcessesFileLocally

      attribute :file, Decidim::Attributes::Blob

      validates :file, presence: true, file_content_type: { allow: ["text/csv"] }
      validate :validate_csv, unless: ->(f) { f.file.blank? }

      def validate_csv
        process_file_locally(file) do |file_path|
          CSV.open(file_path, &:readline)
        end
      rescue CSV::MalformedCSVError
        errors.add(:file, :malformed)
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
decidim-admin-0.29.1 app/forms/decidim/admin/user_group_csv_verification_form.rb
decidim-admin-0.28.4 app/forms/decidim/admin/user_group_csv_verification_form.rb
decidim-admin-0.27.9 app/forms/decidim/admin/user_group_csv_verification_form.rb
decidim-admin-0.29.0 app/forms/decidim/admin/user_group_csv_verification_form.rb
decidim-admin-0.28.3 app/forms/decidim/admin/user_group_csv_verification_form.rb
decidim-admin-0.27.8 app/forms/decidim/admin/user_group_csv_verification_form.rb
decidim-admin-0.29.0.rc4 app/forms/decidim/admin/user_group_csv_verification_form.rb
decidim-admin-0.29.0.rc3 app/forms/decidim/admin/user_group_csv_verification_form.rb
decidim-admin-0.29.0.rc2 app/forms/decidim/admin/user_group_csv_verification_form.rb
decidim-admin-0.29.0.rc1 app/forms/decidim/admin/user_group_csv_verification_form.rb
decidim-admin-0.28.2 app/forms/decidim/admin/user_group_csv_verification_form.rb
decidim-admin-0.27.7 app/forms/decidim/admin/user_group_csv_verification_form.rb
decidim-admin-0.28.1 app/forms/decidim/admin/user_group_csv_verification_form.rb
decidim-admin-0.27.6 app/forms/decidim/admin/user_group_csv_verification_form.rb
decidim-admin-0.28.0 app/forms/decidim/admin/user_group_csv_verification_form.rb
decidim-admin-0.27.5 app/forms/decidim/admin/user_group_csv_verification_form.rb
decidim-admin-0.28.0.rc5 app/forms/decidim/admin/user_group_csv_verification_form.rb
decidim-admin-0.28.0.rc4 app/forms/decidim/admin/user_group_csv_verification_form.rb
decidim-admin-0.27.4 app/forms/decidim/admin/user_group_csv_verification_form.rb
decidim-admin-0.27.3 app/forms/decidim/admin/user_group_csv_verification_form.rb