Blame view

src/scheduler/views.py 1.41 KB
7a1effdd   haribo   scheduler app cre...
1
from django.shortcuts import render
715fabb7   haribo   #3430 (100%)
2
from pyrosapp.models import Sequence, Schedule
94082e77   haribo   Date: 03/06/2016
3
from django.contrib.auth.decorators import login_required
715fabb7   haribo   #3430 (100%)
4
5
6
7
8
from scheduler.simulator import Simulator
from operator import attrgetter

SIMULATION_FILE = 'file:./scheduler/sequences_cador.html'

94082e77   haribo   Date: 03/06/2016
9
@login_required
715fabb7   haribo   #3430 (100%)
10
def current_schedule(request):
7a79e25b   haribo   Date: 19/05/2016
11
12
13
    schedule = Schedule.objects.order_by("-created")[0]
    shs_list = schedule.shs.all()
    sequences = [(shs.sequence, shs) for shs in shs_list]
715fabb7   haribo   #3430 (100%)
14

7a79e25b   haribo   Date: 19/05/2016
15
16
17
    nb_scheduled_sequences = len(shs_list)
    executed_sequences = len([shs for shs in shs_list if shs.status == Sequence.EXECUTED])

715fabb7   haribo   #3430 (100%)
18
19
20
21
22

    return render(request, 'scheduler/current_schedule.html', {'sequences' : sequences, 'schedule' : schedule, 'nb_scheduled_sequences' : nb_scheduled_sequences, 'executed_sequences' : executed_sequences})



94082e77   haribo   Date: 03/06/2016
23
@login_required
715fabb7   haribo   #3430 (100%)
24
25
26
def schedule_simulation(request):
    simulator = Simulator()
    schedule, sequences = simulator.simulate(SIMULATION_FILE)
7a79e25b   haribo   Date: 19/05/2016
27
28
29
30
31
32

    nb_scheduled_sequences = len([sequence for sequence in sequences if sequence[1].status != Sequence.OBSERVABLE])
    executed_sequences = len([sequence for sequence in sequences if sequence[1].status == Sequence.EXECUTED])


    sequences.sort(key=lambda seq: seq[1].tsp)
715fabb7   haribo   #3430 (100%)
33
    return render(request, 'scheduler/current_schedule.html', {'sequences' : sequences, 'schedule' : schedule, 'nb_scheduled_sequences' : nb_scheduled_sequences, 'executed_sequences' : executed_sequences})
7a1effdd   haribo   scheduler app cre...