<commit_before>from Crypto.Random.random import randint
from django.contrib.auth.models import User
from django.db import models
from django.db.models.deletion import SET_NULL

from phase0.models import Text


class Team(models.Model):
    user = models.OneToOneField(to=User, blank=True, related_name='team')
    name = models.CharField(max_length=50)
    votes = models.IntegerField(default=0)
    text = models.ForeignKey(to='phase0.Text', null=True, blank=True, related_name='teams',
                             on_delete=SET_NULL)

    def generate_password(self):
        return "_".join([str(member.student_id) for member in self.members.all()])

    def add_text(self):
        texts = Text.objects.count()
        self.text = Text.objects.all()[randint(0, texts-1)]

    def save(self, *args, **kwargs):
        if self.id is None:
            count = 0
            last_team = Team.objects.last()
            if last_team:
                count = last_team.pk
            self.user = User.objects.create_user(username='team' + str(count+1),
                                                 password='')

        if not self.text:
            self.add_text()
        super().save(*args, **kwargs)<commit_msg>another bug:D<commit_after>from Crypto.Random.random import randint
from django.contrib.auth.models import User
from django.db import models
from django.db.models.deletion import SET_NULL

from phase0.models import Text


class Team(models.Model):
    user = models.OneToOneField(to=User, blank=True, related_name='team')
    name = models.CharField(max_length=50)
    votes = models.IntegerField(default=0)
    text = models.ForeignKey(to='phase0.Text', null=True, blank=True, related_name='teams',
                             on_delete=SET_NULL)

    def generate_password(self):
        return "_".join([str(member.student_id) for member in self.members.all()])

    def add_text(self):
        texts = Text.objects.count()
        if texts > 0:
            self.text = Text.objects.all()[randint(0, texts-1)]

    def save(self, *args, **kwargs):
        if self.id is None:
            count = 0
            last_team = Team.objects.last()
            if last_team:
                count = last_team.pk
            self.user = User.objects.create_user(username='team' + str(count+1),
                                                 password='')

        if not self.text:
            self.add_text()
        super().save(*args, **kwargs)
{'fraction_non_alphanumeric': 0.1173842404549147, 'fraction_numerical': 0.007717303005686434, 'mean_word_length': 2.33739837398374, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7342691', 'n_tokens_mistral': 727, 'n_tokens_neox': 709, 'n_words': 157}