Giter Club home page Giter Club logo

django-photologue's Introduction

Django-photologue

Photologue

CI status on Travis CI Coverage Status

A powerful image management and gallery application for the Django web framework. Upload photos, group them into galleries, apply effects such as watermarks.

this fork has some nice modifications check it now!

Examples

We have some examples of sites using Photologue on our wiki.

Documentation

Please head over to our online documentation for instructions on installing and configuring this application.

Python 3?

Of course! Photologue is CI tested against both Python 2 and Python 3.

Support

If you have any questions or need help with any aspect of Photologue then please join our mailing list.

django-photologue's People

Contributors

akaihola avatar benliles avatar ferhatelmas avatar hermanschaaf avatar jdriscoll avatar jnns avatar jonashaag avatar karolmajta avatar kdeebee avatar kinetifex avatar petry avatar phretor avatar polinom avatar reavis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

django-photologue's Issues

POSTs to wrong path on S3 when editting pre-existing photo in django admin

I am able to create new photos and delete them with the result POSTing an image (uploading it) to my Amazon S3 account.

However, if I go back and edit that photologue photo (say change the name), I get a 400 Invalid Request error from django. It seems that when editing a pre-existing photo, it tries to POST to an admin location (even though the images exist in the media folder - no admin). Again, I can create and delete photos just fine, but editing them causes this error (such as changing tags, name, description, etc).

Here is the log from heroku after I save any changes to a photologue photo:

2014-04-16T23:13:31.889623+00:00 heroku[router]: at=info method=POST path=/admin /photologue/photo/22/ host=myapp.herokuapp.com request_id=blablablabla fwd="x.x.x.x" dyno=web.1 connect=1ms service=997ms sta tus=400 bytes=211

How might photologue be configured so that when editting any changes to a pre-existing photo, it POSTs the result back to the correct location (where it was originally created using the same django admin interface)?

My current work around is every time I need to edit a photo I just delete it and re-upload it with any changes to the meta data I require.

ImageModel tries to open Images from local file system

There are a few occasions where the ImageModel uses a local file path to create an Image instance (e.g. line 373). This fails in a setup using non-local storage.

It would be better to retrieve files using the DefaultStorage instead.

SuspiciousOperation when using S3

There's a catch when using S3 as your storage backend - saving and retrieving photos works as you would expect, but when trying to clear the cache folder (for example after rotating the photo) and maybe in some other cases, _get_SIZE_filename() is called, and that in turn returns a path based on MEDIA_ROOT - causing a SuspiciousOperation at least in Django 1.4 and above.

The code in issue is in photologue/models.py:

    def _get_SIZE_filename(self, size):
        photosize = PhotoSizeCache().sizes.get(size)
        generator = PhotologueSpec(photo=self, photosize=photosize)
        return os.path.join(settings.MEDIA_ROOT, generator.cachefile_name)

For my use case, where I needed to be able to delete cached sized versions of images, overriding the _get_SIZE_filename method with something like

    def _get_SIZE_filename(self, size):
        photosize = PhotoSizeCache().sizes.get(size)
        generator = PhotologueSpec(photo=self, photosize=photosize)
        return generator.cachefile_name

but there should be a better way of dealing with this in an storage independent kind of way.

re-fix upload gallery

Traceback (most recent call last):

  File "/opt/projects/donnatune/virtualenv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 115, in get_response
    response = callback(request, *callback_args, **callback_kwargs)

  File "/opt/projects/donnatune/virtualenv/local/lib/python2.7/site-packages/newrelic-2.0.0.1/newrelic/api/object_wrapper.py", line 257, in __call__
    self._nr_instance, args, kwargs, **self._nr_kwargs)

  File "/opt/projects/donnatune/virtualenv/local/lib/python2.7/site-packages/newrelic-2.0.0.1/newrelic/hooks/framework_django.py", line 485, in wrapper
    return wrapped(*args, **kwargs)

  File "/opt/projects/donnatune/virtualenv/local/lib/python2.7/site-packages/django/contrib/admin/options.py", line 372, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)

  File "/opt/projects/donnatune/virtualenv/local/lib/python2.7/site-packages/django/utils/decorators.py", line 91, in _wrapped_view
    response = view_func(request, *args, **kwargs)

  File "/opt/projects/donnatune/virtualenv/local/lib/python2.7/site-packages/django/views/decorators/cache.py", line 89, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)

  File "/opt/projects/donnatune/virtualenv/local/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 202, in inner
    return view(request, *args, **kwargs)

  File "/opt/projects/donnatune/virtualenv/local/lib/python2.7/site-packages/django/utils/decorators.py", line 25, in _wrapper
    return bound_func(*args, **kwargs)

  File "/opt/projects/donnatune/virtualenv/local/lib/python2.7/site-packages/django/utils/decorators.py", line 91, in _wrapped_view
    response = view_func(request, *args, **kwargs)

  File "/opt/projects/donnatune/virtualenv/local/lib/python2.7/site-packages/django/utils/decorators.py", line 21, in bound_func
    return func(self, *args2, **kwargs2)

  File "/opt/projects/donnatune/virtualenv/local/lib/python2.7/site-packages/django/db/transaction.py", line 223, in inner
    return func(*args, **kwargs)

  File "/opt/projects/donnatune/virtualenv/local/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1007, in add_view
    self.save_model(request, new_object, form, False)

  File "/opt/projects/donnatune/virtualenv/local/lib/python2.7/site-packages/django/contrib/admin/options.py", line 740, in save_model
    obj.save()

  File "/opt/projects/donnatune/virtualenv/src/django-photologue/photologue/models.py", line 260, in save
    gallery = self.process_zipfile()

  File "/opt/projects/donnatune/virtualenv/src/django-photologue/photologue/models.py", line 265, in process_zipfile
    if os.path.isfile(self.zip_file.path):

  File "/opt/projects/donnatune/virtualenv/local/lib/python2.7/site-packages/django/db/models/fields/files.py", line 59, in _get_path
    return self.storage.path(self.name)

  File "/opt/projects/donnatune/virtualenv/local/lib/python2.7/site-packages/django/core/files/storage.py", line 85, in path
    raise NotImplementedError("This backend doesn't support absolute paths.")

NotImplementedError: This backend doesn't support absolute paths.

Exception on delete. Amazon S3 only.

2013-10-29T02:22:42.738048+00:00 app[web.1]: Traceback (most recent call last):
2013-10-29T02:22:42.738048+00:00 app[web.1]: Internal Server Error: /admin/photologue/photo/6/delete/
2013-10-29T02:22:42.738048+00:00 app[web.1]:     response = callback(request, *callback_args, **callback_kwargs)
2013-10-29T02:22:42.738048+00:00 app[web.1]:     return wrapped(*args, **kwargs)
2013-10-29T02:22:42.738048+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/newrelic-1.12.0.56/newrelic/api/object_wrapper.py", line 237, in __call__
2013-10-29T02:22:42.738048+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/newrelic-1.12.0.56/newrelic/hooks/framework_django.py", line 475, in wrapper
2013-10-29T02:22:42.738048+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 115, in get_response
2013-10-29T02:22:42.738248+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 202, in inner
2013-10-29T02:22:42.738048+00:00 app[web.1]:     self._nr_instance, args, kwargs, **self._nr_kwargs)
2013-10-29T02:22:42.738248+00:00 app[web.1]:     response = view_func(request, *args, **kwargs)
2013-10-29T02:22:42.738048+00:00 app[web.1]:     return self.admin_site.admin_view(view)(*args, **kwargs)
2013-10-29T02:22:42.738248+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/views/decorators/cache.py", line 89, in _wrapped_view_func
2013-10-29T02:22:42.738048+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/options.py", line 372, in wrapper
2013-10-29T02:22:42.738248+00:00 app[web.1]:     response = view_func(request, *args, **kwargs)
2013-10-29T02:22:42.738248+00:00 app[web.1]:     return view(request, *args, **kwargs)
2013-10-29T02:22:42.738248+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py", line 25, in _wrapper
2013-10-29T02:22:42.738248+00:00 app[web.1]:     return bound_func(*args, **kwargs)
2013-10-29T02:22:42.738248+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py", line 91, in _wrapped_view
2013-10-29T02:22:42.738248+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py", line 91, in _wrapped_view
2013-10-29T02:22:42.738248+00:00 app[web.1]:     response = view_func(request, *args, **kwargs)
2013-10-29T02:22:42.738388+00:00 app[web.1]:     return func(self, *args2, **kwargs2)
2013-10-29T02:22:42.738388+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/db/transaction.py", line 223, in inner
2013-10-29T02:22:42.738388+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py", line 21, in bound_func
2013-10-29T02:22:42.738388+00:00 app[web.1]:     return func(*args, **kwargs)
2013-10-29T02:22:42.738388+00:00 app[web.1]:     self.delete_model(request, obj)
2013-10-29T02:22:42.738388+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1333, in delete_view
2013-10-29T02:22:42.738785+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/storages/backends/s3boto.py", line 201, in delete
2013-10-29T02:22:42.738388+00:00 app[web.1]:   File "/app/.heroku/src/django-photologue/photologue/models.py", line 415, in delete
2013-10-29T02:22:42.738388+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/options.py", line 746, in delete_model
2013-10-29T02:22:42.738785+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/storages/backends/s3boto.py", line 150, in _clean_name
2013-10-29T02:22:42.738388+00:00 app[web.1]:     obj.delete()
2013-10-29T02:22:42.738388+00:00 app[web.1]:     self.image.storage.delete(self.image)
2013-10-29T02:22:42.738785+00:00 app[web.1]:     name = self._normalize_name(self._clean_name(name))
2013-10-29T02:22:42.738785+00:00 app[web.1]:     return os.path.normpath(name).replace('\\', '/')
2013-10-29T02:22:42.738785+00:00 app[web.1]: AttributeError: 'ImageFieldFile' object has no attribute 'startswith'
2013-10-29T02:22:42.738785+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/posixpath.py", line 327, in normpath
2013-10-29T02:22:42.738785+00:00 app[web.1]:     initial_slashes = path.startswith('/')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.