<commit_before>from __future__ import unicode_literals

from django.db import models
from django.utils import timezone

from books.models import *
from vocab.models import *


CATEGORIES = {
    'author': {
        'primary_model': Author,
        'secondary_model': None,
        'icon': 'user',
        'noun': 'an author',
    },
    'book': {
        'primary_model': Book,
        'secondary_model': None,
        'icon': 'book',
        # TODO: differentiate between books & publications
        'noun': 'a book',
    },
    'tag': {
        'primary_model': Tag,
        'secondary_model': None,
        'icon': 'tag',
        'noun': 'a tag',
    },
    'note': {
        'primary_model': Note,
        'secondary_model': Book,
        'icon': 'sticky note',
        'noun': 'a note',
    },
    'section': {
        'primary_model': Section,
        'secondary_model': Book,
        'icon': 'file alternate outline',
        # TODO: differentiate between chapters/articles/webpages?
        'noun': 'a section',
    },
    'note_tag': {
        'primary_model': Note,
        'secondary_model': Tag,
        'icon': 'tags',
        'noun': 'a note tag',
    },
    'term': {
        'primary_model': TermOccurrence,
        'secondary_model': Book,
        'icon': 'flag',  # TODO: this is wrong
        'noun': 'a vocabulary term',
    }
}
CATEGORY_CHOICES = [
    (key, value['noun']) for key, value in CATEGORIES.iteritems()
]
VERB_CHOICES = [
    ('added', 'added'),
    ('edited', 'edited'),
    ('deleted', 'deleted'),
]


class Action(models.Model):
    timestamp = models.DateTimeField(default=timezone.now)
    primary_id = models.IntegerField(blank=True, null=True)
    secondary_id = models.IntegerField(blank=True, null=True)
    category = models.CharField(max_length=10, choices=CATEGORY_CHOICES)
    verb = models.CharField(max_length=10)
    details = models.CharField(max_length=100, blank=True)

    class Meta:
        ordering = ['-timestamp']

    @property
    def display_template(self):
        return 'actions/{}.html'.format(self.category)

    @property<commit_msg>Increase max length of details field on Action<commit_after>from __future__ import unicode_literals

from django.db import models
from django.utils import timezone

from books.models import *
from vocab.models import *


CATEGORIES = {
    'author': {
        'primary_model': Author,
        'secondary_model': None,
        'icon': 'user',
        'noun': 'an author',
    },
    'book': {
        'primary_model': Book,
        'secondary_model': None,
        'icon': 'book',
        # TODO: differentiate between books & publications
        'noun': 'a book',
    },
    'tag': {
        'primary_model': Tag,
        'secondary_model': None,
        'icon': 'tag',
        'noun': 'a tag',
    },
    'note': {
        'primary_model': Note,
        'secondary_model': Book,
        'icon': 'sticky note',
        'noun': 'a note',
    },
    'section': {
        'primary_model': Section,
        'secondary_model': Book,
        'icon': 'file alternate outline',
        # TODO: differentiate between chapters/articles/webpages?
        'noun': 'a section',
    },
    'note_tag': {
        'primary_model': Note,
        'secondary_model': Tag,
        'icon': 'tags',
        'noun': 'a note tag',
    },
    'term': {
        'primary_model': TermOccurrence,
        'secondary_model': Book,
        'icon': 'flag',  # TODO: this is wrong
        'noun': 'a vocabulary term',
    }
}
CATEGORY_CHOICES = [
    (key, value['noun']) for key, value in CATEGORIES.iteritems()
]
VERB_CHOICES = [
    ('added', 'added'),
    ('edited', 'edited'),
    ('deleted', 'deleted'),
]


class Action(models.Model):
    timestamp = models.DateTimeField(default=timezone.now)
    primary_id = models.IntegerField(blank=True, null=True)
    secondary_id = models.IntegerField(blank=True, null=True)
    category = models.CharField(max_length=10, choices=CATEGORY_CHOICES)
    verb = models.CharField(max_length=10)
    details = models.CharField(max_length=255, blank=True)

    class Meta:
        ordering = ['-timestamp']

    @property
    def display_template(self):
        return 'actions/{}.html'.format(self.category)

    @property
{'fraction_non_alphanumeric': 0.145926800472255, 'fraction_numerical': 0.003305785123966942, 'mean_word_length': 2.6081771720613287, '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': '4118451', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1348, 'n_words': 306}