You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
969 B
29 lines
969 B
# # -*- coding: utf-8 -*-
|
|
|
|
from cms.plugin_base import CMSPluginBase
|
|
from cms.plugin_pool import plugin_pool
|
|
from django.utils.translation import ugettext as _
|
|
# from .models import Promo
|
|
from django.db.models import Q, Count
|
|
from .models import Search
|
|
|
|
|
|
class TrademarkSearchPluginPublisher(CMSPluginBase):
|
|
# model = PollPluginModel # model where plugin data are saved
|
|
module = _("Trademark")
|
|
name = _("Search Form Plugin") # name of the plugin in the interface
|
|
render_template = "trademark/form.html"
|
|
cache = False
|
|
|
|
def render(self, context, instance, placeholder):
|
|
search = Search.objects.annotate(results_count=Count('results')) \
|
|
.filter(similarity=146, results_count__gt=0).order_by('?')[0]
|
|
|
|
keyword = search.keyword.request
|
|
|
|
context.update({
|
|
'keyword_request': keyword,
|
|
})
|
|
return context
|
|
|
|
plugin_pool.register_plugin(TrademarkSearchPluginPublisher) # register the plugin
|
|
|