Commits

Maciej Wiśniowski committed d4aafca

cleanup + locales

Comments (0)

Files changed (3)

lfs_carousel/images.py

-# django imports
-from django.contrib.auth.decorators import permission_required
-from django.core.exceptions import ObjectDoesNotExist
-from django.core.urlresolvers import reverse
-from django.http import HttpResponse
-from django.http import HttpResponseRedirect
-from django.template import RequestContext
-from django.template.loader import render_to_string
-from django.utils.translation import ugettext_lazy as _
-from django.utils import simplejson
-
-# lfs.imports
-import lfs.core.utils
-from lfs.caching.utils import lfs_get_object_or_404
-from lfs.catalog.models import Image
-from lfs.catalog.models import Product
-from lfs.core.signals import product_changed
-from lfs.core.utils import LazyEncoder
-
-# Load logger
-import logging
-logger = logging.getLogger("default")
-
-@permission_required("core.manage_shop", login_url="/login/")
-def manage_images(request, product_id, as_string=False, template_name="lfc_carousel/images.html"):
-    """
-    """
-    product = lfs_get_object_or_404(Product, pk=product_id)
-
-    result = render_to_string(template_name, RequestContext(request, {
-        "product": product,
-    }))
-
-    if as_string:
-        return result
-    else:
-        result = simplejson.dumps({
-            "images": result,
-            "message": _(u"Images has been added."),
-        }, cls=LazyEncoder)
-
-        return HttpResponse(result)
-
-
-# Actions
-# @permission_required("core.manage_shop", login_url="/login/")
-def add_image(request, product_id):
-    """Adds an image to product with passed product_id.
-    """
-    product = lfs_get_object_or_404(Product, pk=product_id)
-    if request.method == "POST":
-        for file_content in request.FILES.getlist("file"):
-            image = Image(content=product, title=file_content.name)
-            try:
-                image.image.save(file_content.name, file_content, save=True)
-            except Exception, e:
-                logger.info("Upload image: %s %s" % (file_content.name, e))
-                continue
-
-    # Refresh positions
-    for i, image in enumerate(product.images.all()):
-        image.position = (i + 1) * 10
-        image.save()
-
-    product_changed.send(product, request=request)
-
-    result = simplejson.dumps({"name": file_content.name, "type": "image/jpeg", "size": "123456789"})
-    return HttpResponse(result)
-
-
-@permission_required("core.manage_shop", login_url="/login/")
-def update_images(request, product_id):
-    """Saves/deletes images with given ids (passed by request body).
-    """
-    product = lfs_get_object_or_404(Product, pk=product_id)
-
-    action = request.POST.get("action")
-    if action == "delete":
-        message = _(u"Images has been deleted.")
-        for key in request.POST.keys():
-            if key.startswith("delete-"):
-                try:
-                    id = key.split("-")[1]
-                    image = Image.objects.get(pk=id).delete()
-                except (IndexError, ObjectDoesNotExist):
-                    pass
-
-    elif action == "update":
-        message = _(u"Images has been updated.")
-        for key, value in request.POST.items():
-            if key.startswith("title-"):
-                id = key.split("-")[1]
-                try:
-                    image = Image.objects.get(pk=id)
-                except ObjectDoesNotExist:
-                    pass
-                else:
-                    image.title = value
-                    image.save()
-
-            elif key.startswith("position-"):
-                try:
-                    id = key.split("-")[1]
-                    image = Image.objects.get(pk=id)
-                except (IndexError, ObjectDoesNotExist):
-                    pass
-                else:
-                    image.position = value
-                    image.save()
-
-    # Refresh positions
-    for i, image in enumerate(product.images.all()):
-        image.position = (i + 1) * 10
-        image.save()
-
-    product_changed.send(product, request=request)
-
-    html = [["#images", manage_images(request, product_id, as_string=True)]]
-    result = simplejson.dumps({
-        "html": html,
-        "message": message,
-    }, cls=LazyEncoder)
-
-    return HttpResponse(result)
-
-
-@permission_required("core.manage_shop", login_url="/login/")
-def move_image(request, id):
-    """Moves the image with passed id up or down.
-
-    **Parameters:**
-
-        id
-            The id of the image which should be edited.
-
-    **Query String:**
-
-        direction
-            The direction in which the image should be moved. One of 0 (up)
-            or 1 (down).
-
-    **Permission:**
-
-        edit (of the belonging content object)
-    """
-    image = Image.objects.get(pk=id)
-    product = image.content
-
-    direction = request.GET.get("direction", 0)
-
-    if direction == "1":
-        image.position += 15
-    else:
-        image.position -= 15
-        if image.position < 0:
-            image.position = 10
-
-    image.save()
-
-    # Refresh positions
-    for i, image in enumerate(product.images.all()):
-        image.position = (i + 1) * 10
-        image.save()
-
-    html = [["#images", manage_images(request, product.id, as_string=True)]]
-
-    result = simplejson.dumps({
-         "html": html,
-    }, cls=LazyEncoder)
-
-    return HttpResponse(result)
-
-
-@permission_required("core.manage_shop", login_url="/login/")
-def update_active_images(request, product_id):
-    """Updates the images activity state for product variants.
-    """
-    product = Product.objects.get(pk=product_id)
-    if request.POST.get("active_images"):
-        product.active_images = True
-    else:
-        product.active_images = False
-    product.save()
-
-    return lfs.core.utils.set_message_cookie(
-        url=reverse("lfs_manage_product", kwargs={"product_id": product.id}),
-        msg=_(u"Active images has been updated."),
-    )

lfs_carousel/locale/pl/LC_MESSAGES/django.mo

Binary file added.

lfs_carousel/locale/pl/LC_MESSAGES/django.po

+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: LFS Carousel\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2012-02-05 17:41+0100\n"
+"PO-Revision-Date: 2012-02-05 17:44+0100\n"
+"Last-Translator: Maciej Wiśniowski <pigletto@gmail.com>\n"
+"Language-Team: natcam.pl <hello@natcam.pl>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
+"X-Poedit-Language: Polish\n"
+"X-Poedit-Country: POLAND\n"
+"X-Poedit-SourceCharset: utf-8\n"
+
+#: models.py:27
+msgid "Content type"
+msgstr "Typ treści"
+
+#: models.py:28
+msgid "Content id"
+msgstr "Id treści"
+
+#: models.py:31
+#: templates/lfs_carousel/items.html:21
+msgid "Title"
+msgstr "Tytuł"
+
+#: models.py:32
+#: templates/lfs_carousel/items.html:18
+msgid "Image"
+msgstr "Obraz"
+
+#: models.py:33
+#: templates/lfs_carousel/items.html:24
+msgid "URL"
+msgstr "URL"
+
+#: models.py:34
+#: templates/lfs_carousel/items.html:27
+msgid "Text"
+msgstr "Text"
+
+#: models.py:35
+#: templates/lfs_carousel/items.html:30
+msgid "Position"
+msgstr "Pozycja"
+
+#: views.py:67
+msgid "Carousel items have been added."
+msgstr "Elementy zostały dodane."
+
+#: views.py:102
+msgid "Carousel items have been deleted."
+msgstr "Eementy zostały usunięte."
+
+#: views.py:112
+msgid "Carousel items have been updated."
+msgstr "Elementy zostały uaktualnione."
+
+#: templates/lfs_carousel/items.html:3
+msgid "Carousel items"
+msgstr "Elementy"
+
+#: templates/lfs_carousel/items.html:33
+msgid "Manage"
+msgstr "Zarządzaj"
+
+#: templates/lfs_carousel/items.html:66
+msgid "Move Up"
+msgstr "W górę"
+
+#: templates/lfs_carousel/items.html:71
+msgid "Move Down"
+msgstr "W dół"
+
+#: templates/lfs_carousel/items.html:82
+msgid "Update items"
+msgstr "Aktualizuj elementy"
+
+#: templates/lfs_carousel/items.html:84
+msgid "Delete items"
+msgstr "Usuń elementy"
+
+#: templates/lfs_carousel/items.html:88
+msgid "There are no items"
+msgstr "Brak elementów"
+
+#: templates/lfs_carousel/items.html:91
+msgid "Add items"
+msgstr "Dodaj elementy"
+
+#: templates/lfs_carousel/items.html:98
+msgid "Uploading images:"
+msgstr "Ładowanie obrazów:"
+