Example #1
0
 def register_indexex(self):
     register_index(Indexed, {
         'name': ('iexact', 'endswith', 'istartswith', 'iendswith', 'contains',
                  'icontains', re.compile('^i+', re.I), re.compile('^I+'),
                  re.compile('^i\d*i$', re.I)),
         'published': ('month', 'day', 'year', 'week_day'),
         'tags': ('iexact', 'icontains', StandardLookup() ),
     #    'foreignkey': 'iexact',
         'foreignkey__title': 'iexact',
         'foreignkey__name_fi': 'iexact',
         'foreignkey__fk__name_fi2': ('iexact', 'endswith'),
         'foreignkey2__name_fi2': (StandardLookup(), 'iexact'),
         'foreignkey2__age': (StandardLookup())
     })
     
     register_index(ForeignIndexed, {
         'title': 'iexact',
         'name_fi': ('iexact', 'icontains'),
         'fk__name_fi2': ('iexact', 'endswith'),
         'fk__age': (StandardLookup()),
     })
Example #2
0
from models import Recipe, Question
from dbindexer.api import register_index

register_index(Recipe, {'text': 'icontains'})
Example #3
0
from dbindexer import autodiscover
autodiscover()

from facebook_app.models import Course
from dbindexer.api import register_index
register_index(Course, {'name': ('icontains', 'contains')})
#register_index(Course,{'teacher':('icontains','contains')})
Example #4
0
from django.conf import settings

if 'django.contrib.auth' in settings.INSTALLED_APPS:
    from dbindexer.api import register_index
    from django.contrib.auth.models import User

    register_index(User, {
        'username': '******',
        'email': 'iexact',
    })

if 'django.contrib.admin' in settings.INSTALLED_APPS:
    from dbindexer.api import register_index
    from django.contrib.admin.models import LogEntry

    register_index(LogEntry, {
        'object_id': 'exact',
    })
Example #5
0
from .models import Choice
from dbindexer.api import register_index

register_index(Choice, {
    'poll__pub_date': 'year',
})
Example #6
0
from dbindexer.api import register_index
from emailconfirmation.models import EmailAddress

register_index(EmailAddress, {'email': 'iexact', })
Example #7
0
from models import Book, Writer
from dbindexer.api import register_index

register_index(Book, {'search': 'icontains'})
register_index(Writer, {'search': 'icontains'})

Example #8
0
from .models import Blog, Post
from dbindexer.api import register_index
from dbindexer import autodiscover

autodiscover()
register_index(Blog, {'title': 'icontains'})
#register_index(Post, {'title': 'icontains', 'url': 'icontains', 'author':'iexact'})
Example #9
0
from prospects.models import Prospect 
from dbindexer.api import register_index
register_index(Prospect, {'email': 'iexact'})
Example #10
0
from dbindexer.lookups import StandardLookup
from dbindexer.api import register_index
from app_users.models import UserProfile

register_index(UserProfile, {'user__username': (StandardLookup(), 'iexact'),})
Example #11
0
from dbindexer.api import register_index
from tagging.models import Tag

register_index(MyModel, {'name': 'icontains'})
Example #12
0
'''
Created on Jan 5, 2014

@author: zhouguangyi2009

this module is to make sure ajango-autoload function well:
ensure the registration of all database indexes specified in my project

This file need to be stored in the same folder as settings.py
'''

from dbindexer import autodiscover
autodiscover()

from myBlog.models import Author, Post
from django.contrib.auth.models import User 
from dbindexer.lookups import StandardLookup
from dbindexer.api import register_index

register_index(Post,{'author__username': StandardLookup(),})
Example #13
0
from models import Recipe, Question
from dbindexer.api import register_index

register_index(Recipe, {'name': 'icontains'})
register_index(Question, {'name': 'icontains'})
Example #14
0
from models import Recipe, Question
from dbindexer.api import register_index

register_index(Recipe, {"text": "icontains"})
Example #15
0
from models import Post
from dbindexer.api import register_index


register_index(Post, {'title': 'contains',})
Example #16
0

from models import UploadModel
from dbindexer.lookups import StandardLookup
from dbindexer.api import register_index

register_index(UploadModel, {'date': 'year'})
register_index(UploadModel, {'date': 'month'})
Example #17
0
from django.contrib.auth.models import User
from dbindexer.api import register_index

register_index(User, {
    'username': '******',
    'email':'icontains',
    'first_name':'icontains',
    'last_name':'icontains'
})
Example #18
0
from models import VesselDetail, Passage
from dbindexer.api import register_index
register_index(VesselDetail, {'ship_name': 'istartswith'})
register_index(Passage, {'ship_name': 'icontains'})
#register_index(Passage, {'date_added': 'day'})
#register_index(Passage, {'date_added': 'month'})
#register_index(Passage, {'date_added': 'year'})
Example #19
0
from dbindexer import autodiscover
autodiscover()

from facebook_app.models import Course
from dbindexer.api import register_index
register_index(Course,{'name':('icontains','contains')})
#register_index(Course,{'teacher':('icontains','contains')})
Example #20
0
    title = models.CharField(max_length=500)
    name_fi = models.CharField(max_length=500)
    fk = models.ForeignKey(ForeignIndexed2, null=True)

class Indexed(models.Model):
    name = models.CharField(max_length=500)
    published = models.DateTimeField(auto_now_add=True)
    foreignkey = models.ForeignKey(ForeignIndexed, null=True)
    foreignkey2 = models.ForeignKey(ForeignIndexed2, related_name='idx_set', null=True)

register_index(Indexed, {
    'name': ('iexact', 'endswith', 'istartswith', 'iendswith', 'contains',
        'icontains', re.compile('^i+', re.I), re.compile('^I+'),
        re.compile('^i\d*i$', re.I)),
    'published': ('month', 'day', 'week_day'),
    'foreignkey': 'iexact',
    'foreignkey__title': 'iexact',
    'foreignkey__fk__name_fi2': 'iexact',
    'foreignkey__name_fi': 'iexact',
    'foreignkey2__name_fi2': '$default'
})

class TestIndexed(TestCase):
    def setUp(self):
        juubi = ForeignIndexed2(name_fi2='Juubi')
        juubi.save()
        kyuubi = ForeignIndexed(name_fi='Kyuubi', title='Bijuu', fk=juubi)
        kyuubi.save()
        Indexed(name='ItAchi', foreignkey=kyuubi, foreignkey2=juubi).save()
        Indexed(name='YondAimE', foreignkey=kyuubi, foreignkey2=juubi).save()
        Indexed(name='I1038593i', foreignkey=kyuubi, foreignkey2=juubi).save()
Example #21
0
from models import Question, Questionnaire
from dbindexer.lookups import StandardLookup
from dbindexer.api import register_index

register_index(Question, {'questionnaire__product__uniqueName': StandardLookup()})
register_index(Questionnaire, {'product__uniqueName': StandardLookup()})
Example #22
0
from dbindexer.api import register_index
from pirate_forum.models import View
# dbindexes.py:
register_index(View, {'modified_dt': 'month', 'modified_dt': 'day',
						'modified_dt': 'year', 'created_dt': 'month', 'created_dt': 'day', 'created_dt': 'year'})
Example #23
0
from models import *
from dbindexer.lookups import StandardLookup
from dbindexer.api import register_index

register_index(Boban, {'email': 'iexact',
                         'last_name':  'icontains',
                           })
Example #24
0
# for use when you are using django non-rel which needs
# a little help to be able to execute some 'complex' queries.

from django.contrib.auth.models import User
from dbindexer.api import register_index

register_index(User, {
    'username': '******',
    'email': 'iexact',
    })
Example #25
0
from models import Post
from dbindexer.api import register_index

register_index(Post, {'title': ('iexact', 'icontains')})
Example #26
0
from django.conf import settings


if 'django.contrib.auth' in settings.INSTALLED_APPS:
    from dbindexer.api import register_index
    from django.contrib.auth.models import User

    register_index(User, {
        'username': '******',
        'email': 'iexact',
    })

if 'django.contrib.admin' in settings.INSTALLED_APPS:
    from dbindexer.api import register_index
    from django.contrib.admin.models import LogEntry

    register_index(LogEntry, {
        'object_id': 'exact',
    })
Example #27
0
from models import Order
from dbindexer.api import register_index
import logging

logging.info("registering index")
register_index(Order, {'from_raw': 'icontains', 'to_raw': 'icontains'})
Example #28
0
from books.models import Book
from dbindexer.api import register_index

register_index(Book, {"title": {"contains"}})
# models.py:

class MyModel(models.Model):
    name = models.CharField(max_length=64)
    last_modified = models.DateTimeField(auto_now=True)

def run_query(name, month):
    MyModel.objects.filter(name__iexact=name, last_modified__month=month)
    
# dbindexes.py:

from models import MyModel
from dbindexer.api import register_index
register_index(MyModel, {'name': 'iexact', 'last_modified': 'month'})
Example #30
0
from models import Survey
from dbindexer.lookups import StandardLookup
from dbindexer.api import register_index

register_index(Survey, {'user__username': StandardLookup()})
Example #31
0
# for use when you are using django non-rel which needs
# a little help to be able to execute some 'complex' queries.

from django.contrib.auth.models import User
from dbindexer.api import register_index

register_index(User, {
    'username': '******',
    'email': 'iexact',
})
Example #32
0
    published = models.DateTimeField(auto_now_add=True)
    foreignkey = models.ForeignKey(ForeignIndexed, null=True)
    foreignkey2 = models.ForeignKey(ForeignIndexed2,
                                    related_name='idx_set',
                                    null=True)


register_index(
    Indexed, {
        'name':
        ('iexact', 'endswith', 'istartswith', 'iendswith', 'contains',
         'icontains', re.compile(
             '^i+', re.I), re.compile('^I+'), re.compile('^i\d*i$', re.I)),
        'published': ('month', 'day', 'week_day'),
        'foreignkey':
        'iexact',
        'foreignkey__title':
        'iexact',
        'foreignkey__fk__name_fi2':
        'iexact',
        'foreignkey__name_fi':
        'iexact',
        'foreignkey2__name_fi2':
        '$default'
    })


class TestIndexed(TestCase):
    def setUp(self):
        juubi = ForeignIndexed2(name_fi2='Juubi')
        juubi.save()
        kyuubi = ForeignIndexed(name_fi='Kyuubi', title='Bijuu', fk=juubi)
Example #33
0
from models import Profile, Skill
from dbindexer.api import register_index
register_index(Profile, {'full_name': 'icontains', 'email': 'icontains'})
register_index(Skill, {'name': 'icontains'})
Example #34
0
from models import items
from dbindexer.api import register_index

register_index(items, {'title': ('icontains'), 'title_join_descrip': ('icontains')})
Example #35
0
from temprly.models import *
from dbindexer.lookups import StandardLookup
from dbindexer.api import register_index

register_index(SensorReading, {'sensor__name': StandardLookup(),
                               'sensor__location': StandardLookup(),
                               'sensor__location__name': StandardLookup(),
                               'sensor__location__id': StandardLookup(),
                               'sensor__location__owner__username': StandardLookup(),
})