Commit e51fd4a8 by Dányi Bence

Merge branch 'master' of ssh://giccero.cloud.ik.bme.hu/cloud

parents 96f1b1e0 8347df83
......@@ -23,6 +23,7 @@ from one.models import *
from school.models import *
import django.contrib.auth as auth
import logging
from django.views.decorators.csrf import ensure_csrf_cookie
logger = logging.getLogger(__name__)
......@@ -30,6 +31,7 @@ def logout(request):
auth.logout(request)
return redirect('/Shibboleth.sso/Logout?return=https%3a%2f%2fcloud.ik.bme.hu%2f')
@ensure_csrf_cookie
def login(request):
try:
user = User.objects.get(username=request.META['niifPersonOrgID'])
......
......@@ -16,6 +16,9 @@ class StoreApi:
# ssl_auth = True
# verify_ssl = False
@staticmethod
def get_host():
return settings['store_host']
@staticmethod
def post_request(url, payload):
headers = {'content-type': 'application/json'}
if settings['ssl_auth'] == 'True' and settings['basic_auth'] == 'True':
......@@ -126,6 +129,14 @@ class StoreApi:
else:
return False
@staticmethod
def requestquota(neptun):
url = settings['store_url']+'/'+neptun
r = StoreApi.get_request(url)
if r.status_code == requests.codes.ok:
return json.loads(r.content)
else:
return False
@staticmethod
def userexist(neptun):
url = settings['store_url']+'/'+neptun
r = StoreApi.get_request(url)
......
......@@ -22,7 +22,8 @@ function postKey(key) {
function (respond) {
alert(respond);
}
);
)
.error(function (respond) { alert(JSON.stringify(respond)); });
}
function resetKey() {
$.post("/store/gui/", "",
......
......@@ -8,7 +8,11 @@
<input type="hidden" name="auth" value="True">
</form>
</td>
<td></td>
<td>
{% for k,v in quota.items %}
{{ k }} : {{ v }}
{% endfor %}
</td>
<td></td>
<td>
<form action="/store/" method="POST"
......
# Create your views here.
from django.core.context_processors import csrf
from django.http import HttpResponse
from django.shortcuts import render_to_response, redirect
from django.template import RequestContext
......@@ -78,7 +79,8 @@ def index(request):
#Normalize path (Need double dirname /folder/ -> /folder -> /
backpath = os.path.normpath(os.path.dirname(os.path.dirname(path)))
file_list = StoreApi.listfolder(user,path)
return render_to_response('store/list.html', RequestContext(request, {'file_list': file_list, 'path' : path, 'backpath' : backpath, 'username' : user}))
quota = StoreApi.requestquota(user)
return render_to_response('store/list.html', RequestContext(request, {'file_list': file_list, 'path' : path, 'backpath' : backpath, 'username' : user, 'quota' : quota}))
@login_required
def ajax_listfolder(request):
......@@ -145,10 +147,11 @@ def toplist(request):
file_list = StoreApi.toplist(user)
return render_to_response('store/list.html', RequestContext(request, {'file_list': file_list, 'path' : path, 'backpath' : backpath, 'username' : user}))
@login_required
def gui(request):
user = request.user.username
if request.method == 'GET':
return render_to_response('store/gui.html', RequestContext(request, {'username' : user, 'host' : '10.9.1.86'}))
return render_to_response('store/gui.html', RequestContext(request, {'username' : user, 'host' : StoreApi.get_host()}))
elif request.method == 'POST':
try:
details = request.user.userclouddetails_set.all()[0]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment