当前位置: 首页>>代码示例>>Python>>正文


Python ServerTime.ui_string方法代码示例

本文整理汇总了Python中corehq.util.timezones.conversions.ServerTime.ui_string方法的典型用法代码示例。如果您正苦于以下问题:Python ServerTime.ui_string方法的具体用法?Python ServerTime.ui_string怎么用?Python ServerTime.ui_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在corehq.util.timezones.conversions.ServerTime的用法示例。


在下文中一共展示了ServerTime.ui_string方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: submission_or_completion_time

# 需要导入模块: from corehq.util.timezones.conversions import ServerTime [as 别名]
# 或者: from corehq.util.timezones.conversions.ServerTime import ui_string [as 别名]
 def submission_or_completion_time(self):
     time = iso_string_to_datetime(safe_index(self.form, self.report.time_field.split('.')))
     if self.report.by_submission_time:
         user_time = ServerTime(time).user_time(self.report.timezone)
     else:
         user_time = PhoneTime(time, self.report.timezone).user_time(self.report.timezone)
     return user_time.ui_string(USER_DATETIME_FORMAT_WITH_SEC)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:9,代码来源:display.py

示例2: broadcast_form

# 需要导入模块: from corehq.util.timezones.conversions import ServerTime [as 别名]
# 或者: from corehq.util.timezones.conversions.ServerTime import ui_string [as 别名]
    def broadcast_form(self):
        if self.request.method == 'POST':
            return self.form_class(self.request.POST, **self.form_kwargs)

        broadcast = self.broadcast
        start_user_time = ServerTime(broadcast.start_datetime).user_time(self.project_timezone)
        initial = {
            'timing': SEND_LATER,
            'date': start_user_time.ui_string('%Y-%m-%d'),
            'time': start_user_time.ui_string('%H:%M'),
            'recipient_type': broadcast.recipient,
            'case_group_id': broadcast.sample_id,
            'user_group_id': broadcast.user_group_id,
            'content_type': broadcast.method,
            'message': broadcast.events[0].message.get(broadcast.default_lang, None),
            'subject': broadcast.events[0].subject.get(broadcast.default_lang, None),
            'form_unique_id': broadcast.events[0].form_unique_id,
            'location_ids': ','.join(broadcast.location_ids),
            'include_child_locations': broadcast.include_child_locations,
        }
        if toggles.EWS_BROADCAST_BY_ROLE.enabled(self.domain):
            initial['role'] = broadcast.user_data_filter.get('role', [None])[0]
        return self.form_class(initial=initial, **self.form_kwargs)
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:25,代码来源:views.py

示例3: rows

# 需要导入模块: from corehq.util.timezones.conversions import ServerTime [as 别名]
# 或者: from corehq.util.timezones.conversions.ServerTime import ui_string [as 别名]
    def rows(self):
        def form_data_link(instance_id):
            return "<a class='ajax_dialog' target='_new' href='%(url)s'>%(text)s</a>" % {
                "url": absolute_reverse('render_form_data', args=[self.domain, instance_id]),
                "text": _("View Form")
            }

        submissions = [res['_source'] for res in self.es_results.get('hits', {}).get('hits', [])]

        for form in submissions:
            uid = form["form"]["meta"]["userID"]
            username = form["form"]["meta"].get("username")
            try:
                if username not in ['demo_user', 'admin']:
                    full_name = get_cached_property(CouchUser, uid, 'full_name', expiry=7*24*60*60)
                    name = '"%s"' % full_name if full_name else ""
                else:
                    name = ""
            except (ResourceNotFound, IncompatibleDocument):
                name = "<b>[unregistered]</b>"

            time = iso_string_to_datetime(safe_index(form, self.time_field.split('.')))
            if self.by_submission_time:
                user_time = ServerTime(time).user_time(self.timezone)
            else:
                user_time = PhoneTime(time, self.timezone).user_time(self.timezone)

            init_cells = [
                form_data_link(form["_id"]),
                (username or _('No data for username')) + (" %s" % name if name else ""),
                user_time.ui_string(USER_DATETIME_FORMAT_WITH_SEC),
                xmlns_to_name(self.domain, form.get("xmlns"), app_id=form.get("app_id")),
            ]

            def cell(field):
                return form["form"].get(field)
            init_cells.extend([cell(field) for field in self.other_fields])
            yield init_cells
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:40,代码来源:inspect.py

示例4: _format_time

# 需要导入模块: from corehq.util.timezones.conversions import ServerTime [as 别名]
# 或者: from corehq.util.timezones.conversions.ServerTime import ui_string [as 别名]
    def _format_time(self, time):
        if not time:
            return ''

        user_time = ServerTime(time).user_time(self.project_timezone)
        return user_time.ui_string(SERVER_DATETIME_FORMAT)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:8,代码来源:views.py

示例5: test_ui_string

# 需要导入模块: from corehq.util.timezones.conversions import ServerTime [as 别名]
# 或者: from corehq.util.timezones.conversions.ServerTime import ui_string [as 别名]
 def test_ui_string(self):
     now = datetime.datetime.utcnow()
     user_time = ServerTime(now).user_time(pytz.FixedOffset(-4 * 60))
     self.assertEqual(user_time.ui_string(),
                      user_time.done().strftime(USER_DATETIME_FORMAT))
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:7,代码来源:test_timezone_conversions.py

示例6: format_broadcast_name

# 需要导入模块: from corehq.util.timezones.conversions import ServerTime [as 别名]
# 或者: from corehq.util.timezones.conversions.ServerTime import ui_string [as 别名]
 def format_broadcast_name(self, broadcast):
     user_time = ServerTime(broadcast.start_datetime).user_time(self.project_timezone)
     return user_time.ui_string(SERVER_DATETIME_FORMAT)
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:5,代码来源:views.py


注:本文中的corehq.util.timezones.conversions.ServerTime.ui_string方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。