Каталог МКТУ

master
Alexander Kondratyev 9 years ago
parent 0ca4296ccb
commit 318d1838df
  1. 20
      trademark/migrations/0002_nice_glyph.py
  2. 53
      trademark/models.py
  3. 2
      trademark/templates/trademark/form.html
  4. 12
      trademark/templates/trademark/index.html
  5. 2
      trademark/templates/trademark/nice_block_busy.html
  6. 70
      trademark/templates/trademark/nice_detail.html
  7. 59
      trademark/templates/trademark/nices_catalog.html
  8. 92
      trademark/templates/trademark/product_detail.html
  9. 1
      trademark/templates/trademark/registration.html
  10. 2
      trademark/templates/trademark/search_detail.html
  11. 3
      trademark/urls.py
  12. 49
      trademark/views.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('trademark', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='nice',
name='glyph',
field=models.CharField(default='', max_length=255),
preserve_default=False,
),
]

@ -2,6 +2,7 @@
from django.db import models
from django.db.models.signals import post_save, pre_save
from django.dispatch import receiver
from django.db import connection
from django.utils.translation import ugettext_lazy as _
@ -14,6 +15,9 @@ from datetime import date
from datetime import timedelta
# from .cms_appconfig import TrademarkConfig
from collections import defaultdict
import re
TrademarkAPI = TrademarkSearchAPI()
class Owner(models.Model):
@ -37,6 +41,7 @@ class Nice(models.Model):
nice_id = models.IntegerField()
title = models.CharField(max_length=255)
description = models.TextField()
glyph = models.CharField(max_length=255)
class Meta:
verbose_name = _('nice')
@ -49,6 +54,54 @@ class Nice(models.Model):
def __str__(self):
return self.title
@property
def popular_products(self):
ids = [str(pid) for pid in Product.objects.filter(nice_id=self.nice_id).values_list('id', flat=True)]
cursor = connection.cursor()
query = "SELECT product_id, count(trademark_id) FROM trademark_trademark_products WHERE product_id IN (%s) GROUP BY product_id ORDER BY count(trademark_id) DESC" % ','.join(ids)
cursor.execute(query)
top_ids = [result[0] for result in cursor.fetchall() if result[1] > 10]
products = Product.objects.filter(id__in=top_ids)
return sorted(products, key=lambda p: top_ids.index(p.pk))
@property
def popular_products_alphabet(self):
alphabet = defaultdict(lambda : defaultdict(list))
for product in self.popular_products:
letter = product.title[0].upper()
first_word = product.title.split(' ')[0]
# if title_sense:
alphabet[letter][first_word.capitalize()].append(product)
# elif not alphabet[letter][first_word.capitalize()]:
# alphabet[letter][first_word.capitalize()] = []
for letter, words in alphabet.items():
for first_word, products in words.items():
if len(products) == 1:
del alphabet[letter][first_word]
product = products.pop()
words = product.title
alphabet[letter][words] = product.id
else:
words = []
for product in alphabet[letter][first_word]:
title = re.sub("[\(\[].*?[\)\]]", "", product.title)
title_sense = title.replace(first_word, '').strip()
if title_sense:
words.append(title_sense)
# words = [product.title for product in alphabet[letter][first_word]]
alphabet[letter][first_word] = ', '.join(set(words))
letter_items = alphabet[letter]
alphabet[letter] = sorted(letter_items.items(), key=lambda x: type(x[1]), reverse=True)
# alphabet[letter] = letter_items.items()
print alphabet
return sorted(alphabet.items())
class Product(models.Model):
title = models.TextField()

@ -2,7 +2,7 @@
<div class="trademark-search no-print">
<div class="trademark-search-form">
<div class="trademark-search-field input-group">
<input type="text" placeholder="Название товарного знака" class="trademark-search-request form-control">
<input type="text" placeholder="Название знака" class="trademark-search-request form-control">
<span class="input-group-btn">
<button class="btn btn-primary trademark-search-submit" type="button">Найти</button>
</span>

@ -1,11 +1,11 @@
{% extends "trademark/base.html" %}
{% block trademark_content %}
<h1>Онлайн-поиск товарных знаков <small>по базе свидетельств Роспатента</small>
</h1>
{% include 'trademark/form.html' %}
<h3>Для вдохновения</h3>
<p>Исключительные права на эти товарные знаки не продлили, поэтому их <a href="http://zuykov.com/ru/trademarks/registraciya-tovarnogo-znaka/">регистрация</a> возможна после проведения <a href="http://zuykov.com/ru/trademarks/poisk-tovarnogo-znaka/">полного поиска</a>.</p>
<h1>История поисков товарных знаков</h1>
<ul class="trademarks-searches">
{% for tm in trademarks|slice:":10" %}
<li><a href="results/{{ tm.slug }}">{{ tm.request|title }}</a></li>
{% endfor %}
</ul>
{% endblock %}

@ -1,6 +1,6 @@
{% load dict %}
<div class="trademark-search-nice-busy">
<h2>«{{ keyword|title }}» был зарегистрирован в следующих классах</h2>
<h2>«{{ keyword|title }}» был зарегистрирован в следующих классах <a href="{% url 'trademark:nices-catalog' %}">МКТУ</a></h2>
<ul class="list-unstyled load-more-results" list-type="nices">
{% for nice in nice_busy %}

@ -0,0 +1,70 @@
{% extends "trademark/base.html" %}
{% load i18n menu_tags cms_tags %}
{% block trademark_content %}
<div class="nice-landing nice-detail">
<div class="row">
<div class="col-xs-12 col-sm-8">
<h1><i class="fa {{ nice.glyph }}" aria-hidden="true"></i> <strong>Класс {{ nice.nice_id }}</strong> <small>{{ nice.title }}</small></h1>
<ol class="list-unstyled list-inline breadcrumb" vocab="http://schema.org/" typeof="BreadcrumbList">
<li property="itemListElement" typeof="ListItem">
<a href="{% page_url "main" %}" property="item" typeof="WebPage"><span property="name">Главная страница</span></a>
<meta property="position" content="1">
</li>
<li property="itemListElement" typeof="ListItem">
<a href="{% page_url "trademarks" %}" property="item" typeof="WebPage"><span property="name">Товарные знаки</span></a>
<meta property="position" content="2">
</li>
<li property="itemListElement" typeof="ListItem">
<a href="{% url 'trademark:nices-catalog' %}" property="item" typeof="WebPage"><span property="name">Каталог классов МКТУ</span></a>
<meta property="position" content="3">
</li>
<li property="itemListElement" typeof="ListItem">
<span property="name">Класс {{ nice.nice_id }}</span>
<meta property="position" content="4">
</li>
</ol>
<p>{{ nice.description }}</p>
</div>
<div class="col-xs-12 col-sm-4 no-print">
<div class="trademark-search-block">
<h3>Поиск товарных знаков</h3>
{% include 'trademark/form.html' %}
</div>
{% if identity.count > 0 %}
{% include 'trademark/registration.html' with trademark_title=keyword.request nice_available=nice_available nice_busy=nice_busy %}
{% endif %}
</div>
</div>
<h4>{% if nice.nice_id > 38 %}Услуги{% else %}Товары{% endif %}, которые относятся к {{ nice.nice_id }} классу МКТУ:</h4>
<ul class="nice-products-alphabet list-inline">
{% for letter, words in nice.popular_products_alphabet %}
<li class="nice-products-alphabet-letter">
<h4>{{ letter }}</h4>
<ul class="nice-products-list list-inline">
{% for word, products in words %}
{% if products|length %}
<li class="product-a-lot">
<button popover="{{ products }}" popover-trigger="mouseenter" popover-placement="right" class="btn btn-xs btn-default">{{ word }}</button>
</li>
{% elif products %}
<li class="product-one">
<a href="{% url 'trademark:product-detail' pk=products %}">{{ word }}</a>
</li>
{% endif %}
</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
</div>
{% endblock %}

@ -0,0 +1,59 @@
{% extends "trademark/base.html" %}
{% load i18n menu_tags cms_tags %}
{% block trademark_content %}
<div class="nice-landing">
<h1>Классы МКТУ</h1>
<ol class="list-unstyled list-inline breadcrumb" vocab="http://schema.org/" typeof="BreadcrumbList">
<li property="itemListElement" typeof="ListItem">
<a href="{% page_url "main" %}" property="item" typeof="WebPage"><span property="name">Главная страница</span></a>
<meta property="position" content="1">
</li>
<li property="itemListElement" typeof="ListItem">
<a href="{% page_url "trademarks" %}" property="item" typeof="WebPage"><span property="name">Товарные знаки</span></a>
<meta property="position" content="2">
</li>
<li property="itemListElement" typeof="ListItem">
<span property="name">Каталог классов МКТУ</span>
<meta property="position" content="3">
</li>
</ol>
<div class="row">
<div class="col-xs-12 col-sm-8">
<p>Каждый товарный знак регистрируется в отношении определённых товаров и услуг, распределенных по классам. Всего таких классов на сегодняшний день 45 (34 — товаров и 11 — услуг), они установлены Международной классификацией товаров и услуг для регистрации знаков (МКТУ).</p>
<p>МКТУ — это сокращенное название Международной классификации товаров и услуг (International (Nice) Classification of Goods and Services for the Purposes of the Registration of Marks), учрежденной Соглашением о классификациях (Ниццкое соглашение), предназначенной для регистрации товарных знаков.</p>
<p>По принципу действия коды МКТУ (МКТиУ) сроднимы с кодами ОКВЭД (Общероссийский классификатор видов экономической деятельности).</p>
</div>
<div class="col-xs-12 col-sm-4 no-print">
<div class="trademark-search-block">
<h3>Поиск товарных знаков</h3>
{% include 'trademark/form.html' %}
</div>
{% if identity.count > 0 %}
{% include 'trademark/registration.html' with trademark_title=keyword.request nice_available=nice_available nice_busy=nice_busy %}
{% endif %}
</div>
</div>
<ul class="nice-classes-list list-unstyled list-inline">
{% for nice in nices %}
<li>
<h4><i class="fa {{ nice.glyph }}" aria-hidden="true"></i> <a href="{% url 'trademark:nice-detail' pk=nice.id %}">Класс {{ nice.nice_id }}</a> <small>{{ nice.title }}</small></h4>
<p>{{ nice.description }}</p>
<p>Примеры {% if nice.nice_id > 38 %}услуг{% else %}товаров{% endif %} из класса:</p>
<ul class="nice-products-list list-inline">
{% for product in nice.popular_products|slice:":10" %}
<li>{{ product.title }}</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
</div>
{% endblock %}

@ -0,0 +1,92 @@
{% extends "trademark/base.html" %}
{% load i18n menu_tags cms_tags %}
{% block trademark_content %}
<div class="nice-landing">
<h1>{{ product.title }}</h1>
<ol class="list-unstyled list-inline breadcrumb" vocab="http://schema.org/" typeof="BreadcrumbList">
<li property="itemListElement" typeof="ListItem">
<a href="{% page_url "main" %}" property="item" typeof="WebPage"><span property="name">Главная страница</span></a>
<meta property="position" content="1">
</li>
<li property="itemListElement" typeof="ListItem">
<a href="{% page_url "trademarks" %}" property="item" typeof="WebPage"><span property="name">Товарные знаки</span></a>
<meta property="position" content="2">
</li>
<li property="itemListElement" typeof="ListItem">
<a href="{% url 'trademark:nices-catalog' %}" property="item" typeof="WebPage"><span property="name">Каталог классов МКТУ</span></a>
<meta property="position" content="3">
</li>
<li property="itemListElement" typeof="ListItem">
<a href="{% url 'trademark:nice-detail' pk=nice.id %}" property="item" typeof="WebPage"><span property="name">Класс {{ nice.nice_id }}</span></a>
<meta property="position" content="4">
</li>
<li property="itemListElement" typeof="ListItem">
<span property="name">{{ product.title }}</span>
<meta property="position" content="5">
</li>
</ol>
<div class="row">
<div class="col-xs-12 col-sm-8">
<p>«{{ product.title }}» — это категория {% if nice.nice_id > 38 %}услуг{% else %}товаров{% endif %} в классе {{ nice.nice_id }} по классификации <a href="{% url 'trademark:nices-catalog' %}">МКТУ</a>, который описывает <a href="{% url 'trademark:nice-detail' pk=nice.id %}">{{ nice.title|lower }}</a>.</p>
<h3><i class="fa {{ nice.glyph }}" aria-hidden="true"></i> <strong>Класс {{ nice.nice_id }}</strong> <small>{{ nice.title }}</small></h3>
<p>{{ nice.description }}</p>
<p>Каждый товарный знак регистрируется в отношении определённых товаров и услуг, распределенных по классам. Всего таких классов на сегодняшний день 45 (34 — товаров и 11 — услуг), они установлены Международной классификацией товаров и услуг для регистрации знаков (<a href="{% url 'trademark:nices-catalog' %}">МКТУ</a>).</p>
</div>
<div class="col-xs-12 col-sm-4 no-print">
<div class="trademark-search-block">
<h3>Поиск товарных знаков</h3>
{% include 'trademark/form.html' %}
</div>
{% if identity.count > 0 %}
{% include 'trademark/registration.html' with trademark_title=keyword.request nice_available=nice_available nice_busy=nice_busy %}
{% endif %}
</div>
</div>
<div class="app-trademark">
{% if trademarks_expired %}
<ul class="trademark-search-results load-more-results list-inline list-unstyled">
<li class="trademark-search-results-detail">
<h3>Товарные знаки в {{ nice.nice_id }} классе, для которых возможна регистрация</h3>
<h5 class="trademark-search-results-detail-count"></h5>
<p>Исключительные права на эти товарные знаки не продлили, поэтому их <a href="http://zuykov.com/ru/trademarks/registraciya-tovarnogo-znaka/">регистрация</a> возможна после проведения <a href="http://zuykov.com/ru/trademarks/poisk-tovarnogo-znaka/">полного поиска</a>.</p>
<p>Эти товарные знаки были зарегистрированы в классе про <a href="{% url 'trademark:nice-detail' pk=nice.id %}">{{ nice.title|lower }}</a> в категории {% if nice.nice_id > 38 %}услуг{% else %}товаров{% endif %} {{ product.title|lower }}.</p>
</li>
{% for tm in trademarks_expired %}
{% include 'trademark/search_list_item.html' with tm=tm %}
{% endfor %}
<li class="load-more-li">
<button class="btn btn-default load-more">Показать ещё</button> — осталось <span class="load-more-count"></span>
</li>
</ul>
{% endif %}
{% if trademarks_acting %}
<ul class="trademark-search-results load-more-results list-inline list-unstyled">
<li class="trademark-search-results-detail">
<h3>Товарные знаки в {{ nice.nice_id }} классе <small>{{ nice.title }}</small></h3>
<p>Товарные знаки, зарегистрированные в классе про <a href="{% url 'trademark:nice-detail' pk=nice.id %}">{{ nice.title|lower }}</a> в категории {% if nice.nice_id > 38 %}услуг{% else %}товаров{% endif %} {{ product.title|lower }}.</p>
<h5 class="trademark-search-results-detail-count"></h5>
</li>
{% for tm in trademarks_acting %}
{% include 'trademark/search_list_item.html' with tm=tm %}
{% endfor %}
<li class="load-more-li">
<button class="btn btn-default load-more">Показать ещё</button> — осталось <span class="load-more-count"></span>
</li>
</ul>
{% endif %}
</div>
</div>
<script type="text/javascript">
var searchResults = TrademarkSearchResult('.app-trademark');
searchResults.expand();
</script>
{% endblock %}

@ -2,7 +2,6 @@
<div class="trademark-register-block">
<h1>Зарегистрируйте знак <span class="no-wrap">«{{ trademark_title|title }}»</span></h1>
<div class="description">
<p>
<p>Перед подачей заявки на регистрацию рекомендуем сделать <a href="http://zuykov.com/ru/trademarks/poisk-tovarnogo-znaka/">полный поиск</a>.</p>

@ -53,7 +53,7 @@
{% endif %}
{% else %}
<span>Зарегистрирован во всех классах</span>
<span>Зарегистрирован во всех классах <a href="{% url 'trademark:nices-catalog' %}">МКТУ</a></span>
{% endif %}
</a>
</li>

@ -8,6 +8,9 @@ from trademark.landing.api import get_random_list_trademarks
urlpatterns = patterns('',
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'^nices/$', views.NicesView.as_view(), name='nices-catalog'),
url(r'^nices/(?P<pk>[\w-]+)/$', views.NiceDetailView.as_view(), name='nice-detail'),
url(r'^products/(?P<pk>[\w-]+)/$', views.ProductDetailView.as_view(), name='product-detail'),
url(r'^results/(?P<slug>[\w-]+)/$', views.SearchDetailView.as_view(), name='search-detail'),
url(r'^trademark/(?P<pk>[\w-]+)/$', views.TrademarkDetailView.as_view(), name='trademark-detail'),
url(r'^random-trademarks/', get_random_list_trademarks, name='random-trademarks'),

@ -4,6 +4,7 @@
# from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.views import generic
from django.http import HttpResponse
import json
@ -77,12 +78,52 @@ class TrademarkDetailView(generic.DetailView):
return context
class IndexView(generic.ListView):
class IndexView(generic.TemplateView):
template_name = 'trademark/index.html'
context_object_name = 'trademarks'
def get_queryset(self):
return Keyword.objects.all()
class NicesView(generic.TemplateView):
template_name = 'trademark/nices_catalog.html'
def get_context_data(self, **kwargs):
context = super(NicesView, self).get_context_data(**kwargs)
context['nices'] = Nice.objects.all().order_by('nice_id')
return context
class NiceDetailView(generic.DetailView):
model = Nice
context_object_name = 'nice'
template_name = 'trademark/nice_detail.html'
view_url_name = 'trademark:nice-detail'
def get_context_data(self, **kwargs):
context = super(NiceDetailView, self).get_context_data(**kwargs)
nice = self.get_object()
context['nice'] = nice
return context
class ProductDetailView(generic.DetailView):
model = Product
context_object_name = 'product'
template_name = 'trademark/product_detail.html'
view_url_name = 'trademark:product-detail'
def get_context_data(self, **kwargs):
context = super(ProductDetailView, self).get_context_data(**kwargs)
product = self.get_object()
context['product'] = product
context['nice'] = Nice.objects.get(nice_id=product.nice_id)
context['trademarks_expired'] = product.trademark_set.filter(status='Expired').order_by('?')[:42]
context['trademarks_acting'] = product.trademark_set.filter(status='Acting').order_by('?')[:42]
return context
import threading
import time

Loading…
Cancel
Save