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 #208 from EsupPortail/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
DrClockwork authored Jun 1, 2017
2 parents 2ce1ef4 + d36f45a commit a514075
Show file tree
Hide file tree
Showing 33 changed files with 1,578 additions and 1,066 deletions.
2 changes: 0 additions & 2 deletions pod_project/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ class Video(models.Model):
duration = models.IntegerField(
_('Duration'), default=0, editable=False, blank=True)
infoVideo = models.TextField(null=True, blank=True, editable=False)



class Meta:
ordering = ['-date_added', '-id']
Expand Down
17 changes: 11 additions & 6 deletions pod_project/core/populatedCASbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@

import sys
import logging
#logger = logging.getLogger(__name__)
FORMAT = '%(asctime)-15s %(clientip)s %(user)-8s %(message)s'
logging.basicConfig(format=FORMAT)
d = {'clientip': '192.168.0.1', 'user': 'fbloggs'}
logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -82,18 +86,19 @@ def authenticate(self, ticket, service, request):
user.is_staff = True

except:
print u'\n*****Unexpected error link :%s - %s' % (sys.exc_info()[0], sys.exc_info()[1])
# print u'\n*****Unexpected error link :%s -
# %s' % (sys.exc_info()[0], sys.exc_info()[1])
msg = u'\n*****Unexpected error link :%s - %s' % (
sys.exc_info()[0], sys.exc_info()[1])
logger.error(msg)
logger.error(msg, extra=d)
except:
user.is_active = False
user.save()
msg = u'\n*****Unexpected error link :%s - %s' % (
sys.exc_info()[0], sys.exc_info()[1])
logger.error(msg)
logger.error(msg, extra=d)
except ldap.LDAPError, e:
logger.error(e)
logger.error(e, extra=d)
else:
if request.session.get('attributes') and settings.AUTH_USER_ATTR_MAP != ():
if settings.AUTH_USER_ATTR_MAP.get('first_name') and request.session['attributes'].get(settings.AUTH_USER_ATTR_MAP['first_name']):
Expand All @@ -117,7 +122,7 @@ def authenticate(self, ticket, service, request):
except:
msg = u'\n*****Unexpected error link :%s - %s' % (
sys.exc_info()[0], sys.exc_info()[1])
logger.error(msg)
logger.error(msg, extra=d)

# on sauvegarde l'utilisateur
user.save()
Expand All @@ -127,7 +132,7 @@ def authenticate(self, ticket, service, request):
except:
msg = u'\n*****Unexpected error link :%s - %s' % (
sys.exc_info()[0], sys.exc_info()[1])
logger.error(msg)
logger.error(msg, extra=d)

else:
msg = u'%s' % _(u'Unable to authenticate')
Expand Down
41 changes: 11 additions & 30 deletions pod_project/core/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ voir http://www.gnu.org/licenses/

var Pod = ( function ( Pod ) {

// Prevents page unload alert box.
Pod.preventUnloadPrompt = false;

// Used to prevent XHR video form upload when file field is empty.
Pod.allowAjaxUpload = true;

Expand Down Expand Up @@ -81,11 +78,11 @@ $(document).ready(function() {

/** SELECT USER **/

$('#ownerbox').keyup(function(){
$('#ownerbox').keyup(function() {
var valThis = $(this).val().toLowerCase();
if(valThis == "") $('.navList>div>label>input:not(:checked)').parent("label").parent("div").hide();
else {
$('.navList>div>label>input:not(:checked)').each(function(){ //:not(:checked)
$('.navList>div>label>input:not(:checked)').each(function() { //:not(:checked)
var text = $(this).parent("label").children("span.fullname").text().toLowerCase();
(text.indexOf(valThis) != -1) ? $(this).parent("label").parent("div").show() : $(this).parent("label").parent("div").hide();
});
Expand All @@ -104,24 +101,10 @@ $(document).ready(function() {

/** FORM VIDEO **/
$('form:not(#video_form)').on('submit', function() {
//$('form').on('submit', function() {
Pod.preventUnloadPrompt = true;
//$('#process').find('div.anim').html(ajax_image);
//$('#process').show();
$('form').hide();
return true;
});

$(window).bind("beforeunload", function(e) {
if (typeof messageBeforeUnload != 'undefined' && messageBeforeUnload != "") {
if (Pod.preventUnloadPrompt) {
return;
} else {
return messageBeforeUnload;
}
}
});

var initial = new Array();
$('#id_theme option:selected').each(function () {
initial.push($(this).val());
Expand All @@ -141,7 +124,7 @@ $(document).ready(function() {
};
});

$('#id_channel').change(function(){
$('#id_channel').change(function() {
var str = "";
$('#id_theme')
.find('option')
Expand Down Expand Up @@ -220,18 +203,18 @@ var csrftoken = getCookie('csrftoken');

/** video list **/

$(document).on('click', "#pagination .paginator a", function () {
$(document).on('click', "#pagination .paginator a", function() {
var newurl = $(this).attr('href');
get_ajax_url(newurl);
return false;
});

$(document).on('change', "#orderby", function () {
$(document).on('change', "#orderby", function() {
createCookie("orderby", $(this).val(), null);
get_ajax_url(window.location.href);
});

$(document).on('change', "#perpage", function () {
$(document).on('change', "#perpage", function() {
createCookie("perpage", $(this).val(), null);
get_ajax_url(window.location.href);
});
Expand Down Expand Up @@ -285,7 +268,7 @@ $(document).on('click', "#share a", function() {
/** end video share embed **/


$(document).on('click', 'button#button_video_report', function (event) {
$(document).on('click', 'button#button_video_report', function(event) {
event.preventDefault();
if($(this).parent('form').length==0){
alert($(this).children('span.sr-only').text());
Expand Down Expand Up @@ -333,8 +316,6 @@ function show_messages( msgText, msgClass, loadUrl ) {

if ( loadUrl !== false ) {

Pod.preventUnloadPrompt = true;

$msgBox.delay( 4000 ).fadeOut( function( ) {

if ( loadUrl === true ) {
Expand Down Expand Up @@ -363,7 +344,7 @@ function show_messages( msgText, msgClass, loadUrl ) {

/** FUNCTIONS **/

Number.prototype.toHHMMSS = function () {
Number.prototype.toHHMMSS = function() {
var seconds = Math.floor(this),
hours = Math.floor(seconds / 3600);
seconds -= hours*3600;
Expand Down Expand Up @@ -418,7 +399,7 @@ function setPerPage() {
cperpage = getCookie("perpage");
if(cperpage!=null) {
$("#perpage").val(cperpage);
$("#perpage option").each(function(){
$("#perpage option").each(function() {
if ($(this).attr("value") == cperpage) {
$(this).attr("selected",true);
} else {
Expand All @@ -434,7 +415,7 @@ function setOrderBy() {
if(corderby==null) corderby="order_by_-date_added"
if(corderby!=null) {
$("#orderby").val(corderby);
$("#orderby option").each(function(){
$("#orderby option").each(function() {
if ($(this).attr("value") == corderby) {
$(this).attr("selected",true);
} else {
Expand Down Expand Up @@ -510,7 +491,7 @@ function get_ajax_url(newurl, attrs) {
});
}

function frameReady(){
function frameReady() {
//alert('frameready');
$("#framemessage").hide();
$("#resultFrame").height("450px");
Expand Down
5 changes: 4 additions & 1 deletion pod_project/core/static/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ function loadVideo() {
clickToToggle: (!isMobile()),
clickAndDrag: true,
autoMobileOrientation: true,
backToVerticalCenter: false,
backToHorizonCenter: false,
initFov: 100,
NoticeMessage: (isMobile())? "please move your phone" : "please use your mouse drag and drop the video",
VREnable: false,
NoticeMessage: (isMobile())? NoticeMessageMobile : NoticeMessageMouse,
callback: function () {
//if(!isMobile()) myPlayer.play();
}
Expand Down
3 changes: 1 addition & 2 deletions pod_project/core/templates/userProfile.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
<script type="text/javascript" src="{{ STATIC_URL }}admin/js/jquery.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}admin/js/jquery.init.js"></script>
<script>
var messageBeforeUnload = "{% trans 'Warning, you will leave this page. If you have made changes without clicking the Save button, your changes will be lost.' %}",
num = 0,
var num = 0,
name = "";
</script>
{% endblock bootstrap3_extra_head %}
Expand Down
51 changes: 49 additions & 2 deletions pod_project/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
import logging
import traceback
from django.conf import settings
from django.core.mail import EmailMultiAlternatives
from django.utils.translation import ugettext_lazy as _
from django.core.mail import EmailMultiAlternatives, send_mail
from core.models import EncodingType, get_media_guard
from pods.models import EncodingPods
from pods.models import Pod
Expand Down Expand Up @@ -181,7 +182,7 @@ def encode_video(video_to_encode):
video_to_encode.encoding_status = "GET SAR"
video_to_encode.save()
sar_w, sar_h = [
int(_) for _ in stream.get("sample_aspect_ratio").split(':')]
int(__) for __ in stream.get("sample_aspect_ratio").split(':')]
sar = 1
if sar_w != 0 and sar_h != 0:
sar = (1. * sar_w / sar_h)
Expand Down Expand Up @@ -319,6 +320,52 @@ def encode_video(video_to_encode):
video.encoding_in_progress = False
video.save()

encoding_user_email_data = video_to_encode.get_encoding_user_email_data()
if encoding_user_email_data and video.encoding_status.startswith("DONE"):
from django.utils.translation import override
content_url = "%s/video/%s/" % (
encoding_user_email_data['root_url'], video.slug)
list_url = "%s/owner_videos_list/" % encoding_user_email_data[
'root_url']
with override(encoding_user_email_data['curr_lang']):
send_mail(
"[%s] %s" % (
settings.TITLE_SITE,
_(u"Encoding #%(content_id)s completed") % {
'content_id': VIDEO_ID
}
),
"%s\n\n%s\n%s\n%s" % (
_(u"The content “%(content_title)s” has been encoded to Web formats, and is now available on %(site_title)s.") % {
'content_title': video.title,
'site_title': settings.TITLE_SITE
},
_(u"You will find it here:"),
content_url,
_(u"and in your content list: %(content_list)s.") % {
'content_list': list_url
}
),
settings.DEFAULT_FROM_EMAIL,
[encoding_user_email_data['user_email']],
html_message='<p>%s</p><p>%s<br><a href="%s"><i>%s</i></a>\
<br>%s</p>' % (
_(u"The content “%(content_title)s” has been encoded to Web formats, and is now available on %(site_title)s.") % {
'content_title': '<b>%s</b>' % video.title,
'site_title': settings.TITLE_SITE
},
_(u"You will find it here:"),
content_url,
content_url,
_(u"and in %(your_content_list)s.") % {
'your_content_list': '<a href="%s">%s</a>' % (
list_url,
_(u"your content list")
)
}
)
)

# end encode_video(video):


Expand Down
8 changes: 7 additions & 1 deletion pod_project/django_cas_gateway/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ def _verify_cas3(ticket, service):
params = {'ticket': ticket, 'service': service}
url = (urljoin(settings.CAS_SERVER_URL, 'proxyValidate') + '?' +
urlencode(params))
page = urlopen(url)
if settings.CAS_PROXY:
proxy_support = urllib2.ProxyHandler({'http': settings.CAS_PROXY_HTTP, 'https': settings.CAS_PROXY_HTTPS})
opener = urllib2.build_opener(proxy_support)
urllib2.install_opener(opener)
page = urllib2.urlopen(url)
else:
page = urlopen(url)
try:
user = None
attributes = {}
Expand Down
Binary file modified pod_project/locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit a514075

Please sign in to comment.