From 8fff540b407c4fae3dfb16c216f83f41ba97af83 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Wed, 5 Jun 2019 14:54:17 -0400 Subject: [PATCH] Respond to review. --- manage.py | 3 +-- milestones/admin.py | 3 +-- milestones/api.py | 3 +-- milestones/data.py | 3 +-- milestones/exceptions.py | 3 +-- milestones/models.py | 29 +++++++++++++++++------------ milestones/serializers.py | 3 +-- milestones/services.py | 3 +-- milestones/tests/test_api.py | 3 +-- milestones/tests/test_data.py | 3 +-- milestones/tests/test_services.py | 3 +-- milestones/tests/utils.py | 3 +-- milestones/validators.py | 3 +-- setup.py | 3 +-- 14 files changed, 30 insertions(+), 38 deletions(-) diff --git a/manage.py b/manage.py index e979b3ff..91634b45 100755 --- a/manage.py +++ b/manage.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import os import sys diff --git a/milestones/admin.py b/milestones/admin.py index 9e4eb04e..c97be9dd 100644 --- a/milestones/admin.py +++ b/milestones/admin.py @@ -1,8 +1,7 @@ """ Admin module for milestones app """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals from django.contrib import admin from milestones.models import ( diff --git a/milestones/api.py b/milestones/api.py index a88bdbeb..c0f6e271 100644 --- a/milestones/api.py +++ b/milestones/api.py @@ -12,8 +12,7 @@ Note the terminology difference at this layer vs. Data -- add/edit/get/remove """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals from . import data from . import exceptions from . import validators diff --git a/milestones/data.py b/milestones/data.py index c719117c..d6bec719 100644 --- a/milestones/data.py +++ b/milestones/data.py @@ -24,8 +24,7 @@ else: import milestones.resources as remote """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import six diff --git a/milestones/exceptions.py b/milestones/exceptions.py index cc8f3ee0..6bd44ea7 100644 --- a/milestones/exceptions.py +++ b/milestones/exceptions.py @@ -1,8 +1,7 @@ """ Application-specific exception classes used throughout the implementation """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals from django.core.exceptions import ValidationError diff --git a/milestones/models.py b/milestones/models.py index 8d052f71..41a4f563 100644 --- a/milestones/models.py +++ b/milestones/models.py @@ -8,12 +8,13 @@ which leverages Django's signal framework. """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals from django.db import models +from django.utils.encoding import python_2_unicode_compatible from model_utils.models import TimeStampedModel +@python_2_unicode_compatible class Milestone(TimeStampedModel): """ A Milestone is a representation of an accomplishment which can be @@ -33,10 +34,11 @@ class Meta: """ Meta class for this Django model """ unique_together = (("namespace", "name"),) - def __unicode__(self): - return str(self.namespace) + def __str__(self): + return self.namespace +@python_2_unicode_compatible class MilestoneRelationshipType(TimeStampedModel): """ A MilestoneRelationshipType represents a category of link available @@ -62,8 +64,8 @@ class MilestoneRelationshipType(TimeStampedModel): description = models.TextField(blank=True) active = models.BooleanField(default=True) - def __unicode__(self): - return str(self.name) + def __str__(self): + return self.name @classmethod # pylint: disable=invalid-name @@ -76,6 +78,7 @@ def get_supported_milestone_relationship_types(cls): return RELATIONSHIP_TYPE_CHOICES +@python_2_unicode_compatible class CourseMilestone(TimeStampedModel): """ A CourseMilestone represents the link between a Course and a @@ -95,10 +98,11 @@ class Meta: """ Meta class for this Django model """ unique_together = (("course_id", "milestone"),) - def __unicode__(self): - return str("%s:%s:%s" % (self.course_id, self.milestone_relationship_type, self.milestone)) + def __str__(self): + return "%s:%s:%s" % (self.course_id, self.milestone_relationship_type, self.milestone) +@python_2_unicode_compatible class CourseContentMilestone(TimeStampedModel): """ A CourseContentMilestone represents the link between a specific @@ -126,10 +130,11 @@ class Meta: """ Meta class for this Django model """ unique_together = (("course_id", "content_id", "milestone"),) - def __unicode__(self): - return str("%s:%s:%s" % (self.content_id, self.milestone_relationship_type, self.milestone)) + def __str__(self): + return "%s:%s:%s" % (self.content_id, self.milestone_relationship_type, self.milestone) +@python_2_unicode_compatible class UserMilestone(TimeStampedModel): """ A UserMilestone represents an stage reached or event experienced @@ -155,5 +160,5 @@ class Meta: """ Meta class for this Django model """ unique_together = ("user_id", "milestone") - def __unicode__(self): - return str("%s:%s" % (self.user_id, self.milestone)) + def __str__(self): + return "%s:%s" % (self.user_id, self.milestone) diff --git a/milestones/serializers.py b/milestones/serializers.py index 39cb67ca..a7396d3e 100644 --- a/milestones/serializers.py +++ b/milestones/serializers.py @@ -2,8 +2,7 @@ Data layer serialization operations. Converts querysets to simple python containers (mainly arrays and dicts). """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import json from . import models diff --git a/milestones/services.py b/milestones/services.py index 926a2ea1..717ad0fd 100644 --- a/milestones/services.py +++ b/milestones/services.py @@ -2,8 +2,7 @@ A wrapper class around requested methods exposed in api.py """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import types from milestones import api as milestones_api diff --git a/milestones/tests/test_api.py b/milestones/tests/test_api.py index e30abd48..83c219ab 100644 --- a/milestones/tests/test_api.py +++ b/milestones/tests/test_api.py @@ -4,8 +4,7 @@ """ Milestones API Module Test Cases """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals from opaque_keys.edx.keys import UsageKey diff --git a/milestones/tests/test_data.py b/milestones/tests/test_data.py index b752f9f7..fd750f41 100644 --- a/milestones/tests/test_data.py +++ b/milestones/tests/test_data.py @@ -5,8 +5,7 @@ Note: 'Unit Test: ' labels are output to the console during test runs """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import milestones.api as api import milestones.data as data import milestones.exceptions as exceptions diff --git a/milestones/tests/test_services.py b/milestones/tests/test_services.py index af786aa0..87731bc2 100644 --- a/milestones/tests/test_services.py +++ b/milestones/tests/test_services.py @@ -2,8 +2,7 @@ Test for the xBlock service """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import unittest import types diff --git a/milestones/tests/utils.py b/milestones/tests/utils.py index a04de96a..ea93f915 100644 --- a/milestones/tests/utils.py +++ b/milestones/tests/utils.py @@ -2,8 +2,7 @@ """ Utility module for Milestones test cases """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals from django.contrib.auth.models import User from django.test import TestCase from opaque_keys.edx.keys import CourseKey, UsageKey diff --git a/milestones/validators.py b/milestones/validators.py index ab36ee66..7c6ce2bb 100644 --- a/milestones/validators.py +++ b/milestones/validators.py @@ -1,8 +1,7 @@ """ Validators confirm the integrity of inbound information prior to a data.py handoff """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import json import six diff --git a/setup.py b/setup.py index 727048d7..7f5002c8 100755 --- a/setup.py +++ b/setup.py @@ -1,7 +1,6 @@ #!/usr/bin/env python -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals from setuptools import setup, find_packages from milestones import __version__ as VERSION