Commit 12f1ec8e authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

Merge branch 'latest-quota' of https://code.grnet.gr/git/synnefo into latest-quota

parents 41485327 f3d6202e
......@@ -109,6 +109,7 @@ def authenticate_old(request, user=None):
user_info = {
'id': user.id,
'username': user.username,
'uuid': user.uuid,
'uniq': user.email,
'auth_token': user.auth_token,
'auth_token_created': user.auth_token_created.isoformat(),
......@@ -147,6 +148,7 @@ def authenticate(request, user=None):
user_info = {
'id': user.id,
'userid': user.username,
'uuid': user.uuid,
'email': [user.email],
'name': user.realname,
'auth_token': user.auth_token,
......
......@@ -76,7 +76,7 @@ def call(func_name):
if not QUOTAHOLDER_URL:
return ()
c = get_client()
c = get_client()
func = c.__dict__.get(func_name)
if not func:
return ()
......@@ -108,7 +108,7 @@ def send_quota(users):
export_limit = None
flags = 0
args = (
user.id, resource, key, quantity, capacity, import_limit,
user.uuid, resource, key, quantity, capacity, import_limit,
export_limit, flags)
append(args)
return data
......@@ -194,7 +194,7 @@ def get_quota(users):
append = data.append
for user in users:
try:
entity = user.id
entity = user.uuid
except AttributeError:
continue
else:
......@@ -223,7 +223,7 @@ def create_entities(entities, field=''):
def register_users(users):
users, copy = itertools.tee(users)
rejected = create_entities(entities=users, field='id')
rejected = create_entities(entities=users, field='uuid')
created = (e for e in copy if unicode(e) not in rejected)
return send_quota(created)
......
......@@ -1228,17 +1228,26 @@ def project_detail(request, application_id):
if form.is_valid():
sorting = form.cleaned_data.get('sorting')
return object_detail(
request,
queryset=ProjectApplication.objects.select_related(),
object_id=application_id,
template_name='im/projects/project_detail.html',
extra_context={
'resource_catalog':resource_catalog,
'sorting':sorting,
'addmembers_form':addmembers_form
}
)
rollback = False
try:
return object_detail(
request,
queryset=ProjectApplication.objects.select_related(),
object_id=application_id,
template_name='im/projects/project_detail.html',
extra_context={
'resource_catalog':resource_catalog,
'sorting':sorting,
'addmembers_form':addmembers_form
}
)
except:
rollback = True
finally:
if rollback == True:
transaction.rollback()
else:
transaction.commit()
@require_http_methods(["GET", "POST"])
@signed_terms_required
......@@ -1320,14 +1329,11 @@ def project_join(request, application_id):
logger.exception(e)
messages.error(request, _(astakos_messages.GENERIC_ERROR))
rollback = True
else:
return project_detail(request, application_id)
finally:
if rollback:
transaction.rollback()
else:
transaction.commit()
next = restrict_next(next, domain=COOKIE_DOMAIN)
return redirect(next)
......
......@@ -31,6 +31,8 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
import logging
from time import time, mktime
from urlparse import urlparse
from urllib import quote, unquote
......@@ -40,6 +42,7 @@ from django.utils import simplejson as json
from synnefo.lib.pool.http import get_http_connection
logger = logging.getLogger(__name__)
def authenticate(token, authentication_url='http://127.0.0.1:8000/im/authenticate'):
p = urlparse(authentication_url)
......@@ -63,7 +66,7 @@ def authenticate(token, authentication_url='http://127.0.0.1:8000/im/authenticat
if status < 200 or status >= 300:
raise Exception(data, status)
return json.loads(data)
def user_for_token(token, authentication_url, override_users):
......@@ -95,10 +98,15 @@ def get_user(request, authentication_url='http://127.0.0.1:8000/im/authenticate'
if not user:
user = user_for_token(fallback_token, authentication_url, override_users)
if not user:
logger.warning("Cannot retrieve user details from %s",
authentication_url)
return
# use user uuid, instead of email, keep email/username reference to user_id
request.user_uniq = user['uuid']
request.user = user
request.user_uniq = user['uniq']
request.user_id = user['username']
return user
def get_token_from_cookie(request, cookiename):
......
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 to comment