<commit_before>#
# Copyright (c) 2009 <NAME> <<EMAIL>>
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

from django.db import models
from django.contrib.auth.models import User

class Note(models.Model):
    NOTE_PERMISSIONS = (
        (0, 'Private'), (1, 'Public'), 
    )

    guid = models.CharField(max_length=36)

    author = models.ForeignKey(User)

    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)
    user_modified = models.DateTimeField(auto_now_add=True)

    title = models.CharField(max_length=128)
    content = models.TextField(blank=True)
    content_version = models.CharField(max_length=10)

    tags = models.ManyToManyField('NoteTag', null=True, blank=True)
    permissions = models.IntegerField(choices=NOTE_PERMISSIONS,
                                      default=0)

    open_on_startup = models.BooleanField(default=False)

    class Meta:
        get_latest_by = 'user_modified'
        unique_together = ('author', 'title')

    def __unicode__(self):
        return self.title

class NoteTag(models.Model):
    author = models.ForeignKey(User)
    name = models.CharField(max_length=256)
    is_notebook = models.BooleanField(default=False)

    class Meta:
        unique_together = ('author', 'name')

    def __unicode__(self):
        return self.name

    def get_name_for_display(self):
        if self.is_notebook:
            return self.name.split(':', 3)[-1]
        return self.name<commit_msg>Add a unique_together for guids, and split the notebook's name correctly<commit_after>#
# Copyright (c) 2009 <NAME> <<EMAIL>>
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

from django.db import models
from django.contrib.auth.models import User

class Note(models.Model):
    NOTE_PERMISSIONS = (
        (0, 'Private'), (1, 'Public'), 
    )

    guid = models.CharField(max_length=36)

    author = models.ForeignKey(User)

    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)
    user_modified = models.DateTimeField(auto_now_add=True)

    title = models.CharField(max_length=128)
    content = models.TextField(blank=True)
    content_version = models.CharField(max_length=10)

    tags = models.ManyToManyField('NoteTag', null=True, blank=True)
    permissions = models.IntegerField(choices=NOTE_PERMISSIONS,
                                      default=0)

    open_on_startup = models.BooleanField(default=False)

    class Meta:
        get_latest_by = 'user_modified'
        unique_together = (('author', 'title'), ('author', 'guid'), )

    def __unicode__(self):
        return self.title

class NoteTag(models.Model):
    author = models.ForeignKey(User)
    name = models.CharField(max_length=256)
    is_notebook = models.BooleanField(default=False)

    class Meta:
        unique_together = ('author', 'name')

    def __unicode__(self):
        return self.name

    def get_name_for_display(self):
        if self.is_notebook:
            return self.name.split(':', 2)[-1]
        return self.name
{'fraction_non_alphanumeric': 0.09540471191975741, 'fraction_numerical': 0.009330534173081408, 'mean_word_length': 3.466666666666667, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4462907', 'n_tokens_mistral': 1280, 'n_tokens_neox': 1213, 'n_words': 381}