remotes/origin/hotix/author_balances_and_access_expire_fix_11-02-19
parent
826352fd3e
commit
f3edc58046
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