summaryrefslogtreecommitdiff
path: root/tbc
diff options
context:
space:
mode:
authorTrupti Rajesh Kini2017-01-11 15:16:45 +0530
committerGitHub2017-01-11 15:16:45 +0530
commit02fdfa7adcf388892dd06c470c0fa55c842a0e81 (patch)
treeb4c22c674146ff855d47d8b6ae26de7ab640f4bd /tbc
parentbd71243597d7e2777f35d20bf40cb94aba602c39 (diff)
parentfa473c4d1c443d87311c97486fb92d5971db6b54 (diff)
downloadPython-TBC-Interface-02fdfa7adcf388892dd06c470c0fa55c842a0e81.tar.gz
Python-TBC-Interface-02fdfa7adcf388892dd06c470c0fa55c842a0e81.tar.bz2
Python-TBC-Interface-02fdfa7adcf388892dd06c470c0fa55c842a0e81.zip
Merge pull request #43 from kinitrupti/master
Fixed duplicate notebook bug
Diffstat (limited to 'tbc')
-rw-r--r--tbc/models.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tbc/models.py b/tbc/models.py
index 9b2adbf..48c6952 100644
--- a/tbc/models.py
+++ b/tbc/models.py
@@ -4,6 +4,8 @@ from PythonTBC import settings
from django.contrib.admin.models import LogEntry
from .local import sitemap_path
from taggit.managers import TaggableManager
+from django.core.files.storage import FileSystemStorage
+import os
CATEGORY = (("fluid mechanics", "Fluid Mechanics"),
("control systems", "Control Theory & Control Systems"),
@@ -114,6 +116,14 @@ class Book(models.Model):
name = self.title or 'Book'
return '%s'%(name)
+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))
+ 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)