models: change path construction in petal_directory (fixes #21111)

Use an md5 hash of the CUT.uuid instead of the first 4 characters which
are constant now.
This commit is contained in:
Benjamin Dauvergne 2018-01-11 15:04:36 +01:00
parent c39bf2773e
commit d04235f7a4
1 changed files with 3 additions and 1 deletions

View File

@ -14,6 +14,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import hashlib
from django.db import models
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
@ -111,7 +113,7 @@ def petal_directory(instance, filename):
return 'data/{0}/{1}/{2}/{3}'.format(
instance.partner.name,
instance.cut.uuid[:3],
hashlib.md5(instance.cut.uuid).hexdigest()[:3],
instance.cut.uuid,
instance.name)