Merge pull request #21069 from edx/INCR-405

INCR-405 python3 compatibility
This commit is contained in:
Ayub
2019-08-02 15:15:06 +05:00
committed by GitHub
9 changed files with 31 additions and 21 deletions

View File

@@ -1,7 +1,7 @@
from __future__ import print_function
from __future__ import absolute_import, print_function
from django.contrib.auth.models import Group, User
from django.core.management.base import BaseCommand, CommandError
from django.contrib.auth.models import User, Group
class Command(BaseCommand):

View File

@@ -1,18 +1,17 @@
from __future__ import print_function
from django.core.management.base import BaseCommand
from django.contrib.auth.models import User
from student.models import UserTestGroup
from __future__ import absolute_import, print_function
import datetime
import json
import random
import sys
import datetime
from textwrap import dedent
import json
from django.contrib.auth.models import User
from django.core.management.base import BaseCommand
from pytz import UTC
from student.models import UserTestGroup
# Examples:
# python manage.py assigngroups summary_test:0.3,skip_summary_test:0.7 log.txt "Do previews of future materials help?"
# python manage.py assigngroups skip_capacitor:0.3,capacitor:0.7 log.txt "Do we show capacitor in linearity tutorial?"

View File

@@ -2,6 +2,8 @@
Management command to change many user enrollments in many courses using
csv file.
"""
from __future__ import absolute_import
import csv
import logging
from os import path

View File

@@ -1,5 +1,7 @@
""" Command line script to change user enrollments. """
from __future__ import absolute_import
import logging
from django.core.management.base import BaseCommand, CommandError

View File

@@ -1,16 +1,14 @@
from __future__ import print_function
from __future__ import absolute_import, print_function
from django.conf import settings
from django.contrib.auth.models import User
from django.utils import translation
from opaque_keys.edx.keys import CourseKey
from six import text_type
from student.forms import AccountCreationForm
from student.helpers import do_create_account
from student.helpers import AccountValidationError, do_create_account
from student.models import CourseEnrollment, create_comments_service_user
from student.helpers import AccountValidationError
from track.management.tracked_command import TrackedCommand

View File

@@ -3,6 +3,8 @@ Management command `manage_group` is used to idempotently create Django groups
and set their permissions by name.
"""
from __future__ import absolute_import
from django.apps import apps
from django.contrib.auth.models import Group, Permission
from django.contrib.contenttypes.models import ContentType

View File

@@ -1,11 +1,16 @@
"""
Command to back-populate domain of the site the user account was created on.
"""
from __future__ import absolute_import
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.core.management.base import BaseCommand, CommandError
from student.models import UserAttribute, Registration
from student.models import Registration, UserAttribute
import six
CREATED_ON_SITE = 'created_on_site'
@@ -51,7 +56,8 @@ class Command(BaseCommand):
except Site.DoesNotExist:
question = "The site you specified is not configured as a Site in the system. " \
"Are you sure you want to continue? (y/n):"
if str(raw_input(question)).lower().strip()[0] != 'y':
if str(six.moves.input(question)).lower().strip()[0] != 'y':
return
for user_id in user_ids:

View File

@@ -137,7 +137,7 @@ class TestPopulateUserAttribute(SiteMixin, TestCase):
Test management command with invalid site domain.
"""
fake_site_domain = 'fake-site-domain'
with mock.patch('__builtin__.raw_input', return_value=populate):
with mock.patch('six.moves.input', return_value=populate):
call_command(
"populate_created_on_site_user_attribute",
"--users", self.user_ids,

View File

@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-04-25 20:18
from __future__ import unicode_literals
from __future__ import absolute_import, unicode_literals
import uuid
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import simple_history.models
import uuid
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):