Exemplo n.º 1
0
class VendorSearch(models.Model):
    """Model pointing to the original searched model."""

    link = models.OneToOneField('market.Vendor', on_delete=models.CASCADE)
    name = models.CharField(max_length=100)
    motto = models.CharField(max_length=255)
    description = models.TextField(null=True)

    fts_name = TSVectorField(('name', ), dictionary=settings.PG_FT_LANGUAGE)
    fts = TSVectorField((('name', 'A'), ('motto', 'B'), ('description', 'C')),
                        dictionary=settings.PG_FT_LANGUAGE)

    class Meta:
        """Define mandatory app_label."""
        app_label = 'search'
        required_db_vendor = 'postgresql'
        required_db_features = ['tsearch2']
Exemplo n.º 2
0
class Article(models.Model):
    title = models.CharField(max_length=255)
    article = models.TextField()

    fts_index = TSVectorField((('title', 'A'), 'article'),
                              dictionary='portuguese')

    def __str__(self):
        return self.title
Exemplo n.º 3
0
class TSQueryModel(models.Model):
    title = models.CharField(max_length=50)
    body = models.TextField()
    sometext = models.CharField(max_length=50, null=True, blank=True)

    tsvector = TSVectorField(('title', 'body'))

    def __str__(self):
        return self.title
Exemplo n.º 4
0
class TSMultidicModel(models.Model):
    title = models.CharField(max_length=50)
    body = models.TextField()
    sometext = models.CharField(max_length=50, null=True, blank=True)
    dictionary = models.CharField(
        max_length=15,
        choices=(('english', 'english'), ('portuguese', 'portuguese')),
        default='english'
    )
    tsvector = TSVectorField((('title', 'A'), 'body'),
                             dictionary='dictionary')

    def __str__(self):
        return self.title
Exemplo n.º 5
0
class LocalityIndex(models.Model):
    """
    LocalityIndex enables FullTextSearch filtering for the *Locality* based on
    its *Values* and *fts_rank* specified by a *Specification*

    LocalityIndex will be autoupdated when 'SIG_locality_values_updated' is
    triggered
    """

    locality = models.OneToOneField('Locality')
    ranka = models.TextField(null=True)
    rankb = models.TextField(null=True)
    rankc = models.TextField(null=True)
    rankd = models.TextField(null=True)
    fts_index = TSVectorField(
        (('ranka', 'A'), ('rankb', 'B'), ('rankc', 'C'), ('rankd', 'D')))
Exemplo n.º 6
0
class Rate(models.Model):
    determination = models.ForeignKey(WageDetermination)
    dollars_per_hour = models.DecimalField(max_digits=6, decimal_places=2)
    fringe = models.TextField()
    group_qualifier = models.TextField(blank=True)

    construction_type = models.TextField()
    construction_subtype = models.TextField(blank=True)
    construction_qualifier = models.TextField(blank=True)
    construction_survey_qualifier = models.TextField(blank=True)

    occupation = models.TextField()
    occupation_qualifier = models.TextField(blank=True)
    rate_name = models.TextField(blank=True)
    rate_name_qualifier = models.TextField(blank=True)
    subrate_name = models.TextField(blank=True)
    subrate_name_qualifier = models.TextField(blank=True)

    counties = models.ManyToManyField(County)
    location_qualifier = models.TextField(blank=True)
    survey_location_qualifier = models.TextField(blank=True)

    # when a user needs to request a new determination
    # official_dol = models.BooleanField(default=True)

    _STR_TEMPLATE = '{determination}: {occupation}/{rate_name}/{subrate_name} '
    _STR_TEMPLATE += '${dollars_per_hour}'

    def __str__(self):
        return self._STR_TEMPLATE.format(determination=self.determination,
                                         **self.__dict__)

    fts_index = TSVectorField((
        ('occupation', 'A'),
        ('rate_name', 'B'),
        ('subrate_name', 'B'),
        'occupation_qualifier',
        'rate_name_qualifier',
        'subrate_name_qualifier',
    ),
                              dictionary='english')
Exemplo n.º 7
0
        class TSVectorModelError(models.Model):
            title = models.CharField(max_length=50)
            body = models.TextField()

            tsvector = TSVectorField(
                (('x', 'z'), 'body'))
Exemplo n.º 8
0
        class TSVectorModelClean(models.Model):
            title = models.CharField(max_length=50)
            body = models.TextField()

            tsvector = TSVectorField(
                (('title', 'A'), 'body'))