Ejemplo n.º 1
0
class XSLFile(models.Model):
    file = models.FileField(
        upload_to=upload_to_journal,
        storage=JanewayFileSystemStorage('files/xsl'))
    journal = models.ForeignKey("journal.Journal", on_delete=models.CASCADE,
                                blank=True, null=True)
    date_uploaded = models.DateTimeField(default=timezone.now)
    label = models.CharField(max_length=255,
        help_text="A label to help recognise this stylesheet",
        unique=True,
    )
    comments = models.TextField(blank=True, null=True)
    original_filename = models.CharField(max_length=255)

    def save(self, *args, **kwargs):
        super().save(*args, **kwargs)

    def __str__(self):
        return "%s(%s@%s)" % (
            self.__class__.__name__, self.label, self.file.path)
Ejemplo n.º 2
0
from django.db import models
from django.conf import settings
from django.core.files.storage import FileSystemStorage
from django.core.files.images import get_image_dimensions
from django.utils import timezone
from django.core.exceptions import ValidationError

from metrics.logic import get_iso_country_code
from utils.shared import get_ip_address
from core import models as core_models
from plugins.books import files
from core.file_system import JanewayFileSystemStorage


fs = JanewayFileSystemStorage()


def cover_images_upload_path(instance, filename):
    try:
        filename = str(uuid.uuid4()) + '.' + str(filename.split('.')[1])
    except IndexError:
        filename = str(uuid.uuid4())

    path = "cover_images/"
    return os.path.join(path, filename)


class BookSetting(models.Model):
    book_page_title = models.CharField(
        max_length=255,