Revision c7b82fdc snf-astakos-app/astakos/im/views.py

b/snf-astakos-app/astakos/im/views.py
91 91
    SendNotificationError,
92 92
    accept_membership, reject_membership, remove_membership,
93 93
    leave_project, join_project, enroll_member)
94
# from astakos.im.endpoints.qh import timeline_charge
95 94
from astakos.im.settings import (
96 95
    COOKIE_DOMAIN, LOGOUT_NEXT,
97 96
    LOGGING_LEVEL, PAGINATE_BY,
98 97
    RESOURCES_PRESENTATION_DATA, PAGINATE_BY_ALL,
99 98
    MODERATION_ENABLED)
100 99
from astakos.im import settings as astakos_settings
101
#from astakos.im.tasks import request_billing
102 100
from astakos.im.api.callpoint import AstakosCallpoint
103 101
from astakos.im import auth_providers
104 102
from astakos.im.templatetags.filters import ResourcePresentation
......
843 841
                           resource_usage=backenddata,
844 842
                           result=result)
845 843

  
846

  
847
##@require_http_methods(["GET"])
848
#@require_http_methods(["POST", "GET"])
849
#@signed_terms_required
850
#@login_required
851
#def billing(request):
852
#
853
#    today = datetime.today()
854
#    month_last_day = calendar.monthrange(today.year, today.month)[1]
855
#    start = request.POST.get('datefrom', None)
856
#    if start:
857
#        today = datetime.fromtimestamp(int(start))
858
#        month_last_day = calendar.monthrange(today.year, today.month)[1]
859
#
860
#    start = datetime(today.year, today.month, 1).strftime("%s")
861
#    end = datetime(today.year, today.month, month_last_day).strftime("%s")
862
#    r = request_billing.apply(args=('pgerakios@grnet.gr',
863
#                                    int(start) * 1000,
864
#                                    int(end) * 1000))
865
#    data = {}
866
#
867
#    try:
868
#        status, data = r.result
869
#        data = _clear_billing_data(data)
870
#        if status != 200:
871
#            messages.error(request, _(astakos_messages.BILLING_ERROR) % status)
872
#    except:
873
#        messages.error(request, r.result)
874
#
875
#    return render_response(
876
#        template='im/billing.html',
877
#        context_instance=get_context(request),
878
#        data=data,
879
#        zerodate=datetime(month=1, year=1970, day=1),
880
#        today=today,
881
#        start=int(start),
882
#        month_last_day=month_last_day)
883

  
884

  
885
#def _clear_billing_data(data):
886
#
887
#    # remove addcredits entries
888
#    def isnotcredit(e):
889
#        return e['serviceName'] != "addcredits"
890
#
891
#    # separate services
892
#    def servicefilter(service_name):
893
#        service = service_name
894
#
895
#        def fltr(e):
896
#            return e['serviceName'] == service
897
#        return fltr
898
#
899
#    data['bill_nocredits'] = filter(isnotcredit, data['bill'])
900
#    data['bill_vmtime'] = filter(servicefilter('vmtime'), data['bill'])
901
#    data['bill_diskspace'] = filter(servicefilter('diskspace'), data['bill'])
902
#    data['bill_addcredits'] = filter(servicefilter('addcredits'), data['bill'])
903
#
904
#    return data
905

  
906

  
907
# #@require_http_methods(["GET"])
908
# @require_http_methods(["POST", "GET"])
909
# @signed_terms_required
910
# @login_required
911
# def timeline(request):
912
# #    data = {'entity':request.user.email}
913
#     timeline_body = ()
914
#     timeline_header = ()
915
# #    form = TimelineForm(data)
916
#     form = TimelineForm()
917
#     if request.method == 'POST':
918
#         data = request.POST
919
#         form = TimelineForm(data)
920
#         if form.is_valid():
921
#             data = form.cleaned_data
922
#             timeline_header = ('entity', 'resource',
923
#                                'event name', 'event date',
924
#                                'incremental cost', 'total cost')
925
#             timeline_body = timeline_charge(
926
#                 data['entity'], data['resource'],
927
#                 data['start_date'], data['end_date'],
928
#                 data['details'], data['operation'])
929
#
930
#     return render_response(template='im/timeline.html',
931
#                            context_instance=get_context(request),
932
#                            form=form,
933
#                            timeline_header=timeline_header,
934
#                            timeline_body=timeline_body)
935
#     return data
936

  
937

  
938 844
# TODO: action only on POST and user should confirm the removal
939 845
@require_http_methods(["GET", "POST"])
940 846
@login_required

Also available in: Unified diff