views.py 1.19 KB
Newer Older
1
from django.shortcuts import render, redirect
2
from django.views.generic import View
3
4
from django.contrib.auth.decorators import login_required
from django.contrib.auth import logout as process_logout
5
6
7
8
from report_api.views import get_degree_information
from degree.models import Degree
from uploads.models import Submission
import json
Odair M.'s avatar
Odair M. committed
9

10
11

@login_required
12
def index(request,degree_id):
13
14
15
16
17
18
19
    degree = Degree.objects.get(code=degree_id)
    if not (degree in request.user.educator.degree.all()):
        return redirect("adega:dashboard")

    degree_data = get_degree_information(request.session,degree)
    return render(request,"degree/index.html",{"degree":degree,"degree_data":degree_data})

20
#class Views(View):
21
#    template_name = "index.html"
22
23
#    @login_required
#    def setDegree(self,request,degree_id):
24
25
#        request.session["degree"] = degree_id
#        return redirect('degree:index' )
26
27
#    def index(self,request):
#        if("degree" in request.session):
28
#            degree = Degree.objects.get(code = request.session["degree"])
29
#        else:
30
#            return redirect("adega:dashboard")
31
#        submission = degree.submission
32
33
#        return render(request,"degree/index",{"degree":degree})
#
34
#