|
|
@ -5,8 +5,9 @@ from django.contrib.auth import authenticate, login, logout |
|
|
|
from django.contrib.auth.models import User |
|
|
|
from django.contrib.auth.models import User |
|
|
|
from django.contrib import messages |
|
|
|
from django.contrib import messages |
|
|
|
from quiz.models import Answer |
|
|
|
from quiz.models import Answer |
|
|
|
import oauth2 as oauth, cgi, json |
|
|
|
import oauth2 as oauth, cgi, json, git, os, signal |
|
|
|
import securityquiz.secrets as secrets |
|
|
|
import securityquiz.secrets as secrets |
|
|
|
|
|
|
|
import securityquiz.settings as settings |
|
|
|
|
|
|
|
|
|
|
|
AVANS_KEY = secrets.AVANS_KEY |
|
|
|
AVANS_KEY = secrets.AVANS_KEY |
|
|
|
AVANS_SECRET = secrets.AVANS_SECRET |
|
|
|
AVANS_SECRET = secrets.AVANS_SECRET |
|
|
@ -62,6 +63,19 @@ def avans_logout(request): |
|
|
|
logout(request) |
|
|
|
logout(request) |
|
|
|
return HttpResponse('Je bent nu uitgelogd... <a href="/">Opnieuw inloggen</a>') |
|
|
|
return HttpResponse('Je bent nu uitgelogd... <a href="/">Opnieuw inloggen</a>') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def pull(request): |
|
|
|
|
|
|
|
if request.method == 'POST': |
|
|
|
|
|
|
|
g = git.cmd.Git(settings.PROJECT_PATH) |
|
|
|
|
|
|
|
output = str(g.pull()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Reload source code |
|
|
|
|
|
|
|
os.kill(os.getpid(), signal.SIGINT) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return HttpResponse(output) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
return HttpResponseRedirect('/') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def home(request): |
|
|
|
def home(request): |
|
|
|
if not request.user.is_authenticated(): |
|
|
|
if not request.user.is_authenticated(): |
|
|
|
return avans_login(request) |
|
|
|
return avans_login(request) |
|
|
@ -81,4 +95,4 @@ def home(request): |
|
|
|
for answer in answers: |
|
|
|
for answer in answers: |
|
|
|
answers_dict[answer.question] = answer.string |
|
|
|
answers_dict[answer.question] = answer.string |
|
|
|
|
|
|
|
|
|
|
|
return render(request, 'index.html', {'answers': answers_dict}) |
|
|
|
return render(request, 'index.html', {'answers': answers_dict}) |
|
|
|