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

Python events._函数代码示例

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

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



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

示例1: steps

    def steps(self):

        if self._steps:
            return self._steps

        steps = [
            NavigationStep('submit', _(u'Enter'), None),
            NavigationStep('preview', _(u'Verify'), None),
            NavigationStep('finish', _(u'Finish'), None)
        ]

        if self.__name__ == 'submit':
            steps[0].url = self.context.absolute_url() + '/@@submit'
            steps[1].url = None
            steps[2].url = None
        elif self.__name__ == 'preview':
            steps[0].url = self.directory.absolute_url() + '/@@submit'
            steps[1].url = self.context.absolute_url() + '/@@preview'
            steps[2].url = None
        elif self.__name__ == 'finish':
            steps[0].url = self.directory.absolute_url() + '/@@submit'
            steps[1].url = self.context.absolute_url() + '/@@preview'
            steps[2].url = self.context.absolute_url() + '/@@finish'

        for i in range(0, len(steps)):
            if steps[i].url:
                steps[i].url = append_token(self.context, steps[i].url)

        self._steps = steps
        return self._steps
开发者ID:seantis,项目名称:seantis.dir.events,代码行数:30,代码来源:form.py


示例2: handle_save

    def handle_save(self, action):
        if not self.allow_edit:
            self.message(_(u'Imported events may not be edited, '
                           u'no changes where applied'))
            return

        data, errors = self.extractData()
        validate_event_submission(data)

        if errors:
            self.status = self.formErrorsMessage
            return

        self.prepare_coordinates(data)
        self.apply_coordinates(self.getContent())

        self.prepare_submission(data)
        self.apply_submission(self.getContent())

        changes = self.applyChanges(data)

        if changes:
            self.message(_(u'Event Saved'))
        else:
            self.message(_(u'No changes were applied'))

        url = self.context.absolute_url()
        self.redirect(append_token(self.context, url))
开发者ID:seantis,项目名称:seantis.dir.events,代码行数:28,代码来源:form.py


示例3: setup_form

    def setup_form(self):
        self.buttons = button.Buttons()
        self.handlers = button.Handlers()

        if self.form_type() == 'addform':
            preview = button.Button(title=_(u'Continue'), name='save')
            self.buttons += button.Buttons(preview)

            preview_handler = button.Handler(
                preview, self.__class__.handle_preview
            )
            self.handlers.addHandler(preview, preview_handler)

            self.ignoreContext = True
            self.ignoreReadonly = True
        else:
            update = button.Button(title=_(u'Continue'), name='save')
            self.buttons += button.Buttons(update)

            update_handler = button.Handler(
                update, self.__class__.handle_update
            )
            self.handlers.addHandler(update, update_handler)

            self.context = self.event

        cancel = button.Button(title=_(u'Cancel'), name='cancel')
        self.buttons += button.Buttons(cancel)

        cancel_handler = button.Handler(cancel, self.__class__.handle_cancel)
        self.handlers.addHandler(cancel, cancel_handler)
开发者ID:seantis,项目名称:seantis.dir.events,代码行数:31,代码来源:form.py


示例4: validate_image

def validate_image(value):
    if not value:
        return

    if not imghdr.what(value.filename, value.data):
        raise Invalid(_(u'Unknown image format'))

    check_filesize(value, 1, _(u'Images'))
开发者ID:vidyacraghav,项目名称:seantis.dir.events,代码行数:8,代码来源:interfaces.py


示例5: update_widgets

 def update_widgets(self):
     occurrences = self.widgets['title'].occurrences_count
     if occurrences > 1:
         self.label = _(u'List Preview (${number} Occurrences)', mapping={
             'number': occurrences
         })
     else:
         self.label = _(u'List Preview (No Occurrences)')
开发者ID:seantis,项目名称:seantis.dir.events,代码行数:8,代码来源:form.py


示例6: state_filter_list

    def state_filter_list(self):

        submitted = utils.translate(self.request, _(u'Submitted'))
        submitted += u' (%i)' % self.catalog.submitted_count

        return [
            ('submitted', submitted),
            ('published', _(u'Published'))
        ]
开发者ID:vidyacraghav,项目名称:seantis.dir.events,代码行数:9,代码来源:directory.py


示例7: human_date_short

def human_date_short(date, request):
    now = default_now()

    if now.date() == date.date():
        return _(u'Today')

    if now.date() + timedelta(days=1) == date.date():
        return _(u'Tomorrow')

    if now.year == date.year:
        return date.strftime('%d.%m')
    else:
        return date.strftime('%d.%m.%Y')
开发者ID:seantis,项目名称:seantis.dir.events,代码行数:13,代码来源:dates.py


示例8: validate_attachment

def validate_attachment(value):
    if not value:
        return

    filetype = magic.from_buffer(value.data[:1024], mime=True)

    if filetype not in mime_whitelist:
        raise Invalid(
            _(
                u'Unsupported fileformat. Supported is ${formats}',
                mapping={'formats': u','.join(sorted(mime_whitelist.values()))}
            )
        )

    check_filesize(value, 10, _(u'Attachments'))
开发者ID:seantis,项目名称:seantis.dir.events,代码行数:15,代码来源:interfaces.py


示例9: human_date

def human_date(date, request):
    now = default_now()

    if now.date() == date.date():
        return _(u'Today')

    if now.date() + timedelta(days=1) == date.date():
        return _(u'Tomorrow')

    calendar = request.locale.dates.calendars['gregorian']
    weekday = calendar.getDayNames()[date.weekday()]

    if now.year == date.year:
        return weekday + ' ' + date.strftime('%d.%m.')
    else:
        return weekday + ' ' + date.strftime('%d.%m.%Y.')
开发者ID:vidyacraghav,项目名称:seantis.dir.events,代码行数:16,代码来源:dates.py


示例10: handle_cancel

    def handle_cancel(self, action):
        try:
            clear_token(self.context)
        except ComponentLookupError:
            pass

        self.message(_(u"Event submission cancelled"))
        self.redirect(self.directory.absolute_url())
开发者ID:seantis,项目名称:seantis.dir.events,代码行数:8,代码来源:form.py


示例11: validate_terms_and_conditions

def validate_terms_and_conditions(agreed):
    if not agreed:
        raise Invalid(
            _(
                u'You have to agree to the terms '
                u'and conditions to submit this event'
            )
        )
开发者ID:vidyacraghav,项目名称:seantis.dir.events,代码行数:8,代码来源:interfaces.py


示例12: check_filesize

def check_filesize(value, size_in_mb, type):

    if value.getSize() > size_in_mb * 1024 ** 2:
        raise Invalid(
            _(
                u'${type} bigger than ${max} Megabyte are not allowed',
                mapping={'max': size_in_mb, 'type': type}
            )
        )
开发者ID:vidyacraghav,项目名称:seantis.dir.events,代码行数:9,代码来源:interfaces.py


示例13: attachment_filename

    def attachment_filename(self, attachment):
        filename = getattr(self, attachment).filename

        if not filename:
            number = attachment[-1]
            return _(u'Attachment ${number}', mapping=dict(number=number))

        if len(filename) > 100:
            return filename[:100] + '...'
        else:
            return filename
开发者ID:seantis,项目名称:seantis.dir.events,代码行数:11,代码来源:item.py


示例14: handleSubmit

    def handleSubmit(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        self.context.submitter = data['submitter']
        self.context.submitter_email = data['submitter_email']

        clear_token(self.context)
        self.context.submit()
        IStatusMessage(self.request).add(_(u"Event submitted"), "info")
        self.request.response.redirect(self.directory.absolute_url())
开发者ID:seantis,项目名称:seantis.dir.events,代码行数:13,代码来源:form.py


示例15: handle_update

    def handle_update(self, action):
        data, errors = self.extractData()
        validate_event_submission(data)

        if errors:
            self.status = self.formErrorsMessage
            return

        self.prepare_coordinates(data)
        self.apply_coordinates(self.getContent())

        self.prepare_submission(data)
        self.apply_submission(self.getContent())

        changes = self.applyChanges(data)

        if changes:
            self.message(_(u'Event Preview Updated'))
        else:
            self.message(_(u'No changes were applied'))

        url = self.context.absolute_url() + '/preview'
        self.redirect(append_token(self.context, url))
开发者ID:seantis,项目名称:seantis.dir.events,代码行数:23,代码来源:form.py


示例16: check_coordinates_present

    def check_coordinates_present(self):
        try:
            geo = IGeoreferenced(self.context)
            if geo.type:
                return
        except TypeError:
            pass

        self.context.plone_utils.addPortalMessage(
            _(
                u'No location set. The event will not be displayed in the'
                u' map.'
            ), 'warning'
        )
开发者ID:seantis,项目名称:seantis.dir.events,代码行数:14,代码来源:form.py


示例17: human_daterange

def human_daterange(start, end, request):

    if is_whole_day(start, end):
        if split_days_count(start, end) < 1:
            return utils.translate(request, _(u'Whole Day'))
        else:
            if default_now().year == start.year:
                return start.strftime('%d.%m. - ') \
                    + end.strftime('%d.%m. ') \
                    + utils.translate(request, _(u'Whole Day'))
            else:
                return start.strftime('%d.%m.%Y. - ') \
                    + end.strftime('%d.%m.%Y. ') \
                    + utils.translate(request, _(u'Whole Day'))

    if split_days_count(start, end) < 1:
        return start.strftime('%H:%M - ') + end.strftime('%H:%M')
    else:
        if default_now().year == start.year:
            return start.strftime('%d.%m. %H:%M - ') \
                + end.strftime('%d.%m. %H:%M')
        else:
            return start.strftime('%d.%m.%Y. %H:%M - ') \
                + end.strftime('%d.%m.%Y. %H:%M')
开发者ID:vidyacraghav,项目名称:seantis.dir.events,代码行数:24,代码来源:dates.py


示例18: update_dynamic_fields

    def update_dynamic_fields(self):
        self.fields['submitter'].field.required = True
        self.fields['submitter_email'].field.required = True

        # remove the terms and conditions agreement if there is none
        if not self.context.get_parent().terms:
            del self.fields['agreed']
        else:
            # otherwise be sure to link to it
            url = self.context.get_parent().absolute_url() + '/@@terms'
            self.fields['agreed'].field.description = utils.translate(
                self.request, _(
                    u"I agree to the <a target='_blank' href='${url}'>"
                    u"Terms and Conditions</a>",
                    mapping={'url': url}
                )
            )
开发者ID:seantis,项目名称:seantis.dir.events,代码行数:17,代码来源:form.py


示例19: no_events_helptext

 def no_events_helptext(self):
     if 'published' == self.catalog.state:
         return _(u'No events for the current daterange')
     else:
         return _(u'No events for the current state')
开发者ID:vidyacraghav,项目名称:seantis.dir.events,代码行数:5,代码来源:directory.py


示例20: import

from zope.interface import Invalid, Interface, Attribute, alsoProvides
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm

from seantis.dir.base.schemafields import Email, AutoProtocolURI
from seantis.dir.base.interfaces import (
    IDirectory,
    IDirectoryItem,
    IDirectoryItemCategories
)

from seantis.dir.events import _


days = SimpleVocabulary(
    [
        SimpleTerm(value='MO', title=_(u'Mo')),
        SimpleTerm(value='TU', title=_(u'Tu')),
        SimpleTerm(value='WE', title=_(u'We')),
        SimpleTerm(value='TH', title=_(u'Th')),
        SimpleTerm(value='FR', title=_(u'Fr')),
        SimpleTerm(value='SA', title=_(u'Sa')),
        SimpleTerm(value='SU', title=_(u'Su')),
    ]
)

# cannot use the comprehension in the zope interface definition
# because zope takes some weird magic to work
days.keys = [str(d.value) for d in days._terms]


class ITokenAccess(Interface):
开发者ID:vidyacraghav,项目名称:seantis.dir.events,代码行数:31,代码来源:interfaces.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python reservation._函数代码示例发布时间:2022-05-27
下一篇:
Python wiki.get_personal_wiki_repo函数代码示例发布时间: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