|
|
|
|
@ -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']) |
|
|
|
|
|
|
|
|
|
|