Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
m3_webInterface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
m3
m3_webInterface
Commits
7f126a95
Commit
7f126a95
authored
Sep 21, 2019
by
Mario Chirinos Colunga
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
status
parent
522fd2e7
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
226 additions
and
17 deletions
+226
-17
admin.py
catalog/admin.py
+1
-1
customSearch.py
catalog/management/commands/customSearch.py
+57
-0
updateDB.py
catalog/management/commands/updateDB.py
+1
-1
models.py
catalog/models.py
+2
-1
audioPlay.html
catalog/templates/new/audioPlay.html
+62
-0
audioPlayerTest.html
catalog/templates/new/audioPlayerTest.html
+34
-0
status.html
catalog/templates/new/status.html
+44
-5
views.py
catalog/views.py
+25
-9
No files found.
catalog/admin.py
View file @
7f126a95
...
...
@@ -7,7 +7,7 @@ from catalog.models import Publisher
#admin.site.register(Publisher)
class
PublisherAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'name'
,
'shortName'
,
'type'
,
'url'
)
list_display
=
(
'name'
,
'shortName'
,
'type'
,
"active"
,
'url'
)
admin
.
site
.
register
(
Publisher
,
PublisherAdmin
)
catalog/management/commands/customSearch.py
0 → 100644
View file @
7f126a95
from
django.core.management.base
import
BaseCommand
,
CommandError
from
catalog.models
import
User
,
News
,
Publisher
,
Topic
,
audioTime
,
Search
from
django.db.models
import
Q
from
django.core.paginator
import
Paginator
from
django.contrib.postgres.search
import
SearchQuery
import
os
import
json
import
csv
from
django.core
import
serializers
import
sys
import
datetime
class
Command
(
BaseCommand
):
help
=
'Custom search'
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'jsonfile'
,
nargs
=
1
,
type
=
str
)
#(options['basedir'][0]
parser
.
add_argument
(
'outfile'
,
nargs
=
1
,
type
=
str
)
def
handle
(
self
,
*
args
,
**
options
):
filename
=
options
[
'jsonfile'
][
0
]
with
open
(
filename
,
'r'
)
as
f
:
searchCfg
=
json
.
load
(
f
)
myQuery
=
~
Q
()
myQuery
&=
Q
(
publisher_id__in
=
searchCfg
[
'publishers'
])
myQuery
&=
Q
(
date__gte
=
searchCfg
[
'startDate'
])
myQuery
&=
Q
(
date__lte
=
searchCfg
[
'endDate'
])
qText
=
None
for
i
in
searchCfg
[
"phrases"
]:
if
qText
is
None
:
qText
=
SearchQuery
(
i
,
search_type
=
'phrase'
)
else
:
qText
|=
SearchQuery
(
i
,
search_type
=
'phrase'
)
#myQuery &=qText
news
=
News
.
objects
.
filter
(
myQuery
,
search_vector
=
qText
)
print
(
news
.
count
())
if
news
.
count
()
>
0
:
nn
=
news
[
0
]
print
(
nn
.
publisher
.
shortName
,
nn
)
qs_json
=
list
()
#serializers.serialize('json', news)
for
n
in
news
:
qs_json
.
append
({
"publisher"
:
n
.
publisher
.
shortName
,
"date"
:
n
.
date
,
"title"
:
n
.
title
,
"text"
:
n
.
text
,
"url"
:
n
.
url
})
print
(
qs_json
[
0
])
with
open
(
options
[
'outfile'
][
0
],
"w"
)
as
ff
:
w
=
csv
.
DictWriter
(
ff
,
qs_json
[
0
]
.
keys
())
w
.
writeheader
()
for
i
in
qs_json
:
w
.
writerow
(
i
)
catalog/management/commands/updateDB.py
View file @
7f126a95
...
...
@@ -18,7 +18,7 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
if
Fals
e
:
if
Tru
e
:
#update radio stations recotding time
print
(
"Recording Time:"
)
# recordingsDir = "/home/mario/virtualHDD/m3/recordings/"
...
...
catalog/models.py
View file @
7f126a95
...
...
@@ -17,7 +17,8 @@ class Publisher(models.Model):
type
=
models
.
CharField
(
max_length
=
32
,
default
=
''
)
url
=
models
.
URLField
(
default
=
""
)
active
=
models
.
BooleanField
(
default
=
True
)
country
=
models
.
CharField
(
max_length
=
32
,
default
=
''
)
region
=
models
.
CharField
(
max_length
=
32
,
default
=
''
)
def
__str__
(
self
):
return
self
.
shortName
...
...
catalog/templates/new/audioPlay.html
0 → 100644
View file @
7f126a95
{% extends "new/adminLTE2_base.html" %}
{% load static %}
{% block headMedia %}
<link
rel=
"stylesheet"
id=
"rangecalendar-style-css"
href=
"{% static 'css/rangecalendar.css' %}"
type=
"text/css"
media=
"all"
>
<link
rel=
"stylesheet"
id=
"rangecalendar-style-css"
href=
"{% static 'css/calendar-style.css' %}"
type=
"text/css"
media=
"all"
>
<link
rel=
"stylesheet"
id=
"rangecalendar-style-css"
href=
"{% static 'css/audioplayer.css' %}"
type=
"text/css"
media=
"all"
>
{% endblock %}
{% block dash-title %}
<b>
{{publisher.name}}
</b>
{% endblock %}
{% block dash %}
<div
class=
"row"
>
<div
class=
"col-lg-12"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
{{publisher.name}}
</div>
<!-- /.panel-heading -->
<div
class=
"panel-body"
>
<div
id=
"audioCalendar"
></div>
<div
id=
"audioDiv"
>
<audio
id=
"audioPlay"
controls
></audio>
</div>
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
{% endblock %}
<script
type=
"text/javascript"
src=
"http://cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js"
></script>
<script
type=
"text/javascript"
src=
"http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.7.0/moment-with-langs.min.js"
></script>
<script
type=
"text/javascript"
src=
"{% static 'js/jquery.rangecalendar.js' %}"
></script>
{% block scripts %}
<script>
function
rangeChanged
(
target
,
range
)
{
console
.
log
(
range
);
};
var
calendar
=
$
(
"#audioCalendar"
).
rangeCalendar
({
theme
:
"full-red-theme"
,
changeRangeCallback
:
rangeChanged
});
</script>
{% endblock %}
catalog/templates/new/audioPlayerTest.html
0 → 100644
View file @
7f126a95
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Audio Player
</title>
</head>
<body>
<audio
controls
id=
"audioplayer"
>
Your browser does not support the audio element.
</audio>
<script>
audiourl
=
"http://m3.geoint.mx/catalog/streaming/{{publisher}}/"
playlist
=
{{
filelist
|
safe
}};
player
=
document
.
getElementById
(
"audioplayer"
);
player
.
src
=
audiourl
+
playlist
[
0
]
+
"/"
;
player
.
load
();
i
=
0
;
player
.
addEventListener
(
'ended'
,
function
(){
i
++
;
player
.
src
=
audiourl
+
playlist
[
i
]
+
"/"
;
//player.pause();
player
.
load
();
player
.
play
();
});
</script>
</body>
</html>
catalog/templates/new/status.html
View file @
7f126a95
...
...
@@ -51,13 +51,11 @@ es<!DOCTYPE html>
<div
class=
"container"
style=
"height: auto; min-height: 100%;"
>
<div
class=
"row"
>
<div
class=
"col-8 align-self-center"
>
<div
class=
"box"
>
<div
class=
"box-header"
>
<h3
class=
"box-title"
>
Medios en Texto
</h3>
<h3
class=
"box-title"
>
Medios en Texto
(Activos)
</h3>
<div
class=
"box-tools"
>
</div>
...
...
@@ -67,6 +65,7 @@ es<!DOCTYPE html>
<tbody>
<tr>
<th>
Medio
</th>
<th>
Origen
</th>
<th>
Documentos
</th>
<th>
Desde
</th>
<th>
Ultima Noticia
</th>
...
...
@@ -74,7 +73,7 @@ es<!DOCTYPE html>
</tr>
{% for k, v in textPublishers.items %}
<tr>
<td>
{{k}}
</td><td>
{{v.docs|intcomma}}
</td><td>
{{v.startDate|date:"M d, Y"}}
</td><td>
{{v.endDate|date:"M d, Y"}}
</td>
<td>
{{k}}
</td><td>
{{v.
origen}}
</td><td>
{{v.
docs|intcomma}}
</td><td>
{{v.startDate|date:"M d, Y"}}
</td><td>
{{v.endDate|date:"M d, Y"}}
</td>
<td>
{% if v.status > 1 %}
<span
class=
"label label-danger"
>
{{v.status}} dias
</span>
...
...
@@ -91,6 +90,46 @@ es<!DOCTYPE html>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-8 align-self-center"
>
<div
class=
"box"
>
<div
class=
"box-header"
>
<h3
class=
"box-title"
>
Medios en Texto (Inactivos)
</h3>
<div
class=
"box-tools"
>
</div>
</div>
<!-- /.box-header -->
<div
class=
"box-body table-responsive no-padding"
>
<table
class=
"table table-hover"
>
<tbody>
<tr>
<th>
Medio
</th>
<th>
Origen
</th>
<th>
Documentos
</th>
<th>
Desde
</th>
<th>
Ultima Noticia
</th>
<th>
Estado
</th>
</tr>
{% for k, v in textPublishers2.items %}
<tr>
<td>
{{k}}
</td><td>
{{v.origen}}
</td><td>
{{v.docs|intcomma}}
</td><td>
{{v.startDate|date:"M d, Y"}}
</td><td>
{{v.endDate|date:"M d, Y"}}
</td>
<td>
{% if v.status > 1 %}
<span
class=
"label label-danger"
>
{{v.status}} dias
</span>
{% else %}
<span
class=
"label label-success"
>
OK
</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- /.box-body -->
</div>
</div>
</div>
<div
class=
"row"
>
...
...
catalog/views.py
View file @
7f126a95
...
...
@@ -121,7 +121,7 @@ def getNewsByRequest(request, values=None):
return
News
.
objects
.
filter
(
myQuery
)
#-------------------------------------------------------------------------------
def
status
(
request
):
tPublishers
=
Publisher
.
objects
.
filter
(
type
=
"texto"
)
tPublishers
=
Publisher
.
objects
.
filter
(
type
=
"texto"
)
.
filter
(
active
=
True
)
tdic
=
{}
...
...
@@ -132,21 +132,37 @@ def status(request):
status
[
"startDate"
]
=
News
.
objects
.
filter
(
publisher
=
p
)
.
order_by
(
'date'
)[
0
]
.
date
status
[
"endDate"
]
=
News
.
objects
.
filter
(
publisher
=
p
)
.
order_by
(
'-date'
)[
0
]
.
date
status
[
"status"
]
=
(
datetime
.
datetime
.
now
(
datetime
.
timezone
.
utc
)
-
status
[
"endDate"
])
.
days
status
[
"origen"
]
=
p
.
region
+
", "
+
p
.
country
tdic
[
p
.
name
]
=
status
tPublishers2
=
Publisher
.
objects
.
filter
(
type
=
"texto"
)
.
filter
(
active
=
False
)
tdic2
=
{}
for
p
in
tPublishers2
:
status
=
{}
status
[
"docs"
]
=
News
.
objects
.
filter
(
publisher
=
p
)
.
count
()
status
[
"startDate"
]
=
News
.
objects
.
filter
(
publisher
=
p
)
.
order_by
(
'date'
)[
0
]
.
date
status
[
"endDate"
]
=
News
.
objects
.
filter
(
publisher
=
p
)
.
order_by
(
'-date'
)[
0
]
.
date
status
[
"status"
]
=
(
datetime
.
datetime
.
now
(
datetime
.
timezone
.
utc
)
-
status
[
"endDate"
])
.
days
status
[
"origen"
]
=
p
.
region
+
", "
+
p
.
country
tdic2
[
p
.
name
]
=
status
aPublishers
=
Publisher
.
objects
.
filter
(
type
=
"audio"
)
adic
=
{}
for
p
in
aPublishers
:
status
=
{}
status
[
"time"
]
=
math
.
floor
(
audioTime
.
objects
.
filter
(
publisher
=
p
)[
0
]
.
minutes
/
60
)
status
[
"startDate"
]
=
audioTime
.
objects
.
filter
(
publisher
=
p
)[
0
]
.
startDate
status
[
"endDate"
]
=
audioTime
.
objects
.
filter
(
publisher
=
p
)[
0
]
.
endDate
status
[
"status"
]
=
(
datetime
.
datetime
.
now
(
datetime
.
timezone
.
utc
)
-
status
[
"endDate"
])
.
days
adic
[
p
.
name
]
=
status
return
render
(
request
,
'new/status.html'
,{
"textPublishers"
:
tdic
,
"audioPublishers"
:
adic
})
if
audioTime
.
objects
.
filter
(
publisher
=
p
)
.
count
()
>
0
:
status
[
"time"
]
=
math
.
floor
(
audioTime
.
objects
.
filter
(
publisher
=
p
)[
0
]
.
minutes
/
60
)
status
[
"startDate"
]
=
audioTime
.
objects
.
filter
(
publisher
=
p
)[
0
]
.
startDate
status
[
"endDate"
]
=
audioTime
.
objects
.
filter
(
publisher
=
p
)[
0
]
.
endDate
status
[
"status"
]
=
(
datetime
.
datetime
.
now
(
datetime
.
timezone
.
utc
)
-
status
[
"endDate"
])
.
days
status
[
"origen"
]
=
p
.
region
+
", "
+
p
.
country
adic
[
p
.
name
]
=
status
return
render
(
request
,
'new/status.html'
,{
"textPublishers"
:
tdic
,
"textPublishers2"
:
tdic2
,
"audioPublishers"
:
adic
})
#-------------------------------------------------------------------------------
def
index
(
request
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment