Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Soft delete for disapproved posts. #246

Open
snehlata08 opened this issue Aug 27, 2021 · 3 comments
Open

Soft delete for disapproved posts. #246

snehlata08 opened this issue Aug 27, 2021 · 3 comments
Labels

Comments

@snehlata08
Copy link

snehlata08 commented Aug 27, 2021

Currently the posts/topics which are disapproved gets deleted straight away from the database. I request a feature where the posts are not deleted for certain days(for eg. 15 days) so that they can be reviewed and re-posted.
@ellmetha

@rg2609
Copy link

rg2609 commented Aug 27, 2021

  • Post submissions will enter a review queue and be accepted or rejected by the Forum admins within x days. The # of days can be configurable or hard-coded.

  • Rejections will be accompanied by feedback. Submissions do not appear until they are approved.

@rg2609
Copy link

rg2609 commented Aug 27, 2021

@ellmetha, Most required feature, we also want this feature to be added

@BoPeng
Copy link
Contributor

BoPeng commented Apr 23, 2022

I have implemented this, but for a private project. Essentially, what we did was

  1. Overriding the field approved to a tri-status field
    approved = models.BooleanField(
        null=True, default=None, db_index=True, verbose_name='Approved')

by extending Topic and Post.

  1. Change the model and view querysets by adding the logics such as exclude(approved=False)and
        if self.request.user.is_authenticated and not self.request.user.is_staff:
            cond = Q(approved=False) & ~Q(poster=self.request.user)
        else:
            cond = Q(approved=False)
        return Post.objects.exclude(cond)

so that the deleted posts will still be seen by their own authors.

  1. Then we changed the delete logic to something like
def delete(self, *args, **kwargs):
    if self.approved is False:
        super().delete(*args, **kwargs)
    else:
        self.approved = False
        self.save(update_fields=['approved'])
  1. In the templates, the approved=None, approved=True, and approved=False posts are displayed differently. Right now we make all None and True posts public, and False only visible to their posters.

I am sure that I am allowed to make the relevant changes public but I am not sure if @ellmetha welcome such a PR. I can image a flag is needed (TRI_STATE_APPROVAL_STATUS?) to keep backward compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants