<commit_before>from django.db import models

from ..magic import MisencodedCharField, MisencodedTextField
from .users import UserProfile

class Phorum(models.Model):
    nickname = MisencodedCharField(max_length=64)
    email = MisencodedTextField(blank=True, null=True)
    datum = models.DateTimeField(auto_now_add=True)
    text = MisencodedTextField()
    # stands for 'registered', contains either '1' or IP address
    reg = MisencodedCharField(max_length=50)
    reputace = models.IntegerField()
    user = models.ForeignKey(UserProfile, on_delete=models.SET_NULL, blank=True, null=True)

    class Meta:
        db_table = 'forum'

    @property
    def user_profile_url(self):
        if self.user:
            return self.user.profile_url
        else:
            return None

    @property
    def by_registered_user(self):
        return self.reg == '1'<commit_msg>fix: Be more defensive for user link before complete migration (fixes #130)<commit_after>from django.db import models

from ..magic import MisencodedCharField, MisencodedTextField
from .users import UserProfile

class Phorum(models.Model):
    nickname = MisencodedCharField(max_length=64)
    email = MisencodedTextField(blank=True, null=True)
    datum = models.DateTimeField(auto_now_add=True)
    text = MisencodedTextField()
    # stands for 'registered', contains either '1' or IP address
    reg = MisencodedCharField(max_length=50)
    reputace = models.IntegerField()
    user = models.ForeignKey(UserProfile, on_delete=models.SET_NULL, blank=True, null=True)

    class Meta:
        db_table = 'forum'

    @property
    def user_profile_url(self):
        if self.user:
            return self.user.profile_url
        else:
            return None

    @property
    def by_registered_user(self):
        return self.reg == '1' and self.user
{'fraction_non_alphanumeric': 0.08679039301310043, 'fraction_numerical': 0.008187772925764192, 'mean_word_length': 3.4816625916870416, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3602945', 'n_tokens_mistral': 549, 'n_tokens_neox': 529, 'n_words': 136}