diff options
author | Trupti Rajesh Kini | 2017-02-17 15:02:03 +0530 |
---|---|---|
committer | GitHub | 2017-02-17 15:02:03 +0530 |
commit | 7b9d346d10f38ae0e06626386fad1f87d16dce9f (patch) | |
tree | 3c32ef84f8f67eebd94c0deb4f6585d083785f48 /tbc | |
parent | 02fdfa7adcf388892dd06c470c0fa55c842a0e81 (diff) | |
download | Python-TBC-Interface-7b9d346d10f38ae0e06626386fad1f87d16dce9f.tar.gz Python-TBC-Interface-7b9d346d10f38ae0e06626386fad1f87d16dce9f.tar.bz2 Python-TBC-Interface-7b9d346d10f38ae0e06626386fad1f87d16dce9f.zip |
Fixed duplicate screenshots and chapters bug
Fix will now overwrite existing file with the same name instead of renaming with characters.
Diffstat (limited to 'tbc')
-rw-r--r-- | tbc/models.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tbc/models.py b/tbc/models.py index 48c6952..a36d4ce 100644 --- a/tbc/models.py +++ b/tbc/models.py @@ -120,14 +120,14 @@ class OverwriteStorage(FileSystemStorage): def get_available_name(self, name): if self.exists(name): - os.remove(os.path.join("/Site/tbc-python_fossee_in/PythonTBC/Python-TBC-Interface/tbc/static/Python-Textbook-Companions/", name)) + os.remove(os.path.join(settings.MEDIA_ROOT, name)) return name fs = OverwriteStorage(location="/Site/tbc-python_fossee_in/PythonTBC/Python-TBC-Interface/tbc/static/Python-Textbook-Companions/") class Chapters(models.Model): name = models.CharField(max_length=200) - notebook = models.FileField(upload_to=get_notebook_dir) + notebook = models.FileField(storage=OverwriteStorage(), upload_to=get_notebook_dir) book = models.ForeignKey(Book) screen_shots = models.ManyToManyField('ScreenShots') def __unicode__(self): @@ -139,7 +139,7 @@ class Chapters(models.Model): class ScreenShots(models.Model): caption = models.CharField(max_length=128) - image = models.FileField(upload_to=get_image_dir) + image = models.FileField(storage=OverwriteStorage(), upload_to=get_image_dir) book = models.ForeignKey(Book) def __unicode__(self): name = self.caption or 'ScreenShots' @@ -174,7 +174,7 @@ class Proposal(models.Model): class SampleNotebook(models.Model): proposal = models.ForeignKey(Proposal) name = models.CharField(max_length=40) - sample_notebook = models.FileField(upload_to=get_sample_dir) + sample_notebook = models.FileField(storage=OverwriteStorage(), upload_to=get_sample_dir) def __unicode__(self): notebook = self.proposal.accepted.title or 'notebook' return '%s'%(notebook) |