本文整理汇总了Python中util.date_utils.get_default_time_display函数的典型用法代码示例。如果您正苦于以下问题:Python get_default_time_display函数的具体用法?Python get_default_time_display怎么用?Python get_default_time_display使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_default_time_display函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _get_course_email_context
def _get_course_email_context(course):
"""
Returns context arguments to apply to all emails, independent of recipient.
"""
course_id = course.id.to_deprecated_string()
course_title = course.display_name
course_start_date = get_default_time_display(course.start)
course_end_date = get_default_time_display(course.end)
course_root = reverse('course_root', kwargs={'course_id': course_id})
course_url = '{}{}'.format(
settings.LMS_ROOT_URL,
course_root
)
image_url = u'{}{}'.format(settings.LMS_ROOT_URL, course_image_url(course))
email_context = {
'course_title': course_title,
'course_root': course_root,
'course_language': course.language,
'course_url': course_url,
'course_image_url': image_url,
'course_start_date': course_start_date,
'course_end_date': course_end_date,
'account_settings_url': '{}{}'.format(settings.LMS_ROOT_URL, reverse('account_settings')),
'email_settings_url': '{}{}'.format(settings.LMS_ROOT_URL, reverse('dashboard')),
'platform_name': configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME),
}
return email_context
开发者ID:Stanford-Online,项目名称:edx-platform,代码行数:27,代码来源:tasks.py
示例2: get_ordered_updates
def get_ordered_updates(self, request, course):
"""
Returns any course updates in reverse chronological order.
"""
info_module = get_course_info_section_module(request, request.user, course, 'updates')
updates = info_module.items if info_module else []
info_block = getattr(info_module, '_xmodule', info_module) if info_module else None
ordered_updates = [update for update in updates if update.get('status') == self.STATUS_VISIBLE]
ordered_updates.sort(
key=lambda item: (self.safe_parse_date(item['date']), item['id']),
reverse=True
)
keyword_context = {
'username': request.user.username,
'user_id': request.user.id,
'name': request.user.profile.name,
'course_title': course.display_name,
'course_id': course.id,
'course_start_date': get_default_time_display(course.start),
'course_end_date': get_default_time_display(course.end),
}
for update in ordered_updates:
update['content'] = info_block.system.replace_urls(update['content'])
update['content'] = info_block.system.substitute_keywords_with_data(update['content'], keyword_context)
return ordered_updates
开发者ID:stvstnfrd,项目名称:edx-platform,代码行数:26,代码来源:course_updates.py
示例3: get_course_info_section
def get_course_info_section(request, course, section_key):
"""
This returns the snippet of html to be rendered on the course info page,
given the key for the section.
Valid keys:
- handouts
- guest_handouts
- updates
- guest_updates
"""
info_module = get_course_info_section_module(request, course, section_key)
html = ''
if info_module is not None:
try:
html = info_module.render(STUDENT_VIEW).content
context = {
'username': request.user.username,
'user_id': request.user.id,
'name': request.user.profile.name,
'course_title': course.display_name,
'course_id': course.id,
'course_start_date': get_default_time_display(course.start),
'course_end_date': get_default_time_display(course.end),
}
html = substitute_keywords_with_data(html, context)
except Exception: # pylint: disable=broad-except
html = render_to_string('courseware/error-message.html', None)
log.exception(
u"Error rendering course=%s, section_key=%s",
course, section_key
)
return html
开发者ID:caseylitton,项目名称:edx-platform,代码行数:35,代码来源:courses.py
示例4: get_html
def get_html(self):
if self.system.substitute_keywords_with_data:
course = self.descriptor.runtime.modulestore.get_course(self.course_id)
user = self.system.get_real_user(self.system.anonymous_student_id)
context = {
"user_id": user.id if user else None,
"name": user.profile.name if user else "",
"course_title": course.display_name,
"course_id": self.course_id,
"course_start_date": get_default_time_display(course.start),
"course_end_date": get_default_time_display(course.end),
}
return self.system.substitute_keywords_with_data(self.data, context)
return self.data
开发者ID:sigberto,项目名称:edx-platform,代码行数:14,代码来源:html_module.py
示例5: test_start_date_on_page
def test_start_date_on_page(self):
"""
Verify that the course start date is included on the course outline page.
"""
def _get_release_date(response):
"""Return the release date from the course page"""
parsed_html = lxml.html.fromstring(response.content)
return parsed_html.find_class('course-status')[0].find_class('status-release-value')[0].text_content()
def _assert_settings_link_present(response):
"""
Asserts there's a course settings link on the course page by the course release date.
"""
parsed_html = lxml.html.fromstring(response.content)
settings_link = parsed_html.find_class('course-status')[0].find_class('action-edit')[0].find('a')
self.assertIsNotNone(settings_link)
self.assertEqual(settings_link.get('href'), reverse_course_url('settings_handler', self.course.id))
outline_url = reverse_course_url('course_handler', self.course.id)
response = self.client.get(outline_url, {}, HTTP_ACCEPT='text/html')
# A course with the default release date should display as "Unscheduled"
self.assertEqual(_get_release_date(response), 'Unscheduled')
_assert_settings_link_present(response)
self.course.start = datetime.datetime(2014, 1, 1, tzinfo=pytz.utc)
modulestore().update_item(self.course, ModuleStoreEnum.UserID.test)
response = self.client.get(outline_url, {}, HTTP_ACCEPT='text/html')
self.assertEqual(_get_release_date(response), get_default_time_display(self.course.start))
_assert_settings_link_present(response)
开发者ID:LeslieZhu,项目名称:edx-platform,代码行数:31,代码来源:test_course_index.py
示例6: _section_course_info
def _section_course_info(course, access):
""" Provide data for the corresponding dashboard section """
course_key = course.id
section_data = {
'section_key': 'course_info',
'section_display_name': _('Course Info'),
'access': access,
'course_id': course_key,
'course_display_name': course.display_name,
'has_started': course.has_started(),
'has_ended': course.has_ended(),
'start_date': get_default_time_display(course.start),
'end_date': get_default_time_display(course.end) or _('No end date set'),
'num_sections': len(course.children),
'list_instructor_tasks_url': reverse('list_instructor_tasks', kwargs={'course_id': unicode(course_key)}),
}
if settings.FEATURES.get('DISPLAY_ANALYTICS_ENROLLMENTS'):
section_data['enrollment_count'] = CourseEnrollment.objects.enrollment_counts(course_key)
if settings.ANALYTICS_DASHBOARD_URL:
# dashboard_link is already made safe in _get_dashboard_link
dashboard_link = _get_dashboard_link(course_key)
# so we can use Text() here so it's not double-escaped and rendering HTML on the front-end
message = Text(_("Enrollment data is now available in {dashboard_link}.")).format(dashboard_link=dashboard_link)
section_data['enrollment_message'] = message
if settings.FEATURES.get('ENABLE_SYSADMIN_DASHBOARD'):
section_data['detailed_gitlogs_url'] = reverse('gitlogs_detail', kwargs={'course_id': unicode(course_key)})
try:
sorted_cutoffs = sorted(course.grade_cutoffs.items(), key=lambda i: i[1], reverse=True)
advance = lambda memo, (letter, score): "{}: {}, ".format(letter, score) + memo
section_data['grade_cutoffs'] = reduce(advance, sorted_cutoffs, "")[:-2]
except Exception: # pylint: disable=broad-except
section_data['grade_cutoffs'] = "Not Available"
# section_data['offline_grades'] = offline_grades_available(course_key)
try:
section_data['course_errors'] = [(escape(a), '') for (a, _unused) in modulestore().get_course_errors(course.id)]
except Exception: # pylint: disable=broad-except
section_data['course_errors'] = [('Error fetching errors', '')]
return section_data
开发者ID:AndreySonetico,项目名称:edx-platform,代码行数:45,代码来源:instructor_dashboard.py
示例7: _section_course_info
def _section_course_info(course, access):
""" Provide data for the corresponding dashboard section """
course_key = course.id
section_data = {
"section_key": "course_info",
"section_display_name": _("Course Info"),
"access": access,
"course_id": course_key,
"course_display_name": course.display_name,
"has_started": course.has_started(),
"has_ended": course.has_ended(),
"start_date": get_default_time_display(course.start),
"end_date": get_default_time_display(course.end) or _("No end date set"),
"num_sections": len(course.children),
"list_instructor_tasks_url": reverse("list_instructor_tasks", kwargs={"course_id": unicode(course_key)}),
}
if settings.FEATURES.get("DISPLAY_ANALYTICS_ENROLLMENTS"):
section_data["enrollment_count"] = CourseEnrollment.objects.enrollment_counts(course_key)
if settings.ANALYTICS_DASHBOARD_URL:
dashboard_link = _get_dashboard_link(course_key)
message = _("Enrollment data is now available in {dashboard_link}.").format(dashboard_link=dashboard_link)
section_data["enrollment_message"] = message
if settings.FEATURES.get("ENABLE_SYSADMIN_DASHBOARD"):
section_data["detailed_gitlogs_url"] = reverse("gitlogs_detail", kwargs={"course_id": unicode(course_key)})
try:
sorted_cutoffs = sorted(course.grade_cutoffs.items(), key=lambda i: i[1], reverse=True)
advance = lambda memo, (letter, score): "{}: {}, ".format(letter, score) + memo
section_data["grade_cutoffs"] = reduce(advance, sorted_cutoffs, "")[:-2]
except Exception: # pylint: disable=broad-except
section_data["grade_cutoffs"] = "Not Available"
# section_data['offline_grades'] = offline_grades_available(course_key)
try:
section_data["course_errors"] = [(escape(a), "") for (a, _unused) in modulestore().get_course_errors(course.id)]
except Exception: # pylint: disable=broad-except
section_data["course_errors"] = [("Error fetching errors", "")]
return section_data
开发者ID:lemontreeran,项目名称:edx-platform,代码行数:43,代码来源:instructor_dashboard.py
示例8: _get_release_date
def _get_release_date(xblock, user=None):
"""
Returns the release date for the xblock, or None if the release date has never been set.
"""
# If year of start date is less than 1900 then reset the start date to DEFAULT_START_DATE
if xblock.start.year < 1900 and user:
xblock.start = DEFAULT_START_DATE
xblock = _update_with_callback(xblock, user)
# Treat DEFAULT_START_DATE as a magic number that means the release date has not been set
return get_default_time_display(xblock.start) if xblock.start != DEFAULT_START_DATE else None
开发者ID:189140879,项目名称:edx-platform,代码行数:11,代码来源:item.py
示例9: get_plain_html_updates
def get_plain_html_updates(self, request, course):
"""
Returns any course updates in an html chunk. Used
for older implementations and a few tests that store
a single html object representing all the updates.
"""
info_module = get_course_info_section_module(request, request.user, course, 'updates')
info_block = getattr(info_module, '_xmodule', info_module)
update_content = info_block.system.replace_urls(info_module.data) if info_module else ''
keyword_context = {
'username': request.user.username,
'user_id': request.user.id,
'name': request.user.profile.name,
'course_title': course.display_name,
'course_id': course.id,
'course_start_date': get_default_time_display(course.start),
'course_end_date': get_default_time_display(course.end),
}
update_content = info_block.system.substitute_keywords_with_data(update_content, keyword_context)
return update_content
开发者ID:stvstnfrd,项目名称:edx-platform,代码行数:20,代码来源:course_updates.py
示例10: __init__
def __init__(self, fake_email, num_sent, num_failed):
super(FakeEmailInfo, self).__init__()
self.created = get_default_time_display(fake_email.created)
number_sent = str(num_sent) + ' sent'
if num_failed > 0:
number_sent += ', ' + str(num_failed) + " failed"
self.number_sent = number_sent
fake_email_dict = fake_email.to_dict()
self.email = {feature: fake_email_dict[feature] for feature in self.EMAIL_FEATURES}
self.requester = u'expected'
开发者ID:Appius,项目名称:edx-platform,代码行数:12,代码来源:utils.py
示例11: _get_course_email_context
def _get_course_email_context(course):
"""
Returns context arguments to apply to all emails, independent of recipient.
"""
course_id = course.id.to_deprecated_string()
course_title = course.display_name
course_url = 'https://{}{}'.format(
settings.SITE_NAME,
reverse('course_root', kwargs={'course_id': course_id})
)
image_url = 'https://{}{}'.format(settings.SITE_NAME, course_image_url(course))
email_context = {
'course_title': course_title,
'course_url': course_url,
'course_image_url': image_url,
'course_start_date': get_default_time_display(course.start),
'course_end_date': get_default_time_display(course.end),
'account_settings_url': 'https://{}{}'.format(settings.SITE_NAME, reverse('dashboard')),
'platform_name': settings.PLATFORM_NAME,
}
return email_context
开发者ID:dmohrC,项目名称:edx-platform,代码行数:21,代码来源:tasks.py
示例12: test_sub_mutiltple_tags
def test_sub_mutiltple_tags(self, test_info):
""" Test that subbing works with multiple subtags """
anon_id = '123456789'
patched_dict = {
'%%USER_ID%%': lambda x, y: anon_id,
'%%USER_FULLNAME%%': lambda x, y: self.user.profile.name,
'%%COURSE_DISPLAY_NAME': lambda x, y: self.course.display_name,
'%%COURSE_END_DATE': lambda x, y: get_default_time_display(self.course.end)
}
with patch.dict(Ks.KEYWORD_FUNCTION_MAP, patched_dict):
result = Ks.substitute_keywords_with_data(test_info['test_string'], self.user.id, self.course.id)
self.assertEqual(result, test_info['expected'])
开发者ID:JacobWay,项目名称:edx-platform,代码行数:13,代码来源:test_keyword_sub_utils.py
示例13: _get_asset_json
def _get_asset_json(display_name, date, location, thumbnail_location, locked):
"""
Helper method for formatting the asset information to send to client.
"""
asset_url = StaticContent.get_url_path_from_location(location)
return {
'display_name': display_name,
'date_added': get_default_time_display(date),
'url': asset_url,
'portable_url': StaticContent.get_static_path_from_location(location),
'thumbnail': StaticContent.get_url_path_from_location(thumbnail_location) if thumbnail_location is not None else None,
'locked': locked,
# Needed for Backbone delete/update.
'id': asset_url
}
开发者ID:lonjoy,项目名称:edx-platform,代码行数:15,代码来源:assets.py
示例14: _get_asset_json
def _get_asset_json(display_name, date, location, thumbnail_location, locked):
"""
Helper method for formatting the asset information to send to client.
"""
asset_url = _add_slash(location.to_deprecated_string())
external_url = settings.LMS_BASE + asset_url
return {
'display_name': display_name,
'date_added': get_default_time_display(date),
'url': asset_url,
'external_url': external_url,
'portable_url': StaticContent.get_static_path_from_location(location),
'thumbnail': _add_slash(unicode(thumbnail_location)) if thumbnail_location else None,
'locked': locked,
# Needed for Backbone delete/update.
'id': unicode(location)
}
开发者ID:AdityaKashyap,项目名称:edx-platform,代码行数:17,代码来源:assets.py
示例15: extract_email_features
def extract_email_features(email_task):
"""
From the given task, extract email content information
Expects that the given task has the following attributes:
* task_input (dict containing email_id and to_option)
* task_output (optional, dict containing total emails sent)
With this information, gets the corresponding email object from the
bulk emails table, and loads up a dict containing the following:
* created, the time the email was sent displayed in default time display
* sent_to, the group the email was delivered to
* email, dict containing the subject, id, and html_message of an email
* number_sent, int number of emails sent
If task_input cannot be loaded, then the email cannot be loaded
and None is returned for these fields.
"""
# Load the task input info to get email id
try:
task_input_information = json.loads(email_task.task_input)
except ValueError:
log.error("Could not parse task input as valid json; task input: %s", email_task.task_input)
return email_error_information()
email = CourseEmail.objects.get(id=task_input_information['email_id'])
creation_time = get_default_time_display(email.created)
email_feature_dict = {'created': creation_time, 'sent_to': task_input_information['to_option']}
features = ['subject', 'html_message', 'id']
email_info = {feature: unicode(getattr(email, feature)) for feature in features}
# Pass along email as an object with the information we desire
email_feature_dict['email'] = email_info
number_sent = None
if hasattr(email_task, 'task_output') and email_task.task_output is not None:
try:
task_output = json.loads(email_task.task_output)
except ValueError:
log.error("Could not parse task output as valid json; task output: %s", email_task.task_output)
else:
if 'total' in task_output:
number_sent = int(task_output['total'])
email_feature_dict['number_sent'] = number_sent
return email_feature_dict
开发者ID:GuxGomes,项目名称:edx-platform,代码行数:46,代码来源:instructor_task_helpers.py
示例16: _get_asset_json
def _get_asset_json(display_name, content_type, date, location, thumbnail_location, locked):
'''
Helper method for formatting the asset information to send to client.
'''
asset_url = StaticContent.serialize_asset_key_with_slash(location)
external_url = settings.LMS_BASE + asset_url
return {
'display_name': display_name,
'content_type': content_type,
'date_added': get_default_time_display(date),
'url': asset_url,
'external_url': external_url,
'portable_url': StaticContent.get_static_path_from_location(location),
'thumbnail': StaticContent.serialize_asset_key_with_slash(thumbnail_location) if thumbnail_location else None,
'locked': locked,
# needed for Backbone delete/update.
'id': unicode(location)
}
开发者ID:AlexxNica,项目名称:edx-platform,代码行数:18,代码来源:assets.py
示例17: _show_receipt_json
def _show_receipt_json(order):
"""Render the receipt page as JSON.
The included information is deliberately minimal:
as much as possible, the included information should
be common to *all* order items, so the client doesn't
need to handle different item types differently.
Arguments:
request (HttpRequest): The request for the receipt.
order (Order): The order model to display.
Returns:
HttpResponse
"""
order_info = {
'orderNum': order.id,
'currency': order.currency,
'status': order.status,
'purchase_datetime': get_default_time_display(order.purchase_time) if order.purchase_time else None,
'billed_to': {
'first_name': order.bill_to_first,
'last_name': order.bill_to_last,
'street1': order.bill_to_street1,
'street2': order.bill_to_street2,
'city': order.bill_to_city,
'state': order.bill_to_state,
'postal_code': order.bill_to_postalcode,
'country': order.bill_to_country,
},
'total_cost': order.total_cost,
'items': [
{
'quantity': item.qty,
'unit_cost': item.unit_cost,
'line_cost': item.line_cost,
'line_desc': item.line_desc,
'course_key': unicode(item.course_id)
}
for item in OrderItem.objects.filter(order=order).select_subclasses()
]
}
return JsonResponse(order_info)
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:44,代码来源:views.py
示例18: setUp
def setUp(self):
super(KeywordSubTest, self).setUp(create_user=False)
self.user = UserFactory.create(
email="[email protected]",
username="testuser",
profile__name="Test User"
)
self.course = CourseFactory.create(
org='edx',
course='999',
display_name='test_course'
)
self.context = {
'user_id': self.user.id,
'course_title': self.course.display_name,
'name': self.user.profile.name,
'course_end_date': get_default_time_display(self.course.end),
}
开发者ID:189140879,项目名称:edx-platform,代码行数:19,代码来源:test_keyword_sub_utils.py
示例19: _get_release_date
def _get_release_date(xblock, user=None):
"""
Returns the release date for the xblock, or None if the release date has never been set.
"""
# If year of start date is less than 1900 then reset the start date to DEFAULT_START_DATE
reset_to_default = False
try:
reset_to_default = xblock.start.year < 1900
except ValueError:
# For old mongo courses, accessing the start attribute calls `to_json()`,
# which raises a `ValueError` for years < 1900.
reset_to_default = True
if reset_to_default and user:
xblock.start = DEFAULT_START_DATE
xblock = _update_with_callback(xblock, user)
# Treat DEFAULT_START_DATE as a magic number that means the release date has not been set
return get_default_time_display(xblock.start) if xblock.start != DEFAULT_START_DATE else None
开发者ID:weicliu,项目名称:edx-platform-local,代码行数:19,代码来源:item.py
示例20: _get_course_email_context
def _get_course_email_context(course):
"""
Returns context arguments to apply to all emails, independent of recipient.
"""
course_id = course.id.to_deprecated_string()
course_title = course.display_name
course_end_date = get_default_time_display(course.end)
scheme = u"https" if settings.HTTPS == "on" else u"http"
course_url = '{}://{}{}'.format(
scheme,
settings.SITE_NAME,
reverse('course_root', kwargs={'course_id': course_id})
)
image_url = u'{}://{}{}'.format(scheme, settings.SITE_NAME, course_image_url(course))
email_context = {
'course_title': course_title,
'course_url': course_url,
'course_image_url': image_url,
'course_end_date': course_end_date,
'account_settings_url': '{}://{}{}'.format(scheme, settings.SITE_NAME, reverse('account_settings')),
'platform_name': microsite.get_value('platform_name', settings.PLATFORM_NAME),
}
return email_context
开发者ID:Velody,项目名称:edunext-platform,代码行数:23,代码来源:tasks.py
注:本文中的util.date_utils.get_default_time_display函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论