Sha256: 029a3dbe43504a52bef2ad42be4f69975c6cda6947019b5f0e0898af9c37d75e

Contents?: true

Size: 1.2 KB

Versions: 45

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module Decidim
  module InitiativesVotes
    class VoteCell < Decidim::ViewModel
      delegate :timestamp, :hash_id, to: :model

      def show
        render
      end

      def initiative_id
        model.initiative.reference
      end

      def initiative_title
        translated_attribute(model.initiative.title)
      end

      def name_and_surname
        metadata[:name_and_surname]
      end

      def document_number
        metadata[:document_number]
      end

      def date_of_birth
        metadata[:date_of_birth]
      end

      def postal_code
        metadata[:postal_code]
      end

      def time_and_date
        model.created_at
      end

      def scope
        return I18n.t("decidim.scopes.global") if model.decidim_scope_id.nil?
        return I18n.t("decidim.initiatives.unavailable_scope") if model.scope.blank?

        translated_attribute(model.scope.name)
      end

      protected

      def encryptor
        @encryptor ||= Decidim::Initiatives::DataEncryptor.new(secret: "personal user metadata")
      end

      def metadata
        @metadata ||= model.encrypted_metadata ? encryptor.decrypt(model.encrypted_metadata) : {}
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
decidim-initiatives-0.27.9 app/cells/decidim/initiatives_votes/vote_cell.rb
decidim-initiatives-0.27.8 app/cells/decidim/initiatives_votes/vote_cell.rb
decidim-initiatives-0.27.7 app/cells/decidim/initiatives_votes/vote_cell.rb
decidim-initiatives-0.27.6 app/cells/decidim/initiatives_votes/vote_cell.rb
decidim-initiatives-0.26.10 app/cells/decidim/initiatives_votes/vote_cell.rb
decidim-initiatives-0.26.9 app/cells/decidim/initiatives_votes/vote_cell.rb
decidim-initiatives-0.27.5 app/cells/decidim/initiatives_votes/vote_cell.rb
decidim-initiatives-0.26.8 app/cells/decidim/initiatives_votes/vote_cell.rb
decidim-initiatives-0.27.4 app/cells/decidim/initiatives_votes/vote_cell.rb
decidim-initiatives-0.27.3 app/cells/decidim/initiatives_votes/vote_cell.rb
decidim-initiatives-0.26.7 app/cells/decidim/initiatives_votes/vote_cell.rb
decidim-initiatives-0.26.5 app/cells/decidim/initiatives_votes/vote_cell.rb
decidim-initiatives-0.27.2 app/cells/decidim/initiatives_votes/vote_cell.rb
decidim-initiatives-0.27.1 app/cells/decidim/initiatives_votes/vote_cell.rb
decidim-initiatives-0.26.4 app/cells/decidim/initiatives_votes/vote_cell.rb
decidim-initiatives-0.27.0 app/cells/decidim/initiatives_votes/vote_cell.rb
decidim-initiatives-0.26.3 app/cells/decidim/initiatives_votes/vote_cell.rb
decidim-initiatives-0.27.0.rc2 app/cells/decidim/initiatives_votes/vote_cell.rb
decidim-initiatives-0.27.0.rc1 app/cells/decidim/initiatives_votes/vote_cell.rb
decidim-initiatives-0.26.2 app/cells/decidim/initiatives_votes/vote_cell.rb