-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
93 lines (69 loc) · 3.13 KB
/
models.py
File metadata and controls
93 lines (69 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import uuid
from django.contrib.auth.models import AbstractUser
from django.db import models
class User(AbstractUser):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
email = models.EmailField(blank=False, unique=True, null=False)
credit = models.IntegerField(default=0)
class Filament(models.Model):
class Type(models.TextChoices):
PLA = 'PLA'
REINFORCED_PLA = 'REINFORCED_PLA'
PETG = 'PETG'
ABS = 'ABS'
TPE = 'TPE/TPU'
class Color(models.TextChoices):
RED = 'RED'
GREEN = 'GREEN'
YELLOW = 'YELLOW'
BLUE = 'BLUE'
MAGENTA = 'MAGENTA'
WHITE = 'WHITE'
BLACK = 'BLACK'
PURPLE = 'PURPLE'
BROWN = 'BROWN'
GREY = 'GREY'
ORANGE = 'ORANGE'
colour = models.CharField(choices=Color.choices, max_length=25, null=False, blank=False)
type = models.CharField(choices=Type.choices, max_length=25, null=False, blank=False)
quantity = models.PositiveIntegerField(default=0)
price = models.PositiveIntegerField(default=0)
class File(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
user_id=models.ForeignKey(User, on_delete=models.CASCADE)
filament_id=models.ManyToManyField(Filament)
path = models.FileField(upload_to='uploads/%Y/%m/%d')
number_of_printing = models.PositiveIntegerField(default=1)
para_slicer = models.JSONField(null=True, blank=True)
class Printer(models.Model):
class Status(models.TextChoices):
UP = 'UP'
DOWN = 'DOWN'
USED = 'USED'
class Model(models.TextChoices):
Creality_K1C = 'Creality_K1C'
Prusa_MK3S = 'Prusa_MK3S'
type = models.CharField(choices=Model.choices, max_length=25, null=False, blank=False)
status = models.CharField(choices=Status.choices, max_length=25, null=False, blank=False, default=Status.DOWN)
class Request(models.Model):
class Status(models.TextChoices):
PENDING = 'PENDING'
PROCESSING = 'PROCESSING'
COMPLETED = 'COMPLETED'
FAILED = 'FAILED'
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
file_id = models.ForeignKey(File, on_delete=models.CASCADE)
printer_id = models.ForeignKey(Printer, on_delete=models.CASCADE, null=True)
created_at = models.DateTimeField(auto_now_add=True)
status = models.CharField(choices=Status.choices, max_length=25, null=False, blank=False, default=Status.PENDING)
class Operation(models.Model):
class Type(models.TextChoices):
CASH = 'CASH'
CARD = 'CARD'
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
beneficiary_id = models.ForeignKey(User, on_delete=models.CASCADE, related_name='operation_beneficiary')
agent_id = models.ForeignKey(User, on_delete=models.CASCADE, related_name='operation_agent')
created_at = models.DateTimeField(auto_now_add=True)
operation_type = models.CharField(choices=Type.choices, max_length=25, null=False, blank=False)
comment = models.TextField(null=True, blank=True)
amount = models.IntegerField(default=0)