Fix for LEARNER-859: Updating styling on the course updates page to more clearly differentiate between multiple updates. Specifically:

- Updated styling on date in the top left corner
- Added horizontal line between updates
- Removed ability to toggle updates on and off
- Cleaned up code to always show all updates:
This commit is contained in:
Harry Rein
2017-05-30 15:10:55 -04:00
parent b97af89fe8
commit 6761a87bfb
8 changed files with 97 additions and 27 deletions

View File

@@ -447,23 +447,26 @@ class CourseInfoModule(CourseInfoFields, HtmlModuleMixin):
return self.data.replace("%%USER_ID%%", self.system.anonymous_student_id)
return self.data
else:
course_updates = self.ordered_updates()
# This should no longer be called on production now that we are using a separate updates page
# and using a fragment HTML file - it will be called in tests until those are removed.
course_updates = self.order_updates(self.items)
context = {
'visible_updates': course_updates[:3],
'hidden_updates': course_updates[3:],
}
return self.system.render_template("{0}/course_updates.html".format(self.TEMPLATE_DIR), context)
def ordered_updates(self):
@classmethod
def order_updates(self, updates):
"""
Returns any course updates in reverse chronological order.
"""
course_updates = [item for item in self.items if item.get('status') == self.STATUS_VISIBLE]
course_updates.sort(
key=lambda item: (CourseInfoModule.safe_parse_date(item['date']), item['id']),
sorted_updates = [update for update in updates if update.get('status') == self.STATUS_VISIBLE]
sorted_updates.sort(
key=lambda item: (self.safe_parse_date(item['date']), item['id']),
reverse=True
)
return course_updates
return sorted_updates
@staticmethod
def safe_parse_date(date):

View File

@@ -1,14 +1,14 @@
import unittest
from mock import Mock
from xblock.field_data import DictFieldData
from xmodule.html_module import HtmlModule, HtmlDescriptor, CourseInfoModule
from . import get_test_system, get_test_descriptor_system
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from xblock.field_data import DictFieldData
from xblock.fields import ScopeIds
from xmodule.html_module import CourseInfoModule, HtmlDescriptor, HtmlModule
from . import get_test_descriptor_system, get_test_system
def instantiate_descriptor(**field_data):
"""
@@ -148,7 +148,7 @@ class HtmlDescriptorIndexingTestCase(unittest.TestCase):
class CourseInfoModuleTestCase(unittest.TestCase):
"""
Make sure that CourseInfoModule renders updates properly
Make sure that CourseInfoModule renders updates properly.
"""
def test_updates_render(self):
"""