<commit_before># encoding: utf-8
from django.db import models
from allauthdemo.auth.models import DemoUser
from allauthdemo.demo.models import Problem


def user_directory_path(instance, filename):
    # file will be uploaded to MEDIA_ROOT/<problem>/<user_id>_<problem>.<extension>
    extension = filename.split('.')

    if len(extension) != 0:
        extension = extension[-1]
    return '{1}/{1}_user_{0}.{2}'.format(instance.user.id, instance.problem.name, extension)


class Submission(models.Model):
    file = models.FileField(upload_to=user_directory_path)
    slug = models.SlugField(max_length=50, blank=True)
    url = models.CharField(max_length=200, null=True, blank=True)
    user = models.ForeignKey(DemoUser, null=True)
    problem = models.ForeignKey(Problem, null=True)<commit_msg>Add a random hash to the filenam #19<commit_after># encoding: utf-8
from django.db import models
from allauthdemo.auth.models import DemoUser
from allauthdemo.demo.models import Problem
import os
import binascii


def user_directory_path(instance, filename):
    # file will be uploaded to MEDIA_ROOT/<problem>/<user_id>_<problem>.<extension>
    extension = filename.split('.')

    if len(extension) != 0:
        extension = extension[-1]

    random_part = str(binascii.hexlify(os.urandom(16)))[2:-1]
    return '{1}/{1}_user_{0}_{3}.{2}'.format(instance.user.id, instance.problem.name, extension, random_part)


class Submission(models.Model):
    file = models.FileField(upload_to=user_directory_path)
    slug = models.SlugField(max_length=50, blank=True)
    url = models.CharField(max_length=200, null=True, blank=True)
    user = models.ForeignKey(DemoUser, null=True)
    problem = models.ForeignKey(Problem, null=True)
{'fraction_non_alphanumeric': 0.1265164644714038, 'fraction_numerical': 0.017908723281340265, 'mean_word_length': 4.931506849315069, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '6918669', 'n_tokens_mistral': 584, 'n_tokens_neox': 551, 'n_words': 117}