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


Python common._函数代码示例

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


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

示例1: update

    def update(self):
        result = []
        periods = self.periods()
        numSlots = self.numSlots()
        for i in range(len(self.days())):
            day = []
            for j in range(numSlots[i]):
                name = 'period_%d_%d' % (i, j)
                if name not in self.request:
                    self.error = _('Please provide all periods.')
                    return False
                day.append(self.request[name])
            result.append(day)

        # Validate that all periods are selected
        errors = set()
        for i, day in enumerate(self.days()):
            seen = set()
            for period in result[i]:
                if period not in seen:
                    seen.add(period)
                else:
                    error = _("$period on day $day",
                              mapping={'period': period, 'day': self.days()[i]})
                    errors.add(translate(error, context=self.request))
        if errors:
            self.error = _('The following periods were selected more'
                           ' than once: $periods',
                           mapping={'periods': ', '.join(errors)})
            return False

        self.getSessionData()['periods_order'] = result
        return True
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:33,代码来源:ttwizard.py

示例2: renderBookedTable

    def renderBookedTable(self):
        prefix = "remove_item"
        available_columns = self.columns()
        available_columns[0].cell_formatter = label_cell_formatter_factory(prefix)
        available_columns[2].title = _('Reserved by others')
        columns = list(available_columns)

        title=_('Release resource')
        # XXX: this getter is just plain wrong
        getter = lambda r: r.__name__

        remove_column = ImageInputColumn(
            prefix, name='action',
            title=title, alt=title,
            library='schooltool.skin.flourish',
            image='remove-icon.png', id_getter=getter)
        columns.append(remove_column)

        formatter = zc.table.table.FormFullFormatter(
            self.context, self.request, self.getBookedItems(),
            columns=columns,
            sort_on=self.sortOn(),
            prefix="booked")
        formatter.cssClasses['table'] = 'data'

        return formatter()
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:26,代码来源:event.py

示例3: columns

 def columns(self):
     first_name = table.column.LocaleAwareGetterColumn(
         name='first_name',
         title=_(u'First Name'),
         getter=lambda i, f: i.first_name,
         subsort=True)
     last_name = table.column.LocaleAwareGetterColumn(
         name='last_name',
         title=_(u'Last Name'),
         getter=lambda i, f: i.last_name,
         subsort=True)
     result = [first_name, last_name]
     optional_column_token = self.request.get('optional')
     if optional_column_token is not None:
         provider_name, column_name = optional_column_token.split('.')
         provider = getAdapter(self.view, IColumnProvider,
                               name=provider_name)
         optional_column = None
         for column in provider.columns:
             if column.name == column_name:
                 optional_column = column
                 break
         if optional_column is not None:
             result.append(optional_column)
     return result
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:25,代码来源:group.py

示例4: populate

 def populate(self, states):
     super(GroupMembershipStatesStartup, self).populate(states)
     states.add(_('Pending'), INACTIVE, 'i')
     states.add(_('Member'), ACTIVE, 'a')
     states.add(_('Suspended'), INACTIVE, 's')
     states.add(_('Removed'), INACTIVE, 'r')
     states.add(_('Added in error'), INACTIVE, 'e')
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:7,代码来源:states.py

示例5: columns

 def columns(self):
     task_id = table.column.IndexedGetterColumn(
         index='task_id',
         name='task_id',
         cell_formatter=self.task_id_formatter,
         title=_(u'Task ID'),
         getter=lambda i, f: i.task_id,
         subsort=True)
     signature = table.table.GetterColumn(
         name='signature',
         title=_(u'Signature'),
         getter=lambda i, f: i.signature,
         subsort=True)
     internal_state = table.column.IndexedGetterColumn(
         index='internal_state',
         name='internal_state',
         title=_(u'Internal state'),
         getter=lambda i, f: i,
         cell_formatter=task_state_formatter,
         subsort=True)
     directlyProvides(internal_state, ISortableColumn)
     scheduled = table.column.IndexedGetterColumn(
         index='scheduled',
         name='scheduled',
         title=_(u'Scheduled'),
         getter=lambda i, f: i.scheduled,
         cell_formatter=table.table.datetime_formatter,
         subsort=True)
     directlyProvides(scheduled, ISortableColumn)
     return [task_id, signature, internal_state, scheduled]
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:30,代码来源:task.py

示例6: renderAvailableTable

    def renderAvailableTable(self):
        prefix = "add_item"
        available_columns = self.columns()
        available_columns[0].cell_formatter = label_cell_formatter_factory(prefix)
        available_columns[2].title = _('Reserved by others')
        columns = list(available_columns)

        title=_('Reserve resource')
        # XXX: this getter is just plain wrong
        getter = lambda r: r.__name__

        add_column = ImageInputColumn(
            prefix, name='action',
            title=title, alt=title,
            library='schooltool.skin.flourish',
            image='add-icon.png', id_getter=getter)
        columns.append(add_column)

        formatter = zc.table.table.FormFullFormatter(
            self.context, self.request, self.filter(self.availableResources),
            columns=columns,
            batch_start=self.batch.start, batch_size=self.batch.size,
            sort_on=self.sortOn(),
            prefix="available")
        formatter.cssClasses['table'] = 'data'


        return formatter()
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:28,代码来源:event.py

示例7: email_container_table_columns

def email_container_table_columns():
    from_address = GetterColumn(name='from_address',
                                title=_(u'From'),
                                getter=lambda i, f: i.from_address,
                                subsort=True)
    directlyProvides(from_address, ISortableColumn)
    to_addresses = GetterColumn(name='to_addresses',
                                title=_(u'To'),
                                getter=lambda i, f: i.to_addresses,
                                cell_formatter=to_addresses_formatter,
                                subsort=True)
    directlyProvides(to_addresses, ISortableColumn)
    subject = GetterColumn(name='subject',
                           title=_(u'Subject'),
                           getter=lambda i, f: i.subject,
                           cell_formatter=subject_formatter,
                           subsort=True)
    directlyProvides(subject, ISortableColumn)
    time_created = GetterColumn(name='time_created',
                                title=_(u'Created on'),
                                getter=lambda i, f: i.time_created,
                                cell_formatter=table.table.datetime_formatter,
                                subsort=True)
    directlyProvides(time_created, ISortableColumn)
    time_sent = GetterColumn(name='time_sent',
                                title=_(u'Last time tried'),
                                getter=lambda i, f: i.time_sent,
                                cell_formatter=table.table.datetime_formatter,
                                subsort=True)
    directlyProvides(time_sent, ISortableColumn)
    return [from_address, to_addresses, subject, time_created, time_sent]
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:31,代码来源:email.py

示例8: sizeForDisplay

 def sizeForDisplay(self):
     num = self.sizeForSorting()[1]
     if num == 1:
         msgid = _("1 person")
     else:
         msgid = _("${number} persons", mapping={'number': num})
     return msgid
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:7,代码来源:__init__.py

示例9: toFieldValue

 def toFieldValue(self, value):
     if value is None or value == '':
         return z3c.form.interfaces.NOT_CHANGED
     if value == 'delete':
         # XXX: delete checkbox was marked
         return None
     data = value.read()
     try:
         image = Image.open(StringIO(data))
         if image.format not in ('JPEG', 'PNG'):
             raise IOError()
     except (IOError,):
         raise FormatterValidationError(
             _('The file uploaded is not a JPEG or PNG image'), value)
     size = len(data)
     if size > self.field.max_file_size:
         msg = _('The image uploaded cannot be larger than ${size} MB')
         raise FormatterValidationError(
             format_message(
                 msg,
                 mapping={'size': '%.2f' % (float(size) / (10**6))}),
             value)
     data = self.processImage(image)
     f = ImageFile()
     self.updateFile(f, data)
     return f
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:26,代码来源:widgets.py

示例10: update

    def update(self):
        """Read and validate form data, and update model if necessary.

        Also choose the correct template to render.
        """
        self.field_errors = []
        self.template = self.select_template

        if 'CANCEL' in self.request:
            self.request.response.redirect(
                absoluteURL(self.context, self.request))
            return

        if 'date' in self.request:
            try:
                self.date = parse_date(self.request['date'])
            except ValueError:
                self.error = _("Invalid date. Please use YYYY-MM-DD format.")
            else:
                self.term = getTermForDate(self.date)
                if self.term is None:
                    self.error = _("The date does not belong to any term.")
                    self.date = None

        if self.date:
            self.template = self.form_template

        if self.date and 'SUBMIT' in self.request:
            replacements = self.extractMeetings()
            if self.field_errors:
                self.error = self.field_error_message
            else:
                self.updateExceptions(replacements)
                self.request.response.redirect(
                    absoluteURL(self.context, self.request))
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:35,代码来源:schedule.py

示例11: parseCSVRows

    def parseCSVRows(self, rows):
        """Parse rows (a list of strings) in CSV format.

        Returns a list of rows as lists.

        rows must be in the encoding specified during construction of
        BaseCSVImportView; the returned values are in unicode.

        If the provided data is invalid, self.errors.generic will be updated
        and None will be returned.
        """
        result = []
        reader = csv.reader(rows)
        line = 0
        try:
            while True:
                line += 1
                values = [v.strip() for v in reader.next()]
                if self.charset:
                    values = [unicode(v, self.charset) for v in values]
                # Remove trailing empty cells.
                while values and not values[-1].strip():
                    del values[-1]
                result.append(values)
        except StopIteration:
            return result
        except csv.Error:
            error_msg = _("Error in CSV data, line ${line_no}",
                          mapping={'line_no': line})
            self.errors.generic.append(error_msg)
        except UnicodeError:
            error_msg = _("Conversion to unicode failed in line ${line_no}",
                          mapping={'line_no': line})
            self.errors.generic.append(error_msg)
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:34,代码来源:csvimport.py

示例12: choices

 def choices(self):
     session = self.getSessionData()
     if session['cycle'] == 'rotating':
         choices = ((True,  _("Have names")),)
     else:
         choices = ((True,  _("Have names")),
                    (False, _("Designated by time")))
     return choices
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:8,代码来源:ttwizard.py

示例13: updateWidgets

 def updateWidgets(self):
     super(FlourishTermAddView, self).updateWidgets()
     description = _(u'The year starts ${year_start}',
         mapping={'year_start': self.dateString(self.context.first)})
     self.widgets['first'].field.description = description
     description = _(u'The year ends ${year_end}',
         mapping={'year_end': self.dateString(self.context.last)})
     self.widgets['last'].field.description = description
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:8,代码来源:term.py

示例14: subtitle

 def subtitle(self):
     cursor_yw = year_week(self.cursor)
     if cursor_yw == year_week(self.today):
         return _("This Week")
     if cursor_yw == year_week(self.today - datetime.timedelta(weeks=1)):
         return _("Last Week")
     if cursor_yw == year_week(self.today + datetime.timedelta(weeks=1)):
         return _("Next Week")
     return None
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:9,代码来源:calendar.py

示例15: types

 def types(self):
     options = [
         {'id': 'equipment',
          'title': _('Equipment')},
         {'id': 'location',
          'title': _('Location')},
         {'id': 'resource',
          'title': _('Resource')},
         ]
     return options
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:10,代码来源:resource.py


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