I have a large Django Project that has hundreds of views already. I am creating a tasks
feature where users are able to complete specific tasks associated with the specific application in the project they are using. I have multiple interfaces (aka Django apps in the project) : admin
, management
, onsite
, etc... and each interface has its own navigation with a tasks
link.
What I want is to be able to change the color of this link if a user is in an interface where a task
has yet to be completed.
This is easy to check in each view and then I could universally render the correct color for the link based on a variable passed into the view, but that is extremely tedious with hundreds of views.
I suppose I could add a filter in each interface/Django App to simplify this a bit, but is that the most simple solution?
Here is an example of the method I want to be called in each interface's navigation:
from objects_client.task_models.task_models import Tasks
def does_interface_have_open_tasks(current_interface, db_alias):
if Tasks.objects.using(db_alias)\
.filter(interface=current_interface, completed=0).exists():
return True
return False