<commit_before>from django.conf import settings
from django.db import models
from django.core.files.storage import FileSystemStorage

from django_extensions.db.models import TimeStampedModel, TitleSlugDescriptionModel

from core.fields import DeletingFileField

def get_map_file_path(obj, filename):
    return "stacks/{0}/{1}.map".format(obj.user.username, obj.slug)

class Stack(TimeStampedModel, TitleSlugDescriptionModel):


    user = models.ForeignKey(settings.AUTH_USER_MODEL, 
                             null=True, 
                             blank=True, 
                             related_name='stacks')

    map_file = DeletingFileField(
        max_length=255, 
        upload_to=get_map_file_path,
        null=True,
        blank=True,
        default=None,
        storage=FileSystemStorage(location=settings.FILE_STORAGE_DIRECTORY))

    def __unicode__(self):
        return self.title


class Role(TimeStampedModel, TitleSlugDescriptionModel):


    role_name = models.CharField(max_length=64)
    
    
class StackMetdata(TimeStampedModel, TitleSlugDescriptionModel):


    stack = models.ForeignKey(Stack, null=True, blank=True, related_name='metadata')
    role = models.ForeignKey(Role, null=True, blank=True)
    instance_count = models.IntegerField(default=0)
    host_pattern = models.CharField(max_length=32)


class Host(TimeStampedModel, TitleSlugDescriptionModel):


    stack = models.ForeignKey(Stack, null=True, blank=True, related_name='hosts')
    role = models.ForeignKey(Role, null=True, blank=True, related_name='hosts')

<commit_msg>PI-27: Merge<commit_after>from django.conf import settings
from django.db import models
from django.core.files.storage import FileSystemStorage

from django_extensions.db.models import TimeStampedModel, TitleSlugDescriptionModel

from core.fields import DeletingFileField

def get_map_file_path(obj, filename):
    return "stacks/{0}/{1}.map".format(obj.user.username, obj.slug)

class Stack(TimeStampedModel, TitleSlugDescriptionModel):


    user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='stacks')

    map_file = DeletingFileField(
        max_length=255, 
        upload_to=get_map_file_path,
        null=True,
        blank=True,
        default=None,
        storage=FileSystemStorage(location=settings.FILE_STORAGE_DIRECTORY))

    def __unicode__(self):
        return self.title


class Role(TimeStampedModel, TitleSlugDescriptionModel):


    role_name = models.CharField(max_length=64)
    
    
class StackMetdata(TimeStampedModel, TitleSlugDescriptionModel):


    stack = models.ForeignKey(Stack, related_name='metadata')
    role = models.ForeignKey(Role)
    instance_count = models.IntegerField(default=0)
    host_pattern = models.CharField(max_length=32)


class Host(TimeStampedModel, TitleSlugDescriptionModel):


    stack = models.ForeignKey(Stack, related_name='hosts')
    role = models.ForeignKey(Role, related_name='hosts')


{'fraction_non_alphanumeric': 0.09023066485753053, 'fraction_numerical': 0.007462686567164179, 'mean_word_length': 4.128695652173913, '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': '5799898', 'n_tokens_mistral': 903, 'n_tokens_neox': 859, 'n_words': 153}