Problem/Motivation

Currently you can only set a poll as active or inactive. However, inactive is not the same as unpublished since in many cases, you still want to be able to view the poll results.

Steps to reproduce

Create a poll and watch how the active flag behaves.

Proposed resolution

  • Add an extra state and update the schema/entity. This should be the one from core entity functionality
  • Update all access handler logic.
  • Add & update tests

Remaining tasks

MR with the points above.

User interface changes

An extra checkbox will be added.

API changes

N/A?

Data model changes

Extra definition in the schema

Original issue summary

It appears that when a poll is closed (i.e. 'active' is unchecked), it is still visible to a plebeian (one that doesn't have an administer poll permission).

I have modified the access handler for Polls to check if the Poll is open and only grant access based on that or the fallback - if they have the administer polls permission.

Issue fork poll-3045110

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

johnsicili created an issue. See original summary.

johnsicili’s picture

Status: Active » Needs review
rasikap’s picture

Assigned: Unassigned » rasikap

This functionality works for me in my project with Drupal version 8.6.16 without applying this patch.

Thanks,
Rasika P

naheemsays’s picture

There will be many times where you want the results of a closed poll to be visible. This probably needs to be an option on a per poll basis and not based on permissions.

nevergone’s picture

Closed poll: visible, but not voteable.

naheemsays’s picture

Status: Needs review » Needs work

The issue of some drupal sites wanting to show the final result is a tricky one that isnt considered in the patch.

Where are you seeing the poll that you dont like?

If it is in a listing, maybe there should be (or is?) a iews option to not list closed polls?

If it is for the poll itself etc, then the options need to consider a lot more - you will often want the result of a closed poll to be visible.

ivnish’s picture

@Berdir, @BramDriesen, what do you think about it?

bramdriesen’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Assigned: rasikap » Unassigned
Category: Bug report » Feature request
Issue tags: +Needs issue summary update

I think it makes more sense to allow a poll to be unpublished similar to a regular entity/node. A closed poll should still be accessible to show the results in many/most cases.

bramdriesen’s picture

Title: Closed Polls Still Visible » Allow a poll to be unpublished
bramdriesen’s picture

Priority: Normal » Major
Issue summary: View changes
Issue tags: -Needs issue summary update
samitk’s picture

Hi @BramDriesen,

The "published" = "status" (entity_keys) is already exists as Active(A flag indicating whether the poll is active.) Field,

this Active filed is used to open or close any poll, I guess we have to introduce new filed for open or close any poll, and will use this field to publish or unpublished any poll.

Please confirm.

Thanks
Samit K.

bramdriesen’s picture

Assigned: Unassigned » bramdriesen
Issue tags: +Barcelona2024

bramdriesen’s picture

Some extra things that came to mind:

- Needs update hook to update all existing polls to copy over the value from what is now published to the new Active field. Probably best to also set "published" to TRUE as default for now. (needs to be a batch!)
- Update view
- Update list builder

bramdriesen’s picture

Status: Needs work » Needs review
Issue tags: +Needs tests

Can already be tested. Only needs to add some tests for this.

ivnish’s picture

Status: Needs review » Needs work

I tested it manually:

1) I created a new poll with anonymous votes. Poll is active and published.
2) Anonymous user can view poll and can vote
3) I set active=false, Anonymous user can view poll and can't vote
4) I set active=true and published=false
5) Anonymous user can't view poll

It works as expected.

But, after I set poll published=false, poll hide from Poll List Builder.

Proposed solution:

1) Allow to view unpublished polls into List Builder
2) We can also add new column "status" as Node List Builder with publishing status

bramdriesen’s picture

The list builder I must admit I did not test yet! Thanks for the manual review :-) really helps

ivnish’s picture

@Bram, do you have time to continue this issue? It looks like 90% ready :)

bramdriesen’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new166.86 KB

Poll list viewer seems to work fine.

Did notice in the listbuilder class that the votes section is not implemented. Will create a follow up issue for that.

ivnish’s picture

Looks like MR needs reroll 🤔

bramdriesen’s picture

Assigned: bramdriesen » Unassigned

All green now :-)

ivnish’s picture

I will test it now :)

bramdriesen’s picture

ivnish’s picture

Existing sites don't have new "status" field in /admin/content/poll, because they have "old" poll admin view. Should we add in hook_update re-import views.view.poll_admin.yml config form poll config/install directory?

bramdriesen’s picture

That has crossed my mind as well. Not sure how to deal with that, as sites might have overwritten the view.

ivnish’s picture

Or we can write about it in release notes

bramdriesen’s picture

I think a change records makes sense. Will draft it here: https://www.drupal.org/node/3479831

bramdriesen’s picture

Done 👆

ivnish’s picture

Status: Needs review » Reviewed & tested by the community

  • bramdriesen committed 8b8709f4 on 2.0.x
    Issue #3045110 by bramdriesen, johnsicili, ivnish: Allow a poll to be...
bramdriesen’s picture

Status: Reviewed & tested by the community » Fixed

Also added the view related info in the CR.

Thanks for your reviews! @ivnish. Thanks to the rest that participated!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.