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'

[((69, 114), 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(255)', 'unique': '(True)'}), '(max_length=255, unique=True)\n', (85, 114), False, 'from django.db import models\n'), ((133, 151), 'django.db.models.TextField', 'models.TextField', ([], {}), '()\n', (149, 151), False, 'from django.db import models\n'), ((165, 287), 'django.db.models.OneToOneField', 'models.OneToOneField', (['"""events.Registrant"""'], {'related_name': '"""author_idea"""', 'on_delete': 'models.CASCADE', 'blank': '(True)', 'null': '(True)'}), "('events.Registrant', related_name='author_idea',\n    on_delete=models.CASCADE, blank=True, null=True)\n", (185, 287), False, 'from django.db import models\n'), ((437, 551), 'django.db.models.ForeignKey', 'models.ForeignKey', (['"""users.User"""'], {'related_name': '"""written_idea"""', 'on_delete': 'models.CASCADE', 'blank': '(True)', 'null': '(True)'}), "('users.User', related_name='written_idea', on_delete=\n    models.CASCADE, blank=True, null=True)\n", (454, 551), False, 'from django.db import models\n'), ((699, 813), 'django.db.models.ForeignKey', 'models.ForeignKey', (['"""events.Event"""'], {'related_name': '"""event_idea"""', 'on_delete': 'models.CASCADE', 'blank': '(True)', 'null': '(True)'}), "('events.Event', related_name='event_idea', on_delete=\n    models.CASCADE, blank=True, null=True)\n", (716, 813), False, 'from django.db import models\n'), ((944, 978), 'django.db.models.BooleanField', 'models.BooleanField', ([], {'default': '(False)'}), '(default=False)\n', (963, 978), False, 'from django.db import models\n'), ((1012, 1050), 'django.db.models.PositiveIntegerField', 'models.PositiveIntegerField', ([], {'default': '(7)'}), '(default=7)\n', (1039, 1050), False, 'from django.db import models\n'), ((1068, 1107), 'django.db.models.DateTimeField', 'models.DateTimeField', ([], {'auto_now_add': '(True)'}), '(auto_now_add=True)\n', (1088, 1107), False, 'from django.db import models\n'), ((1126, 1161), 'django.db.models.DateTimeField', 'models.DateTimeField', ([], {'auto_now': '(True)'}), '(auto_now=True)\n', (1146, 1161), False, 'from django.db import models\n'), ((1178, 1211), 'django.db.models.BooleanField', 'models.BooleanField', ([], {'default': '(True)'}), '(default=True)\n', (1197, 1211), False, 'from django.db import models\n'), ((1372, 1459), 'django.db.models.ForeignKey', 'models.ForeignKey', (['Idea'], {'related_name': '"""idea_team_member"""', 'on_delete': 'models.CASCADE'}), "(Idea, related_name='idea_team_member', on_delete=models.\n    CASCADE)\n", (1389, 1459), False, 'from django.db import models\n'), ((1468, 1567), 'django.db.models.OneToOneField', 'models.OneToOneField', (['"""events.Registrant"""'], {'related_name': '"""member_idea"""', 'on_delete': 'models.CASCADE'}), "('events.Registrant', related_name='member_idea',\n    on_delete=models.CASCADE)\n", (1488, 1567), False, 'from django.db import models\n')]