# Path: partners/models.py
# class Partner(models.Model):
# 	
# 	name = models.CharField(max_length=100)
# 	description = models.TextField()
# 	address = models.TextField()
# 	fone = models.CharField(max_length=12)
# 
# 	def save_patners(self, partner_name, partner_description, partner_address, partner_fone):
# 		partner = Partner(name=partner_name, description = partner_description, address = partner_address, fone = partner_fone)
# 		partner.save()
# 		
# 	
# 	def __str__(self):
#                 return self.name


from polymorphic.models import PolymorphicModel
from django.db import models
from partners.models import Partner
    date_danation = models.DateField(auto_now=True)

    def register_equipment(self, name_equipment):
        available = AvailableEquipment()
        available.save()
        self.state = available
        self.equipment_name = name_equipment
        super(Equipment, self).save()

    def start_state(self):
        available = AvailableEquipment()
        available.save()
        self.state = available
        super(Equipment,self).save()

    def fix_equipment(self):
        try:
            previous_state = self.state.fix_equipment()
            (self.state).delete()
            self.state = previous_state
        except TypeError:
            pass

    def borrow_equipment(self, partner):
        try:
            # previous_state = self.state.borrow_equipment()
            # self.state.delete()
            previous_state = self.state.borrow_equipment(partner)
            (self.state).delete()


# Path: partners/models.py
# class Partner(models.Model):
# 	
# 	name = models.CharField(max_length=100)
# 	description = models.TextField()
# 	address = models.TextField()
# 	fone = models.CharField(max_length=12)
# 
# 	def save_patners(self, partner_name, partner_description, partner_address, partner_fone):
# 		partner = Partner(name=partner_name, description = partner_description, address = partner_address, fone = partner_fone)
# 		partner.save()
# 		
# 	
# 	def __str__(self):
#                 return self.name


# Path: equipments/models.py
from polymorphic.models import PolymorphicModel
from django.db import models
from partners.models import Partner

    date_danation = models.DateField(auto_now=True)

    def register_equipment(self, name_equipment):
        available = AvailableEquipment()
        available.save()
        self.state = available
        self.equipment_name = name_equipment
        super(Equipment, self).save()

    def start_state(self):
        available = AvailableEquipment()
        available.save()
        self.state = available
        super(Equipment,self).save()

    def fix_equipment(self):
        try:
            previous_state = self.state.fix_equipment()
            (self.state).delete()
            self.state = previous_state
        except TypeError:
            pass

    def borrow_equipment(self, partner):
        try:
            # previous_state = self.state.borrow_equipment()
            # self.state.delete()
            previous_state = self.state.borrow_equipment(partner)
            (self.state).delete()


            self.state = previous_state