From: yomguy Date: Wed, 5 Dec 2012 18:48:16 +0000 (+0100) Subject: set all MEDIA_URL with set_host X-Git-Tag: 1.3-TC~56^2~1 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=278f4ee0506364ecafb0524700cff17cab1af2d7;p=teleforma.git set all MEDIA_URL with set_host --- diff --git a/teleforma/context_processors.py b/teleforma/context_processors.py index 64aea0f4..20c2a628 100644 --- a/teleforma/context_processors.py +++ b/teleforma/context_processors.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- from django.conf import settings import socket +import fcntl +import struct interfaces = ['eth0', 'eth1', 'eth2', 'eth0-eth2', 'eth3', 'eth4', 'wlan0', 'wlan1', 'wlan2', 'wlan3', 'wlan4'] @@ -15,7 +17,7 @@ def get_ip_address(ifname): return ip def get_local_host(): - local_ip = '' + ip = '' for interface in interfaces: try: ip = get_ip_address(interface) @@ -23,12 +25,12 @@ def get_local_host(): local_ip = ip break except: - local_ip = '127.0.0.1' + local_ip = '127.0.0.1' return local_ip def get_http_host(request): - host = request.META['HTTP_HOST'] + host = request.META['REMOTE_ADDR'] if ':' in host: host = host.split(':')[0] return host @@ -38,9 +40,6 @@ def host(request): request_host = get_http_host(request) local_host = get_local_host() - print request_host - print local_host - if request_host.split('.')[0] == local_host.split('.')[0] or \ request_host == '127.0.0.1' or request_host == 'localhost': # LAN access @@ -49,4 +48,3 @@ def host(request): ip = settings.ROUTER_IP return {'HOST': ip } - diff --git a/teleforma/management/commands/teleforma-export-stream-m-slugs.py b/teleforma/management/commands/teleforma-export-stream-m-slugs.py new file mode 100644 index 00000000..ddb4a3e8 --- /dev/null +++ b/teleforma/management/commands/teleforma-export-stream-m-slugs.py @@ -0,0 +1,53 @@ +from optparse import make_option +from django.conf import settings +from django.core.management.base import BaseCommand, CommandError +from django.contrib.auth.models import User +from django.template.defaultfilters import slugify +from telemeta.models import * +from telemeta.util.unaccent import unaccent +from teleforma.models import * +import logging +import json + +class Command(BaseCommand): + help = "Export course slugs to a Stream-M server conf file" + args = "password, path" + admin_email = 'webmaster@parisson.com' + ext = 'webm' + data = """ +# server.bindAddress +# example: 127.0.0.1, 192.168.1.1 +# localhost. www.example.com also work +#server.bindAddress = 192.168.0.12 + +# server.port +# listening port +server.port=8080 + +streams.safe=true +streams.safe.password=source2parisson +streams.safe.limit=100 +""" + + def export(self): + courses = Course.objects.all() + types = CourseType.objects.all() + for course in courses: + for type in types: + slug = course.slug + '-' + type.name.lower() + slug = course.department.name.lower() + '-' + slug + self.data += '\nstreams.' + slug + '=true\n' + self.data += 'streams.' + slug + '.password=' + self.passwd + '\n' + self.data += 'streams.' + slug + '.limit=1000\n' + + def handle(self, *args, **options): + self.passwd = args[0] + file = args[1] + self.export() + f = open(file, 'w') + f.write(self.data) + f.close() + + + + diff --git a/teleforma/templates/teleforma/course_media.html b/teleforma/templates/teleforma/course_media.html index 14ede644..5c91979a 100644 --- a/teleforma/templates/teleforma/course_media.html +++ b/teleforma/templates/teleforma/course_media.html @@ -59,7 +59,7 @@ $(document).ready(function(){ {% block module-action %} {% if media.item.file and media.is_published %}
- {% trans "Download" %} + {% trans "Download" %}
{% endif %} {% endblock module-action %} @@ -95,7 +95,7 @@ $(document).ready(function(){
@@ -105,7 +105,7 @@ $(document).ready(function(){ {% if media.item.related.all %} {% for related in media.item.related.all %} {% if related.title == "preview" %} - + {% endif %} {% endfor %} {% else %} @@ -114,7 +114,7 @@ $(document).ready(function(){
{% endif %} diff --git a/teleforma/templates/teleforma/inc/media_list.html b/teleforma/templates/teleforma/inc/media_list.html index e0770566..dea22473 100644 --- a/teleforma/templates/teleforma/inc/media_list.html +++ b/teleforma/templates/teleforma/inc/media_list.html @@ -19,7 +19,7 @@ {% for related in media.item.related.all %} {% if related.title == "preview" %} {% thumbnail related.file "168x96" as im %} -
+
{% trans 'Click here' %}
{% endthumbnail %} @@ -52,7 +52,7 @@ {% endif %} {% if media.item.file %} - + {% endif %}