fnp
/
audio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
reqs fix
[audio.git]
/
apps
/
archive
/
forms.py
diff --git
a/apps/archive/forms.py
b/apps/archive/forms.py
old mode 100755
(executable)
new mode 100644
(file)
index
c551cf8
..
cdc416e
--- a/
apps/archive/forms.py
+++ b/
apps/archive/forms.py
@@
-7,7
+7,7
@@
from django.utils.translation import ugettext_lazy as _
import mutagen
from archive.models import Audiobook
import mutagen
from archive.models import Audiobook
-from archive.settings import FILES_PATH
+from archive.settings import FILES_PATH
, NEW_PATH
from archive.utils import ExistingFile, sha1_file
class AudiobookForm(forms.ModelForm):
from archive.utils import ExistingFile, sha1_file
class AudiobookForm(forms.ModelForm):
@@
-15,6
+15,10
@@
class AudiobookForm(forms.ModelForm):
model = Audiobook
def save(self, commit=True, path=None):
model = Audiobook
def save(self, commit=True, path=None):
+ """ Performs normal save, with given file as an source audiobook.
+
+ `path' is relative to NEW_PATH.
+ """
m = super(AudiobookForm, self).save(commit=False)
m.modified = datetime.now()
m = super(AudiobookForm, self).save(commit=False)
m.modified = datetime.now()
@@
-24,9
+28,10
@@
class AudiobookForm(forms.ModelForm):
os.makedirs(FILES_PATH)
# save the file in model
os.makedirs(FILES_PATH)
# save the file in model
+ abs_path = os.path.join(NEW_PATH, path)
m.source_file.save(
m.source_file.save(
-
os.path.basename(path)
,
- ExistingFile(path))
+
path
,
+ ExistingFile(
abs_
path))
f = open(m.source_file.path)
m.source_sha1 = sha1_file(f)
f = open(m.source_file.path)
m.source_sha1 = sha1_file(f)