def named_tuple(self, name): """ Return named tuple for model status use """ named_tuple = [ (signal_marker.val, signal_marker.name, signal_marker.description) for signal_marker in self.signal_map ] return get_namedtuple_choices(name, tuple(named_tuple))
# -*- coding: utf-8 -*- from toolkit.utils import get_namedtuple_choices from toolkit.utils import _class_importer from dateutil import parser BASE_MARKER_ACTION_TYPES = get_namedtuple_choices('ACTION_TYPE', ( (0, 'remote', 'Remote'), (1, 'redirect', 'Redirect'), (2, 'modal', 'Modal'), )) class Marker(object): ACTION_TYPE = BASE_MARKER_ACTION_TYPES # overridden with customer .getter and .setter _tool = None _description = None _long_description = None val = None name = None signals = [] action_name = None action_type = None action = None action_user_class = [] # must be a list so we can handle multiple types
from .mixins import (RequestDocumentUploadMixin, ReviewInProgressMixin, SigningInProgressMixin, RequestedDocumentReminderEmailsMixin, RevisionReviewReminderEmailsMixin, RevisionSignReminderEmailsMixin, ItemLastCommentByMixin) from jsonfield import JSONField from uuidfield import UUIDField import datetime BASE_ITEM_STATUS = get_namedtuple_choices('ITEM_STATUS', ( (0, 'new', 'New'), (1, 'final', 'Final'), (2, 'executed', 'Executed'), )) class Item(IsDeletedMixin, ApiSerializerMixin, RequestDocumentUploadMixin, ReviewInProgressMixin, SigningInProgressMixin, RequestedDocumentReminderEmailsMixin, RevisionReviewReminderEmailsMixin, RevisionSignReminderEmailsMixin, ItemLastCommentByMixin, models.Model): """
"manage_document_reviews": False, "manage_items": False, "manage_signature_requests": False, "manage_clients": False, "manage_tasks": False, "manage_attachments": False, } # # Not logged in or random user permissions # ANONYMOUS_USER_PERMISSIONS = dict.fromkeys([key for key, value in GRANULAR_PERMISSIONS], False) ROLES = get_namedtuple_choices('ROLES', ( (0, 'noone', 'No Access'), (1, 'owner', 'Owner'), (2, 'client', 'Client'), (3, 'colleague', 'Colleague'), (4, 'thirdparty', '3rd Party'), )) class WorkspaceParticipants(models.Model): """ Model to store the Users permissions with regards to a matter """ # ROLES are simply for the GUI as ideally all of our users would # simple have 1 or more of a set of permission ROLES = ROLES PERMISSIONS = MATTER_OWNER_PERMISSIONS.keys() # as the MATTER_OWNER_PERMISSIONS always has ALL of them MATTER_OWNER_PERMISSIONS = MATTER_OWNER_PERMISSIONS PRIVILEGED_USER_PERMISSIONS = PRIVILEGED_USER_PERMISSIONS
def test_named_tuple(self): subject = self._get_test_subject(markers=MULTIPLE_MARKERS) # set up the test comparison # take our basic list and turn it into a named tuple EXPECTED_MONKEYS = get_namedtuple_choices('MONKEYS', tuple([(signal_marker.val, signal_marker.name, signal_marker.description) for signal_marker in MULTIPLE_MARKERS])) self.assertEqual(subject.named_tuple(name='MONKEYS'), EXPECTED_MONKEYS)
from uuidfield import UUIDField from jsonfield import JSONField from rulez import registry as rulez_registry from .managers import RevisionManager from .mixins import StatusLabelsMixin import re import os BASE_REVISION_STATUS = get_namedtuple_choices('REVISION_STATUS', ( (0, 'draft', 'Draft'), (1, 'for_discussion', 'For Discussion'), (2, 'final', 'Final'), (3, 'executed', 'Executed'), (4, 'filed', 'Filed'), )) def _upload_revision(instance, filename): split_file_name = os.path.split(filename)[-1] filename_no_ext, ext = os.path.splitext(split_file_name) identifier = '%s-%d-%s' % (instance.slug, instance.item.pk, instance.uploaded_by.username) full_file_name = '%s-%s%s' % (identifier, slugify(filename_no_ext), ext) if identifier in slugify(filename): # # If we already have this filename as part of the recombined filename