Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Revert "Merge pull request #178 from edx/edx/kdmccormick/course-listi…
Browse files Browse the repository at this point in the history
…ng-reimp-final" (#179)

This reverts commit 14e3a01, reversing
changes made to 859d376.

Reverts API version from v1 back to v0.
See EDUCATOR-1355 to track the eventual refactor and re-commit of these changes.
  • Loading branch information
thallada authored Sep 14, 2017
1 parent 14e3a01 commit 5c63501
Show file tree
Hide file tree
Showing 57 changed files with 865 additions and 2,154 deletions.
2 changes: 1 addition & 1 deletion analytics_data_api/constants/enrollment_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
PROFESSIONAL_NO_ID = u'no-id-professional'
VERIFIED = u'verified'

ALL = frozenset([AUDIT, CREDIT, HONOR, PROFESSIONAL, PROFESSIONAL_NO_ID, VERIFIED])
ALL = [AUDIT, CREDIT, HONOR, PROFESSIONAL, PROFESSIONAL_NO_ID, VERIFIED]
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"problem_display_name": "Earth Science Question",
"question_text": "Enter your answer:"
},
"model": "v1.problemfirstlastresponseanswerdistribution",
"model": "v0.problemfirstlastresponseanswerdistribution",
"pk": 1
},
{
Expand All @@ -32,7 +32,7 @@
"problem_display_name": "Earth Science Question",
"question_text": "Enter your answer:"
},
"model": "v1.problemfirstlastresponseanswerdistribution",
"model": "v0.problemfirstlastresponseanswerdistribution",
"pk": 2
},
{
Expand All @@ -50,7 +50,7 @@
"problem_display_name": "Earth Science Question",
"question_text": "Enter your answer:"
},
"model": "v1.problemfirstlastresponseanswerdistribution",
"model": "v0.problemfirstlastresponseanswerdistribution",
"pk": 3
},
{
Expand All @@ -68,7 +68,7 @@
"problem_display_name": "Earth Science Question",
"question_text": "Enter your answer:"
},
"model": "v1.problemfirstlastresponseanswerdistribution",
"model": "v0.problemfirstlastresponseanswerdistribution",
"pk": 4
},
{
Expand All @@ -86,7 +86,7 @@
"problem_display_name": null,
"question_text": null
},
"model": "v1.problemfirstlastresponseanswerdistribution",
"model": "v0.problemfirstlastresponseanswerdistribution",
"pk": 5
},
{
Expand All @@ -104,7 +104,7 @@
"problem_display_name": null,
"question_text": null
},
"model": "v1.problemfirstlastresponseanswerdistribution",
"model": "v0.problemfirstlastresponseanswerdistribution",
"pk": 6
},
{
Expand All @@ -122,7 +122,7 @@
"problem_display_name": null,
"question_text": null
},
"model": "v1.problemfirstlastresponseanswerdistribution",
"model": "v0.problemfirstlastresponseanswerdistribution",
"pk": 7
},
{
Expand All @@ -140,7 +140,7 @@
"problem_display_name": "Example problem",
"question_text": "Enter an answer:"
},
"model": "v1.problemfirstlastresponseanswerdistribution",
"model": "v0.problemfirstlastresponseanswerdistribution",
"pk": 8
},
{
Expand All @@ -158,7 +158,7 @@
"problem_display_name": "Example problem",
"question_text": "Enter an answer:"
},
"model": "v1.problemfirstlastresponseanswerdistribution",
"model": "v0.problemfirstlastresponseanswerdistribution",
"pk": 9
},
{
Expand All @@ -176,7 +176,7 @@
"problem_display_name": "Example problem",
"question_text": "Enter an answer:"
},
"model": "v1.problemfirstlastresponseanswerdistribution",
"model": "v0.problemfirstlastresponseanswerdistribution",
"pk": 10
},
{
Expand All @@ -194,7 +194,7 @@
"problem_display_name": "Example problem",
"question_text": "Randomized answer"
},
"model": "v1.problemfirstlastresponseanswerdistribution",
"model": "v0.problemfirstlastresponseanswerdistribution",
"pk": 11
},
{
Expand All @@ -212,7 +212,7 @@
"problem_display_name": "Example problem",
"question_text": "Randomized answer"
},
"model": "v1.problemfirstlastresponseanswerdistribution",
"model": "v0.problemfirstlastresponseanswerdistribution",
"pk": 12
},

Expand All @@ -231,7 +231,7 @@
"problem_display_name": "Example problem",
"question_text": "Select from the choices below:"
},
"model": "v1.problemfirstlastresponseanswerdistribution",
"model": "v0.problemfirstlastresponseanswerdistribution",
"pk": 13
},
{
Expand All @@ -249,7 +249,7 @@
"problem_display_name": "Example problem",
"question_text": "Select from the choices below:"
},
"model": "v1.problemfirstlastresponseanswerdistribution",
"model": "v0.problemfirstlastresponseanswerdistribution",
"pk": 14
},
{
Expand All @@ -267,7 +267,7 @@
"problem_display_name": "Example problem",
"question_text": "Select from the choices below:"
},
"model": "v1.problemfirstlastresponseanswerdistribution",
"model": "v0.problemfirstlastresponseanswerdistribution",
"pk": 15
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from django.utils import timezone

from analytics_data_api.constants import engagement_events
from analytics_data_api.v1 import models
from analytics_data_api.v0 import models
from analyticsdataserver.clients import CourseBlocksApiClient

logging.basicConfig(level=logging.INFO)
Expand Down
2 changes: 1 addition & 1 deletion analytics_data_api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from rest_framework.urlpatterns import format_suffix_patterns

urlpatterns = [
url(r'^v1/', include('analytics_data_api.v1.urls', 'v1')),
url(r'^v0/', include('analytics_data_api.v0.urls', 'v0')),
]

urlpatterns = format_suffix_patterns(urlpatterns)
24 changes: 1 addition & 23 deletions analytics_data_api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from opaque_keys.edx.locator import CourseKey
from opaque_keys import InvalidKeyError

from analytics_data_api.v1.exceptions import (
from analytics_data_api.v0.exceptions import (
ReportFileNotFoundError,
CannotCreateReportDownloadLinkError
)
Expand Down Expand Up @@ -230,25 +230,3 @@ def get_expiration_date(seconds):
Determine when a given link will expire, based on a given lifetime
"""
return datetime.datetime.utcnow() + datetime.timedelta(seconds=seconds)


class classproperty(object):
"""
A decorator for declaring a class-level property.
Conceptually ike combining @classmethod and @property, however that
doesn't work in practice, so we have to define our own decorator here.
"""

def __init__(self, getter):
self.getter = getter

def __get__(self, instance, owner):
return self.getter(owner)


def join_dicts(*dicts):
joined = {}
for d in dicts:
joined.update(d)
return joined
1 change: 1 addition & 0 deletions analytics_data_api/v0/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default_app_config = 'analytics_data_api.v0.apps.ApiAppConfig'
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class ApiAppConfig(AppConfig):

name = 'analytics_data_api.v1'
name = 'analytics_data_api.v0'

def ready(self):
from analytics_data_api.utils import load_fully_qualified_definition
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.http.response import JsonResponse
from rest_framework import status

from analytics_data_api.v1.exceptions import (
from analytics_data_api.v0.exceptions import (
CourseKeyMalformedError,
CourseNotSpecifiedError,
LearnerEngagementTimelineNotFoundError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ class Meta(BaseCourseEnrollment.Meta):


class CourseMetaSummaryEnrollment(BaseCourseModel):
catalog_course_title = models.CharField(db_index=True, null=True, max_length=255)
catalog_course_title = models.CharField(db_index=True, max_length=255)
catalog_course = models.CharField(db_index=True, max_length=255)
start_time = models.DateTimeField(null=True)
end_time = models.DateTimeField(null=True)
pacing_type = models.CharField(db_index=True, max_length=255, null=True)
availability = models.CharField(db_index=True, max_length=255, null=True)
start_time = models.DateTimeField()
end_time = models.DateTimeField()
pacing_type = models.CharField(db_index=True, max_length=255)
availability = models.CharField(db_index=True, max_length=255)
enrollment_mode = models.CharField(max_length=255)
count = models.IntegerField(null=False)
cumulative_count = models.IntegerField(null=False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
engagement_events,
enrollment_modes,
)
from analytics_data_api.v1 import models
from analytics_data_api.v0 import models


# Below are the enrollment modes supported by this API.
Expand Down Expand Up @@ -561,7 +561,6 @@ class CourseMetaSummaryEnrollmentSerializer(ModelSerializerWithCreatedField, Dyn
count = serializers.IntegerField(default=0)
cumulative_count = serializers.IntegerField(default=0)
count_change_7_days = serializers.IntegerField(default=0)
verified_enrollment = serializers.IntegerField(default=0)
passing_users = serializers.IntegerField(default=0)
enrollment_modes = serializers.SerializerMethodField()
programs = serializers.SerializerMethodField()
Expand All @@ -570,7 +569,7 @@ def get_enrollment_modes(self, obj):
return obj.get('enrollment_modes', None)

def get_programs(self, obj):
return list(obj.get('programs', set()))
return obj.get('programs', None)

class Meta(object):
model = models.CourseMetaSummaryEnrollment
Expand All @@ -595,13 +594,3 @@ class Meta(object):
# excluding course-related fields because the serialized output will be embedded in a course object
# with those fields already defined
exclude = ('id', 'created', 'course_id')


class CourseTotalsSerializer(serializers.Serializer):
"""
Serializer for course totals data.
"""
count = serializers.IntegerField()
cumulative_count = serializers.IntegerField()
count_change_7_days = serializers.IntegerField()
verified_enrollment = serializers.IntegerField()
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from elasticsearch.exceptions import ElasticsearchException
from mock import patch

from analytics_data_api.v1.connections import BotoHttpConnection, ESConnection
from analytics_data_api.v0.connections import BotoHttpConnection, ESConnection


class ESConnectionTests(TestCase):
Expand Down Expand Up @@ -47,7 +47,7 @@ def fake_connection(*args): # pylint: disable=unused-argument

class BotoHttpConnectionTests(TestCase):

@patch('analytics_data_api.v1.connections.ESConnection.make_request')
@patch('analytics_data_api.v0.connections.ESConnection.make_request')
def test_perform_request_success(self, mock_response):
mock_response.return_value.status = 200
connection = BotoHttpConnection(aws_access_key_id='access_key', aws_secret_access_key='secret')
Expand All @@ -56,7 +56,7 @@ def test_perform_request_success(self, mock_response):
self.assertEqual(status, 200)
self.assertGreater(mock_logger.call_count, 0)

@patch('analytics_data_api.v1.connections.ESConnection.make_request')
@patch('analytics_data_api.v0.connections.ESConnection.make_request')
def test_perform_request_error(self, mock_response):
mock_response.return_value.status = 500
connection = BotoHttpConnection(aws_access_key_id='access_key', aws_secret_access_key='secret')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.test import TestCase
from django_dynamic_fixture import G

from analytics_data_api.v1 import models
from analytics_data_api.v0 import models
from analytics_data_api.constants.country import UNKNOWN_COUNTRY, get_country


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.test import TestCase
from django_dynamic_fixture import G

from analytics_data_api.v1 import models as api_models, serializers as api_serializers
from analytics_data_api.v0 import models as api_models, serializers as api_serializers


class TestSerializer(api_serializers.CourseEnrollmentDailySerializer, api_serializers.DynamicFieldsModelSerializer):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


class UrlRedirectTests(TestCase):
api_root_path = '/api/v1/'
api_root_path = '/api/v0/'

def assertRedirectsToRootPath(self, path, **kwargs):
assert_kwargs = {'status_code': 302}
Expand Down
File renamed without changes.
Loading

0 comments on commit 5c63501

Please sign in to comment.