]> git.parisson.com Git - telemeta.git/commitdiff
continue new access rules
authoryomguy <yomguy@parisson.com>
Sun, 13 Jan 2013 10:50:12 +0000 (11:50 +0100)
committeryomguy <yomguy@parisson.com>
Sun, 13 Jan 2013 10:50:12 +0000 (11:50 +0100)
telemeta/templates/telemeta/collection_detail.html
telemeta/views/collection.py
telemeta/views/core.py
telemeta/views/home.py
telemeta/views/item.py

index 5f6aee152808825c03b38b237af83ace9615f911..d9d15ba3c739ee50dfef1482229f7b1ed26d0dbe 100644 (file)
@@ -52,9 +52,9 @@
 {% endblock %}
 
 {% block content %}
-    <div class="{% if collection.has_mediafile %}{% if public_access or perms.telemeta.can_play_all_items %}with-rightcol{% endif %}{% endif %}">
+    <div class="{% if collection.has_mediafile %}{% if public_access == 'full' or perms.telemeta.can_play_all_items %}with-rightcol{% endif %}{% endif %}">
         {% if collection.has_mediafile %}
-        {% if public_access or perms.telemeta.can_play_all_items %}
+        {% if public_access == 'full' or perms.telemeta.can_play_all_items %}
         <div id="rightcol">
             <div id="collection_player">
              <div class="title">
index 7fb0def438c29b8dc8530e4f57f1a66b3cb17527..bceabfa17d7b1e25039bd4d3d720ca7860eed9d4 100644 (file)
@@ -52,8 +52,6 @@ class CollectionView(object):
             messages.error(request, title)
             return render(request, 'telemeta/messages.html', {'description' : description})
 
-        public_access = get_public_access(collection.public_access, collection.recorded_from_year,
-                                                collection.recorded_to_year)
         playlists = get_playlists(request)
 
         related_media = MediaCollectionRelated.objects.filter(collection=collection)
@@ -67,7 +65,7 @@ class CollectionView(object):
             last_revision = None
 
         return render(request, template, {'collection': collection, 'playlists': playlists,
-                'public_access': public_access, 'items': items, 'related_media': related_media,
+                'items': items, 'related_media': related_media,
                 'parents': parents, 'last_revision': last_revision })
 
     @method_decorator(permission_required('telemeta.change_mediacollection'))
index 2859402472d622fd6e20d82f7fd652d42b8d7863..0357dbc82ed6a65d73566d673db81e1009293fde 100644 (file)
@@ -167,7 +167,7 @@ def get_item_access(item, user):
     # Auto publish after slipping period (settings.TELEMETA_PUBLIC_ACCESS_PERIOD)
     if access != 'full' and item.auto_period_access:
         year_from = str(item.recorded_from_date).split('-')[0]
-        year_to = str(item.recorded_to_date).split('-')[0])
+        year_to = str(item.recorded_to_date).split('-')[0]
 
         if year_from and not year_from == 0:
             year = year_from
index 411193d58d6b0e8221a13dc9f829baa2cf597a2b..e2e38b6b86669fb5f5a99208265f5808f98c8b1e 100644 (file)
@@ -49,8 +49,7 @@ class HomeView(object):
         sound_items = MediaItem.objects.sound()
         _sound_pub_items = []
         for item in sound_items:
-            if get_public_access(item.public_access,  str(item.recorded_from_date).split('-')[0],
-                                            str(item.recorded_to_date).split('-')[0]):
+            if get_item_access(item, request.user) == 'full':
                 _sound_pub_items.append(item)
 
         random.shuffle(_sound_pub_items)
index 6e22c334f5e8296a7d0d1966b53729b04a991820..95ec232e9296e951ac10be20f745da71f204dded 100644 (file)
@@ -468,11 +468,9 @@ class ItemView(object):
         """Export a given media item in the specified format (OGG, FLAC, ...)"""
 
         item = MediaItem.objects.get(public_id=public_id)
-        public_access = get_public_access(item.public_access,
-                                          str(item.recorded_from_date).split('-')[0],
-                                          str(item.recorded_to_date).split('-')[0])
+        public_access = get_item_access(item, request.user)
 
-        if (not public_access or not extension in settings.TELEMETA_STREAMING_FORMATS) and \
+        if (not public_access == 'full' or not extension in settings.TELEMETA_STREAMING_FORMATS) and \
                     not (request.user.has_perm('telemeta.can_play_all_items') or request.user.is_superuser):
             mess = ugettext('Access not allowed')
             title = 'Item file : ' + public_id + '.' + extension + ' : ' + mess