7 from django.template import RequestContext |
7 from django.template import RequestContext |
8 from guardian.shortcuts import get_objects_for_group |
8 from guardian.shortcuts import get_objects_for_group |
9 from ldt.ldt_utils.models import Content, Project |
9 from ldt.ldt_utils.models import Content, Project |
10 from ldt.ldt_utils.views.workspace import search_index as ws_search_index, search_listing as ws_search_listing |
10 from ldt.ldt_utils.views.workspace import search_index as ws_search_index, search_listing as ws_search_listing |
11 from ldt.security.utils import add_change_attr |
11 from ldt.security.utils import add_change_attr |
|
12 from tagging.models import Tag, TaggedItem |
12 |
13 |
13 |
14 |
14 @login_required |
15 @login_required |
15 def front_home(request): |
16 def front_home(request): |
16 # Get the 3 last annotated contents |
17 # Get the 3 last annotated contents |
17 last_contents = Content.objects.order_by('-last_annotated')[:3] |
18 last_contents = Content.objects.order_by('-last_annotated')[:3] |
18 # Get the most annotated contents |
19 # Get the most annotated contents |
19 most_contents = Content.objects.order_by('-nb_annotation')[:8] |
20 most_contents = Content.objects.order_by('-nb_annotation')[:8] |
20 # Get the active groups |
21 # Get the active groups |
21 active_groups = Group.objects.exclude(name=settings.PUBLIC_GROUP_NAME)[:5] |
22 active_groups = Group.objects.exclude(name=settings.PUBLIC_GROUP_NAME)[:5] |
22 |
23 # Get the main tag list |
|
24 tag_cloud = get_content_tags(5) |
23 |
25 |
24 is_gecko = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1); |
26 is_gecko = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1); |
25 |
27 |
26 return render_to_response("front/front_home.html", |
28 return render_to_response("front/front_home.html", |
27 {'last_contents': last_contents, 'most_contents':most_contents, 'active_groups':active_groups, |
29 {'last_contents': last_contents, 'most_contents':most_contents, 'active_groups':active_groups, 'tag_cloud':tag_cloud, |
28 'is_gecko': is_gecko}, |
30 'is_gecko': is_gecko}, |
29 context_instance=RequestContext(request)) |
31 context_instance=RequestContext(request)) |
30 |
32 |
31 |
33 |
32 @login_required |
34 @login_required |
47 context_instance=RequestContext(request)) |
49 context_instance=RequestContext(request)) |
48 |
50 |
49 |
51 |
50 @login_required |
52 @login_required |
51 def all_contents(request): |
53 def all_contents(request): |
|
54 # Get the tag parameter if possible |
|
55 tag_label = request.GET.get("tag") |
52 # Get all the public contents group |
56 # Get all the public contents group |
53 content_list = add_change_attr(request.user, Content.safe_objects.all()) |
57 if tag_label is None : |
|
58 content_list = add_change_attr(request.user, Content.safe_objects.all()) |
|
59 else : |
|
60 content_list = TaggedItem.objects.get_by_model(add_change_attr(request.user, Content.safe_objects.all()), '"'+tag_label+'"') |
|
61 # Get the main tag list |
|
62 tag_cloud = get_content_tags() |
54 |
63 |
55 is_gecko = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1); |
64 is_gecko = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1); |
56 |
65 |
57 return render_to_response("front/front_all_contents.html", |
66 return render_to_response("front/front_all_contents.html", |
58 {'content_list':content_list, |
67 {'content_list':content_list, 'tag_label':tag_label, 'tag_cloud':tag_cloud, |
59 'is_gecko': is_gecko}, |
68 'is_gecko': is_gecko}, |
60 context_instance=RequestContext(request)) |
69 context_instance=RequestContext(request)) |
61 |
70 |
62 |
71 |
63 @login_required |
72 @login_required |
77 else: |
86 else: |
78 # The main project for the content |
87 # The main project for the content |
79 proj = Project.safe_objects.filter(contents__in=[content])[0] |
88 proj = Project.safe_objects.filter(contents__in=[content])[0] |
80 else : |
89 else : |
81 proj = Project.safe_objects.get(ldt_id=project_id) |
90 proj = Project.safe_objects.get(ldt_id=project_id) |
82 |
91 |
83 # Vars for player |
92 # Vars for player |
84 player_id = "player_project_" + proj.ldt_id |
93 player_id = "player_project_" + proj.ldt_id |
85 |
94 |
86 if cutting_id is None : |
95 if cutting_id is None : |
87 json_url = reverse("ldt.ldt_utils.views.json.project_json_id", args=[proj.ldt_id]) |
96 json_url = reverse("ldt.ldt_utils.views.json.project_json_id", args=[proj.ldt_id]) |