Fix minor bugs
authorverrierj
Mon, 16 Jan 2012 17:14:52 +0100
changeset 404 4adc42ab55fd
parent 400 6f507891791a
child 405 b0e13a70a57f
Fix minor bugs
src/ldt/ldt/ldt_utils/forms.py
src/ldt/ldt/ldt_utils/projectserializer.py
src/ldt/ldt/ldt_utils/templates/front/front_group.html
src/ldt/ldt/ldt_utils/templates/front/front_player.html
src/ldt/ldt/ldt_utils/templates/front/front_search_results.html
src/ldt/ldt/ldt_utils/views/content.py
src/ldt/ldt/ldt_utils/views/front.py
src/ldt/ldt/ldt_utils/views/json.py
--- a/src/ldt/ldt/ldt_utils/forms.py	Mon Jan 16 16:03:11 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/forms.py	Mon Jan 16 17:14:52 2012 +0100
@@ -51,7 +51,7 @@
     media_input_type = forms.ChoiceField(required=False, label=_("content.media_input_type"), choices=(("upload", _("file_upload")), ("url", _("url")), ("link", _("existing_media")), ("create", _("create_media")), ("none", _("none_media"))))
     groups = forms.ModelMultipleChoiceField(Group.objects.all(), required=False)
     is_public = forms.BooleanField(required=False)
-    front_project = forms.ModelChoiceField(queryset=Project.objects.all(), required=False, label=_("content.front_project")) 
+    front_project = forms.ModelChoiceField(queryset=Project.objects.none(), required=False, label=_("content.front_project")) 
         
     def clean_iri_id(self):
         data = self.cleaned_data.get('iri_id')
--- a/src/ldt/ldt/ldt_utils/projectserializer.py	Mon Jan 16 16:03:11 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/projectserializer.py	Mon Jan 16 17:14:52 2012 +0100
@@ -16,7 +16,7 @@
 """
 class ProjectSerializer:
     
-    def __init__(self, project, from_contents=True, from_display=True, first_cutting=None, viewable_contents=[]):
+    def __init__(self, project, from_contents=True, from_display=True, first_cutting=None, viewable_contents=[], only_one_cutting=False):
         self.project = project
         self.parsed = False
         self.ldt_doc = None
@@ -35,6 +35,7 @@
         self.display_ensemble_list = []
         self.viewable_contents = viewable_contents
         self.first_cutting = first_cutting
+        self.only_one_cutting = only_one_cutting
         
         
     def __parse_views(self, display_node_list):
@@ -80,6 +81,9 @@
                     if index >= 0:
                         annotation_types[0], annotation_types[index] = annotation_types[index], annotation_types[0]
             
+            if self.only_one_cutting:
+                new_display['annotation_types'] = [new_display['annotation_types'][0]] 
+                            
             self.views_dict[display_id] = new_display
             
     
--- a/src/ldt/ldt/ldt_utils/templates/front/front_group.html	Mon Jan 16 16:03:11 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_group.html	Mon Jan 16 17:14:52 2012 +0100
@@ -20,7 +20,7 @@
     {% for content in content_list %}
     <li class="li_media">
         <a href="{% url ldt.ldt_utils.views.front.annot_content content.iri_id %}">{% thumbnail content.image "134x75" format="PNG" crop="center" as im %}<img src="{{ im.url }}" class="img_media" width="{{ im.width }}" height="{{ im.height }}">{% endthumbnail %}</a>
-        <div class="bulle_annot">120</div>
+        <div class="bulle_annot">{{content.nb_annotation}}</div>
         <p><a href="{% url ldt.ldt_utils.views.front.annot_content content.iri_id %}"><b>{% if content.title|length > 69 %}{{content.title|slice:":69"}}...{% else %}{{content.title}}{% endif %}</b></a></p>
         <p class="font_11">{% trans 'by' %} IRI | {{content.duration|str_duration:"h"}}</p>
     </li>
--- a/src/ldt/ldt/ldt_utils/templates/front/front_player.html	Mon Jan 16 16:03:11 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_player.html	Mon Jan 16 17:14:52 2012 +0100
@@ -47,6 +47,9 @@
 
 {% block body %}
 {{block.super}}
+
+------>{{ project }}
+
 <!-- Player column -->
 <div id="player_col_g">
     <ul class="floatlist" id="top_media">
--- a/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html	Mon Jan 16 16:03:11 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html	Mon Jan 16 17:14:52 2012 +0100
@@ -3,7 +3,7 @@
 {% load thumbnail %}
 {% load front_tags %}
 
-{% block title %}Lignes de temps : {% trans 'search' %} ""{% endblock %}
+{% block title %}Lignes de temps : {% trans 'search' %} "{{search}}" {% endblock %}
 
 {% block js_import %}
 {{block.super}}
--- a/src/ldt/ldt/ldt_utils/views/content.py	Mon Jan 16 16:03:11 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/views/content.py	Mon Jan 16 17:14:52 2012 +0100
@@ -10,7 +10,7 @@
 from django.utils.translation import ugettext as _, ungettext
 from ldt.ldt_utils.forms import ContentForm, MediaForm
 from guardian.shortcuts import remove_perm
-from ldt.ldt_utils.models import Content, Media
+from ldt.ldt_utils.models import Content, Media, Project
 from ldt.security.utils import assign_perm_to_obj, add_change_attr, get_userlist, get_userlist_model
 from ldt.security.cache import cached_assign
 from ldt.user.forms import PictureForm
@@ -249,6 +249,9 @@
                 
         if instance_content is not None:
             content_form.media_input_type = "link"
+                   
+            if request.user.is_staff:
+                content_form.fields['front_project'].queryset = Project.objects.filter(contents__in=[instance_content])
     
     return content_form, media_form, picture_form, form_status
 
--- a/src/ldt/ldt/ldt_utils/views/front.py	Mon Jan 16 16:03:11 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/views/front.py	Mon Jan 16 17:14:52 2012 +0100
@@ -37,7 +37,7 @@
     everyone = Group.objects.get(name=settings.PUBLIC_GROUP_NAME)
     content_list = get_objects_for_group(group, 'ldt_utils.view_content') | get_objects_for_group(everyone, 'ldt_utils.view_content')
     # Group's users
-    users = User.objects.filter(groups__in=[group])
+    users = User.objects.filter(groups__in=[group]).exclude(is_superuser=True)
     
     is_gecko = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1);
 
@@ -68,12 +68,18 @@
     youtube_url = None
     if content.src is not None and "youtube.com" in content.src:
         youtube_url = content.src
+        
     # If project id is not set, we get the default project for the content
-    if project_id is None :
-        # The main project for the content
-        proj = Project.objects.filter(contents__in=[content])[0]
+    if project_id is None or project_id == "_":
+        front_proj = content.front_project
+        if front_proj:
+            proj = front_proj
+        else:
+            # The main project for the content
+            proj = Project.safe_objects.filter(contents__in=[content])[0]
     else :
-        proj = Project.objects.get(ldt_id=project_id)
+        proj = Project.safe_objects.get(ldt_id=project_id)
+        
     # Vars for player
     player_id = "player_project_" + proj.ldt_id
     
@@ -105,6 +111,3 @@
 @login_required
 def search_listing(request):
     return ws_search_listing(request, front_template=True)
-
-
-    
--- a/src/ldt/ldt/ldt_utils/views/json.py	Mon Jan 16 16:03:11 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/views/json.py	Mon Jan 16 17:14:52 2012 +0100
@@ -10,24 +10,21 @@
 from guardian.shortcuts import get_objects_for_user
 
 
-# TODO : for tests only, we use Project.objects
-# should be set to Project.safe_objects for production 
-
 def project_json_id(request, id): 
     
-    project = get_object_or_404(Project.objects, ldt_id=id)
+    project = get_object_or_404(Project.safe_objects, ldt_id=id)
 
     return project_json(request, project, False)
 
 def project_json_cutting_id(request, id, cutting_id):
 
-    project = get_object_or_404(Project.objects, ldt_id=id)
+    project = get_object_or_404(Project.safe_objects, ldt_id=id)
 
     return project_json(request, project, first_cutting=cutting_id)
 
 def project_json_externalid(request, id): 
         
-    res_proj = get_list_or_404(Project.objects.order_by('-modification_date'), contents__external_id=id) #@UndefinedVariable
+    res_proj = get_list_or_404(Project.safe_objects.order_by('-modification_date'), contents__external_id=id) #@UndefinedVariable
     
     return project_json(request, res_proj[0], False)