Commit 97fd3bf5 authored by Floréal Cabanettes's avatar Floréal Cabanettes

Make 3 top filters in recipes on panel functionnal

parent fa594917
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-10-29 12:02+0100\n"
"PO-Revision-Date: 2017-10-29 12:03+0100\n"
"POT-Creation-Date: 2017-10-29 14:06+0100\n"
"PO-Revision-Date: 2017-10-29 14:07+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: fr\n"
......@@ -112,8 +112,8 @@ msgstr "ordre"
msgid "Category"
msgstr "Catégorie"
#: main/models/Category.py:16 templates/panel/base.html:219
#: templates/panel/recipes.html:64 templates/website/sidebar.html:9
#: main/models/Category.py:16 templates/panel/base.html:222
#: templates/panel/recipes.html:72 templates/website/sidebar.html:9
msgid "Categories"
msgstr "Catégories"
......@@ -196,13 +196,17 @@ msgstr "slug"
msgid "Recipe"
msgstr "Recette"
#: main/models/Recipe.py:56 templates/panel/base.html:218
#: templates/panel/index.html:23 templates/panel/recipes.html:7
#: templates/panel/recipes.html:11
#: main/models/Recipe.py:56 templates/panel/base.html:221
#: templates/panel/index.html:23 templates/panel/recipes.html:8
#: templates/panel/recipes.html:12
msgid "Recipes"
msgstr "Recettes"
#: panel/views/IndexView.py:34 panel/views/RecipesView.py:61
#: panel/urls.py:13 website/urls.py:14 website/urls.py:16 website/urls.py:19
msgid "page"
msgstr "page"
#: panel/views/IndexView.py:34 panel/views/RecipesView.py:76
#: templates/website/header.html:20
msgid "User panel"
msgstr "Panel utilisateur"
......@@ -224,35 +228,39 @@ msgid "Sign out"
msgstr "Se déconnecter"
#: templates/panel/base.html:209
msgid "Online"
msgstr "En ligne"
msgid "Staff"
msgstr "Équipe"
#: templates/panel/base.html:217 templates/panel/index.html:11
#: templates/panel/recipes.html:10
#: templates/panel/base.html:211
msgid "Editor"
msgstr "Éditeur"
#: templates/panel/base.html:220 templates/panel/index.html:11
#: templates/panel/recipes.html:11
msgid "Home"
msgstr "Accueil"
#: templates/panel/base.html:220
#: templates/panel/base.html:223
msgid "Medias"
msgstr "Médias"
#: templates/panel/base.html:221
#: templates/panel/base.html:224
msgid "Page"
msgstr "Page"
#: templates/panel/base.html:224
#: templates/panel/base.html:227
msgid "Admin"
msgstr "Admin"
#: templates/panel/base.html:230 templates/panel/index.html:57
#: templates/panel/base.html:233 templates/panel/index.html:57
msgid "Users"
msgstr "Utilisateurs"
#: templates/panel/base.html:231
#: templates/panel/base.html:234
msgid "Website parameters"
msgstr "Paramètres du site"
#: templates/panel/base.html:236 templates/website/base.html:35
#: templates/panel/base.html:239 templates/website/base.html:35
msgid "Powered by"
msgstr "Propulsé par"
......@@ -285,76 +293,76 @@ msgstr "Dernières recettes"
msgid "Latest comments"
msgstr "Derniers commentaires"
#: templates/panel/recipes.html:16
#: templates/panel/recipes.html:18
msgctxt "filter-recipes"
msgid "All"
msgstr "Toutes"
#: templates/panel/recipes.html:18
#: templates/panel/recipes.html:21
msgctxt "filter-recipes"
msgid "Mines"
msgstr "Les miennes"
#: templates/panel/recipes.html:19
#: templates/panel/recipes.html:23
msgctxt "filter-recipes"
msgid "Published"
msgstr "Publiées"
#: templates/panel/recipes.html:25
#: templates/panel/recipes.html:29 templates/panel/recipes.html:125
msgid "Grouped actions"
msgstr "Actions groupées"
#: templates/panel/recipes.html:26
#: templates/panel/recipes.html:30 templates/panel/recipes.html:126
msgid "Publish"
msgstr "Publier"
#: templates/panel/recipes.html:27
#: templates/panel/recipes.html:31 templates/panel/recipes.html:127
msgid "Unpublish"
msgstr "Ne plus publier"
#: templates/panel/recipes.html:28
#: templates/panel/recipes.html:32 templates/panel/recipes.html:128
msgid "Move to trash"
msgstr "Mettre à la corbeille"
#: templates/panel/recipes.html:30
#: templates/panel/recipes.html:34 templates/panel/recipes.html:130
msgid "Apply"
msgstr "Appliquer"
#: templates/panel/recipes.html:34
#: templates/panel/recipes.html:38
msgid "All dates"
msgstr "Toutes les dates"
#: templates/panel/recipes.html:40
#: templates/panel/recipes.html:44
msgctxt "categories"
msgid "All"
msgstr "Toutes"
#: templates/panel/recipes.html:45
#: templates/panel/recipes.html:49
msgctxt "verb"
msgid "Filter"
msgstr "Filtrer"
#: templates/panel/recipes.html:58
#: templates/panel/recipes.html:66
msgid "Title"
msgstr "Titre"
#: templates/panel/recipes.html:61
#: templates/panel/recipes.html:69
msgid "Author"
msgstr "Auteur"
#: templates/panel/recipes.html:70
#: templates/panel/recipes.html:78
msgid "Date"
msgstr "Date"
#: templates/panel/recipes.html:73
#: templates/panel/recipes.html:81
msgid "Thumb"
msgstr "Thumb"
#: templates/panel/recipes.html:99
#: templates/panel/recipes.html:107
msgid "Published"
msgstr "Publiée"
#: templates/panel/recipes.html:101
#: templates/panel/recipes.html:109
msgid "Draft"
msgstr "Brouillon"
......@@ -510,10 +518,6 @@ msgstr "Site web"
msgid "Comment"
msgstr "Commentaire"
#: website/urls.py:14 website/urls.py:16 website/urls.py:19
msgid "page"
msgstr "page"
#: website/urls.py:18 website/urls.py:19
msgctxt "author url"
msgid "author"
......@@ -523,6 +527,9 @@ msgstr "auteur"
msgid "Author:"
msgstr "Auteur :"
#~ msgid "Online"
#~ msgstr "En ligne"
#, fuzzy
#~| msgid "order"
#~ msgid "Order"
......
......@@ -4,9 +4,8 @@ from django.shortcuts import render, redirect
from pywebcooking import settings
from django.utils.translation import ugettext as _
from pywebcooking.settings import MEDIA_ROOT, LOCALE
from main.models import Recipe, Comment
from main.models import Recipe, UserProfile
from main.config import RecipeConfig
from django.contrib.auth.models import User
from django_gravatar.helpers import get_gravatar_url
from .GenericView import GenericView
import locale
......@@ -28,6 +27,16 @@ class RecipesView(View):
nb_my_recipes = recipes_user.count()
nb_recipes_published = recipes.filter(published=True).count()
locale.setlocale(locale.LC_TIME, LOCALE)
user_slug = UserProfile.objects.get(user=request.user).url
kwargs = {}
select = "all"
if "user" in request.GET:
recipes = recipes.filter(author__url=request.GET["user"])
if request.GET["user"] == user_slug:
select = "mines"
elif "published" in request.GET and request.GET["published"] == "1":
recipes = recipes.filter(published=True)
select = "published"
all_dates = set()
show_recipes = []
paginator = Paginator(recipes, 15)
......@@ -68,6 +77,7 @@ class RecipesView(View):
"staff": request.user.is_staff,
"user_name": request.user.first_name + " " + request.user.last_name,
"user": request.user,
"user_slug": user_slug,
"avatar": get_gravatar_url(request.user.email, size=160),
"page": "recipes",
"nb_recipes": nb_recipes,
......@@ -77,6 +87,7 @@ class RecipesView(View):
"categories": GenericView.categories(),
"recipes": show_recipes,
"page_recipe": page_recipe,
"additionnal_kwargs": {},
"additionnal_kwargs": kwargs,
"select": select,
}
return render(request, 'panel/recipes.html', context)
......@@ -14,10 +14,13 @@
</section>
<section class="content">
<!-- Table header -->
<p><a href="#" class="show-all filter-active">{% trans "All" context "filter-recipes" %}</a> ({{ nb_recipes }})
<p><a href="/panel/recipes/" class="show-all {% if select == "all" %}filter-active{% endif %}">
{% trans "All" context "filter-recipes" %}</a> ({{ nb_recipes }})
|
<a href="#" class="show-mines">{% trans "Mines" context "filter-recipes" %}</a> ({{ nb_my_recipes }}) |
<a href="#" class="show-published">{% trans "Published" context "filter-recipes" %}</a>
<a href="?user={{ user_slug }}" class="show-mines {% if select == "mines" %}filter-active{% endif %}">
{% trans "Mines" context "filter-recipes" %}</a> ({{ nb_my_recipes }}) |
<a href="?published=1" class="show-published {% if select == "published" %}filter-active{% endif %}">
{% trans "Published" context "filter-recipes" %}</a>
({{ nb_recipes_published }})
</p>
<div class="form-apply-recipes">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment