fnp
/
audio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add link to projects in admin
[audio.git]
/
apps
/
archive
/
forms.py
diff --git
a/apps/archive/forms.py
b/apps/archive/forms.py
index
772ec0a
..
c551cf8
100755
(executable)
--- a/
apps/archive/forms.py
+++ b/
apps/archive/forms.py
@@
-1,6
+1,6
@@
+from datetime import datetime
import os
import os.path
import os
import os.path
-from datetime import datetime
from django import forms
from django.utils.translation import ugettext_lazy as _
from django import forms
from django.utils.translation import ugettext_lazy as _
@@
-8,7
+8,7
@@
import mutagen
from archive.models import Audiobook
from archive.settings import FILES_PATH
from archive.models import Audiobook
from archive.settings import FILES_PATH
-from archive.utils import ExistingFile
+from archive.utils import ExistingFile
, sha1_file
class AudiobookForm(forms.ModelForm):
class Meta:
class AudiobookForm(forms.ModelForm):
class Meta:
@@
-23,8
+23,14
@@
class AudiobookForm(forms.ModelForm):
if not os.path.isdir(FILES_PATH):
os.makedirs(FILES_PATH)
# save the file in model
if not os.path.isdir(FILES_PATH):
os.makedirs(FILES_PATH)
# save the file in model
- m.source_file.save(os.path.basename(path), ExistingFile(path))
+
+ m.source_file.save(
+ os.path.basename(path),
+ ExistingFile(path))
+
+ f = open(m.source_file.path)
+ m.source_sha1 = sha1_file(f)
+ f.close()
if commit:
m.save()
if commit:
m.save()
-