From: yomguy Date: Thu, 24 Mar 2011 15:05:14 +0000 (+0100) Subject: add rolling publishing date property (overidden bty staff or full public access X-Git-Tag: 1.1~340 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=c1359c876d84f8a43060caf1bd9b4acf3c605143;p=telemeta.git add rolling publishing date property (overidden bty staff or full public access --- diff --git a/telemeta/locale/fr/LC_MESSAGES/django.mo b/telemeta/locale/fr/LC_MESSAGES/django.mo index 9c9544b9..f3360341 100644 Binary files a/telemeta/locale/fr/LC_MESSAGES/django.mo and b/telemeta/locale/fr/LC_MESSAGES/django.mo differ diff --git a/telemeta/locale/fr/LC_MESSAGES/django.po b/telemeta/locale/fr/LC_MESSAGES/django.po index e736ada3..1766ebc5 100644 --- a/telemeta/locale/fr/LC_MESSAGES/django.po +++ b/telemeta/locale/fr/LC_MESSAGES/django.po @@ -834,5 +834,5 @@ msgid "Enumerations" msgstr "Énumérations" #: web.base.py:955 -msgid "Not allowed" -msgstr "Non autorisé" +msgid "Access not allowed" +msgstr "Accès non autorisé" diff --git a/telemeta/templates/telemeta_default/mediaitem_detail.html b/telemeta/templates/telemeta_default/mediaitem_detail.html index 0da5cc22..f5d6bef2 100644 --- a/telemeta/templates/telemeta_default/mediaitem_detail.html +++ b/telemeta/templates/telemeta_default/mediaitem_detail.html @@ -61,8 +61,8 @@ {% block content %}

Item : {{ item }}

-
- {% if item.file and item.public_access == 'full' %} +
+ {% if item.file and item.public_access == 'full' or public_access or user.is_staff %}
Minimize
diff --git a/telemeta/web/base.py b/telemeta/web/base.py index 9e309356..6ac1e52b 100644 --- a/telemeta/web/base.py +++ b/telemeta/web/base.py @@ -245,12 +245,30 @@ class WebView(object): previous, next = self.item_previous_next(item) analyzers = self.item_analyze(item) playlists = self.get_playlists(request) - + + # Rrolling publishing date : Public access when time between recorded year + # and currant year is over settings value PUBLIC_ACCESS_PERIOD + date_from = item.recorded_from_date + date_to = item.recorded_to_date + if date_to: + date = date_to + elif date_from: + date = date_from + else: + date = None + public_access = True + if date: + year = str(date).split('-') + year_now = datetime.datetime.now().strftime("%Y") + if int(year_now) - int(year[0]) < settings.PUBLIC_ACCESS_PERIOD: + public_access = False + return render(request, template, {'item': item, 'export_formats': formats, 'visualizers': graphers, 'visualizer_id': grapher_id,'analysers': analyzers, 'audio_export_enabled': getattr(settings, 'TELEMETA_DOWNLOAD_ENABLED', True), 'previous' : previous, 'next' : next, 'marker': marker_id, 'playlists' : playlists, + 'public_access': public_access, }) @method_decorator(permission_required('telemeta.change_mediaitem')) @@ -952,5 +970,5 @@ class WebView(object): return response def not_allowed(self, request): - messages.error(request, ugettext('Not allowed')) + messages.error(request, ugettext('Access not allowed')) return render(request, 'telemeta/messages.html')