<commit_before># This file is part of the FragDev Website.
# 
# the FragDev Website is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# the FragDev Website is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with the FragDev Website.  If not, see <http://www.gnu.org/licenses/>.

# This file is part of FragDev.
#
# FragDev is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# FragDev is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with FragDev.  If not, see <http://www.gnu.org/licenses/>.

from django.db import models
from django.utils.text import slugify
from imghdr import what


class Image(models.Model):
    '''
    Represents a single uploaded image
    '''
    title = models.CharField(max_length=250)
    desc = models.TextField()
    date = models.DateTimeField(auto_now_add=True)
    imgFile = models.FileField(upload_to='img/')
    slug = models.SlugField()
    content_type = models.CharField(max_length=30)

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

        # Create a slug for this image
        if not self.id and self.slug is '':
            self.slug = slugify(self.title)

        # Generate different versions
        # TODO

        # Save the content type (required for headers later)
        self.content_type = what(self.imgFile)

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


    def get_absolute_url(self):
        return self.imgFile.url

    def __str__(self):
        return self.title<commit_msg>Add [blank,null]=True to Image model to prevent errors in bulk creation of image<commit_after># This file is part of the FragDev Website.
# 
# the FragDev Website is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# the FragDev Website is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with the FragDev Website.  If not, see <http://www.gnu.org/licenses/>.

# This file is part of FragDev.
#
# FragDev is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# FragDev is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with FragDev.  If not, see <http://www.gnu.org/licenses/>.

from django.db import models
from django.utils.text import slugify
from imghdr import what


class Image(models.Model):
    '''
    Represents a single uploaded image
    '''
    title = models.CharField(max_length=250)
    desc = models.TextField()
    date = models.DateTimeField(auto_now_add=True)
    imgFile = models.FileField(upload_to='img/')
    slug = models.SlugField()
    content_type = models.CharField(max_length=30,
            blank=True,
            null=True)

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

        # Create a slug for this image
        if not self.id and self.slug is '':
            self.slug = slugify(self.title)

        # Generate different versions
        # TODO

        # Save the content type (required for headers later)
        self.content_type = what(self.imgFile)

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


    def get_absolute_url(self):
        return self.imgFile.url

    def __str__(self):
        return self.title
{'fraction_non_alphanumeric': 0.07390202702702703, 'fraction_numerical': 0.0029560810810810812, 'mean_word_length': 3.3418881759853347, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7101912', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1269, 'n_words': 587}