remotes/origin/1203
Kotiuk Nazarii 11 years ago
parent 0d85cd1bb2
commit 783b5dabec
  1. 14
      article/management/commands/news_from_old.py
  2. 1
      article/models.py
  3. 1
      settings/old_urls.py
  4. 7
      settings/redirect_views.py
  5. 6
      templates/client/robots.txt

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import datetime
import MySQLdb
from MySQLdb.cursors import DictCursor
from django.core.management.base import BaseCommand, CommandError
@ -22,16 +23,15 @@ class Command(BaseCommand):
cid as author,
date_added as created
FROM `latest_news`
FROM `payed_news`
WHERE status = 1
AND `date_added` >= '2015-04-03'
order by created DESC"""
cursor.execute(sql)
result = cursor.fetchall()
user = User.objects.get(id=1)
now = datetime.datetime.now()
#Article.objects.news().delete()
for a in result:
@ -51,8 +51,9 @@ class Command(BaseCommand):
article = Article(type=Article.news,
id=a['id'],
created=a['created'])
old_id=a['id'],
publish_date=a['created'],
created=now)
if a['author']:
try:
author = User.objects.get(id=a['author'])
@ -72,8 +73,5 @@ class Command(BaseCommand):
except :
print ('error. id:%d'%a['id'])
#print(a['main_title'])

@ -78,6 +78,7 @@ class Article(TranslatableModel):
#set manager of this model
objects = ArticleManager()
slug = models.SlugField(unique=True, max_length=255)
old_id = models.IntegerField(blank=True, null=True)
logo = ImageField(upload_to='articles_preview', blank=True)
theme = models.ManyToManyField('theme.Theme')
tag = models.ManyToManyField('theme.Tag', related_name='tags',blank=True, null=True)

@ -36,6 +36,7 @@ urlpatterns = patterns('',
url(r'^news.php/news/archive/', old_redirect, {'redirect_url': '/news/'}),
url(r'^article_info.php/articles_id/(?P<article>\d+)/(?P<some>.*)$', old_redirect, {'redirect_url': '/blogs/{article}/'}),
url(r'^news.php/news_id/(?P<article>\d+)/(?P<some>.*)$', old_redirect, {'redirect_url': '/news/{article}/'}),
url(r'^newsp.php/news_id/(?P<news_p>\d+)/(?P<some>.*)$', old_redirect, {'redirect_url': '/news/{news_p}/'}),
# users
url(r'^users/(?P<user>.*)$', old_redirect, {'redirect_url': '/{user}/'}),
url(r'^account_edit.php$', old_profile),

@ -79,11 +79,16 @@ class PageRedirect(object):
def get_object_url(self,key, value):
return {key: value}
class News_p(object):
def get_object_url(self,key, value):
obj = get_object_or_404(Article, old_id=value)
return {key: obj.slug}
old_params = {'city': CityRedirect, 'country': CountryRedirect, 'theme': ThemeRedirect, 'tag': TagRedirect,
'event': EventRedirect, 'company': Company, 'article': ArticleRedirect, 'user': UserRedirect,
'page': PageRedirect}
'page': PageRedirect, 'news_p': News_p}
def old_redirect(request, *args, **kwargs):
redirect = kwargs.get('redirect_url')

@ -1,4 +1,6 @@
User-agent: *
Disallow: /images/
Disallow: /social/
Disallow: /profile/
Disallow: /export/
Disallow: /download/
@ -97,6 +99,8 @@ Disallow: /*/serv-catalogs-info.php
Sitemap: http://expomap.ru/sitemap.xml
User-agent: Googlebot
Disallow: /images/
Disallow: /social/
Disallow: /profile/
Disallow: /export/
Disallow: /download/
@ -195,6 +199,8 @@ Disallow: /*/serv-catalogs-info.php
Sitemap: http://expomap.ru/sitemap.xml
User-agent: Yandex
Disallow: /images/
Disallow: /social/
Disallow: /profile/
Disallow: /export/
Disallow: /download/

Loading…
Cancel
Save