<commit_before># -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from util.models import BaseModel
from django.db import models
from django.utils.translation import ugettext_lazy as _
from physical.models import Environment
from django_extensions.db.fields.encrypted import EncryptedCharField



class IntegrationType(BaseModel):
    CLOUDSTACK = 1
    NFSAAS = 2
    
    INTEGRATION_CHOICES = (
        (CLOUDSTACK, 'Cloud Stack'),
        (NFSAAS, 'NFS as a Service'),
    )
    name = models.CharField(verbose_name=_("Offering ID"),
                                         max_length=100,
                                         help_text="Integration Name")
    type = models.IntegerField(choices=INTEGRATION_CHOICES,
                                default=0)

    class Meta:
        permissions = (
            ("view_integrationtype", "Can view integration type."),
        )
    

class IntegrationCredential(BaseModel):

    user = models.CharField(verbose_name=_("User."),
                            max_length=100,
                            help_text=_("User used to authenticate."),
                            blank=False,
                            null=False)
    password = EncryptedCharField(verbose_name=_("Password"), max_length=255, blank=True, null=False)
    integration_type = models.ForeignKey(IntegrationType, related_name="integration_type", on_delete=models.PROTECT)
    token = models.CharField(verbose_name=_("Authentication Token"),
                            max_length=255,
                            blank=True,
                            null=True)
    secret = EncryptedCharField(verbose_name=_("Token"), max_length=255, blank=True, null=False)
    endpoint = models.CharField(verbose_name=_("Endpoint"),
                            max_length=255,
                            help_text=_("Usually it is in the form host:port. Authentication endpoint."),
                            blank=True,
                            null=True)
    environments = models.ManyToManyField(Environment)

    def __unicode__(self):
        return "%s (integration_type=%s)" % (self.user, self.integration_type)

    class Meta:
        permissions = (
            ("view_integrationcredential", "Can view integration credential."),
        )
<commit_msg>Add simple audit to models<commit_after># -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from util.models import BaseModel
from django.db import models
from django.utils.translation import ugettext_lazy as _
from physical.models import Environment
import logging
import simple_audit
from django_extensions.db.fields.encrypted import EncryptedCharField



class IntegrationType(BaseModel):
    CLOUDSTACK = 1
    NFSAAS = 2
    
    INTEGRATION_CHOICES = (
        (CLOUDSTACK, 'Cloud Stack'),
        (NFSAAS, 'NFS as a Service'),
    )
    name = models.CharField(verbose_name=_("Offering ID"),
                                         max_length=100,
                                         help_text="Integration Name")
    type = models.IntegerField(choices=INTEGRATION_CHOICES,
                                default=0)

    class Meta:
        permissions = (
            ("view_integrationtype", "Can view integration type."),
        )
    

class IntegrationCredential(BaseModel):

    user = models.CharField(verbose_name=_("User."),
                            max_length=100,
                            help_text=_("User used to authenticate."),
                            blank=False,
                            null=False)
    password = EncryptedCharField(verbose_name=_("Password"), max_length=255, blank=True, null=False)
    integration_type = models.ForeignKey(IntegrationType, related_name="integration_type", on_delete=models.PROTECT)
    token = models.CharField(verbose_name=_("Authentication Token"),
                            max_length=255,
                            blank=True,
                            null=True)
    secret = EncryptedCharField(verbose_name=_("Token"), max_length=255, blank=True, null=False)
    endpoint = models.CharField(verbose_name=_("Endpoint"),
                            max_length=255,
                            help_text=_("Usually it is in the form host:port. Authentication endpoint."),
                            blank=True,
                            null=True)
    environments = models.ManyToManyField(Environment)

    def __unicode__(self):
        return "%s (integration_type=%s)" % (self.user, self.integration_type)

    class Meta:
        permissions = (
            ("view_integrationcredential", "Can view integration credential."),
        )


simple_audit.register(IntegrationCredential, IntegrationType)
{'fraction_non_alphanumeric': 0.09065991988193127, 'fraction_numerical': 0.009276829011174362, 'mean_word_length': 2.094585779517286, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4028653', 'n_tokens_mistral': 1258, 'n_tokens_neox': 1209, 'n_words': 256}