from django.db import models


class Idea(models.Model):
    title = models.CharField(max_length=255, unique=True)
    description = models.TextField()
    author = models.OneToOneField('events.Registrant',
                                  related_name='author_idea',
                                  on_delete=models.CASCADE,
                                  blank=True,
                                  null=True)
    written_by = models.ForeignKey('users.User',
                                   related_name='written_idea',
                                   on_delete=models.CASCADE,
                                   blank=True,
                                   null=True)
    event = models.ForeignKey('events.Event',
                              related_name='event_idea',
                              on_delete=models.CASCADE,
                              blank=True,
                              null=True)
    is_valid = models.BooleanField(default=False)
    max_number_of_participants = models.PositiveIntegerField(default=7)
    created_at = models.DateTimeField(auto_now_add=True)
    modified_at = models.DateTimeField(auto_now=True)
    is_active = models.BooleanField(default=True)

    class Meta():
        ordering = ['-created_at', '-id']

    def __str__(self):
        return self.title


class IdeaTeamMember(models.Model):
    idea = models.ForeignKey(Idea, related_name='idea_team_member', on_delete=models.CASCADE)
    member = models.OneToOneField('events.Registrant', related_name='member_idea', on_delete=models.CASCADE)

    class Meta():
        ordering = ['idea']
        unique_together = ('idea', 'member')
        verbose_name = 'Team Member'
        verbose_name_plural = 'Groups'

[(5, 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(255)', 'unique': '(True)'}), False, 'from django.db import models\n'), (6, 'django.db.models.TextField', 'models.TextField', ([], {}), False, 'from django.db import models\n'), (7, 'django.db.models.OneToOneField', 'models.OneToOneField', (['"""events.Registrant"""'], {'related_name': '"""author_idea"""', 'on_delete': 'models.CASCADE', 'blank': '(True)', 'null': '(True)'}), False, 'from django.db import models\n'), (12, 'django.db.models.ForeignKey', 'models.ForeignKey', (['"""users.User"""'], {'related_name': '"""written_idea"""', 'on_delete': 'models.CASCADE', 'blank': '(True)', 'null': '(True)'}), False, 'from django.db import models\n'), (17, 'django.db.models.ForeignKey', 'models.ForeignKey', (['"""events.Event"""'], {'related_name': '"""event_idea"""', 'on_delete': 'models.CASCADE', 'blank': '(True)', 'null': '(True)'}), False, 'from django.db import models\n'), (22, 'django.db.models.BooleanField', 'models.BooleanField', ([], {'default': '(False)'}), False, 'from django.db import models\n'), (23, 'django.db.models.PositiveIntegerField', 'models.PositiveIntegerField', ([], {'default': '(7)'}), False, 'from django.db import models\n'), (24, 'django.db.models.DateTimeField', 'models.DateTimeField', ([], {'auto_now_add': '(True)'}), False, 'from django.db import models\n'), (25, 'django.db.models.DateTimeField', 'models.DateTimeField', ([], {'auto_now': '(True)'}), False, 'from django.db import models\n'), (26, 'django.db.models.BooleanField', 'models.BooleanField', ([], {'default': '(True)'}), False, 'from django.db import models\n'), (36, 'django.db.models.ForeignKey', 'models.ForeignKey', (['Idea'], {'related_name': '"""idea_team_member"""', 'on_delete': 'models.CASCADE'}), False, 'from django.db import models\n'), (37, 'django.db.models.OneToOneField', 'models.OneToOneField', (['"""events.Registrant"""'], {'related_name': '"""member_idea"""', 'on_delete': 'models.CASCADE'}), False, 'from django.db import models\n')]