Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #197 from EsupPortail/dev
Browse files Browse the repository at this point in the history
Dev to master
  • Loading branch information
DrClockwork authored May 15, 2017
2 parents 3859e08 + 8ea00dc commit 247f3eb
Show file tree
Hide file tree
Showing 18 changed files with 796 additions and 28 deletions.
11 changes: 8 additions & 3 deletions pod_project/core/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,19 +471,23 @@ function createCookie(name,value,days) {

function get_ajax_url(newurl, attrs) {
$("#objects_list").css("height",$("#objects_list").height());
$(".mainToolbar").hide();
//$(".mainToolbar").hide();
var filter_is_visible = $('#filters').is(":visible")
$('#filters').hide();
$( "#objects_list" ).fadeOut("fast", function() {
$( "#objects_list" ).html( ajax_image ).fadeIn("fast", function() {
$.get( newurl, attrs, function( data ) {
$( "#objects_list" ).fadeOut("fast", function() {
$( "#objects_list" ).html( data );
$( "#objects_list" ).html( data.json_videols );
setOrderBy();
$("a.show-desc span").hide();
$( "#objects_list" ).fadeIn("fast");
$("#objects_list").css("height","auto");
});
$( "#toolbar" ).fadeOut("fast", function() {
$( "#toolbar" ).html( data.json_toolbar );
$( "#toolbar" ).fadeIn("fast");
});

if(attrs){
if (window.history && window.history.pushState) {
Expand All @@ -498,7 +502,8 @@ function get_ajax_url(newurl, attrs) {
}
}
setPerPage();
$(".mainToolbar").show();
//$(".mainToolbar").show();

if(filter_is_visible) $('#filters').show();
}).fail(function() { alert( "error" ); });
});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 12 additions & 2 deletions pod_project/pod_project/settings_local-sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@
#
# ENCODE_VIDEO_CMD = "%(ffprobe)s -v quiet -show_format -show_streams -print_format json -i %(src)s"
ADD_THUMBNAILS_CMD = "nice -n 19 ffmpegthumbnailer -i \"%(src)s\" -s 256x256 -f -t 10%% -o %(out)s_2.png && nice -n 19 ffmpegthumbnailer -i \"%(src)s\" -s 256x256 -f -t 50%% -o %(out)s_3.png && nice -n 19 ffmpegthumbnailer -i \"%(src)s\" -s 256x256 -f -t 75%% -o %(out)s_4.png"
ADD_OVERVIEW_CMD = "for i in $(seq 0 99); do nice -n 19 ffmpegthumbnailer -t $i%% -s %(scale)s -c jpeg -i \"%(src)s\" -o %(out)s_strip$i.jpg; nice -n 19 montage -geometry +0+0 %(out)s %(out)s_strip$i.jpg %(out)s; done; rm %(out)s_strip*.jpg"
ADD_OVERVIEW_CMD = "rm %(out)s;for i in $(seq 0 99); do nice -n 19 ffmpegthumbnailer -t $i%% -s %(scale)s -c jpeg -i \"%(src)s\" -o %(out)s_strip$i.jpg; nice -n 19 montage -geometry +0+0 %(out)s %(out)s_strip$i.jpg %(out)s; done; rm %(out)s_strip*.jpg"
# ENCODE_MP4_CMD = "%(ffmpeg)s -i %(src)s -codec:v libx264 -profile:v high -pix_fmt yuv420p -preset faster -b:v %(bv)s -maxrate %(bv)s -bufsize %(bufsize)s -vf scale=%(scale)s -force_key_frames \"expr:gte(t,n_forced*1)\" -deinterlace -threads 0 -codec:a aac -strict -2 -ar %(ar)s -ac 2 -b:a %(ba)s -movflags faststart -y %(out)s"
# ENCODE_WEBM_CMD = "%(ffmpeg)s -i %(src)s -codec:v libvpx -quality realtime -cpu-used 3 -b:v %(bv)s -maxrate %(bv)s -bufsize %(bufsize)s -qmin 10 -qmax 42 -threads 4 -codec:a libvorbis -y %(out)s"
# ENCODE_MP3_CMD = "%(ffmpeg)s -i %(src)s -vn -ar %(ar)s -ab %(ab)s -f mp3 -threads 0 -y %(out)s"
Expand All @@ -405,6 +405,16 @@
# if set it's used for download and encoding test
# HTTP_PROXY = 'http://localhost:3128/'

##
# Enable RSS feed and ATOM feed on channels and search results
#
# - True : button to suscribe to feed appears in navigation toolbar
#
#
RSS_ENABLED = False
ATOM_HD_ENABLED = False
ATOM_SD_ENABLED = False

# Encode with Celery
CELERY_TO_ENCODE = False
CELERY_NAME = "pod_project"
Expand All @@ -420,4 +430,4 @@
H5P_SAVE = 30 # How often current content state should be saved
H5P_EXPORT = '/exports/' # Location of exports (packages .h5p)
H5P_LANGUAGE = 'fr' # Language of the module H5P.
BASE_URL = 'http://localhost:8000' # Hostname of your django app
BASE_URL = 'http://localhost:8000' # Hostname of your django ap
23 changes: 23 additions & 0 deletions pod_project/pod_project/urls-sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from django.contrib import admin
admin.autodiscover()

from pods.utils_itunesfeed import PodcastHdFeed, PodcastSdFeed, AudiocastFeed, MySelectFeed

urlpatterns = [
url(r'^favicon\.ico$', RedirectView.as_view(
url=settings.STATIC_URL + 'images/favicon.ico', permanent=True)),
Expand Down Expand Up @@ -127,3 +129,24 @@
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL,
document_root=settings.MEDIA_ROOT)

#RSS Feed
if settings.RSS_ENABLED:
urlpatterns += [
url(r'^rss/select/(?P<qparam>[^\/]+)/$', MySelectFeed(), name = 'rss_select'),
]
#ATOM HD Feed
if settings.ATOM_HD_ENABLED:
urlpatterns += [
url(r'^rss/hd/(?P<qparam>[^\/]+)/$', PodcastHdFeed(), name = 'podcast_hd'),
]
# ATOM SD Feed
if settings.ATOM_SD_ENABLED:
urlpatterns += [
url(r'^rss/sd/(?P<qparam>[^\/]+)/$', PodcastSdFeed(), name = 'podcast_sd'),
]
#ATOM Audio Feed
#if settings.ATOM_AUDIO_ENABLED:
# urlpatterns += [
# url(r'^rss/audio/(?P<qparam>[^\/]+)/$', AudiocastFeed(), name = 'audiocast'),
# ]
20 changes: 20 additions & 0 deletions pod_project/pods/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,23 @@ class ReportAdmin(admin.ModelAdmin):
list_filter = ('date_added',)
list_display_links = ('id', 'user', 'video')
admin.site.register(ReportVideo, ReportAdmin)


# RSS Feed
class RssfeedAdmin(admin.ModelAdmin):

def get_owner_by_name(self, obj):
owner = obj.owner
url = url_to_edit_object(owner)
return u'%s %s (%s)' % (owner.first_name, owner.last_name, url)

get_owner_by_name.allow_tags = True
get_owner_by_name.short_description = _('Owner')

list_display = ('title', 'type_rss', 'year', 'get_owner_by_name', 'is_up')
list_filter = ('date_update', 'year', 'type_rss', 'is_up')
list_editable = ('year', 'is_up')
search_fields = ['title', 'description', 'link_rss',
'owner__username', 'owner__first_name', 'owner__last_name']
list_per_page = 20
admin.site.register(Rssfeed, RssfeedAdmin)
41 changes: 41 additions & 0 deletions pod_project/pods/migrations/0014_rssfeed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
from django.conf import settings


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('pods', '0013_pod_is_360'),
]

operations = [
migrations.CreateModel(
name='Rssfeed',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('title', models.CharField(max_length=200, unique_for_year='date_update')),
('description', models.TextField()),
('link_rss', models.URLField()),
('type_rss', models.CharField(default='A', max_length=1, choices=[('A', 'Audio'), ('V', 'Vid\xe9o')])),
('year', models.PositiveSmallIntegerField(default=2017)),
('date_update', models.DateTimeField(auto_now=True)),
('filters', models.TextField(blank=True)),
('limit', models.SmallIntegerField(default=0, help_text='Keep 0 to mean all items', verbose_name='Count items')),
('is_up', models.BooleanField(default=True, help_text='If this box is checked, the video will be visible and accessible by anyone.', verbose_name='Visible')),
('fil_channel', models.ManyToManyField(to='pods.Channel', verbose_name='Channels', blank=True)),
('fil_discipline', models.ManyToManyField(to='pods.Discipline', verbose_name='Disciplines', blank=True)),
('fil_theme', models.ManyToManyField(to='pods.Theme', verbose_name='Themes', blank=True)),
('fil_type_pod', models.ForeignKey(verbose_name='Type', to='pods.Type')),
('owner', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, default=1, to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'RSS',
'verbose_name_plural': 'RSS',
},
),
]
45 changes: 45 additions & 0 deletions pod_project/pods/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from core.models import Video, get_storage_path, EncodingType
import base64
import logging
from django.forms.formsets import ORDERING_FIELD_NAME
logger = logging.getLogger(__name__)
import unicodedata
import json
Expand Down Expand Up @@ -1123,3 +1124,47 @@ class Meta:
verbose_name = _("Report")
verbose_name_plural = _("Reports")
unique_together = ('video', 'user',)

@python_2_unicode_compatible
class Rssfeed(models.Model):
AUDIO = 'A'
VIDEO = 'V'
TYPE_CHOICES = (
(AUDIO, 'Audio'),
(VIDEO, 'Vidéo'),
)
title = models.CharField(max_length=200, blank=False, unique_for_year='date_update')
description = models.TextField(blank=False)
link_rss = models.URLField(max_length=200, blank=False)
type_rss = models.CharField(max_length=1,
choices=TYPE_CHOICES,
default=AUDIO)
year = models.PositiveSmallIntegerField(default=2017)
date_update = models.DateTimeField(auto_now=True)
# récupérer le user à la création
owner = models.ForeignKey(User, blank=False, null=False, on_delete=models.PROTECT, default=1)
filters = models.TextField(blank=True)
fil_type_pod = models.ForeignKey(Type, verbose_name=_('Type'))
fil_discipline = models.ManyToManyField(
Discipline, blank=True, verbose_name=_('Disciplines'))
fil_channel = models.ManyToManyField(
Channel, verbose_name=_('Channels'), blank=True)
fil_theme = models.ManyToManyField(
Theme, verbose_name=_('Themes'), blank=True)
limit = models.SmallIntegerField(verbose_name=_('Count items'),
help_text=_(u'Keep 0 to mean all items'),default=0)
is_up = models.BooleanField(verbose_name=_('Visible'),
help_text=_(
u'If this box is checked, the video will be visible and accessible by anyone.'),
default=True)

class Meta:
verbose_name = _("RSS")
verbose_name_plural = _("RSS")


def __unicode__(self):
return self.title

def __str__(self):
return self.title
18 changes: 17 additions & 1 deletion pod_project/pods/templates/channels/channel.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,23 @@
{% if videos %}
<div class="results">
{% blocktrans count counter=videos.paginator.count %}{{ counter }} video{% plural %}{{ counter }} videos{% endblocktrans %}
</div>
{% if RSS %}
<a type="application/rss+xml" href="{% url 'rss_select' qparam=param %}" title="Click to suscribe to RSS feed">
<img src="/static/images/rss3_ic.png" alt="RSS" height="27px" width="27px"/></a>&nbsp;
{% endif %}
{% if ATOM_HD %}
<a type="application/atom+xml" href="{% url 'podcast_hd' qparam=param %}" title="Click to suscribe to podcasts">
<img src="/static/images/videocast_hd3_ic.png" alt="HD" height="25px" width="25px"/></a>&nbsp;
{% endif %}
{% if ATOM_SD %}
<a type="application/atom+xml" href="{% url 'podcast_sd' qparam=param %}" title="Click to suscribe to podcasts">
<img src="/static/images/videocast_sd3_ic.png" alt="SD" height="25px" width="25px"/></a>&nbsp;
{% endif %}
<!--
<a type="application/atom+xml" href="" title="Click to suscribe to audiocast">
<img src="/static/images/audiocast3_ic.png" alt="Audio" height="25px" width="25px"/></a>
-->
</div>
{% endif %}
{% if user.is_authenticated and request.user in channel.owners.all%}
<div class="resultschannel">
Expand Down
2 changes: 1 addition & 1 deletion pod_project/pods/templates/channels/my_channels.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ <h4><span class="glyphicon glyphicon-info-sign"></span> {% trans "Information"%}
{% block box_note %} {% endblock box_note %}

</aside>
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion pod_project/pods/templates/favorites/my_favorites.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@
{% block box_social %} {% endblock box_social %}
{% block box_note %} {% endblock box_note %}
{% block box_info %} {% endblock box_info %}
{% endblock %}
{% endblock %}
26 changes: 22 additions & 4 deletions pod_project/pods/templates/maintoolbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,28 @@
</div>
{% block stats %}
<div class="col-sm-4 text-right">
<div class="results">
{% blocktrans count counter=videos.paginator.count %}{{ counter }} video{% plural %}{{ counter }} videos{% endblocktrans %}
</div>
<div class="results">
{% blocktrans count counter=videos.paginator.count %}{{ counter }} video{% plural %}{{ counter }} videos{% endblocktrans %}
{% if param|length > 4 %}
{% if RSS %}
<a type="application/rss+xml" href="{% url 'rss_select' qparam=param %}" title="Click to suscribe to RSS feed">
<img src="/static/images/rss3_ic.png" alt="rss" height="27px" width="27px"/></a>&nbsp;
{% endif %}
{% if ATOM_HD %}
<a type="application/atom+xml" href="{% url 'podcast_hd' qparam=param %}" title="Click to suscribe to podcasts">
<img src="/static/images/videocast_hd3_ic.png" alt="HD" height="25px" width="25px"/></a>&nbsp;
{% endif %}
{% if ATOM_SD %}
<a type="application/atom+xml" href="{% url 'podcast_sd' qparam=param %}" title="Click to suscribe to podcasts">
<img src="/static/images/videocast_sd3_ic.png" alt="SD" height="25px" width="25px"/></a>&nbsp;
{% endif %}
<!-- {% if ATOM_AUDIO %}
<a type="application/atom+xml" href="{% url 'audiocast' qparam=param %}" title="Click to suscribe to audiocast">
<img src="/static/images/audiocast3_ic.png" alt="Audio" height="25px" width="25px"/></a>
{% endif %}-->
{% endif %}
</div>
</div>
{% endblock stats %}
</div>
</div>
</div>
33 changes: 31 additions & 2 deletions pod_project/pods/templates/videos/videos.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@
{% block breadcrumbs %}{{ block.super }} <li class="active">{% trans "Videos" %}</li>{% endblock %}

{% block mainToolbar %}
{% include "maintoolbar.html" %}
<span id="toolbar">
{% include "maintoolbar.html" %}
</span>
{% endblock mainToolbar %}

{% block article %}
<div id="objects_list">
{% include "videos/videos_list.html" %}
{% include "videos/videos_list.html" %}
</div>
{% endblock %}

Expand Down Expand Up @@ -158,3 +160,30 @@ <h4><span class="glyphicon glyphicon-filter"></span> {% trans "Filters"%}</h4>
{% endblock box_filtre %}
</aside>
{% endblock %}

<!--
<script>
/*** table scroll ***/
// Change the selector if needed
$(document).on("submit", "#filters form", function (e) {
e.preventDefault();
var jqxhr= '';
jqxhr.done(function(data){
if(data.json_toolbar) {
refresh_list_and_toolbar(data);
}
else {
}
});
});
/*** Refreshes the list of videos after filtering ***/
function refresh_list_and_toolbar(data){
$("span#toolbar").html(data.json_toolbar);
$("div#objects_list").html(data.json_videols);
};
</script>
-->

Loading

0 comments on commit 247f3eb

Please sign in to comment.