license: added set_paid method

remotes/origin/license
Andrey 9 years ago
parent 277bf17448
commit 1932781bea
  1. 10
      project/customer/models.py
  2. 6
      project/yandex_money/views.py

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import os
from datetime import datetime, timedelta from datetime import datetime, timedelta, date
from PIL import Image from PIL import Image
from pytils import numeral from pytils import numeral
@ -11,10 +11,11 @@ from django.conf import settings
from django.db.models import Max from django.db.models import Max
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from . import consts, managers, utils
from project.myauth.models import DokUser from project.myauth.models import DokUser
from project.commons.utils import only_numerics from project.commons.utils import only_numerics
from . import consts, managers, utils
PROFILE_IMAGES_UPLOAD_DIR = 'customer/profile/' # куда сохранять загруженные изображения PROFILE_IMAGES_UPLOAD_DIR = 'customer/profile/' # куда сохранять загруженные изображения
BOSS_SIGN_IMG_SIZE = (159, 65) BOSS_SIGN_IMG_SIZE = (159, 65)
@ -463,6 +464,10 @@ class License(models.Model):
super(License, self).save(*args, **kwargs) super(License, self).save(*args, **kwargs)
def set_paid(self, paid_date=None):
self.paid_date = paid_date or date.today()
self.status = consts.LICENSE_PAID
def get_company(self): def get_company(self):
return self.company.get_company_name() return self.company.get_company_name()
@ -527,4 +532,3 @@ class LicensePrice(models.Model):
self.price, self.price,
numeral.choose_plural(self.price, u"рубль, рубля, рублей"), numeral.choose_plural(self.price, u"рубль, рубля, рублей"),
) )

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import logging import logging
from datetime import datetime, date from datetime import datetime
from django.http import HttpResponse from django.http import HttpResponse
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
@ -16,7 +16,6 @@ from .forms import NoticeForm
from .models import Payment from .models import Payment
from project.customer.models import License from project.customer.models import License
from project.customer import consts
logger = logging.getLogger('yandex_money') logger = logging.getLogger('yandex_money')
@ -148,6 +147,5 @@ class NoticeFormView(BaseView):
payment.status = payment.STATUS.SUCCESS payment.status = payment.STATUS.SUCCESS
payment.save() payment.save()
license = License.objects.get(id=payment.order_number) license = License.objects.get(id=payment.order_number)
license.paid_date = date.today() license.set_paid()
license.status = consts.LICENSE_PAID
license.save() license.save()

Loading…
Cancel
Save