Exemple #1
0
def create_user_profile(sender, instance, created, **kwargs):
    if created and not instance.is_superuser:
        diretorio = Folder(
            owner=instance,
            name=instance.username,
        )
        diretorio.save()
    def forwards(self, orm):
        "Write your forwards methods here."
        #Get or create a filer folder to store images
        from filer.models import Folder, Image
        from django.core.files import File as DjangoFile
        from django.contrib.auth.models import User
        from os.path import basename
        if Folder.objects.filter(name="cmsplugin_gallery").count() == 0:
            target_folder = Folder(name="cmsplugin_gallery")
            target_folder.save()
        else:
            target_folder = Folder.objects.get(name="cmsplugin_gallery")

        user = User.objects.all()[0]

        for image in orm['cmsplugin_gallery.Image'].objects.all():
            with open(image.src.path) as imgfile:
                name = basename(image.src.name)
                djangofile = DjangoFile(imgfile,
                                        name=name)
                img = Image.objects.create(owner=user,
                                           original_filename=name,
                                           file=djangofile,
                                           folder = target_folder)
                img.save()
            #Not sure why 'image.src_new = img' doesn't work
            image.src_new_id = img.id
            image.save()
    def forwards(self, orm):
        "Write your forwards methods here."
        #Get or create a filer folder to store images
        from filer.models import Folder, Image
        from django.core.files import File as DjangoFile
        from django.contrib.auth.models import User
        from os.path import basename
        if Folder.objects.filter(name="cmsplugin_gallery").count() == 0:
            target_folder = Folder(name="cmsplugin_gallery")
            target_folder.save()
        else:
            target_folder = Folder.objects.get(name="cmsplugin_gallery")

        user = User.objects.all()[0]

        for image in orm['cmsplugin_gallery.Image'].objects.all():
            with open(image.src.path) as imgfile:
                name = basename(image.src.name)
                djangofile = DjangoFile(imgfile, name=name)
                img = Image.objects.create(owner=user,
                                           original_filename=name,
                                           file=djangofile,
                                           folder=target_folder)
                img.save()
            #Not sure why 'image.src_new = img' doesn't work
            image.src_new_id = img.id
            image.save()
Exemple #4
0
    def save(self, *args, **kwargs):
        try:
            Folder.objects.get(name='Rankingi')
        except ObjectDoesNotExist:
            Folder(name='Rankingi', parent=None).save()
        try:
            self.ranks_folder
        except:
            parent_folder = Folder.objects.get(name='Rankingi')
            folder = Folder(name="Rankingi {rok}".format(rok=self.ranks_year), parent=parent_folder)
            folder.save()
            self.ranks_folder = folder

        super(Ranks, self).save(*args, **kwargs)
Exemple #5
0
 def get_plugin_params(self):
     folder = Folder(name='test_plugin', parent=None)
     folder.save()
     return {'folder': folder}
 def get_plugin_params(self):
     folder = Folder(name='test_plugin', parent=None)
     folder.save()
     return {'folder': folder}
Exemple #7
0
 def get_plugin_params(self):
     folder = Folder(name="test_plugin", parent=None)
     folder.save()
     return {"folder": folder}
def generate_filer_folder():
    folder = Folder()
    folder.save()
    return folder
Exemple #9
0
    def save(self, *args, **kwargs):
        folder = Folder(name="Rekordy", parent=None)
        folder.save()
        self.folder = folder

        super(Records, self).save(*args, **kwargs)