Site Sections: Satchmo Main | Wiki | Demo Store |

Ticket #593: product_models.patch

File product_models.patch, 1.3 kB (added by mengkuan, 3 months ago)
  • satchmo/product/models.py

    old new  
    1010import random 
    1111import sha 
    1212import signals 
     13import os 
    1314 
    1415from django.conf import settings 
    1516from django.contrib.sites.models import Site 
     
    11131114def _protected_dir(instance, filename): 
    11141115    raw = config_value_safe('PRODUCT', 'PROTECTED_DIR', 'images/') 
    11151116    updir = normalize_dir(raw) 
    1116     return updir 
     1117    return "%s/%s" % (updir, os.path.basename(filename)) 
    11171118 
    11181119class DownloadableProduct(models.Model): 
    11191120    """ 
    11201121    This type of Product is a file to be downloaded 
    11211122    """ 
    11221123    product = models.OneToOneField(Product, verbose_name=_("Product"), primary_key=True) 
    1123     file = FileField(_("File"), upload_to=_protected_dir), 
     1124    file = FileField(_("File"), upload_to=_protected_dir) 
    11241125    num_allowed_downloads = models.IntegerField(_("Num allowed downloads"), help_text=_("Number of times link can be accessed.")) 
    11251126    expire_minutes = models.IntegerField(_("Expire minutes"), help_text=_("Number of minutes the link should remain active.")) 
    11261127    active = models.BooleanField(_("Active"), help_text=_("Is this download currently active?"), default=True)