示例#1
0
class Invitation(CRideModel, models.Model):
    """Invitacion de Circulo

    Una invitación de círculo es un texto aleatorio que actúa
    como un código único que otorga acceso a un círculo específico.
    Estos códigos son generados por usuarios que ya son miembros del
    círculo y tienen un valor de "remaining_invitations" mayor que 0
    """
    code = models.CharField(max_length=50, unique=True)  # Codigo que se generara con la clase Manager.
    issued_by = models.ForeignKey(
        'users.User',
        on_delete=models.CASCADE,
        help_text='Miembro del círculo que proporciona la invitación',
        related_name='emitido_por'
    )  # Quien hizo la hizo la invitacion
    used_by = models.ForeignKey(
        'users.User',
        on_delete=models.CASCADE,
        null=True,  # Una invitacion puede ser usada o no por un usuario
        help_text='Usuario que usó el código para ingresar al círculo'
    )  # El usuario que invitado y que uso el codigo
    circle = models.ForeignKey('circles.Circle', on_delete=models.CASCADE)
    used = models.BooleanField(default=False)  # Si la invitacion fue usada. Con la ayuda de used_by
    used_at = models.DateTimeField(blank=True, null=True)  # La fecha en que se uso el codigo, colocamos
    # nulos por que puede hacer invitaciones sin usarse.

    # Manager
    objects = InvitationManager()  # Redefinimos el manager en la variable por defecto object.

    def __str__(self):
        """Retorna el codigo y el circulo."""
        return '#{}: {}'.format(self.circle.slug_name, self.code)
示例#2
0
class Invitation(CRideModel):
    """Cricle invitation.

    A circle invitation is a random text that acts as
    a unique code that grants access to a specific circle.

    This codes are generated by users that are already
    members of the circle and have a 'remaining_invitations'
    value greater than 0.
    """

    code = models.CharField(max_length=50, unique=True)

    issued_by = models.ForeignKey(
        'users.User',
        on_delete=models.CASCADE,
        help_text='Circle member that is providing the invitation.',
        related_name='issued_by')
    used_by = models.ForeignKey(
        'users.User',
        on_delete=models.CASCADE,
        null=True,
        help_text='User that used the code to enter the circle.')

    circle = models.ForeignKey('circles.Circle', on_delete=models.CASCADE)

    used = models.BooleanField(default=False)
    used_at = models.DateTimeField(blank=True, null=True)

    # Manager
    objects = InvitationManager()

    def __str__(self):
        """Return code and circle"""
        return '#{}: {}'.format(self.circle.slug_name, self.code)
示例#3
0
class Invitation(CRideModel):
    """Circle invitation. 
    A circle invitation is a random text that acts as 
    a unique code that grants access to a specific circle.
    These codes are generated by users that are already 
    members of the circle and have a 'remaining_invitations'
    value greater than 0.
    """

    code = models.CharField(max_length=50, unique=True)
    issued_by = models.ForeignKey(
        "users.User",
        on_delete=models.CASCADE,
        help_text="Circle member that is providing the invitation",
        related_name="issued_by"
    )
    used_by = models.ForeignKey(
        "users.User",
        on_delete=models.CASCADE,
        null=True, blank=True,
        help_text="User that used the code to enter the circle.",

    )
    circle = models.ForeignKey("circles.Circle", on_delete=models.CASCADE)
    used = models.BooleanField(default=False)
    used_at = models.DateTimeField(blank=True, null=True)

    # Manager
    objects = InvitationManager()

    def __str__(self):
        return f"#{self.circle.slug_name} : {self.code}"
示例#4
0
class Invitation(CRideModel):
    """Circle Unique invitations are created by using this model"""

    code = models.CharField(max_length=50, unique=True)

    issued_by = models.ForeignKey(
        'users.User',
        on_delete=models.CASCADE,
        help_text='Circle member that is providing the invitation',
        related_name='issued_by'
    )
    used_by = models.ForeignKey(
        'users.User',
        on_delete=models.CASCADE,
        null=True,
        help_text='User that used the code to enter the circle'
    )

    circle = models.ForeignKey('circles.Circle', on_delete=models.CASCADE)

    used = models.BooleanField(default=False)
    used_at = models.DateTimeField(blank=True, null=True)

    #Managers
    objects = InvitationManager()


    def __str__(self):
        """Return code and circle"""
        return '#{}: #{}'.format(self.circle.slug_name, self.code)
示例#5
0
class Invitation(CRideModel):
    """
        Unique code that grants access to a specific circle.
        This code can be generated by an active member of the circle
        with remaining invitations
    """

    code = models.CharField(max_length=50, unique=True)
    issued_by = models.ForeignKey(
        'users.User',
        on_delete=models.CASCADE,
        help_text='Member that provides the invitation',
        related_name='issued_by')
    used_by = models.ForeignKey('users.User',
                                on_delete=models.CASCADE,
                                null=True,
                                help_text='User that uses the code')

    circle = models.ForeignKey('circles.Circle', on_delete=models.CASCADE)

    used = models.BooleanField(default=False)
    used_at = models.DateTimeField(blank=True, null=True)

    objects = InvitationManager()

    def __str__(self):
        return f'#{self.circle.slug_name}: {self.code}'
class Invitation(CRideModel):

    code = models.CharField(max_length=50, unique=True)
    issued_by = models.ForeignKey('users.User',
                                  on_delete=models.CASCADE,
                                  related_name='issue_by')
    used_by = models.ForeignKey('users.User',
                                on_delete=models.CASCADE,
                                null=True)
    circle = models.ForeignKey('circles.Circle', on_delete=models.CASCADE)
    used = models.BooleanField(default=False)
    used_at = models.DateTimeField(blank=True, null=True)

    # Managers
    objects = InvitationManager()

    def __str__(self):
        return '#{}: {}'.format(self.circle.slug_name, self.code)
示例#7
0
class Invitation(CRideModel):

    code=models.CharField(max_length=50,unique=True)

    issued_by=models.ForeignKey("users.User",on_delete=models.CASCADE,null=True,related_name="issued_by")

    used_by=models.ForeignKey("users.User",on_delete=models.CASCADE,null=True,help_text="Usuario que usó el código para ingresar al círculo")

    circle=models.ForeignKey("circles.Circle",on_delete=models.CASCADE)

    used=models.BooleanField(default=False,help_text="Invitación usada?")

    used_at=models.DateTimeField(blank=True,null=True,help_text="Fecha de uso")

    objects=InvitationManager()

    def __str__(self):
        return "{}: {}".format(self.circle.slug_name,self.code)