-
Notifications
You must be signed in to change notification settings - Fork 9
/
views.py
54 lines (42 loc) · 1.43 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""
Workflows views
"""
import logging
from django.shortcuts import render
from django.views.generic import ListView
from .helpers import get_flaw_or_404
from .models import Workflow
from .serializers import ClassificationWorkflowSerializer, WorkflowSerializer
from .workflow import WorkflowFramework
logger = logging.getLogger(__name__)
class workflows(ListView):
"""graph workflow view"""
model = Workflow
template_name = "graph.html"
def get(self, request, *args, **kwargs):
"""HTTP get graph/workflows"""
logger.info("getting workflow graphs")
context = {
"workflows": WorkflowSerializer(
WorkflowFramework().workflows,
many=True,
).data,
}
return render(request, "graph.html", context)
class classification(ListView):
"""graph workflow view with flaw classification"""
model = Workflow
template_name = "graph.html"
def get(self, request, *args, **kwargs):
"""HTTP get graph/workflows/<str:pk>"""
pk = kwargs["pk"]
logger.info(f"getting workflow graphs with flaw {pk} classification")
flaw = get_flaw_or_404(pk)
context = {
"workflows": ClassificationWorkflowSerializer(
WorkflowFramework().workflows,
context={"flaw": flaw},
many=True,
).data,
}
return render(request, "graph.html", context)