From 570cd673ef223cbc58b0b2d42af4dc9e206cb0a1 Mon Sep 17 00:00:00 2001
From: noraiz-anwar <noraizbhatti@gmail.com>
Date: Mon, 8 Jul 2019 15:20:40 +0500
Subject: [PATCH] change task_input field's type from CharField to TextField

---
 .../migrations/0003_alter_task_input_field.py | 20 +++++++++++++++++
 lms/djangoapps/instructor_task/models.py      |  9 +-------
 .../instructor_task/tests/test_api.py         | 22 -------------------
 3 files changed, 21 insertions(+), 30 deletions(-)
 create mode 100644 lms/djangoapps/instructor_task/migrations/0003_alter_task_input_field.py

diff --git a/lms/djangoapps/instructor_task/migrations/0003_alter_task_input_field.py b/lms/djangoapps/instructor_task/migrations/0003_alter_task_input_field.py
new file mode 100644
index 00000000000..e440e544b7c
--- /dev/null
+++ b/lms/djangoapps/instructor_task/migrations/0003_alter_task_input_field.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.21 on 2019-07-01 12:48
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('instructor_task', '0002_gradereportsetting'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='instructortask',
+            name='task_input',
+            field=models.TextField(),
+        ),
+    ]
diff --git a/lms/djangoapps/instructor_task/models.py b/lms/djangoapps/instructor_task/models.py
index aea28c803ad..5b5cc336ece 100644
--- a/lms/djangoapps/instructor_task/models.py
+++ b/lms/djangoapps/instructor_task/models.py
@@ -70,7 +70,7 @@ class InstructorTask(models.Model):
     task_type = models.CharField(max_length=50, db_index=True)
     course_id = CourseKeyField(max_length=255, db_index=True)
     task_key = models.CharField(max_length=255, db_index=True)
-    task_input = models.CharField(max_length=255)
+    task_input = models.TextField()
     task_id = models.CharField(max_length=255, db_index=True)  # max_length from celery_taskmeta
     task_state = models.CharField(max_length=50, null=True, db_index=True)  # max_length from celery_taskmeta
     task_output = models.CharField(max_length=1024, null=True)
@@ -99,15 +99,8 @@ class InstructorTask(models.Model):
         """
         # create the task_id here, and pass it into celery:
         task_id = str(uuid4())
-
         json_task_input = json.dumps(task_input)
 
-        # check length of task_input, and return an exception if it's too long:
-        if len(json_task_input) > 265:
-            fmt = u'Task input longer than 265: "{input}" for "{task}" of "{course}"'
-            msg = fmt.format(input=json_task_input, task=task_type, course=course_id)
-            raise ValueError(msg)
-
         # create the task, then save it:
         instructor_task = cls(
             course_id=course_id,
diff --git a/lms/djangoapps/instructor_task/tests/test_api.py b/lms/djangoapps/instructor_task/tests/test_api.py
index 042cba4a9de..eae423d5b07 100644
--- a/lms/djangoapps/instructor_task/tests/test_api.py
+++ b/lms/djangoapps/instructor_task/tests/test_api.py
@@ -126,28 +126,6 @@ class InstructorTaskModuleSubmitTest(InstructorTaskModuleTestCase):
         with self.assertRaises(NotImplementedError):
             submit_rescore_problem_for_all_students(request, problem_url)
 
-    def _test_submit_with_long_url(self, task_function, student=None):
-        problem_url_name = 'x' * 255
-        self.define_option_problem(problem_url_name)
-        location = InstructorTaskModuleTestCase.problem_location(problem_url_name)
-        with self.assertRaises(ValueError):
-            if student is not None:
-                task_function(self.create_task_request(self.instructor), location, student)
-            else:
-                task_function(self.create_task_request(self.instructor), location)
-
-    def test_submit_rescore_all_with_long_url(self):
-        self._test_submit_with_long_url(submit_rescore_problem_for_all_students)
-
-    def test_submit_rescore_student_with_long_url(self):
-        self._test_submit_with_long_url(submit_rescore_problem_for_student, self.student)
-
-    def test_submit_reset_all_with_long_url(self):
-        self._test_submit_with_long_url(submit_reset_problem_attempts_for_all_students)
-
-    def test_submit_delete_all_with_long_url(self):
-        self._test_submit_with_long_url(submit_delete_problem_state_for_all_students)
-
     @ddt.data(
         (normalize_repr(submit_rescore_problem_for_all_students), 'rescore_problem'),
         (
-- 
GitLab