Changeset 399 in main


Ignore:
Timestamp:
10/17/11 13:58:24 (8 years ago)
Author:
pcosquer
Message:

put thumbnails in the right directory
Note: THUMBNAILS_URL must have a trailing slash!

Location:
trunk/openPLM
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/plmapp/models.py

    r387 r399  
    654654docfs = DocumentStorage(location=settings.DOCUMENTS_DIR) 
    655655#: :class:`FileSystemStorage` instance which stores thumbnails in :const:`settings.THUMBNAILS_DIR` 
    656 thumbnailfs = FileSystemStorage(location=settings.THUMBNAILS_DIR) 
     656thumbnailfs = FileSystemStorage(location=settings.THUMBNAILS_DIR, 
     657        base_url=settings.THUMBNAILS_URL) 
    657658 
    658659class DocumentFile(models.Model): 
     
    684685    file = models.FileField(upload_to="docs", storage=docfs) 
    685686    size = models.PositiveIntegerField() 
    686     thumbnail = models.ImageField(upload_to="thumbnails", storage=thumbnailfs, 
     687    thumbnail = models.ImageField(upload_to=".", storage=thumbnailfs, 
    687688                                 blank=True, null=True) 
    688689    locked = models.BooleanField(default=lambda: False) 
  • trunk/openPLM/plmapp/views/ajax.py

    r392 r399  
    2525################################################################################ 
    2626 
    27  
     27import urlparse 
     28 
     29from django.conf import settings 
    2830from django.contrib.auth.decorators import login_required 
    2931from django.utils.simplejson import JSONEncoder 
     
    101103    for f in obj.files: 
    102104        if f.thumbnail: 
    103             img = "/media/thumbnails/%s" % f.thumbnail  
     105            img = f.thumbnail.url  
    104106        else: 
    105             img = "/media/img/image-missing.png" 
     107            img = urlparse.urljoin(settings.MEDIA_URL, "img/image-missing.png") 
    106108        files.append((f.filename, "/file/%d/" % f.id, img)) 
    107109    return dict(files=files, doc=doc) 
  • trunk/openPLM/settings.py

    r387 r399  
    113113#: directory that stores documents 
    114114DOCUMENTS_DIR = "/var/openPLM/docs" 
    115 THUMBNAILS_DIR = os.path.join(MEDIA_ROOT, "thumbnails") 
    116 #: directory that stores thumbnails 
    117 THUMBNAILS_URL = MEDIA_URL + "thumbnails" 
     115THUMBNAILS_DIR = os.path.join(MEDIA_ROOT, "thumbnails/") 
     116#: directory that stores thumbnails. Make sure to use a 
     117# trailing slash. 
     118THUMBNAILS_URL = MEDIA_URL + "thumbnails/" 
    118119 
    119120# Cookie used for session is temporary and is deleted when browser is closed 
  • trunk/openPLM/templates/DisplayObjectFiles.htm

    r286 r399  
    5454                                <td class="Content"> 
    5555                        {% if instance.thumbnail %} 
    56                             <img class="thumbnail" src="{{THUMBNAILS_URL}}/{{instance.thumbnail.name}}" 
     56                            <img class="thumbnail" src="{{instance.thumbnail.url}}" 
    5757                                alt="Thumbnail"/> 
    5858                                {% else %} 
Note: See TracChangeset for help on using the changeset viewer.