Commit 32e2b6bb authored by Florent Chehab's avatar Florent Chehab
Browse files

Backend updated with aucreation of userdata and univ modules

Also removed some stuff
parent 5350a0b5
......@@ -2,7 +2,7 @@ from .withUserTestCase import WithUserTestCase
from backend.models.abstract.my_model import ForTestingVersioning
from django.conf import settings
from reversion.models import Version
from backend.signals import new_revision_saved
from backend.signals.__squash_revision_by_user import new_revision_saved
from django.test import override_settings
......
from django.conf import settings
from django.utils.deconstruct import deconstructible
import os
@deconstructible
class friendly_path(object):
"""
class to generate file path with filenames
according to one of the model attribute
"""
def __init__(self, rel_path, attribute_distinction):
self.rel_path = rel_path
self.attr = attribute_distinction
def __call__(self, instance, filename):
ext = filename.split('.')[-1]
i = 0
while True:
filename = '{}_{}.{}'.format(
getattr(instance, self.attr), str(i), ext)
path_and_fn = os.path.join(
settings.MEDIA_ROOT, self.rel_path, filename)
if not os.path.isfile(path_and_fn):
break
i += 1
return os.path.join(self.rel_path, filename)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment