# HG changeset patch # User verrierj # Date 1316080982 -7200 # Node ID 32fbed79d3a151d3d2db527070da6e2cf13834fe # Parent a88714473302c667714cf4a57885201b685d98a4 Display search results on multiple pages diff -r a88714473302 -r 32fbed79d3a1 src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/search_results.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/search_results.html Wed Sep 14 16:48:51 2011 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/search_results.html Thu Sep 15 12:03:02 2011 +0200 @@ -6,6 +6,7 @@ {% endblock %} + {% block content %} {% if msg %} @@ -16,15 +17,34 @@ {% autoescape off %} {% endautoescape %} + + + {% endif %} {% endblock %} \ No newline at end of file diff -r a88714473302 -r 32fbed79d3a1 src/ldt/ldt/ldt_utils/urls.py --- a/src/ldt/ldt/ldt_utils/urls.py Wed Sep 14 16:48:51 2011 +0200 +++ b/src/ldt/ldt/ldt_utils/urls.py Thu Sep 15 12:03:02 2011 +0200 @@ -13,6 +13,7 @@ url(r'^groups/$', 'views.groups'), url(r'^get_group_projects/$', 'views.get_group_projects'), url(r'^search/$', 'views.search_index'), + url(r'^searchListing', 'views.search_listing'), url(r'^search/(?P.*)/(?P.*)$', 'views.search_index_get'), url(r'^searchLdt/(?P.*)/(?P.*)$', 'views.search_ldt'), url(r'^searchSeg/(?P.*)/(?P.*)$', 'views.search_segments'), diff -r a88714473302 -r 32fbed79d3a1 src/ldt/ldt/ldt_utils/views.py --- a/src/ldt/ldt/ldt_utils/views.py Wed Sep 14 16:48:51 2011 +0200 +++ b/src/ldt/ldt/ldt_utils/views.py Thu Sep 15 12:03:02 2011 +0200 @@ -2,6 +2,7 @@ from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User, Group from django.core.urlresolvers import reverse +from django.core.paginator import Paginator, InvalidPage, EmptyPage from django.db.models import Q from django.forms.models import model_to_dict from django.forms.util import ErrorList @@ -232,7 +233,7 @@ return render_to_response('ldt/ldt_utils/search_form.html', {'form': form} , context_instance=RequestContext(request)) def search_index(request): - + sform = SearchForm(request.POST) if sform.is_valid(): search = sform.cleaned_data["search"] @@ -244,12 +245,24 @@ url = settings.WEB_URL + django.core.urlresolvers.reverse("ldt.ldt_utils.views.search_init", args=[field, queryStr]) return render_to_response('ldt/ldt_utils/init_ldt_full.html', {'LDT_MEDIA_PREFIX': settings.LDT_MEDIA_PREFIX, 'colorurl': settings.LDT_MEDIA_PREFIX + 'swf/ldt/pkg/color.xml', 'i18nurl': settings.LDT_MEDIA_PREFIX + 'swf/ldt/pkg/i18n', 'language': language_code, 'baseurl': settings.LDT_MEDIA_PREFIX + 'swf/ldt/', 'url': url}, context_instance=RequestContext(request)) else: - results = get_results_with_context(field, search) - return render_to_response('ldt/ldt_utils/search_results.html', {'results': results, 'search' : search, 'LDT_MEDIA_PREFIX': settings.LDT_MEDIA_PREFIX, 'colorurl': settings.LDT_MEDIA_PREFIX + 'swf/ldt/pkg/color.xml', 'i18nurl': settings.LDT_MEDIA_PREFIX + 'swf/ldt/pkg/i18n', 'language': language_code, 'baseurl': settings.LDT_MEDIA_PREFIX + 'swf/ldt/'}, context_instance=RequestContext(request)) + complete_results = get_results_with_context(field, search) + request.session.__setitem__('complete_results', complete_results) + request.session.__setitem__('search', search) + paginator = Paginator (complete_results, settings.LDT_RESULTS_PER_PAGE) + page = 1 + + try: + results = paginator.page(page) + except (EmptyPage, InvalidPage): + results = paginator.page(paginator.num_pages) + + return render_to_response('ldt/ldt_utils/search_results.html', {'results': results, 'search' : search, 'LDT_MEDIA_PREFIX': settings.LDT_MEDIA_PREFIX, 'colorurl': settings.LDT_MEDIA_PREFIX + 'swf/ldt/pkg/color.xml', 'i18nurl': settings.LDT_MEDIA_PREFIX + 'swf/ldt/pkg/i18n', 'language': language_code, 'baseurl': settings.LDT_MEDIA_PREFIX + 'swf/ldt/'}, context_instance=RequestContext(request)) + else: msg = _("Please enter valid keywords.") return render_to_response('ldt/ldt_utils/search_results.html', {'msg' : msg}, context_instance=RequestContext(request)) + def display_highlighted_seg(request, project_id, content_id, ensemble_id, cutting_id, segment_id): url = settings.WEB_URL + reverse("ldt.ldt_utils.views.init_segment", args=[project_id, content_id, ensemble_id, cutting_id, segment_id]) @@ -257,6 +270,29 @@ return render_to_response('ldt/ldt_utils/init_ldt_full.html', {'LDT_MEDIA_PREFIX': settings.LDT_MEDIA_PREFIX, 'colorurl': settings.LDT_MEDIA_PREFIX + 'swf/ldt/pkg/color.xml', 'i18nurl': settings.LDT_MEDIA_PREFIX + 'swf/ldt/pkg/i18n', 'language': language_code, 'baseurl': settings.LDT_MEDIA_PREFIX + 'swf/ldt/', 'url': url}, context_instance=RequestContext(request)) + +def search_listing(request): + if not request.session.__contains__('complete_results'): + msg = _("Please enter valid keywords.") + return render_to_response('ldt/ldt_utils/search_results.html', {'msg' : msg}, context_instance=RequestContext(request)) + + complete_results = request.session.__getitem__('complete_results') + search = request.session.__getitem__('search') + paginator = Paginator(complete_results, settings.LDT_RESULTS_PER_PAGE) + language_code = request.LANGUAGE_CODE[:2] + + try: + page = int(request.GET.get('page', '1')) + except ValueError: + page = 1 + + try: + results = paginator.page(page) + except (EmptyPage, InvalidPage): + results = paginator.page(paginator.num_pages) + + return render_to_response('ldt/ldt_utils/search_results.html', {'results': results, 'search' : search, 'LDT_MEDIA_PREFIX': settings.LDT_MEDIA_PREFIX, 'colorurl': settings.LDT_MEDIA_PREFIX + 'swf/ldt/pkg/color.xml', 'i18nurl': settings.LDT_MEDIA_PREFIX + 'swf/ldt/pkg/i18n', 'language': language_code, 'baseurl': settings.LDT_MEDIA_PREFIX + 'swf/ldt/'}, context_instance=RequestContext(request)) + def search_index_get(request, field, query): diff -r a88714473302 -r 32fbed79d3a1 src/ldt/ldt/locale/en/LC_MESSAGES/django.po --- a/src/ldt/ldt/locale/en/LC_MESSAGES/django.po Wed Sep 14 16:48:51 2011 +0200 +++ b/src/ldt/ldt/locale/en/LC_MESSAGES/django.po Thu Sep 15 12:03:02 2011 +0200 @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-09-08 14:19+0200\n" +"POT-Creation-Date: 2011-09-15 11:57+0200\n" "PO-Revision-Date: 2010-02-17 03:53+0100\n" "Last-Translator: Yves-Marie Haussonne \n" "Language-Team: LANGUAGE \n" @@ -175,61 +175,65 @@ msgid "changed by" msgstr "changed by" -#: .\ldt_utils\views.py:147 .\ldt_utils\views.py:540 .\ldt_utils\views.py:586 +#: .\ldt_utils\views.py:149 .\ldt_utils\views.py:578 .\ldt_utils\views.py:624 msgid "You can not access this project" msgstr "You can not access this project" -#: .\ldt_utils\views.py:752 +#: .\ldt_utils\views.py:262 .\ldt_utils\views.py:276 +msgid "Please enter valid keywords." +msgstr "Please enter valid keywords." + +#: .\ldt_utils\views.py:790 #, python-format msgid "the project %(title)s is published. please unpublish before deleting." msgstr "the project %(title)s is published. please unpublish before deleting." -#: .\ldt_utils\views.py:753 +#: .\ldt_utils\views.py:791 msgid "can not delete the project. Please correct the following error" msgstr "can not delete the project. Please correct the following error" -#: .\ldt_utils\views.py:754 +#: .\ldt_utils\views.py:792 msgid "title error deleting project" msgstr "Error when deleting project" -#: .\ldt_utils\views.py:756 +#: .\ldt_utils\views.py:794 #, python-format msgid "please confirm deleting project %(title)s" msgstr "Please confirm deleting project %(title)s" -#: .\ldt_utils\views.py:757 +#: .\ldt_utils\views.py:795 msgid "confirm deletion" msgstr "Confirm deletion" -#: .\ldt_utils\views.py:931 +#: .\ldt_utils\views.py:969 msgid "Problem when downloading file from url : " msgstr "Problem when downloading file from url: " -#: .\ldt_utils\views.py:934 +#: .\ldt_utils\views.py:972 msgid "Problem when uploading file : " msgstr "Problem when uploading file: " -#: .\ldt_utils\views.py:1003 +#: .\ldt_utils\views.py:1041 #, python-format msgid "There is %(count)d error when deleting content" msgid_plural "There are %(count)d errors when deleting content" msgstr[0] "There is %(count)d error when deleting content" msgstr[1] "There are %(count)d errors when deleting content" -#: .\ldt_utils\views.py:1004 +#: .\ldt_utils\views.py:1042 msgid "title error deleting content" msgstr "Error when deleting content" -#: .\ldt_utils\views.py:1006 +#: .\ldt_utils\views.py:1044 #, python-format msgid "Confirm delete content %(titles)s" msgstr "Confirm delete content %(titles)s" -#: .\ldt_utils\views.py:1007 +#: .\ldt_utils\views.py:1045 msgid "confirm delete content" msgstr "Confirm delete content" -#: .\ldt_utils\views.py:1041 +#: .\ldt_utils\views.py:1079 #, python-format msgid "" "Content '%(title)s' is referenced by this project : %(project_titles)s. " @@ -492,6 +496,23 @@ msgid "The search field can not be empty." msgstr "The search field can not be empty." +#: .\ldt_utils\templates\ldt\ldt_utils\search_results.html.py:16 +msgid "Results for " +msgstr "" + +#: .\ldt_utils\templates\ldt\ldt_utils\search_results.html.py:33 +msgid "previous" +msgstr "Previous" + +#: .\ldt_utils\templates\ldt\ldt_utils\search_results.html.py:37 +#, python-format +msgid "Page %(number)s of %(num_pages)s" +msgstr "Page %(number)s of %(num_pages)s" + +#: .\ldt_utils\templates\ldt\ldt_utils\search_results.html.py:41 +msgid "next" +msgstr "Next" + #: .\ldt_utils\templates\ldt\ldt_utils\workspace_base.html.py:53 msgid "content list" msgstr "Contents" @@ -861,62 +882,62 @@ msgid "annotation.update_date" msgstr "update date" -#: .\user\admin.py:16 +#: .\user\admin.py:13 msgid "User details" msgstr "User details" -#: .\user\admin.py:17 +#: .\user\admin.py:14 msgid "Groups" msgstr "Groups" -#: .\user\admin.py:18 +#: .\user\admin.py:15 msgid "Permissions" msgstr "Permissions" -#: .\user\admin.py:29 .\user\templates\ldt\user\change_profile.html.py:95 +#: .\user\admin.py:25 .\user\templates\ldt\user\change_profile.html.py:95 #: .\user\templates\ldt\user\login_form.html.py:61 msgid "Password" msgstr "Password" -#: .\user\forms.py:28 .\user\templates\ldt\user\change_password.html.py:40 +#: .\user\forms.py:27 .\user\templates\ldt\user\change_password.html.py:40 #: .\user\templates\ldt\user\change_profile.html.py:108 msgid "New password" msgstr "New password" -#: .\user\forms.py:30 .\user\templates\ldt\user\change_password.html.py:50 +#: .\user\forms.py:29 .\user\templates\ldt\user\change_password.html.py:50 #: .\user\templates\ldt\user\change_profile.html.py:121 msgid "New password confirmation" msgstr "New password confirmation" -#: .\user\forms.py:59 .\user\forms.py:60 +#: .\user\forms.py:58 .\user\forms.py:59 msgid "E-mail" msgstr "E-mail" -#: .\user\forms.py:71 +#: .\user\forms.py:70 msgid "The two emails didn't match." msgstr "The two emails didn't match." -#: .\user\forms.py:82 .\user\templates\ldt\user\change_profile.html.py:44 +#: .\user\forms.py:81 .\user\templates\ldt\user\change_profile.html.py:44 msgid "First name" msgstr "First name" -#: .\user\forms.py:83 +#: .\user\forms.py:82 msgid "Last name" msgstr "Last name" -#: .\user\forms.py:110 .\user\templates\ldt\user\change_profile.html.py:73 +#: .\user\forms.py:109 .\user\templates\ldt\user\change_profile.html.py:73 msgid "Language" msgstr "Language" -#: .\user\views.py:30 +#: .\user\views.py:29 msgid "Your profile has been updated." msgstr "Your profile has been changed." -#: .\user\views.py:54 +#: .\user\views.py:53 msgid "Your password has been updated." msgstr "Your password has been updated." -#: .\user\views.py:74 .\user\templates\registration\login.html.py:24 +#: .\user\views.py:73 .\user\templates\registration\login.html.py:24 msgid "Sorry, that's not a valid username or password." msgstr "Sorry, that's not a valid username or password." diff -r a88714473302 -r 32fbed79d3a1 src/ldt/ldt/locale/fr/LC_MESSAGES/django.po --- a/src/ldt/ldt/locale/fr/LC_MESSAGES/django.po Wed Sep 14 16:48:51 2011 +0200 +++ b/src/ldt/ldt/locale/fr/LC_MESSAGES/django.po Thu Sep 15 12:03:02 2011 +0200 @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-09-08 14:36+0200\n" +"POT-Creation-Date: 2011-09-15 11:57+0200\n" "PO-Revision-Date: 2010-03-09 15:52+0100\n" "Last-Translator: Yves-Marie Haussonne \n" "Language-Team: LANGUAGE \n" @@ -174,62 +174,66 @@ msgid "changed by" msgstr "modifié par" -#: .\ldt_utils\views.py:147 .\ldt_utils\views.py:540 .\ldt_utils\views.py:586 +#: .\ldt_utils\views.py:149 .\ldt_utils\views.py:578 .\ldt_utils\views.py:624 msgid "You can not access this project" msgstr "vous n'avez pas l'autorisation d'accéder à ce projet" -#: .\ldt_utils\views.py:752 +#: .\ldt_utils\views.py:262 .\ldt_utils\views.py:276 +msgid "Please enter valid keywords." +msgstr "Veuillez entrer des mots-clés valides." + +#: .\ldt_utils\views.py:790 #, python-format msgid "the project %(title)s is published. please unpublish before deleting." msgstr "Le projet %(title)s est publié. Déplublier le avant de l'effacer." -#: .\ldt_utils\views.py:753 +#: .\ldt_utils\views.py:791 msgid "can not delete the project. Please correct the following error" msgstr "" "Le projet ne peut pas être effacé. Veuillez corriger les erreurs suivantes." -#: .\ldt_utils\views.py:754 +#: .\ldt_utils\views.py:792 msgid "title error deleting project" msgstr "Erreur lors de l'effacement du projet" -#: .\ldt_utils\views.py:756 +#: .\ldt_utils\views.py:794 #, python-format msgid "please confirm deleting project %(title)s" msgstr "Confirmer l'effacement du projet intitulé %(title)s" -#: .\ldt_utils\views.py:757 +#: .\ldt_utils\views.py:795 msgid "confirm deletion" msgstr "Confirmation d'effacement" -#: .\ldt_utils\views.py:931 +#: .\ldt_utils\views.py:969 msgid "Problem when downloading file from url : " msgstr "Problème lors du téléchargement du fichier : " -#: .\ldt_utils\views.py:934 +#: .\ldt_utils\views.py:972 msgid "Problem when uploading file : " msgstr "Problème lors de l'upload du fichier : " -#: .\ldt_utils\views.py:1003 +#: .\ldt_utils\views.py:1041 #, python-format msgid "There is %(count)d error when deleting content" msgid_plural "There are %(count)d errors when deleting content" msgstr[0] "Il y a %(count)d erreur lors de l'effacement du contenu" msgstr[1] "Il y a %(count)d erreurs lors de l'effacement du contenu" -#: .\ldt_utils\views.py:1004 +#: .\ldt_utils\views.py:1042 msgid "title error deleting content" msgstr "Erreur lors de l'effacement du contenu" -#: .\ldt_utils\views.py:1006 +#: .\ldt_utils\views.py:1044 #, python-format msgid "Confirm delete content %(titles)s" msgstr "Veuillez confirmer l'effacement du contenu %(titles)s" -#: .\ldt_utils\views.py:1007 +#: .\ldt_utils\views.py:1045 msgid "confirm delete content" msgstr "Confirmation effacement contenu" -#: .\ldt_utils\views.py:1041 +#: .\ldt_utils\views.py:1079 #, python-format msgid "" "Content '%(title)s' is referenced by this project : %(project_titles)s. " @@ -488,6 +492,23 @@ msgid "The search field can not be empty." msgstr "Le champ de recherche ne peut pas être vide." +#: .\ldt_utils\templates\ldt\ldt_utils\search_results.html.py:16 +msgid "Results for " +msgstr "Résultats pour " + +#: .\ldt_utils\templates\ldt\ldt_utils\search_results.html.py:33 +msgid "previous" +msgstr "Précedent" + +#: .\ldt_utils\templates\ldt\ldt_utils\search_results.html.py:37 +#, python-format +msgid "Page %(number)s of %(num_pages)s" +msgstr "Page %(number)s de %(num_pages)s" + +#: .\ldt_utils\templates\ldt\ldt_utils\search_results.html.py:41 +msgid "next" +msgstr "Suivant" + #: .\ldt_utils\templates\ldt\ldt_utils\workspace_base.html.py:53 msgid "content list" msgstr "Liste des contenus" @@ -763,7 +784,6 @@ msgstr "Plateforme Ldt" #: .\templates\ldt\ldt_base.html.py:85 -#, fuzzy msgid "Link to admin" msgstr "Lien vers admin" @@ -856,62 +876,62 @@ msgid "annotation.update_date" msgstr "Date de maj" -#: .\user\admin.py:16 +#: .\user\admin.py:13 msgid "User details" msgstr "Détail utilisateur" -#: .\user\admin.py:17 +#: .\user\admin.py:14 msgid "Groups" msgstr "Groupes" -#: .\user\admin.py:18 +#: .\user\admin.py:15 msgid "Permissions" msgstr "Permissions" -#: .\user\admin.py:29 .\user\templates\ldt\user\change_profile.html.py:95 +#: .\user\admin.py:25 .\user\templates\ldt\user\change_profile.html.py:95 #: .\user\templates\ldt\user\login_form.html.py:61 msgid "Password" msgstr "Mot de passe" -#: .\user\forms.py:28 .\user\templates\ldt\user\change_password.html.py:40 +#: .\user\forms.py:27 .\user\templates\ldt\user\change_password.html.py:40 #: .\user\templates\ldt\user\change_profile.html.py:108 msgid "New password" msgstr "Nouveau mot de passe" -#: .\user\forms.py:30 .\user\templates\ldt\user\change_password.html.py:50 +#: .\user\forms.py:29 .\user\templates\ldt\user\change_password.html.py:50 #: .\user\templates\ldt\user\change_profile.html.py:121 msgid "New password confirmation" msgstr "Confirmation du nouveau mot de passe" -#: .\user\forms.py:59 .\user\forms.py:60 +#: .\user\forms.py:58 .\user\forms.py:59 msgid "E-mail" msgstr "E-mail" -#: .\user\forms.py:71 +#: .\user\forms.py:70 msgid "The two emails didn't match." msgstr "les deux emails ne correspondent pas" -#: .\user\forms.py:82 .\user\templates\ldt\user\change_profile.html.py:44 +#: .\user\forms.py:81 .\user\templates\ldt\user\change_profile.html.py:44 msgid "First name" msgstr "Prénom" -#: .\user\forms.py:83 +#: .\user\forms.py:82 msgid "Last name" msgstr "Nom :" -#: .\user\forms.py:110 .\user\templates\ldt\user\change_profile.html.py:73 +#: .\user\forms.py:109 .\user\templates\ldt\user\change_profile.html.py:73 msgid "Language" msgstr "Langue" -#: .\user\views.py:30 +#: .\user\views.py:29 msgid "Your profile has been updated." msgstr "Votre profil a été modifié" -#: .\user\views.py:54 +#: .\user\views.py:53 msgid "Your password has been updated." msgstr "Votre mot de passe a été changeé." -#: .\user\views.py:74 .\user\templates\registration\login.html.py:24 +#: .\user\views.py:73 .\user\templates\registration\login.html.py:24 msgid "Sorry, that's not a valid username or password." msgstr "Saisissez un nom d'utilisateur et un mot de passe valide." @@ -1174,7 +1194,3 @@ msgstr "" "Nous vous avons envoyé par courriel les instructions pour activer le compte " "à l'adresse que vous avez indiquée. Vous devriez le recevoir rapidement." - -#, fuzzy -#~ msgid "Change this project" -#~ msgstr "Créer un nouveau projet d'indexation" diff -r a88714473302 -r 32fbed79d3a1 src/ldt/ldt/settings.py --- a/src/ldt/ldt/settings.py Wed Sep 14 16:48:51 2011 +0200 +++ b/src/ldt/ldt/settings.py Thu Sep 15 12:03:02 2011 +0200 @@ -74,6 +74,7 @@ LDT_MEDIA_PREFIX = getattr(settings, 'LDT_MEDIA_PREFIX', MEDIA_URL + 'ldt/') LDT_MAX_SEARCH_NUMBER = 50 LDT_MAX_FRAGMENT_PER_SEARCH = 3 +LDT_RESULTS_PER_PAGE = 1 LDT_JSON_DEFAULT_INDENT = 2 AUTO_INDEX_AFTER_SAVE = getattr(settings, 'AUTO_INDEX_AFTER_SAVE', True) diff -r a88714473302 -r 32fbed79d3a1 web/ldtplatform/config.py.tmpl --- a/web/ldtplatform/config.py.tmpl Wed Sep 14 16:48:51 2011 +0200 +++ b/web/ldtplatform/config.py.tmpl Thu Sep 15 12:03:02 2011 +0200 @@ -75,6 +75,7 @@ LDT_MAX_SEARCH_NUMBER = 50 LDT_MAX_FRAGMENT_PER_SEARCH = 3 +LDT_RESULTS_PER_PAGE = 1 LDT_JSON_DEFAULT_INDENT = 0 EMPTY_MEDIA_EXTERNALID = None diff -r a88714473302 -r 32fbed79d3a1 web/ldtplatform/settings.py --- a/web/ldtplatform/settings.py Wed Sep 14 16:48:51 2011 +0200 +++ b/web/ldtplatform/settings.py Thu Sep 15 12:03:02 2011 +0200 @@ -190,7 +190,7 @@ # twitter testing TEST_TWITTER_USER = 'jacquesverrier@gmail.com' -TEST_TWITTER_PASSWORD = 'atanyatson' +TEST_TWITTER_PASSWORD = '' # facebook testing #TEST_FACEBOOK_USER = 'testing_account' @@ -198,7 +198,7 @@ # google testing TEST_GOOGLE_USER = 'jacquesverrier@gmail.com' -TEST_GOOGLE_PASSWORD = 'fti:"\'plesimer' +TEST_GOOGLE_PASSWORD = '' AUTO_INDEX_AFTER_SAVE = True