|
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
import json |
|
|
|
|
import hashlib |
|
|
|
|
|
|
|
|
|
from django.shortcuts import render, redirect |
|
|
|
|
@ -56,7 +57,7 @@ def license_list(request): |
|
|
|
|
"""Список счетов на лицензии |
|
|
|
|
""" |
|
|
|
|
template_name = 'customer/profile/license_list.html' |
|
|
|
|
licenses = License.objects.filter(user=request.user).order_by('-id') |
|
|
|
|
licenses = License.objects.filter(user=request.user, deleted=False).order_by('-id') |
|
|
|
|
dictionary = { |
|
|
|
|
'licenses': licenses, |
|
|
|
|
} |
|
|
|
|
@ -68,7 +69,8 @@ def paid_list(request): |
|
|
|
|
"""Оплаченные лицензии |
|
|
|
|
""" |
|
|
|
|
template_name = 'customer/profile/paid_list.html' |
|
|
|
|
licenses = License.objects.filter(user=request.user, status__in=[-1, 1, 2, 3]).order_by('-id') |
|
|
|
|
licenses = License.objects.filter(user=request.user, |
|
|
|
|
status__in=[-1, 1, 2, 3], deleted=False).order_by('-id') |
|
|
|
|
dictionary = { |
|
|
|
|
'licenses': licenses, |
|
|
|
|
} |
|
|
|
|
@ -77,13 +79,20 @@ def paid_list(request): |
|
|
|
|
|
|
|
|
|
@login_required |
|
|
|
|
def delete_license(request, pk): |
|
|
|
|
template_name = 'customer/profile/delete_license.html' |
|
|
|
|
if not request.is_ajax(): |
|
|
|
|
return HttpResponseBadRequest() |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
license = License.objects.get(pk=pk) |
|
|
|
|
license = License.objects.get(pk=pk, status=0, user=request.user) |
|
|
|
|
if request.method == 'POST': |
|
|
|
|
license.deleted = True |
|
|
|
|
license.save() |
|
|
|
|
dictionary = {'res': 'Ok', 'id': pk} |
|
|
|
|
except: |
|
|
|
|
raise Http404 |
|
|
|
|
dictionary = {'license': license} |
|
|
|
|
return render(request, template_name, dictionary) |
|
|
|
|
dictionary = {'res': 'fail'} |
|
|
|
|
|
|
|
|
|
data = json.dumps(dictionary) |
|
|
|
|
return HttpResponse(data, mimetype='application/json') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@csrf_exempt |
|
|
|
|
|