Hey Antony, thanks for posting back what you figured out. I'm sure it will be helpful to others in the future!
On Mon, Dec 1, 2014 at 8:22 AM, <[email protected]> wrote: > I answer to myself hoping that it can be useful for others. > > *Context :* > > - Project with site multi-tenacy [ > http://mezzanine.jupo.org/docs/multi-tenancy.html] > - Django 1.6.7 > - Mezzanine 3.1.10 > > *What :* > > The default configuration of upload dir location for galleries* doesn't > allow users to see their files* in media library once files are uploaded* > when using a zip file*. > > With Mezzanine in multi-tenancy context all uploaded images by user are > saved somewhere in : > [media_root location]/uploads/site-[number]/galleries/... > > But for galleries when using a zip file the location is : > [media_root location]/uploads/page-slug/... > > The "page-slug" directory isn't in the "site-[number]" directory : it is > what prevents users to see their files after upload. > > *Solution :* > I 've monkey patched the var GALLERIES_UPLOAD_DIR of the > mezzanine/galleries/models.py file by including those lines in my app used > to theme mezzanine, theme/models.py : > > def get_galleries_upload_dir(): > import os > from mezzanine.conf import settings > from mezzanine.conf import settings as mezz_settings > from mezzanine.utils.importing import import_dotted_path > from mezzanine.utils.sites import current_site_id > > GALLERIES_UPLOAD_DIR = "galleries" > if settings.PACKAGE_NAME_FILEBROWSER in settings.INSTALLED_APPS: > fb_settings = "%s.settings" % settings.PACKAGE_NAME_FILEBROWSER > try: > fb_dir_upload = import_dotted_path(fb_settings).DIRECTORY > if getattr(mezz_settings, "MEDIA_LIBRARY_PER_SITE", False): > GALLERIES_UPLOAD_DIR = os.path.join( > fb_dir_upload, > "site-%s" % current_site_id(), > "galleries") > except ImportError: > pass > return GALLERIES_UPLOAD_DIR > > from mezzanine.galleries import models as Galleries_models > Galleries_models.GALLERIES_UPLOAD_DIR = get_galleries_upload_dir() > > > *May be a bug found ? :* > > My first try was to used the get_directory() function from > filebrowser_safe, like this : > > from filebrowser_safe.functions import get_directory > [...] > if settings.PACKAGE_NAME_FILEBROWSER in settings.INSTALLED_APPS: > GALLERIES_UPLOAD_DIR = os.path.join(get_directory(), "galleries") > [...] > > > > But this doesn't work when directories are not already created the first > time the function is called. *An error is raised because > default_storage.isdir() doesn't exist.* > > I stop to investigate here, i was too far from my goal and I ended up with > my solution as explained before. > > Best regards > > Le jeudi 27 novembre 2014 14:35:07 UTC+1, [email protected] a écrit : > >> Hello to all Mezzanine users ;-) >> >> Another thing that's difficult to understand about directory structure >> for upload files : >> >> Context : using mezzanine galleries in an multi-tenancy setup project >> >> When I upload a single image ( img1.jpg for instance ), the file goes >> here : >> [..]static/media/uploads/site-1/galleries/img1.jgp >> >> But when i upload a zip file containing several images, the files go here >> : >> [..]static/media/uploads/page_slug/all files from zip >> >> How can I setup Mezzanine this way : >> [..]static/media/uploads/site-1/galleries/page_slug/all files from zip >> >> best regards >> > -- > You received this message because you are subscribed to the Google Groups > "Mezzanine Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Mezzanine Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
