forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release March 24, 2018. (openedx#2472)
* Add ORA2 video upload option openedx#2375 (openedx#2417) * Modified courseware page look and feel openedx#2377 (openedx#2409) * Modified about page openedx#2379 (openedx#2413) * Fix biz bugs. openedx#2404 (openedx#2406) * Fix display width of popup. (openedx#2384) (cherry picked from commit a43c935a575d15fcf629f0edeb81446c778cda95) * Validate duplicate url-code. * Fix bug, when course not found. * Fix order of course as CourseOverview. * Remove additional-info count from contract grid. openedx#2419 (openedx#2437) * Fix order global course. openedx#2420 (openedx#2421) * Add additional info register. openedx#2419 (openedx#2433) * fix survey csv character encode problem openedx#2380 (openedx#2434) * Fix bokchoy for LoginCodeEnabledBizSurveyTest. (openedx#2457) * Fix register students confirm message. (openedx#2461) * Add command to check playback_log. openedx#2438 (openedx#2445) * Fix courseware page lookandfeel (openedx#2446, openedx#2439, openedx#2452, openedx#2453) * Fix box-shadow of sequence-nav-button. openedx#2453 (openedx#2467) * Fix bugs. openedx#2462 openedx#2463 (openedx#2464) * Fix password message in register students page. * Fix glass pane of processing when register additional item. * Fix display width of popup. (openedx#2466) * Fix min-width of sequence-nav. openedx#2468 (openedx#2469) * Fix isRegistered javascript in about page openedx#2470 (openedx#2471)
- Loading branch information
1 parent
d26cd4f
commit 5a993a9
Showing
83 changed files
with
3,459 additions
and
672 deletions.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
biz/djangoapps/ga_achievement/management/commands/check_playback_log.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import logging | ||
from collections import Counter | ||
from datetime import datetime, timedelta | ||
from optparse import make_option | ||
|
||
from django.conf import settings | ||
from django.core.management.base import BaseCommand, CommandError | ||
|
||
from biz.djangoapps.util import datetime_utils | ||
from biz.djangoapps.util.biz_mongo_connection import BizMongoConnection | ||
from biz.djangoapps.util.decorators import handle_command_exception | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
class Command(BaseCommand): | ||
help = """ | ||
Usage: python manage.py lms --settings=aws check_playback_log [--target_date=<yyyymmdd>] | ||
""" | ||
|
||
option_list = BaseCommand.option_list + ( | ||
make_option('--target_date', | ||
default=None, | ||
action='store', | ||
help="target_date should be 'yyyymmdd' format."), | ||
) | ||
|
||
@handle_command_exception('/edx/var/log/biz/check_playback_log_command.txt') | ||
def handle(self, *args, **options): | ||
|
||
if len(args) > 0: | ||
raise CommandError("This command requires no arguments. Use target_date option if you want.") | ||
|
||
target_date = options.get('target_date') | ||
if target_date: | ||
try: | ||
target_date = datetime.strptime(target_date, '%Y%m%d') | ||
except ValueError: | ||
raise CommandError("target_date should be 'yyyymmdd' format.") | ||
else: | ||
# By default, check for today (JST) | ||
target_date = datetime_utils.timezone_today() | ||
|
||
log.info("Command check_playback_log started for {}.".format(target_date.strftime('%Y/%m/%d'))) | ||
|
||
# NOTE: By default, PyMongo deals with only naive datetimes. | ||
# NOTE: emr_aggregate_playback_log sets `created_at` to yesterday's midnight. | ||
# For example, when it runs at 2017-11-13 06:06:07+9:00, it sets as below: | ||
# - u'created_at': datetime.datetime(2017, 11, 12, 0, 0, tzinfo=<bson.tz_util.FixedOffset object>) | ||
target_datetime = datetime.combine(target_date + timedelta(days=-1), datetime.min.time()) | ||
|
||
try: | ||
store_config = settings.BIZ_MONGO['playback_log'] | ||
db_connection = BizMongoConnection(**store_config) | ||
db = db_connection.database | ||
collection = db[store_config['collection']] | ||
except Exception as e: | ||
raise e | ||
|
||
try: | ||
result = collection.aggregate([ | ||
{'$group': { | ||
'_id': { | ||
'course_id': '$course_id', | ||
'vertical_id': '$vertical_id', | ||
'target_id': '$target_id', | ||
'created_at': '$created_at', | ||
}, | ||
'total': {'$sum': 1}, | ||
}}, | ||
{'$match': { | ||
'_id.created_at': target_datetime, | ||
'total': {'$gt': 1}, | ||
}}, | ||
], | ||
allowDiskUse=True, | ||
)['result'] | ||
|
||
except Exception as e: | ||
raise e | ||
|
||
if result: | ||
messages = ["{} duplicated documents are detected in playback_log for {}.".format(len(result), target_date.strftime('%Y/%m/%d'))] | ||
for course_id, count in Counter([x['_id']['course_id'] for x in result]).most_common(): | ||
messages.append('{},{}'.format(course_id, count)) | ||
raise Exception('\n'.join(messages)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from mock import patch | ||
|
||
from django.core.urlresolvers import reverse | ||
|
||
from biz.djangoapps.util.tests.testcase import BizTestBase | ||
from student.tests.factories import UserFactory | ||
|
||
|
||
class ContractAuthAdminTest(BizTestBase): | ||
|
||
def setUp(self): | ||
super(ContractAuthAdminTest, self).setUp() | ||
|
||
user = UserFactory.create(is_staff=True, is_superuser=True) | ||
user.save() | ||
|
||
self.client.login(username=user.username, password='test') | ||
|
||
self.contract = self._create_contract() | ||
self.contract_other = self._create_contract() | ||
self.url_code = 'testUrlCode' | ||
|
||
def test_initial_url_code(self): | ||
with patch( | ||
'biz.djangoapps.ga_contract.admin.get_random_string', | ||
return_value=self.url_code | ||
): | ||
response = self.client.get(reverse('admin:ga_contract_contractauth_add')) | ||
self.assertEqual(200, response.status_code) | ||
self.assertIn('value="{url_code}"'.format(url_code=self.url_code), response.content) | ||
|
||
def test_add(self): | ||
response = self.client.post(reverse('admin:ga_contract_contractauth_add'), data={ | ||
'contract': self.contract.id, | ||
'url_code': self.url_code, | ||
}) | ||
self.assertRedirects(response, reverse('admin:ga_contract_contractauth_changelist')) | ||
|
||
response = self.client.get(reverse('admin:ga_contract_contractauth_changelist')) | ||
self.assertEqual(200, response.status_code) | ||
self.assertIn('{contract_name}({url_code})'.format(contract_name=self.contract.contract_name, url_code=self.url_code), response.content) | ||
|
||
def test_contract_required(self): | ||
response = self.client.post(reverse('admin:ga_contract_contractauth_add'), data={ | ||
'url_code': self.url_code, | ||
}) | ||
self.assertEqual(200, response.status_code) | ||
self.assertIn('This field is required.'.format(url_code=self.url_code), response.content) | ||
|
||
def test_url_code_required(self): | ||
response = self.client.post(reverse('admin:ga_contract_contractauth_add'), data={ | ||
'contract': self.contract.id, | ||
}) | ||
self.assertEqual(200, response.status_code) | ||
self.assertIn('This field is required.'.format(url_code=self.url_code), response.content) | ||
self.assertIn('Url code is invalid. Please enter alphanumeric 8-255 characters.'.format(url_code=self.url_code), response.content) | ||
|
||
def test_url_code_duplicate(self): | ||
response = self.client.post(reverse('admin:ga_contract_contractauth_add'), data={ | ||
'contract': self.contract_other.id, | ||
'url_code': self.url_code, | ||
}) | ||
self.assertRedirects(response, reverse('admin:ga_contract_contractauth_changelist')) | ||
|
||
response = self.client.post(reverse('admin:ga_contract_contractauth_add'), data={ | ||
'contract': self.contract.id, | ||
'url_code': self.url_code, | ||
}) | ||
self.assertEqual(200, response.status_code) | ||
self.assertIn('Url code is duplicated. Please change url code.'.format(url_code=self.url_code), response.content) |
Oops, something went wrong.