Пример #1
0
 def handleDelete(self):
     formkey_to_name = dict(
         [(simple_form_key(level), level.__name__)
          for level in self.context.values()])
     for form_key in self.request.get('delete', []):
         if form_key in formkey_to_name:
             del self.context[formkey_to_name[form_key]]
     self.redirectToContainer()
Пример #2
0
 def handleDelete(self):
     form_items = dict(
         [(simple_form_key(level), level.__name__)
          for level in self.context.values()])
     for form_key, name in form_items.items():
         if 'delete.%s' % form_key in self.request:
             del self.context[name]
             self.deleted = True
Пример #3
0
    def update(self):
        super(FlourishTimetableContainerView, self).update()

        # XXX: deletion without confirmation is quite dangerous
        delete = [
            key for key, item in self.container.items()
            if "delete.%s" % table.simple_form_key(item) in self.request]
        for key in delete:
            del self.container[key]
        if delete:
            self.request.response.redirect(
                absoluteURL(self.context, self.request))
Пример #4
0
 def handleApply(self):
     keys = list(self.context.keys())
     new_keys = keys[:]
     for old_pos, level in enumerate(self.context.values()):
         form_key = 'pos.%s' % simple_form_key(level)
         if form_key not in self.request:
             continue
         new_pos = int(self.request[form_key]) - 1
         if new_pos != old_pos:
             new_keys.remove(level.__name__)
             new_keys.insert(new_pos, level.__name__)
     if keys != new_keys:
         self.context.updateOrder(new_keys)
Пример #5
0
    def update(self):
        super(FlourishTimetableContainerView, self).update()

        # XXX: deletion without confirmation is quite dangerous
        delete = [
            key for key, item in self.container.items()
            if "delete.%s" % table.simple_form_key(item) in self.request
        ]
        for key in delete:
            del self.container[key]
        if delete:
            self.request.response.redirect(
                absoluteURL(self.context, self.request))
Пример #6
0
 def levels(self):
     levels = self.context.values()
     result = []
     positions = range(len(levels))
     for n, level in enumerate(levels):
         pos_numbers = [
             {'value': pos+1,
              'selected': (pos==n and 'selected' or None)}
             for pos in positions]
         result.append({
             'form_key': simple_form_key(level),
             'level': level,
             'positions': pos_numbers})
     return result
Пример #7
0
def getBoundContactFormKey(contact):
    doc_id = getUtility(IIntIds).getId(contact)
    return 'persons.%s%x' % (simple_form_key(contact.__parent__), doc_id)
Пример #8
0
def getBoundContactFormKey(contact):
    doc_id = getUtility(IIntIds).getId(contact)
    return 'persons.%s%x' % (simple_form_key(contact.__parent__), doc_id)
Пример #9
0
 def getPeriodKey(self, day, period):
     return 'period.%s.%s' % (simple_form_key(day),
                              simple_form_key(period))