Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-analytics-data-api
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-analytics-data-api
Commits
1d02923f
Commit
1d02923f
authored
Oct 27, 2014
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved Country Constants to Separate File
parent
8ac02398
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
11 deletions
+11
-11
analytics_data_api/constants/__init__.py
+0
-4
analytics_data_api/constants/country.py
+4
-0
analytics_data_api/v0/models.py
+2
-2
analytics_data_api/v0/tests/test_models.py
+1
-1
analytics_data_api/v0/tests/test_views.py
+4
-4
No files found.
analytics_data_api/constants/__init__.py
View file @
1d02923f
from
iso3166
import
Country
UNKNOWN_COUNTRY_CODE
=
u'UNKNOWN'
UNKNOWN_COUNTRY
=
Country
(
UNKNOWN_COUNTRY_CODE
,
None
,
None
,
None
)
analytics_data_api/constants/country.py
0 → 100644
View file @
1d02923f
from
iso3166
import
Country
UNKNOWN_COUNTRY_CODE
=
u'UNKNOWN'
UNKNOWN_COUNTRY
=
Country
(
UNKNOWN_COUNTRY_CODE
,
None
,
None
,
None
)
analytics_data_api/v0/models.py
View file @
1d02923f
from
django.db
import
models
from
iso3166
import
countries
from
analytics_data_api.constants
import
UNKNOWN_COUNTRY
,
genders
from
analytics_data_api.constants
import
country
,
genders
class
CourseActivityWeekly
(
models
.
Model
):
...
...
@@ -135,7 +135,7 @@ class CourseEnrollmentByCountry(BaseCourseEnrollment):
return
countries
.
get
(
self
.
country_code
)
except
(
KeyError
,
ValueError
,
AttributeError
):
# Country code is not valid ISO-3166
return
UNKNOWN_COUNTRY
return
country
.
UNKNOWN_COUNTRY
class
Meta
(
BaseCourseEnrollment
.
Meta
):
db_table
=
'course_enrollment_location_current'
...
...
analytics_data_api/v0/tests/test_models.py
View file @
1d02923f
...
...
@@ -3,7 +3,7 @@ from django_dynamic_fixture import G
from
iso3166
import
countries
from
analytics_data_api.v0
import
models
from
analytics_data_api.constants
import
UNKNOWN_COUNTRY
from
analytics_data_api.constants
.country
import
UNKNOWN_COUNTRY
class
EducationLevelTests
(
TestCase
):
...
...
analytics_data_api/v0/tests/test_views.py
View file @
1d02923f
...
...
@@ -15,7 +15,7 @@ import pytz
from
opaque_keys.edx.keys
import
CourseKey
from
analytics_data_api.v0
import
models
from
analytics_data_api.constants
import
UNKNOWN_COUNTRY
,
UNKNOWN_COUNTRY_CODE
,
enrollment_modes
from
analytics_data_api.constants
import
country
,
enrollment_modes
from
analytics_data_api.v0.models
import
CourseActivityWeekly
from
analytics_data_api.v0.serializers
import
ProblemResponseAnswerDistributionSerializer
from
analytics_data_api.v0.serializers
import
GradeDistributionSerializer
...
...
@@ -444,16 +444,16 @@ class CourseEnrollmentByLocationViewTests(CourseEnrollmentViewTestCaseMixin, Tes
def
format_as_response
(
self
,
*
args
):
unknown
=
{
'course_id'
:
None
,
'count'
:
0
,
'date'
:
None
,
'country'
:
{
'alpha2'
:
None
,
'alpha3'
:
None
,
'name'
:
UNKNOWN_COUNTRY_CODE
}}
'country'
:
{
'alpha2'
:
None
,
'alpha3'
:
None
,
'name'
:
country
.
UNKNOWN_COUNTRY_CODE
}}
for
arg
in
args
:
if
arg
.
country
.
name
==
UNKNOWN_COUNTRY_CODE
:
if
arg
.
country
.
name
==
country
.
UNKNOWN_COUNTRY_CODE
:
unknown
[
'course_id'
]
=
arg
.
course_id
unknown
[
'date'
]
=
arg
.
date
.
strftime
(
settings
.
DATE_FORMAT
)
unknown
[
'count'
]
+=
arg
.
count
unknown
[
'created'
]
=
arg
.
created
.
strftime
(
settings
.
DATETIME_FORMAT
)
args
=
[
arg
for
arg
in
args
if
arg
.
country
!=
UNKNOWN_COUNTRY
]
args
=
[
arg
for
arg
in
args
if
arg
.
country
!=
country
.
UNKNOWN_COUNTRY
]
args
=
sorted
(
args
,
key
=
lambda
item
:
(
item
.
date
,
item
.
course_id
,
item
.
country
.
alpha3
))
response
=
[
unknown
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment