예제 #1
0
    def __init__(self,
                 verbose_name=None,
                 key="default_key",
                 template="%NNNNN",
                 default=None,
                 name=None,
                 pattern=None,
                 expanders=None,
                 params={},
                 auto=True,
                 **kwargs):

        super().__init__(verbose_name, name, default=default, **kwargs)
        self.default_error_messages = {
            'invalid': strings.SEQUENCE_FIELD_PATTERN_MISMATCH
        }
        self._db_type = kwargs.pop('db_type', None)
        self.evaluate_formfield = kwargs.pop('evaluate_formfield', False)

        self.lazy = kwargs.pop('lazy', True)

        self.key = key

        default_pattern = \
            sequence_field_settings.SEQUENCE_FIELD_DEFAULT_PATTERN
        self.pattern = pattern or default_pattern

        default_template = Sequence.get_template_by_key(self.key)
        self.template = template or default_template

        Sequence.create_if_missing(self.key, self.template)

        default_expanders = \
            sequence_field_settings.SEQUENCE_FIELD_DEFAULT_EXPANDERS

        self.params = params or {}

        self.expanders = expanders or default_expanders

        self.auto = auto

        kwargs['help_text'] = kwargs.get(
            'help_text', self.default_error_messages['invalid'])
예제 #2
0
    def __init__(self, *args, **kwargs):
        self.default_error_messages = {
            'invalid': strings.SEQUENCE_FIELD_PATTERN_MISMATCH
        }
        self._db_type = kwargs.pop('db_type', None)
        self.evaluate_formfield = kwargs.pop('evaluate_formfield', False)

        self.lazy = kwargs.pop('lazy', True)

        
        try:
            self.key = kwargs.pop('key')
        except KeyError:
            self.key = 'default_key'
            #raise SequenceFieldException(
            #   strings.SEQUENCE_FIELD_MISSING_KEY 
            #)
        
        
        default_pattern = \
            sequence_field_settings.SEQUENCE_FIELD_DEFAULT_PATTERN
        self.pattern = kwargs.pop('pattern', default_pattern)

        default_template = Sequence.get_template_by_key(self.key)
        self.template = kwargs.pop('template', default_template)

        Sequence.create_if_missing(self.key, self.template)
        
        default_expanders = \
            sequence_field_settings.SEQUENCE_FIELD_DEFAULT_EXPANDERS

        self.params = kwargs.pop('params', {})

        self.expanders = kwargs.pop('expanders', default_expanders)

        self.auto = kwargs.pop('auto', False)

        kwargs['help_text'] = kwargs.get(
            'help_text', self.default_error_messages['invalid']
        )

        super(SequenceField, self).__init__(*args, **kwargs)
예제 #3
0
    def __init__(self, *args, **kwargs):
        self.default_error_messages = {
            'invalid': strings.SEQUENCE_FIELD_PATTERN_MISMATCH
        }
        self._db_type = kwargs.pop('db_type', None)
        self.evaluate_formfield = kwargs.pop('evaluate_formfield', False)

        self.lazy = kwargs.pop('lazy', True)

        try:
            self.key = kwargs.pop('key')
        except KeyError:
            raise SequenceFieldException(strings.SEQUENCE_FIELD_MISSING_KEY)

        default_pattern = \
            sequence_field_settings.SEQUENCE_FIELD_DEFAULT_PATTERN
        self.pattern = kwargs.pop('pattern', default_pattern)

        default_template = Sequence.get_template_by_key(self.key)
        self.template = kwargs.pop('template', default_template)

        Sequence.create_if_missing(self.key, self.template)

        default_expanders = \
            sequence_field_settings.SEQUENCE_FIELD_DEFAULT_EXPANDERS

        self.params = kwargs.pop('params', {})

        self.expanders = kwargs.pop('expanders', default_expanders)

        self.auto = kwargs.pop('auto', False)

        kwargs['help_text'] = kwargs.get(
            'help_text', self.default_error_messages['invalid'])

        super(SequenceField, self).__init__(*args, **kwargs)
예제 #4
0
 def _next_value(self):
     seq = Sequence.create_if_missing(self.key, self.template)
     return seq.next_value(self.template, self.params, self.expanders)
예제 #5
0
 def _next_value(self):
     seq =  Sequence.create_if_missing(self.key, self.template)
     return seq.next_value(self.template, self.params, self.expanders)