• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python reservation._函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中seantis.reservation._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: human_date

def human_date(date):
    # timezones are currently naive and implicity the one used by
    # the users - we don't have international reservations yet
    now = utils.utcnow()

    this_morning = datetime(
        now.year, now.month, now.day
    ).replace(tzinfo=now.tzinfo)

    time = utils.localize_date(date, time_only=True)

    if date >= this_morning:
        return _(u'Today, at ${time}', mapping={'time': time})

    days = (now.date() - date.date()).days

    if days <= 1:
        return _(u'Yesterday, at ${time}', mapping={
            'time': time
        })
    else:
        return _(u'${days} days ago, at ${time}', mapping={
            'days': days,
            'time': time
        })
开发者ID:seantis,项目名称:seantis.reservation,代码行数:25,代码来源:latest_reservations.py


示例2: add_reservation

    def add_reservation(start, end, reservation):
        day = start.day

        used_days[day] = True

        end += timedelta(microseconds=1)
        start, end = start.strftime("%H:%M"), end.strftime("%H:%M")

        context = resources[utils.string_uuid(reservation.resource)]

        if reservation.status == u"approved":
            rightside_urls = [(_(u"Delete"), reservation_urls.revoke_all_url(reservation.token, context))]
        elif reservation.status == u"pending":
            rightside_urls = [
                (_(u"Approve"), reservation_urls.approve_all_url(reservation.token, context)),
                (_(u"Deny"), reservation_urls.deny_all_url(reservation.token, context)),
            ]
        else:
            raise NotImplementedError

        reservation_lists = report[day][utils.string_uuid(reservation.resource)]
        reservation_lists[reservation.status].append(
            dict(
                start=start,
                end=end,
                email=reservation.email,
                data=reservation.data,
                timespans=json_timespans(start, end),
                rightside_urls=rightside_urls,
                token=reservation.token,
                quota=utils.get_reservation_quota_statement(reservation.quota),
                resource=context,
            )
        )
开发者ID:4teamwork,项目名称:seantis.reservation,代码行数:34,代码来源:monthly_report.py


示例3: hint

    def hint(self):
        if not (self.reservation or self.approved_reservations()):
            return _(u'No such reservation')

        return _(
            u'Do you really want to revoke the following reservations?'
        )
开发者ID:4teamwork,项目名称:seantis.reservation,代码行数:7,代码来源:reserve.py


示例4: isValidThreshold

    def isValidThreshold(Allocation):

        thresholds = [
            Allocation.available_threshold,
            Allocation.partly_available_threshold,
        ]

        if thresholds[0] == thresholds[1]:
            raise Invalid(
                _(u'Thresholds must have differing values')
            )

        if not (thresholds[0] > thresholds[1]):
            raise Invalid(
                _(
                    u'The available threshold must have a larger value than '
                    u'the partly available threshold'
                )
            )

        for threshold in thresholds:
            if not (0 <= threshold and threshold <= 100):
                raise Invalid(
                    _(
                        u'Thresholds must have values between 0 and 100'
                    )
                )
开发者ID:seantis,项目名称:seantis.reservation,代码行数:27,代码来源:settings.py


示例5: links

    def links(self, frame=None):

        # global links
        if not frame:
            baseurl = self.context.absolute_url()
            return [(_(u'Add timeframe'),
                    baseurl + '/++add++seantis.reservation.timeframe')]

        # frame specific links
        links = []

        action_tool = getToolByName(frame, 'portal_actions')
        actions = action_tool.listFilteredActionsFor(frame)['workflow']

        for action in actions:
            if action['visible'] and action['available']:
                action['title'] = utils.translate_workflow(
                    self.context, self.request, action['title']
                )
                links.append((action['title'], action['url']))

        baseurl = frame.absolute_url()
        links.append((_(u'Edit'), baseurl + '/edit'))
        links.append((_(u'Delete'), baseurl + '/delete_confirmation'))

        return links
开发者ID:seantis,项目名称:seantis.reservation,代码行数:26,代码来源:timeframe.py


示例6: validate

    def validate(self, data):
        try:
            start, end = utils.get_date_range(data["day"], data["start_time"], data["end_time"])
            if not self.allocation(data["id"]).contains(start, end):
                utils.form_error(_(u"Reservation out of bounds"))

            return start, end
        except (NoResultFound, TypeError):
            utils.form_error(_(u"Invalid reservation request"))
开发者ID:seantis,项目名称:seantis.reservation,代码行数:9,代码来源:reserve.py


示例7: validate

    def validate(self, data):
        try:
            start, end = utils.get_date_range(
                data['day'], data['start_time'], data['end_time']
            )
            if not self.allocation(data['id']).contains(start, end):
                utils.form_error(_(u'Reservation out of bounds'))

            return start, end
        except (NoResultFound, TypeError):
            utils.form_error(_(u'Invalid reservation request'))
开发者ID:4teamwork,项目名称:seantis.reservation,代码行数:11,代码来源:reserve.py


示例8: uncommitted_reservations

    def uncommitted_reservations(self):
        count = self.uncommitted_reservations_count

        if not count:
            return u""

        if count == 1:
            return _(u"There is one reservation being entered for this resource.")

        return _(
            u"There are ${nb} reservations being entered for this resource.",
            mapping={"nb": self.uncommitted_reservations_count},
        )
开发者ID:seantis,项目名称:seantis.reservation,代码行数:13,代码来源:form.py


示例9: isValidFirstLastHour

    def isValidFirstLastHour(Resource):
        in_valid_range = lambda h: 0 <= h and h <= 24
        first_hour, last_hour = Resource.first_hour, Resource.last_hour

        if not in_valid_range(first_hour):
            raise Invalid(_(u'Invalid first hour'))

        if not in_valid_range(last_hour):
            raise Invalid(_(u'Invalid last hour'))

        if last_hour <= first_hour:
            raise Invalid(
                _(u'First hour must be smaller than last hour')
            )
开发者ID:4teamwork,项目名称:seantis.reservation,代码行数:14,代码来源:interfaces.py


示例10: run_reserve

    def run_reserve(
            self, data, approve_manually, dates=None, group=None, quota=1,
            rrule=None, description=None
    ):

        assert dates or group
        assert not (dates and group)

        email = self.email(data)
        session_id = self.session_id()

        additional_data = self.additional_data(data, add_manager_defaults=True)

        # only store forms defined in the formsets list
        additional_data = dict(
            (
                form, additional_data[form]
            ) for form in self.context.formsets if form in additional_data
        )

        if dates:
            for start, end in utils.pairs(dates):
                run_pre_reserve_script(
                    self.context, start, end, additional_data
                )
        else:
            run_pre_reserve_script(self.context, None, None, additional_data)

        def run():
            if dates:
                return self.scheduler.reserve(
                    email, dates, data=additional_data,
                    session_id=session_id, quota=quota, rrule=rrule,
                    description=description
                )
            else:
                return self.scheduler.reserve(
                    email, group=group,
                    data=additional_data, session_id=session_id, quota=quota,
                    description=description
                )

        token = throttled(run, 'reserve')()

        if approve_manually:
            self.flash(_(u'Added to waitinglist'))
        else:
            self.scheduler.approve_reservation(token)
            self.flash(_(u'Reservation successful'))
开发者ID:4teamwork,项目名称:seantis.reservation,代码行数:49,代码来源:reserve.py


示例11: uncommitted_reservations

    def uncommitted_reservations(self):
        count = self.uncommitted_reservations_count

        if not count:
            return u''

        if count == 1:
            return _(
                u'There is one reservation being entered for this resource.'
            )

        return _(
            u'There are ${nb} reservations being entered for this resource.',
            mapping={'nb': self.uncommitted_reservations_count}
        )
开发者ID:4teamwork,项目名称:seantis.reservation,代码行数:15,代码来源:form.py


示例12: isValidOption

 def isValidOption(Allocation):
     if Allocation.recurrence:
         if Allocation.partly_available and not Allocation.separately:
             raise Invalid(_(
                 u'Partly available allocations can only be reserved '
                 u'separately'
             ))
开发者ID:4teamwork,项目名称:seantis.reservation,代码行数:7,代码来源:interfaces.py


示例13: validate_email

def validate_email(value):
    try:
        if value:
            checkEmailAddress(value)
    except EmailAddressInvalid:
        raise Invalid(_(u'Invalid email address'))
    return True
开发者ID:4teamwork,项目名称:seantis.reservation,代码行数:7,代码来源:interfaces.py


示例14: validate_templates

    def validate_templates(email):
        # go through the *_content attributes
        content_attributes = (
            (k, v) for k, v in IEmailTemplate._v_attrs.items()
            if k.endswith('_content')
        )

        # gather all the %(xxx)s tags
        form_tags = re.compile(r'%\(([a-z_]+)\)')

        # try to fill those with dummy variables
        for key, attr in content_attributes:
            tags = form_tags.findall(attr.getDoc())
            test_data = zip(tags, (str(i) for i in range(0, len(tags))))

            try:
                getattr(email, key) % dict(test_data)

            # if anything fails, it would also in the email sending process
            # which is the last thing we want to fail
            except KeyError as e:
                raise Invalid(
                    _(
                        u"Invalid template variable '${name}' in '${field}'",
                        mapping={
                            'name': e.message,
                            'field': attr.title
                        }
                    )
                )
开发者ID:seantis,项目名称:seantis.reservation,代码行数:30,代码来源:interfaces.py


示例15: change

        def change():
            start = datetime.combine(self.reservation.start.date(), data["start_time"])
            end = datetime.combine(self.reservation.end.date(), data["end_time"])

            changed = self.scheduler.change_reservation_time(
                token=data["token"],
                id=data["id"],
                new_start=start,
                new_end=end,
                send_email=data["send_email"],
                reason=data["reason"],
            )
            if changed:
                self.flash(_(u"Reservation changed."))
            else:
                self.flash(_(u"There was nothing to change."))
开发者ID:seantis,项目名称:seantis.reservation,代码行数:16,代码来源:reserve.py


示例16: validate_template

def validate_template(context, request, data):
    if context.portal_type == 'seantis.reservation.emailtemplate':
        folder = context.aq_inner.aq_parent
    else:
        folder = context

    templates = utils.portal_type_in_context(
        folder, portal_type='seantis.reservation.emailtemplate'
    )

    duplicate = False

    for template in templates:
        if template.id == context.id:
            continue

        if template.getObject().title == context.title:
            duplicate = True
            break

    if duplicate:
        msg = utils.translate(
            context, request,
            _(u"There's already an Email template in the same folder for the "
              u"same language")
        )
        utils.form_error(msg)
开发者ID:seantis,项目名称:seantis.reservation,代码行数:27,代码来源:mail.py


示例17: as_human_readable_string

def as_human_readable_string(value):
    if isinstance(value, six.string_types):
        return value

    if isinstance(value, datetime):
        # don't use strftime here because users may end up entering year '3'
        # strftime does not suppport years before 1900, which is just lame
        # in this case we just use the German locale for now..
        if value.year < 1900:
            return '%02d.%02d.%04d %02d:%02d' % (
                value.day,
                value.month,
                value.year,
                value.hour,
                value.minute
            )
        else:
            return localize_date(value, long_format=True)

    if isinstance(value, date):
        if value.year < 1900:
            return '%02d.%02d.%04d' % (
                value.day,
                value.month,
                value.year
            )
        else:
            dt = datetime(value.year, value.month, value.day)
            return localize_date(dt, long_format=False)

    if isinstance(value, RichTextValue):
        return value.output

    if value is True:
        return _(u'Yes')

    if value is False:
        return _(u'No')

    if value is None:
        return u''

    if isinstance(value, (list, tuple)):
        return ', '.join(as_human_readable_string(v) for v in value)

    return value
开发者ID:seantis,项目名称:seantis.reservation,代码行数:46,代码来源:utils.py


示例18: isValidRange

    def isValidRange(Allocation):
        start, end = utils.get_date_range(
            Allocation.day,
            Allocation.start_time, Allocation.end_time
        )

        if not Allocation.whole_day and abs((end - start).seconds // 60) < 5:
            raise Invalid(_(u'The allocation must be at least 5 minutes long'))
开发者ID:4teamwork,项目名称:seantis.reservation,代码行数:8,代码来源:interfaces.py


示例19: edit

        def edit():
            scheduler.move_allocation(*args)

            # ensure that the allocation is not accessed again by the defaults,
            # this prevents a DirtyReadOnlySession error
            self.allocation_stale = True

            self.flash(_(u'Allocation saved'))
开发者ID:seantis,项目名称:seantis.reservation,代码行数:8,代码来源:allocate.py


示例20: links

    def links(self, template=None):

        # global links
        if not template:
            baseurl = self.context.absolute_url()
            return [(
                _(u'Add email template'),
                baseurl + '/++add++seantis.reservation.emailtemplate'
            )]

        # template specific links
        links = []

        baseurl = template.absolute_url()
        links.append((_(u'Edit'), baseurl + '/edit'))
        links.append((_(u'Delete'), baseurl + '/delete_confirmation'))

        return links
开发者ID:seantis,项目名称:seantis.reservation,代码行数:18,代码来源:mail.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python search.aStarSearch函数代码示例发布时间:2022-05-27
下一篇:
Python events._函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap