mixins.py 984 Bytes
Newer Older
1
2
3
from __future__ import annotations
from typing import Optional
from dataclasses import dataclass
4
5
6
from nm2.lib import assets


7
8
9
10
11
@dataclass
class NavLink:
    url: str
    label: str
    icon: Optional[str] = None
12
    disabled: Optional[bool] = False  # if True, link should be shown as disabled
13
14


15
16
class NM2LayoutMixin(assets.AssetMixin):
    assets = [assets.Bootstrap4, assets.ForkAwesome]
17
18
19
20
21
22
23
24
25
26
27
28
29
30

    def get_person_menu_entries(self):
        return []

    def get_process_menu_entries(self):
        return []

    def get_context_data(self, **kw):
        ctx = super().get_context_data(**kw)
        ctx["navbar"] = {
            "person": self.get_person_menu_entries(),
            "process": self.get_process_menu_entries(),
        }
        return ctx
31
32
33
34
35
36
37
38
39
40


class SignonMixin(NM2LayoutMixin):
    """
    Mixin for signon views
    """
    def get_context_data(self, **kw):
        ctx = super().get_context_data(**kw)
        ctx["base_template"] = "nm2-base.html"
        return ctx