Refactor the filter_for_list method into multiple model manager methods

NEW
Unassigned

Status

Mozilla Developer Network
General
3 years ago
3 years ago

People

(Reporter: jezdez, Unassigned)

Tracking

Details

(Whiteboard: [specification][type:change])

(Reporter)

Description

3 years ago
What feature should be changed? Please provide the URL of the feature if possible.
==================================================================================
This is proposed by :jezdez in pull #2166 (https://github.com/mozilla/kuma/pull/2166):
"This is slowly becoming a kitchen sink and harder to test. Please open a Github issue to refactor the filter_for_list method into multiple model manager methods (e.g. with_errors, without_parents etc)."

I would love to learn more about this. Some newbie thoughts and questions (jumping into cold water, be patient with me):

1) The exclude slugs ("User:", "Talk:") should be synced with the ones we use in the search. How to DRY?
2) No idea about Managers. But looking at the code: Should there be a DocumentListingManager and the filter_for_list should be removed from the BaseDocumentManager?
3) Maybe similar to the DeletedDocumentManager ? Does that manager then offer the methods that are called from the view?

class DocumentListingManager(BaseDocumentManager):
    def get_query_set(self):
        return super(DocumentListingManager, self).get_query_set()
        .filter() // filtering for standard excludes etc...

    def with_errors() // return the error docs

4) Seems like all these views could need tests. Looking at the test files I feel a bit lost. Tips or entry points?

What problems would this solve?
===============================
Fix code smell

Who would use this?
===================
n/a

What would users see?
=====================
n/a

What would users do? What would happen as a result?
===================================================
n/a

Is there anything else we should know?
======================================
You need to log in before you can comment on or make changes to this bug.