<commit_before>from __future__ import unicode_literals

import uuid
from django.db import models
from django.contrib.auth.models import User
from simple_history.models import HistoricalRecords

class APIUserManager(models.Manager):
    """
    Manager to return API users - those with API keys
    """
    def get_queryset(self):
        return super(APIUserManager, self).get_queryset().exclude(api_key__isnull=True)


class DukeDSUser(models.Model):
    """
    Represents a DukeDS user. Keeps track of their API key. The API key
    is used when the corresponding user invokes an action that requires
    communication with DukeDS (e.g. mailing a draft or performing handover)

    """
    user = models.OneToOneField(User, on_delete=models.CASCADE, null=True)
    dds_id = models.CharField(max_length=36, null=False, unique=True)
    api_key = models.CharField(max_length=36, null=True, unique=True)
    full_name = models.TextField(null=True)
    email = models.EmailField(null=True)

    objects = models.Manager()
    api_users = APIUserManager()

    def populated(self):
        if self.full_name and self.email:
            return True
        else:
            return False

    def __str__(self):
        return 'DukeDSUser <{}>'.format(self.dds_id)

class DukeDSProject(models.Model):
    project_id = models.CharField(max_length=36, null=False, unique=True)
    name = models.TextField(null=True)

    def populated(self):
        # Only field to populate is name
        return bool(self.name)


class State(object):
    """
    States for handover and draft objects
    """
    NEW = 0
    NOTIFIED = 1<commit_msg>Cleanup __str__ methods for DukeDSUser/DukeDSProject<commit_after>from __future__ import unicode_literals

import uuid
from django.db import models
from django.contrib.auth.models import User
from simple_history.models import HistoricalRecords

class APIUserManager(models.Manager):
    """
    Manager to return API users - those with API keys
    """
    def get_queryset(self):
        return super(APIUserManager, self).get_queryset().exclude(api_key__isnull=True)


class DukeDSUser(models.Model):
    """
    Represents a DukeDS user. Keeps track of their API key. The API key
    is used when the corresponding user invokes an action that requires
    communication with DukeDS (e.g. mailing a draft or performing handover)

    """
    user = models.OneToOneField(User, on_delete=models.CASCADE, null=True)
    dds_id = models.CharField(max_length=36, null=False, unique=True)
    api_key = models.CharField(max_length=36, null=True, unique=True)
    full_name = models.TextField(null=True)
    email = models.EmailField(null=True)

    objects = models.Manager()
    api_users = APIUserManager()

    def populated(self):
        if self.full_name and self.email:
            return True
        else:
            return False

    def __str__(self):
        return "{} - {} - {}".format(self.dds_id, self.email, self.full_name,)


class DukeDSProject(models.Model):
    project_id = models.CharField(max_length=36, null=False, unique=True)
    name = models.TextField(null=True)

    def populated(self):
        # Only field to populate is name
        return bool(self.name)

    def __str__(self):
        return "{} - {}".format(self.project_id, self.name,)


class State(object):
    """
    States for handover and draft objects
    """
    NEW = 0
    NOTIFIED = 1
{'fraction_non_alphanumeric': 0.09469363822925828, 'fraction_numerical': 0.004690706537672237, 'mean_word_length': 3.363171355498721, 'pattern_counts': {'":': 0, '<': 4, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6474081', 'n_tokens_mistral': 1045, 'n_tokens_neox': 1004, 'n_words': 281}