• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python watson.register函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中watson.register函数的典型用法代码示例。如果您正苦于以下问题:Python register函数的具体用法?Python register怎么用?Python register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了register函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setUp

 def setUp(self):
     # If migrations are off, then this is needed to get the indices installed. It has to
     # be called in the setUp() method, but multiple invocations should be safe.
     call_command("installwatson", verbosity=0)
     # Remove all the current registered models.
     self.registered_models = watson.get_registered_models()
     for model in self.registered_models:
         watson.unregister(model)
     # Register the test models.
     watson.register(self.model1)
     watson.register(self.model2, exclude=("id",))
     complex_registration_search_engine.register(WatsonTestModel1, exclude=("content", "description",), store=("is_published",))
     complex_registration_search_engine.register(WatsonTestModel2, fields=("title",))
     # Create some test models.
     self.test11 = WatsonTestModel1.objects.create(
         title = "title model1 instance11",
         content = "content model1 instance11",
         description = "description model1 instance11",
     )
     self.test12 = WatsonTestModel1.objects.create(
         title = "title model1 instance12",
         content = "content model1 instance12",
         description = "description model1 instance12",
     )
     self.test21 = WatsonTestModel2.objects.create(
         title = "title model2 instance21",
         content = "content model2 instance21",
         description = "description model2 instance21",
     )
     self.test22 = WatsonTestModel2.objects.create(
         title = "title model2 instance22",
         content = "content model2 instance22",
         description = "description model2 instance22",
     )
开发者ID:mhahn,项目名称:django-watson,代码行数:34,代码来源:tests.py


示例2: ready

 def ready(self):
     # Tells what watson what model to search within
     Article = self.get_model("Article")
     # Configures Watson to only search pub=True entries and add front, back and description to meta
     watson.register(
         Article.objects.filter(published_status=True),
         store=("game_name", "game_review_cover", "game_review_back_cover", "game_review_description"),
     )
开发者ID:awaseem,项目名称:vgre.me,代码行数:8,代码来源:apps.py


示例3: ready

    def ready(self):
        # imports here to circumvent RemovedInDjango19Warning: Model doesn't declare an explicit app_label
        import watson
        from app_book.models import Book, Offer
        from app_user.models import User

        disabledShowcases = User.objects.filter(showcaseDisabled=True).values_list('user_ptr')
        bookIds = Offer.objects.exclude(seller_user_id__in=disabledShowcases).exclude(active = False).values_list('book', flat=True)
        watson.register(Book.objects.filter(id__in=bookIds))
        watson.register(User.objects.all())
开发者ID:DSIW,项目名称:sdf,代码行数:10,代码来源:apps.py


示例4: ready

    def ready(self):
        User = django.contrib.auth.get_user_model()

        watson.register(User, UserSearchAdapter, fields=('id', 'email',
                                                         'profile__fullname',
                                                         'profile__mdc',
                                                         'profile__phone',
                                                         'profile__group_str',
                                                         'profile__owns',
                                                         'profile__orgs'))
开发者ID:WPI-LNL,项目名称:lnldb,代码行数:10,代码来源:apps.py


示例5: ready

 def ready(self):
     StoryObject = self.get_model("StoryObject")
     watson.register(StoryObject.objects.filter(published=True))
     Story = self.get_model("Story")
     watson.register(Story.objects.filter(published=True))
     Chapter = self.get_model("Chapter")
     watson.register(Chapter.objects.filter(published=True))
     Scene = self.get_model("Scene")
     watson.register(Scene.objects.filter(published=True))
     Place = self.get_model("Place")
     watson.register(Place.objects.all())
开发者ID:sonus21,项目名称:Django-Chronicles,代码行数:11,代码来源:apps.py


示例6: testRegistration

 def testRegistration(self):
     # Register the model and test.
     watson.register(WatsonTestModel1)
     self.assertTrue(watson.is_registered(WatsonTestModel1))
     self.assertRaises(RegistrationError, lambda: watson.register(WatsonTestModel1))
     self.assertTrue(WatsonTestModel1 in watson.get_registered_models())
     self.assertTrue(isinstance(watson.get_adapter(WatsonTestModel1), watson.SearchAdapter))
     # Unregister the model and text.
     watson.unregister(WatsonTestModel1)
     self.assertFalse(watson.is_registered(WatsonTestModel1))
     self.assertRaises(RegistrationError, lambda: watson.unregister(WatsonTestModel1))
     self.assertTrue(WatsonTestModel1 not in watson.get_registered_models())
     self.assertRaises(RegistrationError, lambda: isinstance(watson.get_adapter(WatsonTestModel1)))
开发者ID:mhahn,项目名称:django-watson,代码行数:13,代码来源:tests.py


示例7: tearDown

 def tearDown(self):
     # Re-register the old registered models.
     for model in self.registered_models:
         watson.register(model)
     # Unregister the test models.
     watson.unregister(self.model1)
     watson.unregister(self.model2)
     complex_registration_search_engine.unregister(WatsonTestModel1)
     complex_registration_search_engine.unregister(WatsonTestModel2)
     # Delete the test models.
     WatsonTestModel1.objects.all().delete()
     WatsonTestModel2.objects.all().delete()
     del self.test11
     del self.test12
     del self.test21
     del self.test22
     # Delete the search index.
     SearchEntry.objects.all().delete()
开发者ID:mhahn,项目名称:django-watson,代码行数:18,代码来源:tests.py


示例8: ready

    def ready(self):
        post_model = self.get_model('Post')
        image_model = self.get_model('Image')
        credit_model = self.get_model('Credit')

        watson.register(post_model.objects.filter(published=True), fields=('heading', 'subheading', 'articletext', 'tags'))
        watson.register(image_model.objects.filter(post__published=True))
        watson.register(credit_model.objects.filter(post__published=True))
开发者ID:genxstylez,项目名称:potential-sansa,代码行数:8,代码来源:apps.py


示例9: ready

 def ready(self):
     BiblioUser = self.get_model("BiblioUser")
     BiblioUser._meta.get_field_by_name('email')[0]._unique=True
     watson.register(
         BiblioUser.objects.filter(is_active=True),
         store=("slug", "avatar_50x50_url","profil_url","username","class_name"),
         fields=("slug","username"),
     ),
     Livre = self.get_model("Livre")
     watson.register(
         Livre.objects.filter(phase__in=['GETMONEY','SUCCES','ECHEC','FEEDBACK'],is_active=True),
         store=("titre", "image_50x50_url","url","class_name"),
         fields=("titre", "tags__text",'resume','pourquoi_ce_livre','phrase_cle','annonces','biographie'),
     )
     UrlIndex = self.get_model("UrlIndex")
     watson.register(
         UrlIndex.objects.all(),
         store=("url", "texte",'titre','image_url',"class_name"),
     )
开发者ID:Bibliocratie,项目名称:Bibliocratie,代码行数:19,代码来源:apps.py


示例10: Bill

            return u'%s' % Est.objects.get(id = self.cid).genesymbol


class Bill(models.Model):
    cartlists = models.ManyToManyField(Cartlist, related_name='b+', blank=True)
    user = models.ForeignKey(User)
    price = models.FloatField(default=0)
    status = models.IntegerField(default=0)
    # 0:submited 1:shipped 2:expired 3:canceled
    name = models.CharField(max_length=30, default='')
    contact = models.CharField(max_length=30, default='')
    address = models.CharField(max_length=30, default='')
    zipcode = models.CharField(max_length=30, blank=True)
    express = models.CharField(max_length=30, default='EMS')
    note = models.TextField(blank=True, default='')
    insert = models.DateTimeField(auto_now_add=True)
    update = models.DateTimeField(auto_now=True)

    class Meta:
        get_latest_by = "id"

    def settle(self):
        price = 0
        lists = self.cartlists.all()
        for list in lists:
            price = price + list.price
        return price

watson.register(Zfish, exclude=("abbreviation", "source", "note"))
watson.register(Est)
开发者ID:shawnplusplus,项目名称:ihb-mainsite,代码行数:30,代码来源:models.py


示例11: __unicode__

    )

    order = models.PositiveIntegerField(
        default=0
    )

    def __unicode__(self):
        return self.question

    class Meta:
        verbose_name = "faq"
        verbose_name_plural = "faqs"
        ordering = ['order', 'id', 'question']

    def get_absolute_url(self):
        """ Gets the url of a Faq

            Returns:
                url of Person

        """
        return "{}{}/".format(
            self.page.page.get_absolute_url(),
            self.url_title
        )

watson.register(Faq)



开发者ID:dan-gamble,项目名称:cms-test,代码行数:27,代码来源:models.py


示例12: __unicode__

    def __unicode__(self):
        return '%s' % (self.name)

    def get_CategoryList(self):
        self.categorylist = NoteCategory.objects.all()
        return self.categorylist


class Note(models.Model):
    title = models.CharField(max_length=110)
    body = RichTextField(config_name='default')
    data_pub = models.DateTimeField()
    published = models.BooleanField(default=False)
    name = models.CharField(max_length=110)
    category = models.ForeignKey(NoteCategory)

    def __unicode__(self):
        return '%s' % (self.name)

    def get_NoteList(self):  # full note list, avalilabled for publish
        self.note_list = Note.objects.filter(published=True)
        return self.note_list

    def get_absolute_url(self):
        return reverse('blog.views.show_blog', args=[str(self.id)])


import watson  # search engine https://github.com/etianen/django-watson/wiki

watson.register(Note)
watson.register(NoteCategory)
开发者ID:Viach,项目名称:Krok,代码行数:31,代码来源:models.py


示例13: Meta

        my guess is that I did actually know this, like at one point,
        based on how it appears that I was gearing up to do stuff with
        this class. That was a while ago, though, erm. """
    
    z_ent = models.IntegerField(
        db_column=u'Z_ENT',
        primary_key=True)
    
    z_name = models.TextField(
        db_column=u'Z_NAME',
        blank=True)
    
    z_super = models.IntegerField(
        null=True,
        db_column=u'Z_SUPER',
        blank=True)
    
    z_max = models.IntegerField(
        null=True,
        db_column=u'Z_MAX',
        blank=True)
    
    class Meta(PathCoreMetaDatum.Meta):
        db_table = u'Z_PRIMARYKEY'
        ordering = ['z_ent', 'z_super', 'z_name']

# watson registration
import watson
for model in coredata_models:
    watson.register(model, adapter_cls=model.adapter())
watson.register(MetaData)
开发者ID:fish2000,项目名称:django-coredata-path,代码行数:31,代码来源:models.py


示例14: __unicode__

    class Meta:
        db_table = 'user_profile'


    def __unicode__(self):
        return 'UserProfile: %s' % self.user.email


class WallItem(BaseModel):
    """
    - Post to your own Wall
    - Post to another profile's wall

    """
    uuid = UUIDField(auto=True, db_index=True, primary_key=True)
    receiver = models.ForeignKey('auth.User', related_name='wall_receiver')
    author = models.ForeignKey('auth.User', related_name='wall_author')
    content = models.TextField()


    class Meta:
        db_table = 'wall_posts'

    def __unicode__(self):
        return 'Wall: %s-%s' % (self.receiver.email, self.author.email)



watson.register(User)
watson.register(UserProfile)
开发者ID:robnanola,项目名称:testsocialapp,代码行数:30,代码来源:models.py


示例15: ready

    def ready(self):
        Service = self.get_model("Service")
        watson.register(Service, ServiceSearchAdapter)

        Work=self.get_model("Work")
        watson.register(Work, WorkSearchAdapter)

        Secret=self.get_model("Secret")
        watson.register(Secret, SecretSearchAdapter)

        Promo=self.get_model("Promo")
        watson.register(Promo, PromoSearchAdapter)

        About=self.get_model("About")
        watson.register(About, AboutSearchAdapter)

        Staff=self.get_model("Staff")
        watson.register(Staff, StaffSearchAdapter)

        Index=self.get_model("Index")
        watson.register(Index, IndexSearchAdapter)
开发者ID:wuprui,项目名称:salonExpert,代码行数:21,代码来源:apps.py


示例16: get_absolute_url

    @type language: models.CharField(200)
    @cvar language: Most common language spoken in this culture
    @type related_figures: models.ManyToManyField('Figure')
    @cvar related_figures: Many to many assocation associating Figures related to this Culture
    @type related_cultures: models.ManyToManyField('self')
    @cvar related_cultures: Many to many assocation associating Cultures similar to this Culture
    @type related_stories: models.ManyToManyField('Story')
    @cvar related_stories:  Many to many assocation associating notable mythological stories belonging within this Culture
    '''
    name                = models.CharField(max_length=200)
    region              = models.CharField(max_length=200)
    history             = models.CharField(max_length=10000)
    language            = models.CharField(max_length=200)
    related_cultures    = models.ManyToManyField('self')

    def get_absolute_url(self):
        return "/cultures/%i/" % self.id

    def __unicode__(self):
        return self.name


# -----
# Watson
# -----

import watson

watson.register(Figure)
watson.register(Culture)
watson.register(Story)
开发者ID:ses110,项目名称:cs373-idb,代码行数:31,代码来源:models.py


示例17:

post_save.connect(add_to_preview,sender=User)
post_save.connect(add_content,sender=Tutorial)
post_save.connect(add_content,sender=Snippet)
post_save.connect(add_content,sender=Wiki)
post_save.connect(add_content,sender=Announcement)
post_save.connect(add_content,sender=News)
post_save.connect(add_content,sender=Blog)
post_save.connect(add_content,sender=Event)
post_save.connect(add_content,sender=EducationalResource)
post_save.connect(add_content,sender=Package)


secretballot.enable_voting_on(Tutorial)
secretballot.enable_voting_on(Snippet)
secretballot.enable_voting_on(Wiki)
secretballot.enable_voting_on(Announcement)
secretballot.enable_voting_on(News)
secretballot.enable_voting_on(Blog)
secretballot.enable_voting_on(Event)
secretballot.enable_voting_on(EducationalResource)
secretballot.enable_voting_on(Package)

watson.register(Tutorial)
watson.register(Snippet)
watson.register(Wiki)
watson.register(Announcement)
watson.register(News)
watson.register(Blog)
watson.register(EducationalResource)
watson.register(Package)
watson.register(Event)
开发者ID:gitter-badger,项目名称:astropython,代码行数:31,代码来源:models.py


示例18:

from rsssync.models import RssEntry
import watson


watson.register(RssEntry)
开发者ID:596acres,项目名称:livinglots-la,代码行数:5,代码来源:models.py


示例19: add

    @staticmethod
    def add(user, work):
        pt = PersonalTop.objects.filter(user=user)
        if pt.filter(work=work).count() == 0:
            PersonalTop(user=user, work=work, position=pt.count() + 1).save()
            return True
        else:
            return False

    def move_up(self):
        if self.position == 1:
            return
        prev = PersonalTop.objects.get(user=self.user, position=self.position-1)
        prev.position = self.position
        prev.save()
        self.position = self.position-1
        self.save()

    def move_down(self):
        if self.position == PersonalTop.objects.filter(user=self.user).count():
            return
        next = PersonalTop.objects.get(user=self.user, position=self.position+1)
        next.position = self.position
        next.save()
        self.position = self.position+1
        self.save()

watson.register(Review, fields=('name','text',))
watson.register(Comment, fields=('text',))
开发者ID:kpx13,项目名称:libfic,代码行数:29,代码来源:models.py


示例20: ProjectAdmin

    extra = 0


class ProjectAdmin(admin.ModelAdmin):
    actions = [admin.site.get_action('delete_selected')]
    fields = ['project_user', 'project_name', 'project_is_dark', 'project_menu_is_horizontal']
    inlines = [ProjectInline]


class GalleryAdmin(admin.ModelAdmin):
    actions = [admin.site.get_action('delete_selected')]

    fields = ['user', 'image']


class UserProfileAdmin(UserAdmin):
    def delete_model(self, request, obj):
        if type(obj) == User and obj == request.user:
            print('asdasdas')
            return False
        else:
            obj.delete()

admin.site.register(Project, ProjectAdmin)
admin.site.register(Gallery, GalleryAdmin)
admin.site.unregister(User)
admin.site.register(User, UserProfileAdmin)

watson.register(Project,fields=("project_name",))
watson.register(PageProject, fields=("page_name","text",))
watson.register(User, fields=("username",))
开发者ID:blackshadow608,项目名称:site-constructor,代码行数:31,代码来源:admin.py



注:本文中的watson.register函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python watson.search函数代码示例发布时间:2022-05-26
下一篇:
Python utils.make_provider函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap