Commit 46b08a57 authored by Olga Brani's avatar Olga Brani
Browse files

:Merge branch '0.6.4' of https://code.grnet.gr/git/astakos into 0.6.4

Conflicts:
	snf-astakos-app/astakos/im/templates/im/billing.html
	snf-astakos-app/astakos/im/templatetags/filters.py
	snf-astakos-app/astakos/im/views.py
parents dc6b3698 314a48e0
......@@ -98,4 +98,4 @@ def month_name(month_number):
@register.filter
def todate(value, arg = ''):
secs = int(value) / 1000
return datetime.datetime.fromtimestamp(secs)
\ No newline at end of file
return datetime.datetime.fromtimestamp(secs)
......@@ -53,8 +53,7 @@ from django.template import RequestContext, loader
from django.utils.http import urlencode
from django.utils.translation import ugettext as _
from django.views.generic.create_update import (create_object, delete_object,
get_model_and_form_class
)
get_model_and_form_class)
from django.views.generic.list_detail import object_list, object_detail
from django.http import HttpResponseBadRequest
......@@ -845,34 +844,32 @@ def group_leave(request, group_id):
)
def handle_membership():
def decorator(func):
@wraps(func)
def wrapper(request, group_id, user_id):
try:
m = Membership.objects.select_related().get(
group__id=group_id,
person__id=user_id
)
except Membership.DoesNotExist:
return HttpResponseBadRequest(_('Invalid membership.'))
else:
if request.user not in m.group.owner.all():
return HttpResponseForbidden(_('User is not a group owner.'))
func(request, m)
return render_response(
template='im/astakosgroup_detail.html',
context_instance=get_context(request),
object=m.group,
quota=m.group.quota
)
return wrapper
return decorator
def handle_membership(func):
@wraps(func)
def wrapper(request, group_id, user_id):
try:
m = Membership.objects.select_related().get(
group__id=group_id,
person__id=user_id
)
except Membership.DoesNotExist:
return HttpResponseBadRequest(_('Invalid membership.'))
else:
if request.user not in m.group.owner.all():
return HttpResponseForbidden(_('User is not a group owner.'))
func(request, m)
return render_response(
template='im/astakosgroup_detail.html',
context_instance=get_context(request),
object=m.group,
quota=m.group.quota
)
return wrapper
@signed_terms_required
@login_required
@handle_membership()
@handle_membership
def approve_member(request, membership):
try:
membership.approve()
......@@ -887,7 +884,7 @@ def approve_member(request, membership):
@signed_terms_required
@login_required
@handle_membership()
@handle_membership
def disapprove_member(request, membership):
try:
membership.disapprove()
......@@ -1001,4 +998,4 @@ def clear_billing_data(data):
data['bill_vmtime'] = filter(servicefilter('vmtime'), data['bill'])
data['bill_diskspace'] = filter(servicefilter('diskspace'), data['bill'])
return data
\ No newline at end of file
return data
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