Project 'adan.salazar/GeoSentinel' was moved to 'mario.chirinos/GeoSentinel'. Please update any links and bookmarks that may still have the old path.
Commit 0ab1253c authored by Mario Chirinos's avatar Mario Chirinos

Merge branch 'master' into dev

parents 5ac0ea28 587bbc9d
......@@ -2,6 +2,7 @@ from django.core.management.base import BaseCommand, CommandError
from catalog.models import News, Publisher, Topic, audioTime
from django.db.models import Q
import os
import glob
import json
import datetime
from django.utils import timezone
......@@ -51,12 +52,30 @@ class Command(BaseCommand):
audioTime.objects.update_or_create(publisher=p, defaults={'minutes': minutes, "startDate": since, "endDate":endDate},)
#load news
os.chdir(options['basedir'][0])
publisherList = os.listdir(options['basedir'][0])
publisherList = [ i for i in os.listdir(options['basedir'][0]) if os.path.isdir(i) ]
for p in publisherList:
print (p)
os.chdir(p)
publisher = Publisher.objects.all().filter(shortName=p)[0]
curentdir = options['basedir'][0]+p+"/"
os.chdir(curentdir)
publisher = Publisher.objects.all().filter(shortName=p)
print(os.getcwd())
if publisher.count()<=0 and os.path.isfile("settings.json") :
print(p, "do not exsist, crating publisher")
with open('settings.json', 'r') as f:
cfgfile = json.load(f)
newPublisher = Publisher()
newPublisher.shortName=p
newPublisher.name=cfgfile["name"]
newPublisher.crawler=cfgfile["crawler"]
newPublisher.url=cfgfile["url"]
newPublisher.type="texto"
newPublisher.save()
publisher = Publisher.objects.all().filter(shortName=p)
publisher=publisher[0]
news = News.objects.all().filter(publisher=publisher.id).order_by("-date")
minYear = 0
lastDate = datetime.datetime(1950,1,1)
......@@ -64,14 +83,15 @@ class Command(BaseCommand):
if news.count()>0:
minYear = news[0].date.year
lastDate = news[0].date
yearList = sorted([ int(y) for y in os.listdir('.')])
yearList = sorted([ int(y) for y in os.listdir('.') if os.path.isdir(y) ])
print (yearList)
for y in sorted(yearList):
if y >=minYear:
os.chdir(str(y))
print (os.getcwd())
filesList = sorted(os.listdir("."))
#filesList = sorted(os.listdir("."))
filesList = sorted(glob.glob("*.json"))
print (filesList)
for f in filesList:
fileDate = datetime.datetime.strptime(f[:f.find(".")], "%Y-%m-%d").date()
......
......@@ -12,7 +12,7 @@
<link rel="icon" href="{% static 'images/m3.png' %}">
<title>Monitoreo de Multiples Medios</title>
{% load staticfiles %}
{% load static %}
<script type="text/javascript" src="{% static 'static_jquery/js/jquery.js' %}" ></script>
<script type="text/javascript" src="{% static 'admin/js/jquery.init.js' %}" ></script>
<link rel="stylesheet" href="{% static 'css/forms.css' %}">
......
{% extends "new/adminLTE2_base.html" %}
{% load staticfiles %}
{% load static %}
{% load humanize %}
{% block headMedia %}
<!-- Morris chart -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment