logs-collector/logs_collector/collector/utils/mixins.py

24 lines
656 B
Python
Raw Permalink Normal View History

class ExtraContextMixin:
"""The class adds additional context
to all child view classes that inherit from it.
Overrides the get_context_data method for CBV
"""
title = 'Collector'
def get_title(self, *args, **kwargs):
"""
Return the class title attr by default,
but you can override this method to further customize
"""
return self.title
def get_context_data(self, **kwargs):
context = {}
try:
context = super().get_context_data(**kwargs)
except Exception:
pass
context['title'] = self.get_title()
return context