Skip to content

Commit

Permalink
feat(backend): add skyroom credential fields (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adibov authored Dec 5, 2023
1 parent ec684f8 commit ff55303
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 4.2.4 on 2023-12-05 19:07

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('backend_api', '0055_alter_discount_code'),
]

operations = [
migrations.AddField(
model_name='presentationparticipation',
name='password',
field=models.CharField(default='KlWfmELW5ixsZmqh', max_length=255),
),
migrations.AddField(
model_name='workshopregistration',
name='password',
field=models.CharField(default='g0WmA7rXbIxm5OVJ', max_length=255),
),
migrations.AlterField(
model_name='discount',
name='code',
field=models.CharField(default='4Hjyva31c9rSMamSNQkqWz1lrMa0kr1E', max_length=32, unique=True),
),
]
12 changes: 12 additions & 0 deletions backend/backend_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,26 +287,38 @@ class StatusChoices(models.IntegerChoices):
AWAITING_PAYMENT = 1, _('Waiting for payment')
PURCHASED = 2, _('Purchase confirmed')

_PASSWORD_LENGTH = 16
workshop = models.ForeignKey(Workshop, on_delete=models.CASCADE)
user = models.ForeignKey(User, on_delete=models.CASCADE)
status = models.IntegerField(choices=StatusChoices.choices, default=StatusChoices.AWAITING_PAYMENT)
password = models.CharField(max_length=SMALL_MAX_LENGTH, default=create_random_string(_PASSWORD_LENGTH))

class Meta:
unique_together = ('workshop', 'user',)

@property
def username(self) -> str:
return f'{self.user.account.email.split("@")[0]}_workshop_{self.workshop.id}'


class PresentationParticipation(models.Model):
class StatusChoices(models.IntegerChoices):
AWAITING_PAYMENT = 1, _('Waiting for payment')
PURCHASED = 2, _('Purchase confirmed')

_PASSWORD_LENGTH = 16
presentation = models.ForeignKey(Presentation, on_delete=models.CASCADE)
user = models.ForeignKey(User, on_delete=models.CASCADE)
status = models.IntegerField(choices=StatusChoices.choices, default=StatusChoices.AWAITING_PAYMENT)
password = models.CharField(max_length=SMALL_MAX_LENGTH, default=create_random_string(_PASSWORD_LENGTH))

class Meta:
unique_together = ('presentation', 'user',)

@property
def username(self) -> str:
return f'{self.user.account.email.split("@")[0]}_presentation_{self.presentation.id}'


class Misc(models.Model):
name = models.CharField(max_length=SMALL_MAX_LENGTH, primary_key=True)
Expand Down

0 comments on commit ff55303

Please sign in to comment.