<commit_before># -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.conf import settings
from django.db import models
from markdownx.models import MarkdownxField
from datetime import datetime
from django.db.models.signals import post_save, pre_save
from django.dispatch import receiver
from util.img_util import scale_img

# Create your models here.

class NsRelease(models.Model):
    name = models.CharField(max_length=4)
    url = models.URLField(default="https://www.nsnam.org/ns-3.26/")

    def __str__(self):
        return u'%s-%s' % ("ns", self.name)

    class Meta:
        ordering = ['-name']

class Tag(models.Model):
    identity = models.CharField(max_length=127, editable=False)
    name = models.CharField(max_length=127)

    def __str__(self):
        return self.name

    def get_tag_name(self):
        return self.name

class App(models.Model):
    TYPES = [ ('F', 'Fork'),
              ('M', 'Module'),
            ] 
    name = models.CharField(max_length=127, unique=True)
    title = models.CharField(max_length=127, unique=True)
    app_type = models.CharField(max_length=6, choices=TYPES)
    abstract = models.CharField(max_length=255, default="NA")
    description = MarkdownxField()
    icon = models.ImageField(upload_to='app_icon_thumbnail/%Y-%m-%d/', blank=True)
    tags = models.ManyToManyField(Tag, blank=True)
    editors = models.ManyToManyField(settings.AUTH_USER_MODEL)
    latest_release_date = models.DateField(auto_now_add=True)
    website = models.URLField(blank=True, null=True)
    documentation = models.URLField(blank=True, null=True)
    coderepo = models.URLField(blank=True, null=True)
    contact = models.EmailField(blank=True, null=True)
    active = models.BooleanField(default=False)
    stars = models.PositiveIntegerField(default=0)
    votes = models.PositiveIntegerField(default=0)
    downloads = models.PositiveIntegerField(default=0)
    has_releases = models.BooleanField(default=False)
    issue = models.URLField(blank=True, null=True)
    mailing_list = models.URLField(blank=True, null=True)

    def __str__(self):
        return self.title

    @property
    def stars_percentage(self):
        return 100 * self.stars / self.votes / 5 if self.votes != 0 else 0

    def update_latest_release_date(self):
        self.latest_release_date = (Release.objects.filter(app=self).latest('date')).date
        self.save()

class Release(models.Model):
    app = models.ForeignKey(App)
    version = models.CharField(max_length=31)
    require = models.ForeignKey(NsRelease, null=True)
    date = models.DateField(default=datetime.now, blank=True)
    notes = MarkdownxField()
    filename = models.FileField(upload_to='release_files/', blank=True, null=True)
    url = models.URLField(blank=True, null=True)

    def __str__(self):
        return '%s %s' % (self.app.title, self.version)

class Comment(models.Model):
    app = models.ForeignKey(App)
    user = models.ForeignKey(settings.AUTH_USER_MODEL)
    title = models.CharField(max_length=50)
    content = MarkdownxField()
    timestamp = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return 'Comment on %s by %s' % (self.app.title, self.user.get_full_name)

class CommentReply(models.Model):
    comment = models.ForeignKey(Comment)
    user = models.ForeignKey(settings.AUTH_USER_MODEL)
    content = MarkdownxField()
    timestamp = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return 'Reply to %s' % (self.comment)
<commit_msg>Adding blank=True as well for require field in Release model<commit_after># -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.conf import settings
from django.db import models
from markdownx.models import MarkdownxField
from datetime import datetime
from django.db.models.signals import post_save, pre_save
from django.dispatch import receiver
from util.img_util import scale_img

# Create your models here.

class NsRelease(models.Model):
    name = models.CharField(max_length=4)
    url = models.URLField(default="https://www.nsnam.org/ns-3.26/")

    def __str__(self):
        return u'%s-%s' % ("ns", self.name)

    class Meta:
        ordering = ['-name']

class Tag(models.Model):
    identity = models.CharField(max_length=127, editable=False)
    name = models.CharField(max_length=127)

    def __str__(self):
        return self.name

    def get_tag_name(self):
        return self.name

class App(models.Model):
    TYPES = [ ('F', 'Fork'),
              ('M', 'Module'),
            ] 
    name = models.CharField(max_length=127, unique=True)
    title = models.CharField(max_length=127, unique=True)
    app_type = models.CharField(max_length=6, choices=TYPES)
    abstract = models.CharField(max_length=255, default="NA")
    description = MarkdownxField()
    icon = models.ImageField(upload_to='app_icon_thumbnail/%Y-%m-%d/', blank=True)
    tags = models.ManyToManyField(Tag, blank=True)
    editors = models.ManyToManyField(settings.AUTH_USER_MODEL)
    latest_release_date = models.DateField(auto_now_add=True)
    website = models.URLField(blank=True, null=True)
    documentation = models.URLField(blank=True, null=True)
    coderepo = models.URLField(blank=True, null=True)
    contact = models.EmailField(blank=True, null=True)
    active = models.BooleanField(default=False)
    stars = models.PositiveIntegerField(default=0)
    votes = models.PositiveIntegerField(default=0)
    downloads = models.PositiveIntegerField(default=0)
    has_releases = models.BooleanField(default=False)
    issue = models.URLField(blank=True, null=True)
    mailing_list = models.URLField(blank=True, null=True)

    def __str__(self):
        return self.title

    @property
    def stars_percentage(self):
        return 100 * self.stars / self.votes / 5 if self.votes != 0 else 0

    def update_latest_release_date(self):
        self.latest_release_date = (Release.objects.filter(app=self).latest('date')).date
        self.save()

class Release(models.Model):
    app = models.ForeignKey(App)
    version = models.CharField(max_length=31)
    require = models.ForeignKey(NsRelease, blank=True, null=True)
    date = models.DateField(default=datetime.now, blank=True)
    notes = MarkdownxField()
    filename = models.FileField(upload_to='release_files/', blank=True, null=True)
    url = models.URLField(blank=True, null=True)

    def __str__(self):
        return '%s %s' % (self.app.title, self.version)

class Comment(models.Model):
    app = models.ForeignKey(App)
    user = models.ForeignKey(settings.AUTH_USER_MODEL)
    title = models.CharField(max_length=50)
    content = MarkdownxField()
    timestamp = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return 'Comment on %s by %s' % (self.app.title, self.user.get_full_name)

class CommentReply(models.Model):
    comment = models.ForeignKey(Comment)
    user = models.ForeignKey(settings.AUTH_USER_MODEL)
    content = MarkdownxField()
    timestamp = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return 'Reply to %s' % (self.comment)

{'fraction_non_alphanumeric': 0.11859649122807017, 'fraction_numerical': 0.009543859649122808, 'mean_word_length': 3.9589422407794017, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2440415', 'n_tokens_mistral': 2311, 'n_tokens_neox': 2241, 'n_words': 448}