# Path: utils.py
# URL_ADVISORIES = 'updates'
# 
# Path: managers.py
# class SkinnyManager(Manager):
#     def get_query_set(self):
#         return SkinnyQuerySet(self.model, using=self._db)


import cpan
import pypi
import pear
import pear2
import nodejs
import github
import rubygems
import packagist
import mavencentral
import os
import sys
import bugs
import utils
from django.db import models
from datetime import datetime
from django.conf import settings
from utils import URL_ADVISORIES
from django.db.models import Manager
from django.contrib.auth.models import User
from managers import SkinnyManager
            db_table = ADVISORY_DB_TABLE

    old = models.ForeignKey(PackageVersion, unique=False, related_name='Old version')
    new = models.ForeignKey(PackageVersion, unique=False, related_name='New version')
#TODO: replace this with a string similarity index based on difflib.SequenceMatcher
# and then reverse utils.which_severity() b/c 100% means no changes, 0% means totally different
# and maybe remove this field altogether and add the data to more.json
    type = models.IntegerField('Change rate %', default=None, null=True, blank=True)
#    type.help_text = "NB: Since 2012-04-20 this holds the change rate %"

    severity = models.IntegerField(choices=SEVERITY_TYPES, default=utils.SEVERITY_UNKNOWN)
#    severity.help_text = "NB: Since 2012-04-20 this is READ-ONLY and based on change rate %"

    status = models.IntegerField(choices=ADVISORY_STATUSES, default=STATUS_NEW, db_index=True)
    assigned_to = models.CharField(blank=True, null=True, max_length=64)

    # when information in DB was generated
    last_updated = models.DateTimeField(null=True, blank=True, db_index=True)

    has_static_page = models.BooleanField(default=False, db_index=True)
    overriden = models.BooleanField(default=False, db_index=True)

    def __unicode__(self):
        return unicode("%s to %s" % (self.old, self.new))

    @classmethod
    def get_full_path_from_string(cls, name, old, new, pk):
        """
            Used internally to avoid DB hits.
        """

# Path: utils.py
# URL_ADVISORIES = 'updates'
# 
# Path: managers.py
# class SkinnyManager(Manager):
#     def get_query_set(self):
#         return SkinnyQuerySet(self.model, using=self._db)


# Path: models.py
import cpan
import pypi
import pear
import pear2
import nodejs
import github
import rubygems
import packagist
import mavencentral
import os
import sys
import bugs
import utils
from django.db import models
from datetime import datetime
from django.conf import settings
from utils import URL_ADVISORIES
from django.db.models import Manager
from django.contrib.auth.models import User
from managers import SkinnyManager

            db_table = ADVISORY_DB_TABLE

    old = models.ForeignKey(PackageVersion, unique=False, related_name='Old version')
    new = models.ForeignKey(PackageVersion, unique=False, related_name='New version')
#TODO: replace this with a string similarity index based on difflib.SequenceMatcher
# and then reverse utils.which_severity() b/c 100% means no changes, 0% means totally different
# and maybe remove this field altogether and add the data to more.json
    type = models.IntegerField('Change rate %', default=None, null=True, blank=True)
#    type.help_text = "NB: Since 2012-04-20 this holds the change rate %"

    severity = models.IntegerField(choices=SEVERITY_TYPES, default=utils.SEVERITY_UNKNOWN)
#    severity.help_text = "NB: Since 2012-04-20 this is READ-ONLY and based on change rate %"

    status = models.IntegerField(choices=ADVISORY_STATUSES, default=STATUS_NEW, db_index=True)
    assigned_to = models.CharField(blank=True, null=True, max_length=64)

    # when information in DB was generated
    last_updated = models.DateTimeField(null=True, blank=True, db_index=True)

    has_static_page = models.BooleanField(default=False, db_index=True)
    overriden = models.BooleanField(default=False, db_index=True)

    def __unicode__(self):
        return unicode("%s to %s" % (self.old, self.new))

    @classmethod
    def get_full_path_from_string(cls, name, old, new, pk):
        """
            Used internally to avoid DB hits.
        """

        return '%s/%s/%s-%s/%s-%s/%d/' % (FQDN, URL_ADVISORIES, name, old, name, new, pk)