src/ldt/ldt/ldt_utils/views/front.py
changeset 504 32a878a71a80
parent 491 b0da8cecb6b3
child 511 2edec83f1bd8
equal deleted inserted replaced
503:4be5eba42451 504:32a878a71a80
     8 from ldt.ldt_utils.models import Content, Project
     8 from ldt.ldt_utils.models import Content, Project
     9 from ldt.ldt_utils.views.workspace import search_index as ws_search_index, search_listing as ws_search_listing
     9 from ldt.ldt_utils.views.workspace import search_index as ws_search_index, search_listing as ws_search_listing
    10 from tagging.models import Tag, TaggedItem
    10 from tagging.models import Tag, TaggedItem
    11 
    11 
    12 
    12 
    13 @login_required
       
    14 def front_home(request):
    13 def front_home(request):
    15     # Get the 3 last annotated contents
    14     # Get the 3 last annotated contents
    16     last_contents = Content.objects.order_by('-last_annotated')[:3]
    15     last_contents = Content.objects.order_by('-last_annotated')[:3]
    17     # Get the most annotated contents
    16     # Get the most annotated contents
    18     most_contents = Content.objects.order_by('-nb_annotation')[:8]
    17     most_contents = Content.objects.order_by('-nb_annotation')[:8]
    28                               {'last_contents': last_contents, 'most_contents':most_contents, 'active_groups':active_groups, 'front_tags':front_tags,
    27                               {'last_contents': last_contents, 'most_contents':most_contents, 'active_groups':active_groups, 'front_tags':front_tags,
    29                                'is_gecko': is_gecko},
    28                                'is_gecko': is_gecko},
    30                               context_instance=RequestContext(request))
    29                               context_instance=RequestContext(request))
    31 
    30 
    32 
    31 
    33 @login_required
       
    34 def group_info(request, group_id):
    32 def group_info(request, group_id):
    35     # Get the active group
    33     # Get the active group
    36     group = Group.objects.get(id=group_id)
    34     group = Group.objects.get(id=group_id)
    37     # list of contents annotated by the group (or everyone)
    35     # list of contents annotated by the group (or everyone)
    38     everyone = Group.objects.get(name=settings.PUBLIC_GROUP_NAME)
    36     everyone = Group.objects.get(name=settings.PUBLIC_GROUP_NAME)
    46                               {'group': group, 'content_list':content_list, 'users':users,
    44                               {'group': group, 'content_list':content_list, 'users':users,
    47                                'is_gecko': is_gecko},
    45                                'is_gecko': is_gecko},
    48                               context_instance=RequestContext(request))
    46                               context_instance=RequestContext(request))
    49 
    47 
    50 
    48 
    51 @login_required
    49 
    52 def all_contents(request):
    50 def all_contents(request):
    53     # Get the tag parameter if possible
    51     # Get the tag parameter if possible
    54     tag_label = request.GET.get("tag")
    52     tag_label = request.GET.get("tag")
    55     # Get all the public contents group
    53     # Get all the public contents group
    56     if tag_label is None :
    54     if tag_label is None :
    57         content_list = Content.safe_objects.all()
    55         content_list = Content.objects.all()
    58     else :
    56     else :
    59         content_list = TaggedItem.objects.get_by_model(Content.safe_objects.all(), '"'+tag_label+'"')
    57         content_list = TaggedItem.objects.get_by_model(Content.objects.all(), '"'+tag_label+'"')
    60     # Get the main tag list
    58     # Get the main tag list
    61     front_tags = settings.FRONT_TAG_LIST
    59     front_tags = settings.FRONT_TAG_LIST
    62     # Get the all tags list
    60     # Get the all tags list
    63     tag_cloud = get_content_tags()
    61     tag_cloud = get_content_tags()
    64     
    62     
    68                               {'content_list':content_list, 'tag_label':tag_label, 'front_tags':front_tags, 'tag_cloud':tag_cloud,
    66                               {'content_list':content_list, 'tag_label':tag_label, 'front_tags':front_tags, 'tag_cloud':tag_cloud,
    69                                'is_gecko': is_gecko},
    67                                'is_gecko': is_gecko},
    70                               context_instance=RequestContext(request))
    68                               context_instance=RequestContext(request))
    71 
    69 
    72 
    70 
    73 @login_required
       
    74 def annot_content(request, content_iri_id, project_id=None, cutting_id=None):
    71 def annot_content(request, content_iri_id, project_id=None, cutting_id=None):
    75     # Get the wanted content
    72     # Get the wanted content
    76     content = Content.objects.get(iri_id=content_iri_id)
    73     content = Content.objects.get(iri_id=content_iri_id)
    77     # Get the content src to see if it is a youtube video
    74     # Get the content src to see if it is a youtube video
    78     youtube_url = None
    75     youtube_url = None
    92                 proj = content.front_project
    89                 proj = content.front_project
    93             else:
    90             else:
    94                 proj = proj[0]           
    91                 proj = proj[0]           
    95     else:
    92     else:
    96         proj = Project.safe_objects.get(ldt_id=project_id)
    93         proj = Project.safe_objects.get(ldt_id=project_id)
    97     
    94         
       
    95     if not proj.state == 2: # If the original front project is unpublished
       
    96         content.create_front_project()
       
    97         proj = content.front_project
       
    98         
       
    99         
    98     # Vars for player
   100     # Vars for player
    99     player_id = "player_project_" + proj.ldt_id
   101     player_id = "player_project_" + proj.ldt_id
   100     
   102     
   101     if cutting_id is None :
   103     if cutting_id is None :
   102         json_url = reverse("ldt.ldt_utils.views.json.project_json_id", args=[proj.ldt_id])
   104         json_url = reverse("ldt.ldt_utils.views.json.project_json_id", args=[proj.ldt_id])