front group page : filter and pagination.
--- a/src/ldt/ldt/ldt_utils/templates/front/front_group.html Wed Mar 13 12:09:26 2013 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_group.html Wed Mar 13 18:14:24 2013 +0100
@@ -13,15 +13,63 @@
{% block js_declaration %}
{{block.super}}
+<script type="text/javascript">
+ $(document).ready(function () {
+ $("#home_tag_cloud").toggle(false);
+ $("#hide_tag_cloud").toggle(false);
+ $("#show_tag_cloud").toggle(true);
+ $("#tag_cloud_link").click(function(){
+ $("#home_tag_cloud").slideToggle("fast");
+ $("#hide_tag_cloud").toggle();
+ $("#show_tag_cloud").toggle();
+ });
+ });
+</script>
{% endblock %}
{% block body %}
{{block.super}}
<ul class="floatlist" id="medias_groupe">
<li class="li_h2">
- <h2>{% trans 'Projects shared by the group' %} {{group.name}}</h2>
+ <h2><a href="?">{% trans 'Projects shared by the group' %} {{group.name}}</a>
+ <span class="tag_link"><a href="#" id="tag_cloud_link" title="{% trans 'Filter' %}"><img id="hide_tag_cloud" src='{% absstatic "ldt/img/little_minus_pink.png" %}' alt="{% trans 'Filter' %}" /><img id="show_tag_cloud" src='{% absstatic "ldt/img/little_plus_pink.png" %}' alt="{% trans 'Filter' %}" /> {% trans 'Filter' %}</a></span></h2>
+ </li>
+ <li class="li_h2" id="home_tag_cloud">
+ <form id="media_search" method="GET" action="">
+ {% trans 'Search in the projects title' %} :
+ <input id="input_title" type="text" name="title"/><input id="search_title" type="submit" value=""/>
+ </form>
</li>
- {% for p in project_list %}
+ <!-- Pagination -->
+ <li id="result_pagination" class="li_h2">
+ <p>
+ {% if results.has_previous %}
+ <a class="blue under" href="?page={{ results.previous_page_number }}{% if project_title %}&title={{project_title}}{% endif %}" title="{% trans 'previous' %}">{% trans "previous" %}</a>
+ {% endif %}
+ {% if results.paginator.num_pages > 1 %}
+ <span class="current">
+ {% for i in results.paginator.num_pages|get_range %}
+ <span class="current">
+ {% if i|add:'1' == results.number %}
+ <span class="pink">{{i|add:'1'}}</span>
+ {% else %}
+ <a class="blue under" href="?page={{i|add:'1'}}{% if project_title %}&title={{project_title}}{% endif %}">{{i|add:'1'}}</a>
+ {% endif %}
+ {% if i|add:'1' < results.paginator.num_pages and 1 < results.paginator.num_pages %}
+ {% endif %}
+ </span>
+ {% endfor %}
+ </span>
+ {% endif %}
+ {% if results.has_next %}
+ <a class="blue under" href="?page={{ results.next_page_number }}{% if project_title %}&title={{project_title}}{% endif %}" title="{% trans 'next' %}">{% trans "next" %}</a>
+ {% endif %}
+ {% if results.paginator.num_pages > 1 %}
+ . <a class="blue under" href="?page=x{% if project_title %}&title={{project_title}}{% endif %}"">({% trans 'All' %})</a>
+ {% endif %}
+ </p>
+ </li>
+ {% for p in results.object_list %}
<li class="li_media">
{% with c=p.contents.all|first %}
<a href="{% url ldt.ldt_utils.views.front.annot_content c.iri_id p.ldt_id %}">{% thumbnail p.image "134x75" format="PNG" crop="center" as im %}<img src="{{ im.url }}" class="img_media" width="{{ im.width }}" height="{{ im.height }}" alt="{% trans 'open this project' %}" title="{% trans 'open this project' %}">{% endthumbnail %}</a>
@@ -30,6 +78,9 @@
{% endwith %}
</li>
{% endfor %}
+ <li class="li_h2">
+ <h2><a href="{% url ldt.ldt_utils.views.front.group_list %}">→ {% trans 'Back to the group list' %}</a></h2>
+ </li>
</ul>
{% comment %}
--- a/src/ldt/ldt/ldt_utils/templates/front/front_home.html Wed Mar 13 12:09:26 2013 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_home.html Wed Mar 13 18:14:24 2013 +0100
@@ -49,7 +49,7 @@
<li class="li_h2" id="home_tag_cloud">
<form id="media_search" method="GET" action="{% url ldt.ldt_utils.views.front.all_contents %}">
{% trans 'Search in the medias title' %} :
- <input id="input_media_title" type="text" name="title"> <input id="search_media_title" type="submit" value=""/>
+ <input id="input_media_title" type="text" name="title"/><input id="search_media_title" type="submit" value=""/>
</form>
{% if tag_cloud|length > 0 %}<p class="left tag_link">{% trans 'All categories of medias' %} : {% for t in tag_cloud %}<a href="{% url ldt.ldt_utils.views.front.all_contents %}?tag={{t.name}}">
<span style="font-size:{{t.font_size|add:"12"}}px;">{{t.name}}</span></a>{% if not forloop.last %}, {% endif %}{% endfor %}</p>
--- a/src/ldt/ldt/ldt_utils/views/front.py Wed Mar 13 12:09:26 2013 +0100
+++ b/src/ldt/ldt/ldt_utils/views/front.py Wed Mar 13 18:14:24 2013 +0100
@@ -1,4 +1,5 @@
from django.conf import settings
+from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import Group, User
from django.core.paginator import Paginator, InvalidPage, EmptyPage
from django.core.urlresolvers import reverse
@@ -50,13 +51,27 @@
'is_gecko': is_gecko},
context_instance=RequestContext(request))
-
+@login_required
def group_info(request, group_id):
# Get the active group
group = Group.objects.select_related("profile").get(id=group_id)
# Get the projects for this group
- project_list = get_group_projects(request.user, group_id, False)
+ project_list = get_group_projects(request.user, group_id, False, False)
+ proj_title = request.GET.get("title")
+ if proj_title is not None:
+ project_list = project_list.filter(title__icontains=proj_title)
+
+ nb = settings.LDT_FRONT_PROJECTS_PER_PAGE
+ page = request.GET.get("page") or 1
+ if page=="x":
+ nb = project_list.count()
+
+ paginator = Paginator(project_list, nb)
+ try:
+ results = paginator.page(page)
+ except (EmptyPage, InvalidPage):
+ results = paginator.page(paginator.num_pages)
## list of contents annotated by the group (or everyone)
#everyone = Group.objects.get(name=settings.PUBLIC_GROUP_NAME)
@@ -68,7 +83,7 @@
is_gecko = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1);
return render_to_response("front/front_group.html",
- {'group': group, 'content_list':None, 'project_list':project_list, 'users':users,
+ {'group': group, 'content_list':None, 'results':results, 'users':users, 'project_title':proj_title,
'is_gecko': is_gecko},
context_instance=RequestContext(request))
--- a/src/ldt/ldt/settings.py Wed Mar 13 12:09:26 2013 +0100
+++ b/src/ldt/ldt/settings.py Wed Mar 13 18:14:24 2013 +0100
@@ -86,6 +86,7 @@
LDT_MAX_CONTENTS_PER_PAGE = getattr(settings, 'LDT_MAX_CONTENTS_PER_PAGE', 10)
LDT_MAX_PROJECTS_PER_PAGE = getattr(settings, 'LDT_MAX_PROJECTS_PER_PAGE', 10)
LDT_FRONT_MEDIA_PER_PAGE = getattr(settings, 'LDT_FRONT_MEDIA_PER_PAGE', 9)
+LDT_FRONT_PROJECTS_PER_PAGE = getattr(settings, 'LDT_FRONT_PROJECTS_PER_PAGE', 12)
AUTO_INDEX_AFTER_SAVE = getattr(settings, 'AUTO_INDEX_AFTER_SAVE', True)
LDT_INDEXATION_INSERT_BATCH_SIZE = getattr(settings, 'LDT_INDEXATION_INSERT_BATCH_SIZE', 5000)
--- a/src/ldt/ldt/static/ldt/css/front_group.css Wed Mar 13 12:09:26 2013 +0100
+++ b/src/ldt/ldt/static/ldt/css/front_group.css Wed Mar 13 18:14:24 2013 +0100
@@ -37,4 +37,22 @@
.li_membre_groupe p {
margin-left: 45px;
+}
+/* media title search input*/
+#search_title{
+ background : url(../img/search.gif) no-repeat;
+ border: none;
+ height: 16px;
+ width: 16px;
+ cursor: pointer;
+}
+#input_title{
+ border: 1px solid #AAAAAA;
+ background: transparent;
+ margin: 0px 7px 10px 0px;
+}
+
+#result_pagination {
+ border: 0 none;
+ margin: 5px 0;
}
\ No newline at end of file