| author | durandn |
| Thu, 09 Apr 2015 12:58:31 +0200 | |
| changeset 1363 | a8f354a9b8e4 |
| parent 1360 | f69b5d8ba4b9 |
| permissions | -rw-r--r-- |
|
338
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
1 |
from django.conf import settings |
| 1191 | 2 |
from django.contrib.auth import get_user_model |
|
1156
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
3 |
from django.contrib.auth.decorators import login_required |
| 1191 | 4 |
from django.contrib.auth.models import Group |
| 740 | 5 |
from django.core.paginator import Paginator, InvalidPage, EmptyPage |
|
339
c6a6ea1ce091
First step of player page in front. Old version of metadata player integrated.
cavaliet
parents:
338
diff
changeset
|
6 |
from django.core.urlresolvers import reverse |
| 1115 | 7 |
from django.db.models import Count |
| 1255 | 8 |
from django.shortcuts import render_to_response, get_object_or_404 |
|
338
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
9 |
from django.template import RequestContext |
|
1187
73403060f297
remove absstatic and goes back to static
ymh <ymh.work@gmail.com>
parents:
1180
diff
changeset
|
10 |
from ldt.ldt_utils.forms import SearchForm |
| 480 | 11 |
from ldt.ldt_utils.models import Content, Project |
| 1191 | 12 |
from ldt.ldt_utils.views.group import get_group_projects |
| 563 | 13 |
from ldt.ldt_utils.views.workspace import get_search_results |
|
1187
73403060f297
remove absstatic and goes back to static
ymh <ymh.work@gmail.com>
parents:
1180
diff
changeset
|
14 |
from ldt.utils.url import static |
|
73403060f297
remove absstatic and goes back to static
ymh <ymh.work@gmail.com>
parents:
1180
diff
changeset
|
15 |
import logging |
| 1255 | 16 |
from guardian.shortcuts import get_objects_for_group |
| 1278 | 17 |
from ldt.indexation import get_results_with_context |
| 563 | 18 |
|
| 1191 | 19 |
User = get_user_model() |
| 1115 | 20 |
logger = logging.getLogger(__name__) |
|
338
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
21 |
|
|
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
22 |
|
|
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
23 |
def front_home(request): |
|
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
24 |
# Get the 3 last annotated contents |
| 1115 | 25 |
last_contents = Content.safe_objects.order_by('-stat_annotation__last_annotated').select_related('stat_annotation').exclude(stat_annotation__nb_annotations=0)[:3] |
|
338
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
26 |
# Get the most annotated contents |
| 1115 | 27 |
most_contents = Content.safe_objects.order_by('-stat_annotation__nb_annotations').select_related('stat_annotation')[:8] |
|
338
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
28 |
# Get the active groups |
|
1360
f69b5d8ba4b9
started upgrading to Django 1.6: fixed transactions, settings, switched django_social_auth to python_social_auth
ndurand
parents:
1296
diff
changeset
|
29 |
active_groups = Group.objects.select_related("profile").annotate(nb_users=Count("user")).exclude(name=settings.PUBLIC_GROUP_NAME)[:5] |
| 409 | 30 |
# Get the main tag list |
|
444
2711eef17092
Update front tag list management with settings/config.
cavaliet
parents:
443
diff
changeset
|
31 |
front_tags = settings.FRONT_TAG_LIST |
|
338
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
32 |
|
| 1255 | 33 |
is_gecko = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1) |
| 1115 | 34 |
|
|
338
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
35 |
return render_to_response("front/front_home.html", |
| 1296 | 36 |
{'last_contents': last_contents, 'most_contents':most_contents, 'active_groups':active_groups, 'front_tags':front_tags, 'is_gecko': is_gecko}, |
|
338
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
37 |
context_instance=RequestContext(request)) |
|
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
38 |
|
|
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
39 |
|
|
1156
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
40 |
def group_list(request): |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
41 |
|
|
338
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
42 |
# Get the active group |
| 1255 | 43 |
group_list = Group.objects.select_related("profile").exclude(name=settings.PUBLIC_GROUP_NAME).order_by('name') |
|
1156
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
44 |
|
| 1255 | 45 |
is_gecko = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1) |
|
1156
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
46 |
|
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
47 |
return render_to_response("front/front_groups.html", |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
48 |
{'group_list':group_list, |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
49 |
'is_gecko': is_gecko}, |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
50 |
context_instance=RequestContext(request)) |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
51 |
|
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
52 |
@login_required |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
53 |
def group_info(request, group_id): |
| 1127 | 54 |
|
55 |
# Get the active group |
|
|
1156
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
56 |
group = Group.objects.select_related("profile").get(id=group_id) |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
57 |
proj_title = request.GET.get("title") |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
58 |
# Get the projects for this group |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
59 |
project_list = get_group_projects(request.user, group_id, False, False) |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
60 |
if not type(project_list) is list: |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
61 |
project_list = project_list.prefetch_related('contents').select_related("owner").filter(state=2) |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
62 |
if proj_title is not None: |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
63 |
project_list = project_list.filter(title__icontains=proj_title) |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
64 |
|
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
65 |
nb = settings.LDT_FRONT_PROJECTS_PER_PAGE |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
66 |
page = request.GET.get("page") or 1 |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
67 |
if page=="x": |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
68 |
nb = project_list.count() |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
69 |
|
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
70 |
paginator = Paginator(project_list, nb) |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
71 |
try: |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
72 |
results = paginator.page(page) |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
73 |
except (EmptyPage, InvalidPage): |
|
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
74 |
results = paginator.page(paginator.num_pages) |
| 1127 | 75 |
|
|
338
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
76 |
# Group's users |
| 404 | 77 |
users = User.objects.filter(groups__in=[group]).exclude(is_superuser=True) |
|
338
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
78 |
|
| 1255 | 79 |
is_gecko = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1) |
|
338
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
80 |
|
|
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
81 |
return render_to_response("front/front_group.html", |
|
1156
662721dc606b
add new group page to maintenance head (and enhance it)
cavaliet
parents:
1021
diff
changeset
|
82 |
{'group': group, 'content_list':None, 'results':results, 'users':users, 'project_title':proj_title, |
| 1255 | 83 |
'projects': True, 'is_gecko': is_gecko}, |
|
338
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
84 |
context_instance=RequestContext(request)) |
|
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
85 |
|
| 1255 | 86 |
@login_required |
87 |
def group_medias(request, group_id): |
|
88 |
group = get_object_or_404(Group, id=group_id) |
|
89 |
||
90 |
content_list = get_objects_for_group(group, 'ldt_utils.view_content') |
|
91 |
||
92 |
# Group's users |
|
93 |
users = User.objects.filter(groups__in=[group]).exclude(is_superuser=True) |
|
94 |
||
95 |
is_gecko = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1) |
|
96 |
||
97 |
return render_to_response("front/front_group.html", |
|
98 |
{'group': group, 'content_list':content_list, 'results':None, 'users':users, |
|
99 |
'projects': False, 'is_gecko': is_gecko}, |
|
100 |
context_instance=RequestContext(request)) |
|
|
338
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
101 |
|
| 504 | 102 |
|
|
1257
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
103 |
|
| 364 | 104 |
def all_contents(request): |
| 740 | 105 |
# Get the page number parameter if possible |
106 |
page = request.GET.get("page") or 1 |
|
|
762
292b15799db2
quick search in media title in the front. Languages updated.
cavaliet
parents:
741
diff
changeset
|
107 |
# Get the medias title filter if possible |
|
292b15799db2
quick search in media title in the front. Languages updated.
cavaliet
parents:
741
diff
changeset
|
108 |
media_title = request.GET.get("title") |
|
292b15799db2
quick search in media title in the front. Languages updated.
cavaliet
parents:
741
diff
changeset
|
109 |
tag_label = None |
|
292b15799db2
quick search in media title in the front. Languages updated.
cavaliet
parents:
741
diff
changeset
|
110 |
if media_title is None : |
|
292b15799db2
quick search in media title in the front. Languages updated.
cavaliet
parents:
741
diff
changeset
|
111 |
# Get the tag parameter if possible |
|
292b15799db2
quick search in media title in the front. Languages updated.
cavaliet
parents:
741
diff
changeset
|
112 |
tag_label = request.GET.get("tag") |
|
292b15799db2
quick search in media title in the front. Languages updated.
cavaliet
parents:
741
diff
changeset
|
113 |
# Get all the public contents group |
|
292b15799db2
quick search in media title in the front. Languages updated.
cavaliet
parents:
741
diff
changeset
|
114 |
if tag_label is None : |
| 1115 | 115 |
content_list = Content.safe_objects.all().select_related('stat_annotation') |
|
762
292b15799db2
quick search in media title in the front. Languages updated.
cavaliet
parents:
741
diff
changeset
|
116 |
else : |
| 1296 | 117 |
#content_list = TaggedItem.objects.get_by_model(Content.safe_objects.all().select_related('stat_annotation'), '"'+tag_label+'"') |
118 |
content_list = Content.safe_objects.select_related('stat_annotation').filter(tags__name__in=[tag_label]) |
|
| 409 | 119 |
else : |
| 1278 | 120 |
#content_list = Content.safe_objects.filter(title__icontains=media_title).select_related('stat_annotation') |
121 |
content_searched = get_results_with_context(Content, "all", media_title) |
|
122 |
content_list = Content.objects.filter(pk__in=[c['indexation_id'] for c in content_searched]).select_related('stat_annotation') |
|
| 740 | 123 |
|
124 |
nb = settings.LDT_FRONT_MEDIA_PER_PAGE |
|
125 |
if page=="x": |
|
126 |
nb = content_list.count() |
|
127 |
||
128 |
paginator = Paginator(content_list, nb) |
|
129 |
try: |
|
130 |
results = paginator.page(page) |
|
131 |
except (EmptyPage, InvalidPage): |
|
132 |
results = paginator.page(paginator.num_pages) |
|
133 |
||
| 409 | 134 |
# Get the main tag list |
|
444
2711eef17092
Update front tag list management with settings/config.
cavaliet
parents:
443
diff
changeset
|
135 |
front_tags = settings.FRONT_TAG_LIST |
| 364 | 136 |
|
| 1255 | 137 |
is_gecko = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1) |
| 364 | 138 |
|
139 |
return render_to_response("front/front_all_contents.html", |
|
| 1296 | 140 |
{'results':results, 'tag_label':tag_label, 'media_title':media_title, 'front_tags':front_tags, 'is_gecko': is_gecko}, |
| 364 | 141 |
context_instance=RequestContext(request)) |
142 |
||
143 |
||
| 399 | 144 |
def annot_content(request, content_iri_id, project_id=None, cutting_id=None): |
|
339
c6a6ea1ce091
First step of player page in front. Old version of metadata player integrated.
cavaliet
parents:
338
diff
changeset
|
145 |
# Get the wanted content |
|
c6a6ea1ce091
First step of player page in front. Old version of metadata player integrated.
cavaliet
parents:
338
diff
changeset
|
146 |
content = Content.objects.get(iri_id=content_iri_id) |
| 543 | 147 |
# Get the content src to see if it is a youtube/dailymotion video |
|
833
20acf3b3b2f0
Embed code corrections : jsonp problem solved, complete adresses in embed_player, display metadataplayer on click when needed, select code on button click, iframe code available in the embed popup
grandjoncl
parents:
795
diff
changeset
|
148 |
annotation_block = True |
| 543 | 149 |
external_url = None |
| 552 | 150 |
if content.src is not None: |
151 |
for external_src in settings.EXTERNAL_STREAM_SRC: |
|
152 |
if external_src in content.src: |
|
153 |
external_url = content.src |
|
154 |
break |
|
| 404 | 155 |
|
| 399 | 156 |
# If project id is not set, we get the default project for the content |
| 404 | 157 |
if project_id is None or project_id == "_": |
|
741
45d814511958
Content PUT api endpoint to add an annotation to a content without giving a project id. #35
cavaliet
parents:
740
diff
changeset
|
158 |
proj = content.get_or_create_front_project() |
| 480 | 159 |
else: |
| 404 | 160 |
proj = Project.safe_objects.get(ldt_id=project_id) |
|
517
2ae1a476a69d
Medias with no annotations are not displayed on front home page
verrierj
parents:
511
diff
changeset
|
161 |
|
|
339
c6a6ea1ce091
First step of player page in front. Old version of metadata player integrated.
cavaliet
parents:
338
diff
changeset
|
162 |
# Vars for player |
|
c6a6ea1ce091
First step of player page in front. Old version of metadata player integrated.
cavaliet
parents:
338
diff
changeset
|
163 |
player_id = "player_project_" + proj.ldt_id |
|
338
631c0edee9ea
First commit for front pages. View, templates, and css img added.
cavaliet
parents:
diff
changeset
|
164 |
|
| 400 | 165 |
if cutting_id is None : |
|
1363
a8f354a9b8e4
Changed json.py to ldt_json.py due to import problem with python json module that now replace django simplejon + started replacing "mimetype" in httpresponses (deprecated) with "content-type" + added fields to forms that didn't declare fields as it's now required by django
durandn
parents:
1360
diff
changeset
|
166 |
json_url = reverse("ldt.ldt_utils.views.ldt_json.project_json_id", kwargs={'id' : proj.ldt_id}) |
|
517
2ae1a476a69d
Medias with no annotations are not displayed on front home page
verrierj
parents:
511
diff
changeset
|
167 |
else: |
|
1363
a8f354a9b8e4
Changed json.py to ldt_json.py due to import problem with python json module that now replace django simplejon + started replacing "mimetype" in httpresponses (deprecated) with "content-type" + added fields to forms that didn't declare fields as it's now required by django
durandn
parents:
1360
diff
changeset
|
168 |
json_url = reverse("ldt.ldt_utils.views.ldt_json.project_json_cutting_id", kwargs={'id':proj.ldt_id, 'cutting_id':cutting_id}) |
|
339
c6a6ea1ce091
First step of player page in front. Old version of metadata player integrated.
cavaliet
parents:
338
diff
changeset
|
169 |
player_width = 550 |
|
c6a6ea1ce091
First step of player page in front. Old version of metadata player integrated.
cavaliet
parents:
338
diff
changeset
|
170 |
player_height = 380 |
|
c6a6ea1ce091
First step of player page in front. Old version of metadata player integrated.
cavaliet
parents:
338
diff
changeset
|
171 |
stream_mode = proj.stream_mode |
|
c6a6ea1ce091
First step of player page in front. Old version of metadata player integrated.
cavaliet
parents:
338
diff
changeset
|
172 |
if stream_mode != "video": |
|
c6a6ea1ce091
First step of player page in front. Old version of metadata player integrated.
cavaliet
parents:
338
diff
changeset
|
173 |
stream_mode = 'radio' |
|
c6a6ea1ce091
First step of player page in front. Old version of metadata player integrated.
cavaliet
parents:
338
diff
changeset
|
174 |
|
| 1255 | 175 |
is_gecko = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1) |
|
339
c6a6ea1ce091
First step of player page in front. Old version of metadata player integrated.
cavaliet
parents:
338
diff
changeset
|
176 |
|
|
c6a6ea1ce091
First step of player page in front. Old version of metadata player integrated.
cavaliet
parents:
338
diff
changeset
|
177 |
|
|
c6a6ea1ce091
First step of player page in front. Old version of metadata player integrated.
cavaliet
parents:
338
diff
changeset
|
178 |
return render_to_response("front/front_player.html", |
|
c6a6ea1ce091
First step of player page in front. Old version of metadata player integrated.
cavaliet
parents:
338
diff
changeset
|
179 |
{'content': content, 'project':proj, 'player_id': player_id, |
| 543 | 180 |
'json_url': json_url, 'player_width':player_width, 'player_height':player_height, 'stream_mode':stream_mode, 'external_url':external_url, |
|
833
20acf3b3b2f0
Embed code corrections : jsonp problem solved, complete adresses in embed_player, display metadataplayer on click when needed, select code on button click, iframe code available in the embed popup
grandjoncl
parents:
795
diff
changeset
|
181 |
'is_gecko': is_gecko, 'annotation_block':annotation_block}, |
|
339
c6a6ea1ce091
First step of player page in front. Old version of metadata player integrated.
cavaliet
parents:
338
diff
changeset
|
182 |
context_instance=RequestContext(request)) |
|
c6a6ea1ce091
First step of player page in front. Old version of metadata player integrated.
cavaliet
parents:
338
diff
changeset
|
183 |
|
|
c6a6ea1ce091
First step of player page in front. Old version of metadata player integrated.
cavaliet
parents:
338
diff
changeset
|
184 |
|
|
1257
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
185 |
|
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
186 |
|
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
187 |
def all_projects_for_media(request, content_iri_id): |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
188 |
# Get the wanted content |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
189 |
content = Content.objects.get(iri_id=content_iri_id) |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
190 |
# Get the content src to see if it is a youtube/dailymotion video |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
191 |
annotation_block = False |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
192 |
external_url = None |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
193 |
if content.src is not None: |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
194 |
for external_src in settings.EXTERNAL_STREAM_SRC: |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
195 |
if external_src in content.src: |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
196 |
external_url = content.src |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
197 |
break |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
198 |
|
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
199 |
# Vars for player |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
200 |
player_id = "player_project_anything" |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
201 |
|
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
202 |
json_url = reverse("api_content_all_projects", kwargs={'api_name': '1.0', 'resource_name': 'contents', 'iri_id': content_iri_id}) |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
203 |
|
|
1258
79cca551f9d0
v1.51.13 and toggle annotations and group filter for merge project.
cavaliet
parents:
1257
diff
changeset
|
204 |
# add filter |
|
79cca551f9d0
v1.51.13 and toggle annotations and group filter for merge project.
cavaliet
parents:
1257
diff
changeset
|
205 |
group_id = request.GET.get("group") |
|
79cca551f9d0
v1.51.13 and toggle annotations and group filter for merge project.
cavaliet
parents:
1257
diff
changeset
|
206 |
if group_id is not None : |
|
79cca551f9d0
v1.51.13 and toggle annotations and group filter for merge project.
cavaliet
parents:
1257
diff
changeset
|
207 |
json_url += "?group=" + group_id |
|
1286
2bbc6c42ca9a
v1.52.4 : correct enhancements on mdp for group page.
cavaliet
parents:
1278
diff
changeset
|
208 |
# add parameter to remove segment with duration = 0 |
|
2bbc6c42ca9a
v1.52.4 : correct enhancements on mdp for group page.
cavaliet
parents:
1278
diff
changeset
|
209 |
remove_zero_duration = False |
|
2bbc6c42ca9a
v1.52.4 : correct enhancements on mdp for group page.
cavaliet
parents:
1278
diff
changeset
|
210 |
remove_zero_param = request.GET.get("remove_zero_duration") |
|
2bbc6c42ca9a
v1.52.4 : correct enhancements on mdp for group page.
cavaliet
parents:
1278
diff
changeset
|
211 |
if remove_zero_param is not None : |
|
2bbc6c42ca9a
v1.52.4 : correct enhancements on mdp for group page.
cavaliet
parents:
1278
diff
changeset
|
212 |
remove_zero_duration = {'true': True, 'false': False, "0": False, "1": True}.get(remove_zero_param.lower()) |
|
1258
79cca551f9d0
v1.51.13 and toggle annotations and group filter for merge project.
cavaliet
parents:
1257
diff
changeset
|
213 |
|
|
1257
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
214 |
player_width = 854 |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
215 |
player_height = 480 |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
216 |
stream_mode = "video" |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
217 |
|
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
218 |
is_gecko = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1) |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
219 |
|
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
220 |
|
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
221 |
return render_to_response("front/front_player.html", |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
222 |
{'content': content, 'player_id': player_id, |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
223 |
'json_url': json_url, 'player_width':player_width, 'player_height':player_height, 'stream_mode':stream_mode, 'external_url':external_url, |
|
1286
2bbc6c42ca9a
v1.52.4 : correct enhancements on mdp for group page.
cavaliet
parents:
1278
diff
changeset
|
224 |
'is_gecko': is_gecko, 'annotation_block':annotation_block, 'toggle_multisegments':True, 'remove_zero_duration':remove_zero_duration}, |
|
1257
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
225 |
context_instance=RequestContext(request)) |
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
226 |
|
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
227 |
|
|
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
228 |
|
| 348 | 229 |
def search_index(request): |
| 563 | 230 |
language_code = request.LANGUAGE_CODE[:2] |
| 570 | 231 |
nb = 0 |
232 |
results = [] |
|
233 |
search = '' |
|
234 |
field = 'all' |
|
| 602 | 235 |
content_tag = None |
|
1187
73403060f297
remove absstatic and goes back to static
ymh <ymh.work@gmail.com>
parents:
1180
diff
changeset
|
236 |
colorurl=static("ldt/swf/ldt/pkg/color.xml") |
|
73403060f297
remove absstatic and goes back to static
ymh <ymh.work@gmail.com>
parents:
1180
diff
changeset
|
237 |
i18nurl=static("ldt/swf/ldt/pkg/i18n") |
|
73403060f297
remove absstatic and goes back to static
ymh <ymh.work@gmail.com>
parents:
1180
diff
changeset
|
238 |
baseurl=static("ldt/swf/ldt/") |
| 570 | 239 |
sform = SearchForm(request.GET) |
| 1278 | 240 |
content_results = None |
241 |
more_contents = False |
|
242 |
||
243 |
# Now we handle the segment search |
|
| 563 | 244 |
if sform.is_valid(): |
245 |
search = sform.cleaned_data["search"] |
|
| 570 | 246 |
field = sform.cleaned_data["field"] |
| 1278 | 247 |
# If the request has a page indicated, we are in segment search |
248 |
if "page" not in request.GET: |
|
249 |
# If not, we are in the first page of results, so we display the first contents |
|
250 |
content_searched = get_results_with_context(Content, field, search) |
|
251 |
if len(content_searched) > settings.LDT_MEDIA_IN_RESULTS_PAGE : |
|
252 |
more_contents = True |
|
253 |
content_searched = content_searched[:settings.LDT_MEDIA_IN_RESULTS_PAGE] |
|
254 |
content_results = Content.objects.filter(pk__in=[c['indexation_id'] for c in content_searched]).select_related('stat_annotation') |
|
255 |
||
| 570 | 256 |
page = sform.cleaned_data["page"] or 1 |
| 599 | 257 |
# If asked, we filter the request with only the contents tagged with content_tag |
258 |
content_tag = sform.cleaned_data["content_tag"] |
|
259 |
content_list = None |
|
260 |
if content_tag is not None and content_tag != "" : |
|
| 1296 | 261 |
#content_list = TaggedItem.objects.get_by_model(Content.objects.all(), '"'+content_tag+'"') |
262 |
content_list = Content.safe_objects.filter(tags__name__in=[content_tag]) |
|
| 1021 | 263 |
results, nb, nb_segment = get_search_results(request, search, field, page, content_list) |
| 1296 | 264 |
|
265 |
# If there was no answer, we check if a search with content's title works |
|
266 |
if nb==0: |
|
267 |
nb = Content.safe_objects.filter(title__icontains=search).count() |
|
268 |
nb_segment = 0 |
|
269 |
content_results = Content.safe_objects.filter(title__icontains=search).select_related('stat_annotation')[:settings.LDT_MEDIA_IN_RESULTS_PAGE] |
|
270 |
else: |
|
271 |
results, nb, nb_segment = None, 0, 0 |
|
272 |
||
| 348 | 273 |
|
| 1278 | 274 |
return render_to_response('front/front_search_results.html', { |
275 |
'results': results, 'nb_results' : nb, 'nb_segment':nb_segment, 'search' : search, |
|
276 |
'field': field, 'tag_label':content_tag, 'colorurl': colorurl, 'i18nurl': i18nurl, |
|
277 |
'language': language_code, 'baseurl': baseurl, |
|
278 |
'content_results': content_results, 'more_contents': more_contents, |
|
279 |
}, context_instance=RequestContext(request)) |
|
| 409 | 280 |
|
281 |
||
|
1257
d2cc6ecc3aa0
merge all content's projects in one (for decoupage).
cavaliet
parents:
1255
diff
changeset
|
282 |