parent
68e7aa0257
commit
8bc648feaa
8 changed files with 145 additions and 16 deletions
@ -0,0 +1,42 @@ |
|||||||
|
import csv |
||||||
|
import jwt |
||||||
|
from django.conf import settings |
||||||
|
from django.core.management.base import BaseCommand |
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand): |
||||||
|
help = 'Добавляет 1 или нескольких юзеров в указанные группы' |
||||||
|
|
||||||
|
def add_arguments(self, parser): |
||||||
|
parser.add_argument( |
||||||
|
'--from', |
||||||
|
type=str, |
||||||
|
dest='from', |
||||||
|
help='Файл подгрузки данных' |
||||||
|
) |
||||||
|
parser.add_argument( |
||||||
|
'--to', |
||||||
|
type=str, |
||||||
|
dest='to', |
||||||
|
help='Файл выгрузки' |
||||||
|
) |
||||||
|
|
||||||
|
def handle(self, *args, **options): |
||||||
|
from_path = options['from'] |
||||||
|
to_path = options['to'] |
||||||
|
with open(from_path) as f: |
||||||
|
with open(to_path, 'w') as out_f: |
||||||
|
fw = csv.writer(out_f) |
||||||
|
fr = csv.reader(f) |
||||||
|
for row in fr: |
||||||
|
email = row[0] |
||||||
|
course_token = row[1] |
||||||
|
period = row[2] |
||||||
|
payload = { |
||||||
|
'period': period, |
||||||
|
'course_token': course_token, |
||||||
|
'email': email.lower(), |
||||||
|
} |
||||||
|
token = jwt.encode(payload, settings.COURSE_PROGRESS_SECRET_KEY, algorithm='HS256').decode("utf-8") |
||||||
|
url = "https://go.skillbox.ru/api/v1/progress/progress_token/?token=%s" % str(token) |
||||||
|
fw.writerow([email.lower(), url]) |
||||||
@ -0,0 +1,20 @@ |
|||||||
|
# -*- coding: utf-8 -*- |
||||||
|
# Generated by Django 1.11.6 on 2018-04-16 18:50 |
||||||
|
from __future__ import unicode_literals |
||||||
|
|
||||||
|
from django.db import migrations, models |
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration): |
||||||
|
|
||||||
|
dependencies = [ |
||||||
|
('progress', '0009_progress_is_freeze'), |
||||||
|
] |
||||||
|
|
||||||
|
operations = [ |
||||||
|
migrations.AddField( |
||||||
|
model_name='progress', |
||||||
|
name='exp_date', |
||||||
|
field=models.DateTimeField(blank=True, null=True, verbose_name='Дата сгорания'), |
||||||
|
), |
||||||
|
] |
||||||
Loading…
Reference in new issue