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


class Application(models.Model):

    name = models.CharField(unique=True)
    alias = models.CharField(blank=True, default='')
    svn_path = models.CharField()
    project_path = models.CharField()
    wsgi_handler = models.CharField()

    def __unicode__(self):
        if self.alias:
            return unicode("{}({})".format(self.alias,
                                           self.name))
        else:
            return self.name


class Server(models.Model):

    is_active = models.BooleanField(default=True)


class Environment(models.Model):

    application = models.ForeignKey(Application)
    key = models.CharField()
    value = models.TextField()


class Relationship(models.Model):

    application = models.ForeignKey(Application)
    server = models.ForeignKey(Server)
    is_active = models.BooleanField(default=True)
    date_created = models.DateTimeField(default=timezone.now())
    date_deprecated = models.DateTimeField(null=True)

    def __unicode__(self):
        if self.is_active:
            state = 'ACTIVE'
        else:
            state = 'INACTIVE'

        return unicode("[{}] {}@{}".format(state,
                                           self.application,
                                           self.server))

@@ -539,47 +539,235 @@
     
-is_active = models.BooleanField(default
+host_name = models.CharField(unique=True)%0A    is_active = models.BooleanField(default=True)%0A    category = models.CharField(choices=(%0A        ('WebSvr', 'web'),%0A        ('AppSvr', 'app'),%0A    ))%0A    url = models.URLField(unique
 =Tru

update empress server model