Esempio n. 1
0
 def getQ(self, field, value, negative=False):
     if isinstance(value, str):
         if value[:1] == self.Separators._safe:
             return ~Q(**{field: value[1:]}) if negative else Q(
                 **{field: value[1:]})
         return ~Q(**{field: make_searchable(value)}) if negative else Q(
             **{field: make_searchable(value)})
     return ~Q(**{field: value}) if negative else Q(**{field: value})
Esempio n. 2
0
 def get_Q(self, field, value, negative=False):
     logger("mighty", "info",
            "field: %s, value: %s, negative: %s" % (field, value, negative),
            self.request.user)
     if isinstance(value, str):
         if value[:1] == self.config["safe"]:
             return ~Q(**{field: value[1:]}) if negative else Q(
                 **{field: value[1:]})
         return ~Q(**{field: make_searchable(value)}) if negative else Q(
             **{field: make_searchable(value)})
     return ~Q(**{field: value}) if negative else Q(**{field: value})
Esempio n. 3
0
 def timeline_search(self):
     if hasattr(self, self.timeline_relate()):
         return [
             make_searchable(field.get_value)
             for field in getattr(self, self.timeline_relate()).filter(
                 field__in=self.search_fields)
         ]
     return []
Esempio n. 4
0
 def get_code(self):
     fields = [
         getattr(self, field) for field in self.code_fields
         if hasattr(self, field)
     ]
     code = "".join([
         field[0] for field in fields
         if re.match(re.compile('[a-zA-Z0-9]+'), field)
     ])
     code = make_searchable(code).upper()
     return generate_code(self, code=code, rule=self.unique_rule)
Esempio n. 5
0
 def render_to_response(self, context, **response_kwargs):
     frmat = self.request.GET.get('format', '')
     objects_list = self.get_queryset().values_list(*self.fields)
     response = StreamingHttpResponse(
         streaming_content=(self.iter_items(objects_list,
                                            StreamingBuffer())),
         content_type='text/csv',
     )
     response[
         'Content-Disposition'] = 'attachment;filename=%s.csv' % get_valid_filename(
             make_searchable(self.model._meta.verbose_name))
     return response
Esempio n. 6
0
 def get_search_fields(self):
     return ' '.join([
         make_searchable(str(getattr(self, field)))
         for field in self.search_fields if getattr(self, field)
     ] + self.timeline_search()).split()
Esempio n. 7
0
 def make_searchable(self, input_str):
     return functions.make_searchable(input_str)
Esempio n. 8
0
 def save(self, *args, **kwargs):
     self.url_name = get_valid_filename(make_searchable(self.name))
     super().save(*args, **kwargs)
Esempio n. 9
0
 def set_to_search(self):
     self.to_search = make_searchable(str(self.__str__()))
Esempio n. 10
0
 def get_company_by_fulltext(self, fulltext):
     if len(fulltext) == 10 and fulltext[0] == 'W':
         return self.get_company_by_rna(fulltext)
     fulltext = re.sub(r"\s+", '-', fulltext)
     return self.get_companies('denominationUniteLegale:%s+AND+etatAdministratifUniteLegale:A' % make_searchable(fulltext))
Esempio n. 11
0
 def get_data(self):
     return make_searchable(self.request.GET.get('check').lower())