1 | from django.db import models
|
---|
2 | from django.contrib.auth.models import User
|
---|
3 |
|
---|
4 |
|
---|
5 | class Customer(models.Model):
|
---|
6 | """
|
---|
7 | classe che gestische le informazioni relativi al cliente
|
---|
8 | """
|
---|
9 |
|
---|
10 | name = models.CharField(max_length = 255, null = False, blank = False)
|
---|
11 | description = models.TextField(max_length = 5000, null = True, blank = True)
|
---|
12 | enabled = models.BooleanField(null = False, blank = False, default = True)
|
---|
13 |
|
---|
14 | def __str__(self):
|
---|
15 | return self.name
|
---|
16 |
|
---|
17 | class CustomerUser(User):
|
---|
18 | """
|
---|
19 | Estensione dell'utente base per memorizzare i dati dell'utente della mailing list
|
---|
20 |
|
---|
21 | """
|
---|
22 | customer = models.ForeignKey(Customer, blank = False, null = True)
|
---|
23 |
|
---|
24 |
|
---|
25 | class Domain(models.Model):
|
---|
26 | """
|
---|
27 | Classe che contiene e gestisce l'elenco dei domini gestiti dal tool
|
---|
28 | di mailing list
|
---|
29 | """
|
---|
30 |
|
---|
31 | domain = models.CharField(max_length = 100, null = False, blank = False)
|
---|
32 | name = models.CharField(max_length = 255, null = False, blank = False)
|
---|
33 | description = models.TextField(max_length = 5000, null = True, blank = True)
|
---|
34 | code = models.CharField(max_length = 50, null = False, blank = False)
|
---|
35 | full_domain = models.CharField(max_length = 255, null = False, blank = False, default = "---")
|
---|
36 | catch_all_forward = models.EmailField(null = True, blank = True)
|
---|
37 |
|
---|
38 | customer = models.ForeignKey(Customer, blank = True, null = True)
|
---|
39 |
|
---|
40 | def __str__(self):
|
---|
41 | return self.domain
|
---|
42 |
|
---|
43 |
|
---|
44 | class Channel(models.Model):
|
---|
45 | """
|
---|
46 | Classe che contiene e gestisce i dati dei canali di invio di ogni cliente
|
---|
47 | """
|
---|
48 |
|
---|
49 | name = models.CharField(max_length = 255, null = False, blank = False)
|
---|
50 | description = models.TextField(max_length = 5000, null = True, blank = True)
|
---|
51 | enabled = models.BooleanField(null = False, blank = False, default = True)
|
---|
52 | code = models.CharField(max_length = 50, null = True, blank = True)
|
---|
53 |
|
---|
54 | domain = models.ForeignKey(Domain, null = False, blank = False)
|
---|
55 |
|
---|
56 | def __str__(self):
|
---|
57 | return self.name
|
---|
58 |
|
---|
59 | class Template(models.Model):
|
---|
60 | """
|
---|
61 | Classe che contiene l'elenco dei templati
|
---|
62 | Un invio può essere associato solo a un template
|
---|
63 | """
|
---|
64 | name = models.CharField(max_length = 255, null = False, blank = False)
|
---|
65 | link = models.URLField(null =True, blank = True)
|
---|
66 | path = models.FileField(null = True, blank = True, upload_to = "mail_templates")
|
---|
67 | code = models.CharField(max_length = 50, null = True, blank = True)
|
---|
68 |
|
---|
69 | def __str__(self):
|
---|
70 | return self.name
|
---|
71 |
|
---|
72 |
|
---|
73 | class Shipment(models.Model):
|
---|
74 | """
|
---|
75 | Classe che traccia i dati degli invii
|
---|
76 | """
|
---|
77 |
|
---|
78 | date = models.DateField(null = False, blank = False)
|
---|
79 | description = models.TextField( max_length = 5000, null = True, blank = True)
|
---|
80 | code = models.CharField(max_length = 50, null = True, blank = True)
|
---|
81 | subject = models.CharField(max_length = 100, null = True, blank = True)
|
---|
82 | sent = models.BooleanField(blank = False, null = False, default = False)
|
---|
83 | started = models.DateTimeField(blank = True, null = True)
|
---|
84 | finished = models.DateTimeField(blank = True, null = True)
|
---|
85 |
|
---|
86 | channel = models.ForeignKey(Channel, null = False, blank = False)
|
---|
87 | template = models.ForeignKey(Template, null = False, blank = False)
|
---|
88 |
|
---|
89 | def __str__(self):
|
---|
90 | return "Shipment of " + str(self.date)
|
---|
91 |
|
---|
92 |
|
---|
93 | class Recipient(models.Model):
|
---|
94 | """
|
---|
95 | Classe che contiene e gestisce l'elenco dei destinatari
|
---|
96 | """
|
---|
97 |
|
---|
98 | mail = models.EmailField(null = False, blank = False)
|
---|
99 | fullname = models.CharField(max_length = 500, null = True, blank = True)
|
---|
100 | enabled = models.BooleanField(null = False, blank = False, default = True)
|
---|
101 | unsubscribed = models.BooleanField(null = False, blank = False, default = False)
|
---|
102 | unsubscribe_date = models.DateTimeField(null = True, blank = True)
|
---|
103 |
|
---|
104 | channel = models.ForeignKey(Channel, null = False, blank = False)
|
---|
105 | shipments = models.ManyToManyField(Shipment, blank = True)
|
---|
106 |
|
---|
107 | def __str__(self):
|
---|
108 | return self.mail + (self.fullname if self.fullname is not None else "")
|
---|
109 |
|
---|
110 |
|
---|
111 | class ShipmentData(models.Model):
|
---|
112 | """
|
---|
113 | Classe che memorizza tutti i dati dell'invio sotto forma di chiave/valore
|
---|
114 | collegati a un destinatario
|
---|
115 | """
|
---|
116 |
|
---|
117 | field = models.CharField(max_length = 25, null = False, blank = False)
|
---|
118 | value = models.TextField(max_length = 10000, null = False, blank = True)
|
---|
119 | deleted = models.BooleanField(null = False, blank = False, default = False)
|
---|
120 |
|
---|
121 | shipment = models.ForeignKey(Shipment, null = False, blank = False)
|
---|
122 | recipient = models.ForeignKey(Recipient, null = False, blank = False)
|
---|
123 |
|
---|
124 | def __str__(self):
|
---|
125 | return self.recipient.mail + " - " + self.field
|
---|
126 |
|
---|
127 |
|
---|
128 | class ChannelData(models.Model):
|
---|
129 | """
|
---|
130 | Classe che memorizza tutti i dati del canale sotto forma di chiave/valore
|
---|
131 | collegati a un destinatario
|
---|
132 | """
|
---|
133 |
|
---|
134 | field = models.CharField(max_length = 25, null = False, blank = False)
|
---|
135 | value = models.TextField(max_length = 10000, null = False, blank = True)
|
---|
136 | deleted = models.BooleanField(null = False, blank = False, default = False)
|
---|
137 |
|
---|
138 | channel = models.ForeignKey(Channel, null = False, blank = False)
|
---|
139 | recipient = models.ForeignKey(Recipient, null = False, blank = False)
|
---|
140 |
|
---|
141 | def __str__(self):
|
---|
142 | return self.recipient.mail + " - " +self.field
|
---|
143 |
|
---|
144 |
|
---|
145 | class Placeholder(models.Model):
|
---|
146 | """
|
---|
147 | Classe che contiene l'elenco dei placeholder ricavati da un template
|
---|
148 | """
|
---|
149 |
|
---|
150 | name = models.CharField(max_length = 100, null = False, blank = False)
|
---|
151 | description = models.TextField(max_length = 5000, null = True, blank = True)
|
---|
152 |
|
---|
153 | template = models.ForeignKey(Template, null = False, blank = False)
|
---|
154 |
|
---|
155 | def __str__(self):
|
---|
156 | return self.name
|
---|
157 |
|
---|
158 |
|
---|
159 | class Link(models.Model):
|
---|
160 | """
|
---|
161 | Classe con l'elenco dei link di un template
|
---|
162 | """
|
---|
163 |
|
---|
164 | name = models.CharField(max_length = 100, null = True, blank = True, default = "")
|
---|
165 | original = models.CharField(max_length = 200, null = False, blank = False)
|
---|
166 | category = models.CharField(max_length = 100, null = True, blank = True, default = "")
|
---|
167 | destination = models.CharField(max_length = 100, null = False, blank = False)
|
---|
168 |
|
---|
169 | template = models.ForeignKey(Template, null = False, blank = False, related_name = "link_template")
|
---|
170 |
|
---|
171 | def __str__(self):
|
---|
172 | return self.destination
|
---|
173 |
|
---|
174 |
|
---|
175 | class LogClick(models.Model):
|
---|
176 | """
|
---|
177 | Classe di memorizzazione dei click sui link
|
---|
178 | """
|
---|
179 |
|
---|
180 | click_date = models.DateField(null = False, blank = False)
|
---|
181 |
|
---|
182 | link = models.ForeignKey(Link, null = True, blank = True)
|
---|
183 | recipient = models.ForeignKey(Recipient, null = True, blank = True)
|
---|
184 | shipment = models.ForeignKey(Shipment, null = True, blank = True)
|
---|
185 |
|
---|
186 |
|
---|
187 | class LogDelivery(models.Model):
|
---|
188 | """
|
---|
189 | Classe che memorizza i dati di ogni singolo invio per ogni destinatario
|
---|
190 | """
|
---|
191 |
|
---|
192 | delivery_date = models.DateTimeField(null = False, blank = False)
|
---|
193 | message_id = models.CharField(max_length = 50, null = False, blank = False)
|
---|
194 | bounce_receive_date = models.DateField(null = True, blank = True)
|
---|
195 | bounce_dsn_code = models.CharField(max_length = 20, null = True, blank = True)
|
---|
196 | bounce_action = models.CharField(max_length = 50, null = True, blank = True)
|
---|
197 | bounce_remote_mta = models.CharField(max_length = 200, null = True, blank = True)
|
---|
198 |
|
---|
199 | recipient = models.ForeignKey(Recipient, blank = False, null = False)
|
---|
200 | shipment = models.ForeignKey(Shipment, blank = False, null =False)
|
---|
201 |
|
---|
202 |
|
---|
203 |
|
---|