Exemplo n.º 1
0
 def _update(self):
     self.do_apply = is_permitted(self.brains, perm='imio.dms.mail: Write treating group field')
     self.fields += Fields(schema.Choice(
         __name__='treating_group',
         title=_(u"Treating groups"),
         description=(not self.do_apply and cannot_modify_field_msg or u''),
         required=self.do_apply,
         vocabulary=(self.do_apply and u'collective.dms.basecontent.treating_groups' or SimpleVocabulary([])),
     ))
Exemplo n.º 2
0
 def _update(self):
     self.do_apply = is_permitted(self.brains)
     self.fields += Fields(schema.Choice(
         __name__='assigned_group',
         title=_(u"Assigned group"),
         description=(not self.do_apply and cannot_modify_field_msg or u''),
         required=(self.do_apply),
         vocabulary=self.do_apply and u'collective.task.AssignedGroups' or SimpleVocabulary([]),
     ))
Exemplo n.º 3
0
 def _update(self):
     self.do_apply = is_permitted(self.brains)
     self.fields += Fields(schema.Datetime(
         __name__='outgoing_date',
         title=_(u"Outgoing Date"),
         description=(not self.do_apply and cannot_modify_field_msg or u''),
         required=(self.do_apply),
         default=datetime.datetime.now(),
     ))
Exemplo n.º 4
0
 def _update(self):
     self.voc = self.get_available_assigneduser_voc()
     self.do_apply = is_permitted(self.brains)
     self.fields += Fields(schema.Choice(
         __name__='assigned_user',
         title=_(u'Assigned user'),
         vocabulary=self.do_apply and self.voc or SimpleVocabulary([]),
         description=((len(self.voc) <= 1 and self.err_msg) or
                      (not self.do_apply and cannot_modify_field_msg) or u''),
         required=self.do_apply))
Exemplo n.º 5
0
 def _update(self):
     self.do_apply = is_permitted(self.brains)
     self.fields += Fields(
         schema.Choice(
             __name__='assigned_group',
             title=_(u"Assigned group"),
             description=(not self.do_apply and cannot_modify_field_msg
                          or u''),
             required=(self.do_apply),
             vocabulary=self.do_apply and u'collective.task.AssignedGroups'
             or SimpleVocabulary([]),
         ))
Exemplo n.º 6
0
 def _update(self):
     self.voc = self.get_available_assigneduser_voc()
     self.do_apply = is_permitted(self.brains)
     self.fields += Fields(
         schema.Choice(
             __name__='assigned_user',
             title=_(u'Assigned user'),
             vocabulary=self.do_apply and self.voc or SimpleVocabulary([]),
             description=((len(self.voc) <= 1 and self.err_msg)
                          or (not self.do_apply and cannot_modify_field_msg)
                          or u''),
             required=self.do_apply))
Exemplo n.º 7
0
 def _update(self):
     self.do_apply = is_permitted(self.brains)
     self.fields += Fields(MasterSelectField(
         __name__='action_choice',
         title=_(u'Batch action choice'),
         description=(not self.do_apply and cannot_modify_field_msg or u''),
         vocabulary=SimpleVocabulary([SimpleTerm(value=u'add', title=_(u'Add items')),
                                      SimpleTerm(value=u'remove', title=_(u'Remove items')),
                                      SimpleTerm(value=u'replace', title=_(u'Replace some items by others')),
                                      SimpleTerm(value=u'overwrite', title=_(u'Overwrite'))]),
         slave_fields=(
             {'name': 'removed_values',
              'slaveID': '#form-widgets-removed_values',
              'action': 'hide',
              'hide_values': (u'add', u'overwrite'),
              'siblings': True,
              },
             {'name': 'added_values',
              'slaveID': '#form-widgets-added_values',
              'action': 'hide',
              'hide_values': (u'remove'),
              'siblings': True,
              },
         ),
         required=self.do_apply,
         default=u'add'
     ))
     if self.do_apply:
         self.fields += Fields(schema.List(
             __name__='removed_values',
             title=_(u"Removed values"),
             description=_(u"Select the values to remove (CTRL+click)"),
             required=False,
             value_type=schema.Choice(vocabulary=u'collective.dms.basecontent.recipient_groups'),
         ))
         self.fields += Fields(schema.List(
             __name__='added_values',
             title=_(u"Added values"),
             description=_(u"Select the values to add (CTRL+click)"),
             required=False,
             value_type=schema.Choice(vocabulary=u'collective.dms.basecontent.recipient_groups'),
         ))
         self.fields["removed_values"].widgetFactory = SelectFieldWidget
         self.fields["added_values"].widgetFactory = SelectFieldWidget
Exemplo n.º 8
0
 def _update(self):
     assert self.attribute
     assert self.field_value_type is not None
     self.do_apply = is_permitted(self.brains)
     self.fields += Fields(
         schema.Choice(
             __name__='action_choice',
             title=_(u'Batch action choice'),
             description=(not self.do_apply and cannot_modify_field_msg
                          or u''),
             vocabulary=SimpleVocabulary([
                 SimpleTerm(value=u'add', title=_(u'Add items')),
                 SimpleTerm(value=u'remove', title=_(u'Remove items')),
                 SimpleTerm(value=u'replace',
                            title=_(u'Replace some items by others')),
                 SimpleTerm(value=u'overwrite', title=_(u'Overwrite'))
             ]),
             required=self.do_apply,
             default=u'add'))
     if self.do_apply:
         self.fields += Fields(
             ContactList(
                 __name__='removed_values',
                 title=_(u"Removed values"),
                 description=_(
                     u"Search and select the values to remove, if necessary."
                 ),
                 required=False,
                 addlink=False,
                 value_type=self.field_value_type,
             ))
         self.fields += Fields(
             ContactList(
                 __name__='added_values',
                 title=_(u"Added values"),
                 description=_(u"Search and select the values to add."),
                 required=False,
                 addlink=False,
                 value_type=self.field_value_type,
             ))
Exemplo n.º 9
0
 def get_labels_vocabulary(self):
     terms, p_labels, g_labels = [], [], []
     context = self.get_labeljar_context()
     try:
         adapted = ILabelJar(context)
     except:
         return SimpleVocabulary(terms), [], []
     self.can_change_labels = is_permitted(self.brains,
                                           perm='ftw.labels: Change Labels')
     for label in adapted.list():
         if label['by_user']:
             p_labels.append(label['label_id'])
             terms.append(
                 SimpleVocabulary.createTerm(
                     '%s:' % label['label_id'], label['label_id'],
                     u'{} (*)'.format(safe_unicode(label['title']))))
         else:
             g_labels.append(label['label_id'])
             if self.can_change_labels:
                 terms.append(
                     SimpleVocabulary.createTerm(
                         label['label_id'], label['label_id'],
                         safe_unicode(label['title'])))
     return SimpleVocabulary(terms), set(p_labels), g_labels
Exemplo n.º 10
0
 def test_is_permitted(self):
     doc_uids = u"{0},{1}".format(self.doc1.UID(), self.doc2.UID())
     brains = brains_from_uids(doc_uids)
     self.assertTrue(is_permitted(brains))
     self.assertFalse(is_permitted(brains, 'Review comments'))
 def test_is_permitted(self):
     doc_uids = u"{0},{1}".format(self.doc1.UID(), self.doc2.UID())
     brains = brains_from_uids(doc_uids)
     self.assertTrue(is_permitted(brains))
     self.assertFalse(is_permitted(brains, 'Review comments'))