Project

General

Profile

0002-dj22-add-on_delete-models.CASCADE-51516.patch

Benjamin Dauvergne, 01 Mar 2021 03:06 PM

Download (5.14 KB)

View differences:

Subject: [PATCH 2/9] dj22: add on_delete=models.CASCADE (#51516)

 zoo/zoo_data/models.py     | 39 +++++++++++++++++++++++++-------------
 zoo/zoo_meta/models.py     |  6 ++++--
 zoo/zoo_nanterre/models.py |  6 ++++--
 3 files changed, 34 insertions(+), 17 deletions(-)
zoo/zoo_data/models.py
112 112
class Entity(CommonData):
113 113
    schema = models.ForeignKey(
114 114
        'zoo_meta.EntitySchema',
115
        verbose_name=_('schema'))
115
        verbose_name=_('schema'),
116
        on_delete=models.CASCADE)
116 117
    created = models.ForeignKey(
117 118
        Transaction,
118 119
        blank=True,
119 120
        null=True,
120 121
        verbose_name=_('created'),
121
        related_name='created_entities')
122
        related_name='created_entities',
123
        on_delete=models.CASCADE)
122 124
    modified = models.ForeignKey(
123 125
        Transaction,
124 126
        blank=True,
125 127
        null=True,
126 128
        verbose_name=_('modified'),
127
        related_name='modified_entities')
129
        related_name='modified_entities',
130
        on_delete=models.CASCADE)
128 131
    deleted = models.ForeignKey(
129 132
        Transaction,
130 133
        verbose_name=_('deleted'),
131 134
        blank=True,
132 135
        null=True,
133
        related_name='deleted_entities')
136
        related_name='deleted_entities',
137
        on_delete=models.CASCADE)
134 138
    meta = JSONField(
135 139
        blank=True,
136 140
        null=True,
......
160 164
class Relation(CommonData):
161 165
    schema = models.ForeignKey(
162 166
        'zoo_meta.RelationSchema',
163
        verbose_name=_('schema'))
167
        verbose_name=_('schema'),
168
        on_delete=models.CASCADE)
164 169
    left = models.ForeignKey(
165 170
        'Entity',
166 171
        verbose_name=_('left'),
167
        related_name='left_relations')
172
        related_name='left_relations',
173
        on_delete=models.CASCADE)
168 174
    right = models.ForeignKey(
169 175
        'Entity',
170 176
        verbose_name=_('right'),
171
        related_name='right_relations')
177
        related_name='right_relations',
178
        on_delete=models.CASCADE)
172 179
    created = models.ForeignKey(
173 180
        Transaction,
174 181
        blank=True,
175 182
        null=True,
176 183
        verbose_name=_('created'),
177
        related_name='created_relations')
184
        related_name='created_relations',
185
        on_delete=models.CASCADE)
178 186
    modified = models.ForeignKey(
179 187
        Transaction,
180 188
        blank=True,
181 189
        null=True,
182 190
        verbose_name=_('modified'),
183
        related_name='modified_relations')
191
        related_name='modified_relations',
192
        on_delete=models.CASCADE)
184 193
    deleted = models.ForeignKey(
185 194
        Transaction,
186 195
        verbose_name=_('deleted'),
187 196
        blank=True,
188 197
        null=True,
189
        related_name='deleted_relations')
198
        related_name='deleted_relations',
199
        on_delete=models.CASCADE)
190 200
    meta = JSONField(
191 201
        blank=True,
192 202
        null=True,
......
205 215
class Log(models.Model):
206 216
    entity = models.ForeignKey(
207 217
        'Entity',
208
        verbose_name=_('entity'))
218
        verbose_name=_('entity'),
219
        on_delete=models.CASCADE)
209 220
    transaction = models.ForeignKey(
210 221
        'Transaction',
211 222
        null=True,
212
        verbose_name=_('transaction'))
223
        verbose_name=_('transaction'),
224
        on_delete=models.CASCADE)
213 225
    timestamp = models.DateTimeField(
214 226
        auto_now_add=True,
215 227
        db_index=True,
......
276 288
        'Transaction',
277 289
        verbose_name='transaction',
278 290
        null=True,
279
        blank=True)
291
        blank=True,
292
        on_delete=models.CASCADE)
280 293

  
281 294
    state = models.PositiveIntegerField(
282 295
        verbose_name=_('state'),
zoo/zoo_meta/models.py
165 165
    left = models.ForeignKey(
166 166
        EntitySchema,
167 167
        verbose_name=_('left schema'),
168
        related_name='+')
168
        related_name='+',
169
        on_delete=models.CASCADE)
169 170
    right = models.ForeignKey(
170 171
        EntitySchema,
171 172
        verbose_name=_('right schema'),
172
        related_name='+')
173
        related_name='+',
174
        on_delete=models.CASCADE)
173 175
    is_symmetric = models.BooleanField(
174 176
        default=False,
175 177
        blank=True,
zoo/zoo_nanterre/models.py
43 43
    first = models.ForeignKey(
44 44
        'zoo_data.Entity',
45 45
        verbose_name=_('first'),
46
        related_name='+')
46
        related_name='+',
47
        on_delete=models.CASCADE)
47 48
    second = models.ForeignKey(
48 49
        'zoo_data.Entity',
49 50
        verbose_name=_('second'),
50
        related_name='+')
51
        related_name='+',
52
        on_delete=models.CASCADE)
51 53

  
52 54
    score = models.DecimalField(
53 55
        decimal_places=2,
54
-