Conversation
Codecov Report
@@ Coverage Diff @@
## master #2604 +/- ##
==========================================
+ Coverage 98.84% 98.85% +0.01%
==========================================
Files 1504 1531 +27
Lines 35293 35987 +694
==========================================
+ Hits 34884 35575 +691
- Misses 409 412 +3 |
832e2f1 to
1eab324
Compare
ea8bb1f to
dc80397
Compare
| <p><%= t ".welcome" %></p> | ||
| <div class="row"> | ||
| <ul> | ||
| <% Decidim::ActionLog.order(id: :desc).first(20).each do |log| %> |
There was a problem hiding this comment.
Shouldn't we order by date?
| optional: true, | ||
| polymorphic: true | ||
|
|
||
| validates :organization, :user, :action, :resource, presence: true |
There was a problem hiding this comment.
Should we also validate the the organization of all associations is the same?
There was a problem hiding this comment.
This is automatically done by the system
| end | ||
|
|
||
| def participatory_space | ||
| resource.participatory_space if resource.respond_to?(:participatory_space) |
There was a problem hiding this comment.
Do all resource delegate the participatory space to the feature?
If not, maybe you can try to get it from the feature too
e34a382 to
f506ae1
Compare
| # | ||
| # Returns a String. | ||
| def action_string | ||
| case action |
There was a problem hiding this comment.
Add .to_s to prevent possible errors when comparing against Nil or if someone returns a symbol? (yay types!)
| resource.participatory_space if resource.respond_to?(:participatory_space) | ||
| end | ||
|
|
||
| def get_title(resource) |
decidim-core/config/locales/en.yml
Outdated
| remove_this_file: Remove this file | ||
| log: | ||
| base_presenter: | ||
| create: "%{user_name} created %{result_name} in %{space_name}" |
| organization: organization || build(:organization) | ||
| ) | ||
| end | ||
| participatory_space { build :participatory_process, organization: organization || build(:organization) } |
There was a problem hiding this comment.
Maybe you should get the organization from the user
docs/activity_log.md
Outdated
| 3. Create a `Presenter` for your model for the log you need. Presenters should be named as `Decidim::<your module name>::<log name>::<your model name>Presenter`. There's currently only one log, `AdminLog`. This means that if your model is `Decidim::Accountability::Result`, then your admin log presenter is must be `Decidim::Accountability::AdminLog::ResultPresenter` | ||
|
|
||
| ## Multiple logs | ||
| Alhotugh Decidim currently only has a log for the admin section, in the future we might need an activity log for the public part. It's easy to assume we might need to render the same data in different formats, so we need to differentiate the presenters for each log. The current system handles the case for multiple logs, although we only have one. No newline at end of file |
docs/activity_log.md
Outdated
|
|
||
| In order to make your component compatible with the activity log, you need to follow these steps: | ||
|
|
||
| 1. Make your model include the `Decidim::Traceable` module. This will enable Decidim to create versions every time your model records are changed. It uses [`paper_trail`](https://github.com/airblade/paper_trail) to generate the versions. |
There was a problem hiding this comment.
Is this really mandatory or recommended?
There was a problem hiding this comment.
It will be needed because the Product team wants to see all changes in all fields when the user updates a resource. For this, the best way is to have paper_trail included though the Traceable module
There was a problem hiding this comment.
Then maybe we need some kind of validation?
There was a problem hiding this comment.
Done, logs are not saved if the resource is not traceable.
| 1. Make your model include the `Decidim::Traceable` module. This will enable Decidim to create versions every time your model records are changed. It uses [`paper_trail`](https://github.com/airblade/paper_trail) to generate the versions. | ||
| 2. Make your commands use `Decidim.traceability` to create and update records. Documentation can be found in `Decidim::Traceability`. This should properly set the author of the change in your record. | ||
| 3. Create a `Presenter` for your model for the log you need. Presenters should be named as `Decidim::<your module name>::<log name>::<your model name>Presenter`. There's currently only one log, `AdminLog`. This means that if your model is `Decidim::Accountability::Result`, then your admin log presenter is must be `Decidim::Accountability::AdminLog::ResultPresenter` | ||
|
|
There was a problem hiding this comment.
An example would be nice.
f6a5c02 to
c6f5915
Compare
182ecf4 to
9581f66
Compare
f0543c3 to
c13d54f
Compare
🎩 What? Why?
See #2603 for reference.
This PR intends to add a log of all actions performed by admins. It will only be visible by organization admins.
In a first iteration of this, I will only log actions on accountability results, since they are already versioned and it's simpler to start. This way I can test the whole feature, work on it, and later improve it when logging actions from other modules.
Note that this is not the MVP, this adds the codebase so the MVP can be added.
📌 Related Issues
📋 Subtasks
ActionLogclassActionLogsDecidim.traceabilityservice log all actionsCHANGELOGentry📷 Screenshots (optional)
The admin dashboard shows the last 20 logs:

The logs section shows all logs, paginated (20 per page):
