Class: Decidim::Log::BasePresenter

Inherits:
Object
  • Object
show all
Defined in:
decidim-core/app/presenters/decidim/log/base_presenter.rb

Overview

This class holds the logic to present a resource for any activity log. It is supposed to be a base class for all other log renderers, as it defines some helpful methods that later presenters can use.

Most presenters that inherit from this class will only need to overwrite the ‘action_string` method, which defines what I18n key will be used for each action. Other methods that might be interesting to overwrite are those named `present_*`. Check the source code and the method docs to see how they work.

See ‘Decidim::ActionLog#render_log` for more info on the log types and presenters.

Usage should be automatic and you should not need to call this class directly, but here is an example:

action_log = Decidim::ActionLog.last
view_helpers # => this comes from the views
BasePresenter.new(action_log, view_helpers).present

Direct Known Subclasses

Accountability::AdminLog::ResultPresenter, Accountability::AdminLog::StatusPresenter, Accountability::AdminLog::TimelineEntryPresenter, AdminLog::AreaPresenter, AdminLog::AreaTypePresenter, AdminLog::AttachmentCollectionPresenter, AdminLog::AttachmentPresenter, AdminLog::CategoryPresenter, AdminLog::ComponentPresenter, AdminLog::ContextualHelpSectionPresenter, AdminLog::ImpersonationLogPresenter, AdminLog::ModerationPresenter, AdminLog::NewsletterPresenter, AdminLog::OAuthApplicationPresenter, AdminLog::OrganizationPresenter, AdminLog::ParticipatorySpacePrivateUserPresenter, AdminLog::ScopePresenter, AdminLog::ScopeTypePresenter, AdminLog::StaticPagePresenter, AdminLog::UserGroupPresenter, AdminLog::UserModerationPresenter, AdminLog::UserPresenter, Assemblies::AdminLog::AssembliesSettingPresenter, Assemblies::AdminLog::AssembliesTypePresenter, Assemblies::AdminLog::AssemblyMemberPresenter, Assemblies::AdminLog::AssemblyPresenter, Assemblies::AdminLog::AssemblyUserRolePresenter, Blogs::AdminLog::PostPresenter, Budgets::AdminLog::BudgetPresenter, Budgets::AdminLog::ProjectPresenter, Conferences::AdminLog::ConferenceInvitePresenter, Conferences::AdminLog::ConferencePresenter, Conferences::AdminLog::ConferenceRegistrationPresenter, Conferences::AdminLog::ConferenceSpeakerPresenter, Conferences::AdminLog::ConferenceUserRolePresenter, Conferences::AdminLog::MediaLinkPresenter, Conferences::AdminLog::PartnerPresenter, Conferences::AdminLog::RegistrationTypePresenter, Debates::AdminLog::DebatePresenter, Elections::AdminLog::ElectionPresenter, Elections::AdminLog::TrusteePresenter, Forms::AdminLog::QuestionnairePresenter, Initiatives::AdminLog::InitiativePresenter, Initiatives::AdminLog::InitiativesSettingsPresenter, Initiatives::AdminLog::InitiativesTypePresenter, Meetings::AdminLog::InvitePresenter, Meetings::AdminLog::MeetingPresenter, Meetings::AdminLog::QuestionnairePresenter, Pages::AdminLog::PagePresenter, ParticipatoryProcesses::AdminLog::ParticipatoryProcessGroupPresenter, ParticipatoryProcesses::AdminLog::ParticipatoryProcessPresenter, ParticipatoryProcesses::AdminLog::ParticipatoryProcessTypePresenter, ParticipatoryProcesses::AdminLog::ParticipatoryProcessUserRolePresenter, ParticipatoryProcesses::AdminLog::StepPresenter, Proposals::AdminLog::ProposalNotePresenter, Proposals::AdminLog::ProposalPresenter, Proposals::AdminLog::ValuationAssignmentPresenter, Sortitions::AdminLog::SortitionPresenter, Templates::AdminLog::TemplatePresenter, Votings::AdminLog::BallotStylePresenter, Votings::AdminLog::MonitoringCommitteeMemberPresenter, Votings::AdminLog::PollingOfficerPresenter, Votings::AdminLog::PollingStationPresenter, Votings::AdminLog::VotingPresenter, Votings::Census::AdminLog::DatasetPresenter

Instance Method Summary collapse

Constructor Details

#initialize(action_log, view_helpers) ⇒ BasePresenter

Public: Initializes the presenter.

action_log - An instance of Decidim::ActionLog view_helpers - An object holding the view helpers at the render time.

Most probably should come automatically from the views.


30
31
32
33
# File 'decidim-core/app/presenters/decidim/log/base_presenter.rb', line 30

def initialize(action_log, view_helpers)
  @action_log = action_log
  @view_helpers = view_helpers
end

Instance Method Details

#presentObject

Public: Renders the given ‘action_log`.

action_log - An instance of Decidim::ActionLog.last view_helpers - An object holding the view helpers at the render time.

Most probably should come automatically from the views.

Returns an HTML-safe String.



42
43
44
# File 'decidim-core/app/presenters/decidim/log/base_presenter.rb', line 42

def present
  present_action_log
end