Commit 254f5980 by Dennis Jen

Education level returned as a string (rather than an education level object).

parent ac59ba71
......@@ -50,7 +50,7 @@ syncdb:
$(foreach db_name,$(DATABASES),./manage.py syncdb --migrate --noinput --database=$(db_name);)
loaddata: syncdb
python manage.py loaddata education_levels problem_response_answer_distribution --database=analytics
python manage.py loaddata problem_response_answer_distribution --database=analytics
python manage.py generate_fake_course_data
demo: clean requirements loaddata
......@@ -58,5 +58,5 @@ demo: clean requirements loaddata
travis: clean requirements syncdb
python manage.py set_api_key edx edx
python manage.py loaddata education_levels problem_response_answer_distribution --database=analytics
python manage.py loaddata problem_response_answer_distribution --database=analytics
python manage.py generate_fake_course_data --num-weeks=1
[
{
"pk": 1,
"model": "v0.educationlevel",
"fields": {
"name": "None",
"short_name": "none"
}
},
{
"pk": 2,
"model": "v0.educationlevel",
"fields": {
"name": "Other",
"short_name": "other"
}
},
{
"pk": 3,
"model": "v0.educationlevel",
"fields": {
"name": "Elementary/Primary School",
"short_name": "primary"
}
},
{
"pk": 4,
"model": "v0.educationlevel",
"fields": {
"name": "Junior Secondary/Junior High/Middle School",
"short_name": "junior_secondary"
}
},
{
"pk": 5,
"model": "v0.educationlevel",
"fields": {
"name": "Secondary/High School",
"short_name": "secondary"
}
},
{
"pk": 6,
"model": "v0.educationlevel",
"fields": {
"name": "Associate's Degree",
"short_name": "associates"
}
},
{
"pk": 7,
"model": "v0.educationlevel",
"fields": {
"name": "Bachelor's Degree",
"short_name": "bachelors"
}
},
{
"pk": 8,
"model": "v0.educationlevel",
"fields": {
"name": "Master's or Professional Degree",
"short_name": "masters"
}
},
{
"pk": 9,
"model": "v0.educationlevel",
"fields": {
"name": "Doctorate",
"short_name": "doctorate"
}
}
]
\ No newline at end of file
......@@ -105,8 +105,7 @@ class Command(BaseCommand):
models.CourseEnrollmentByGender.objects.create(course_id=course_id, date=date, count=count,
gender=gender)
for short_name, ratio in education_level_ratios.iteritems():
education_level = models.EducationLevel.objects.get(short_name=short_name)
for education_level, ratio in education_level_ratios.iteritems():
count = int(ratio * daily_total)
models.CourseEnrollmentByEducation.objects.create(course_id=course_id, date=date, count=count,
education_level=education_level)
......
......@@ -63,19 +63,8 @@ class CourseEnrollmentByBirthYear(BaseCourseEnrollment):
unique_together = [('course_id', 'date', 'birth_year')]
class EducationLevel(models.Model):
name = models.CharField(max_length=255, null=False, unique=True)
short_name = models.CharField(max_length=255, null=False, unique=True)
class Meta(object):
db_table = 'education_levels'
def __unicode__(self):
return "{0} - {1}".format(self.short_name, self.name)
class CourseEnrollmentByEducation(BaseCourseEnrollment):
education_level = models.ForeignKey(EducationLevel)
education_level = models.CharField(max_length=255, null=True)
class Meta(BaseCourseEnrollment.Meta):
db_table = 'course_enrollment_education_level_daily'
......
......@@ -132,15 +132,8 @@ class CountrySerializer(serializers.Serializer):
name = serializers.CharField()
# pylint: disable=no-value-for-parameter
class EducationLevelSerializer(serializers.ModelSerializer):
class Meta(object):
model = models.EducationLevel
fields = ('name', 'short_name')
class CourseEnrollmentByCountrySerializer(BaseCourseEnrollmentModelSerializer):
# pylint: disable=unexpected-keyword-arg
# pylint: disable=unexpected-keyword-arg, no-value-for-parameter
country = CountrySerializer(many=False)
class Meta(object):
......@@ -160,8 +153,6 @@ class CourseEnrollmentByGenderSerializer(BaseCourseEnrollmentModelSerializer):
class CourseEnrollmentByEducationSerializer(BaseCourseEnrollmentModelSerializer):
education_level = EducationLevelSerializer()
class Meta(object):
model = models.CourseEnrollmentByEducation
fields = ('course_id', 'date', 'education_level', 'count', 'created')
......
......@@ -6,17 +6,6 @@ from analytics_data_api.v0 import models
from analytics_data_api.constants.country import UNKNOWN_COUNTRY
class EducationLevelTests(TestCase):
def test_unicode(self):
short_name = 'high_school'
name = 'High School'
education_level = G(models.EducationLevel, short_name=short_name,
name=name)
self.assertEqual(unicode(education_level),
"{0} - {1}".format(short_name, name))
class CourseEnrollmentByCountryTests(TestCase):
def test_country(self):
country = countries.get('US')
......
......@@ -296,15 +296,14 @@ class CourseEnrollmentByEducationViewTests(CourseEnrollmentViewTestCaseMixin, Te
def setUp(self):
super(CourseEnrollmentByEducationViewTests, self).setUp()
self.el1 = G(models.EducationLevel, name='Doctorate', short_name='doctorate')
self.el2 = G(models.EducationLevel, name='Top Secret', short_name='top_secret')
self.el1 = 'doctorate'
self.el2 = 'top_secret'
self.generate_data()
def format_as_response(self, *args):
return [
{'course_id': unicode(ce.course_id), 'count': ce.count, 'date': ce.date.strftime(settings.DATE_FORMAT),
'education_level': {'name': ce.education_level.name, 'short_name': ce.education_level.short_name},
'created': ce.created.strftime(settings.DATETIME_FORMAT)} for
'education_level': ce.education_level, 'created': ce.created.strftime(settings.DATETIME_FORMAT)} for
ce in args]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment