from django.contrib.auth.models import User
from django.db import models

from wrestlers.models import WrestlingEntity


class Review(models.Model):

    reviewed_by = models.ForeignKey(User)
    reviewed_at = models.DateTimeField()

    class Meta:
        abstract = True


class Card(models.Model):

    date = models.DateField()

    def __unicode__(self):
        return unicode(self.date)


class Match(Review):

    card = models.ForeignKey(Card)
    participants = models.ManyToManyField(WrestlingEntity)
    winner = models.ForeignKey(WrestlingEntity, related_name="won_matches",
                               null=True, blank=True)

    def __unicode__(self):
        return " vs. ".join([p.name for p in self.participants.all()])

from django.contrib.auth.models import User
from django.db import models

from promotions.models import Promotion
from wrestlers.models import WrestlingEntity


class Review(models.Model):

    reviewed_by = models.ForeignKey(User)
    reviewed_at = models.DateTimeField()

    class Meta:
        abstract = True


class Card(models.Model):

    date = models.DateField()
    promotion = models.ForeignKey(Promotion)

    name = models.CharField(max_length=127, null=True, blank=True)

    def __unicode__(self):
        return unicode(self.date)


class Match(Review):

    card = models.ForeignKey(Card)
    participants = models.ManyToManyField(WrestlingEntity)
    winner = models.ForeignKey(WrestlingEntity, related_name="won_matches",
                               null=True, blank=True)

    def __unicode__(self):
        return " vs. ".join([p.name for p in self.participants.all()])

Add name and promotion to Card.
Add name and promotion to Card.

  from django.contrib.auth.models import User
  from django.db import models
  
+ from promotions.models import Promotion
  from wrestlers.models import WrestlingEntity
  
  
  class Review(models.Model):
  
      reviewed_by = models.ForeignKey(User)
      reviewed_at = models.DateTimeField()
  
      class Meta:
          abstract = True
  
  
  class Card(models.Model):
  
      date = models.DateField()
+     promotion = models.ForeignKey(Promotion)
+ 
+     name = models.CharField(max_length=127, null=True, blank=True)
  
      def __unicode__(self):
          return unicode(self.date)
  
  
  class Match(Review):
  
      card = models.ForeignKey(Card)
      participants = models.ManyToManyField(WrestlingEntity)
      winner = models.ForeignKey(WrestlingEntity, related_name="won_matches",
                                 null=True, blank=True)
  
      def __unicode__(self):
          return " vs. ".join([p.name for p in self.participants.all()])
  
Add name and promotion to Card.
## Code Before:
from django.contrib.auth.models import User
from django.db import models

from wrestlers.models import WrestlingEntity


class Review(models.Model):

    reviewed_by = models.ForeignKey(User)
    reviewed_at = models.DateTimeField()

    class Meta:
        abstract = True


class Card(models.Model):

    date = models.DateField()

    def __unicode__(self):
        return unicode(self.date)


class Match(Review):

    card = models.ForeignKey(Card)
    participants = models.ManyToManyField(WrestlingEntity)
    winner = models.ForeignKey(WrestlingEntity, related_name="won_matches",
                               null=True, blank=True)

    def __unicode__(self):
        return " vs. ".join([p.name for p in self.participants.all()])

## Instruction:
Add name and promotion to Card.
## Code After:
from django.contrib.auth.models import User
from django.db import models

from promotions.models import Promotion
from wrestlers.models import WrestlingEntity


class Review(models.Model):

    reviewed_by = models.ForeignKey(User)
    reviewed_at = models.DateTimeField()

    class Meta:
        abstract = True


class Card(models.Model):

    date = models.DateField()
    promotion = models.ForeignKey(Promotion)

    name = models.CharField(max_length=127, null=True, blank=True)

    def __unicode__(self):
        return unicode(self.date)


class Match(Review):

    card = models.ForeignKey(Card)
    participants = models.ManyToManyField(WrestlingEntity)
    winner = models.ForeignKey(WrestlingEntity, related_name="won_matches",
                               null=True, blank=True)

    def __unicode__(self):
        return " vs. ".join([p.name for p in self.participants.all()])
