X-Git-Url: https://git.mdrn.pl/audio.git/blobdiff_plain/dcf7736e1811536ed142bb2de32288faf22f2f0e..8903f605dea83f1070bec40d3eea27f1a1289005:/apps/archive/forms.py?ds=inline diff --git a/apps/archive/forms.py b/apps/archive/forms.py index 922bd28..c551cf8 100755 --- a/apps/archive/forms.py +++ b/apps/archive/forms.py @@ -1,6 +1,6 @@ +from datetime import datetime import os import os.path -from datetime import datetime 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.utils import ExistingFile +from archive.utils import ExistingFile, sha1_file class AudiobookForm(forms.ModelForm): class Meta: @@ -25,9 +25,12 @@ class AudiobookForm(forms.ModelForm): # save the file in model m.source_file.save( - os.path.join(FILES_PATH, os.path.basename(path)), + os.path.basename(path), ExistingFile(path)) + f = open(m.source_file.path) + m.source_sha1 = sha1_file(f) + f.close() + if commit: m.save() -