отрицательные балансы у преподавателей See merge request lilschool/site!266remotes/origin/hotfix/categories_api_12-02-19
commit
8f09ae8c57
4 changed files with 57 additions and 34 deletions
@ -0,0 +1,25 @@ |
|||||||
|
from datetime import timedelta |
||||||
|
|
||||||
|
from django.core.management.base import BaseCommand |
||||||
|
|
||||||
|
from apps.payment.models import CoursePayment |
||||||
|
from apps.course.models import Course |
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand): |
||||||
|
help = 'Fix access duration in all paid courses' |
||||||
|
|
||||||
|
def add_arguments(self, parser): |
||||||
|
parser.add_argument('access_duration', type=int, help='New access duration',) |
||||||
|
|
||||||
|
def handle(self, *args, **options): |
||||||
|
access_duration = options.get('access_duration') |
||||||
|
for course in Course.objects.filter(price__gt=0): |
||||||
|
course.access_duration = access_duration |
||||||
|
course.save() |
||||||
|
|
||||||
|
for payment in CoursePayment.objects.filter(status__in=CoursePayment.PW_PAID_STATUSES): |
||||||
|
payment.access_expire = payment.created_at.date() + timedelta(days=payment.course.access_duration) |
||||||
|
payment.save() |
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in new issue