2019-01-19 06:52:00 +00:00
|
|
|
import djconfig
|
2019-01-11 19:16:01 +00:00
|
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
|
|
|
|
|
|
|
|
|
|
class CabinetViewMixin(LoginRequiredMixin):
|
|
|
|
title = 'No title'
|
|
|
|
sidebar_section = None
|
|
|
|
|
2019-01-27 21:20:09 +00:00
|
|
|
def get_sidebar_section(self):
|
|
|
|
return self.sidebar_section
|
|
|
|
|
2019-01-11 19:16:01 +00:00
|
|
|
def get_title(self):
|
|
|
|
return self.title
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
ctx = super(CabinetViewMixin, self).get_context_data(**kwargs)
|
|
|
|
ctx['title'] = self.get_title()
|
2019-01-27 21:20:09 +00:00
|
|
|
ctx['sidebar_section'] = self.get_sidebar_section()
|
2019-01-11 19:16:01 +00:00
|
|
|
return ctx
|
2019-01-19 06:52:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
def cabinet_context_processor(ctx):
|
|
|
|
return {
|
|
|
|
'admin_configs': {form.slug: form.title for form in djconfig.config._registry},
|
|
|
|
}
|