0001_initial.py 20.6 KB
Newer Older
Skia's avatar
Skia committed
1
2
3
4
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
Skia's avatar
Skia committed
5
import django.contrib.auth.models
Skia's avatar
Skia committed
6
7
import django.db.models.deletion
import django.core.validators
8
9
import core.models
import phonenumber_field.modelfields
Skia's avatar
Skia committed
10
from django.conf import settings
11
import django.db.models.deletion
Skia's avatar
Skia committed
12
13
14
15


class Migration(migrations.Migration):

Sli's avatar
Sli committed
16
    dependencies = [("auth", "0006_require_contenttypes_0002")]
Skia's avatar
Skia committed
17
18
19

    operations = [
        migrations.CreateModel(
Sli's avatar
Sli committed
20
            name="User",
Skia's avatar
Skia committed
21
            fields=[
Sli's avatar
Sli committed
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
                (
                    "id",
                    models.AutoField(
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                        auto_created=True,
                    ),
                ),
                ("password", models.CharField(max_length=128, verbose_name="password")),
                (
                    "last_login",
                    models.DateTimeField(
                        null=True, verbose_name="last login", blank=True
                    ),
                ),
                (
                    "username",
                    models.CharField(
                        help_text="Required. 254 characters or fewer. Letters, digits and @/./+/-/_ only.",
                        unique=True,
                        max_length=254,
                        error_messages={
                            "unique": "A user with that username already exists."
                        },
                        verbose_name="username",
                        validators=[
                            django.core.validators.RegexValidator(
                                "^[\\w.@+-]+$",
                                "Enter a valid username. This value may contain only letters, numbers and @/./+/-/_ characters.",
                            )
                        ],
                    ),
                ),
                (
                    "first_name",
                    models.CharField(max_length=64, verbose_name="first name"),
                ),
                (
                    "last_name",
                    models.CharField(max_length=64, verbose_name="last name"),
                ),
                (
                    "email",
                    models.EmailField(
                        unique=True, max_length=254, verbose_name="email address"
                    ),
                ),
                (
                    "date_of_birth",
                    models.DateField(
                        null=True, verbose_name="date of birth", blank=True
                    ),
                ),
                (
                    "nick_name",
                    models.CharField(
                        max_length=64, null=True, verbose_name="nick name", blank=True
                    ),
                ),
                (
                    "is_staff",
                    models.BooleanField(
                        help_text="Designates whether the user can log into this admin site.",
                        verbose_name="staff status",
                        default=False,
                    ),
                ),
                (
                    "is_active",
                    models.BooleanField(
                        help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.",
                        verbose_name="active",
                        default=True,
                    ),
                ),
                (
                    "date_joined",
                    models.DateField(auto_now_add=True, verbose_name="date joined"),
                ),
                (
                    "last_update",
                    models.DateField(verbose_name="last update", auto_now=True),
                ),
                (
                    "is_superuser",
                    models.BooleanField(
                        help_text="Designates whether this user is a superuser. ",
                        verbose_name="superuser",
                        default=False,
                    ),
                ),
                (
                    "sex",
                    models.CharField(
                        choices=[("MAN", "Man"), ("WOMAN", "Woman")],
                        max_length=10,
                        default="MAN",
                        verbose_name="sex",
                    ),
                ),
                (
                    "tshirt_size",
                    models.CharField(
                        choices=[
                            ("-", "-"),
                            ("XS", "XS"),
                            ("S", "S"),
                            ("M", "M"),
                            ("L", "L"),
                            ("XL", "XL"),
                            ("XXL", "XXL"),
                            ("XXXL", "XXXL"),
                        ],
                        max_length=5,
                        default="-",
                        verbose_name="tshirt size",
                    ),
                ),
                (
                    "role",
                    models.CharField(
                        choices=[
                            ("STUDENT", "Student"),
                            ("ADMINISTRATIVE", "Administrative agent"),
                            ("TEACHER", "Teacher"),
                            ("AGENT", "Agent"),
                            ("DOCTOR", "Doctor"),
                            ("FORMER STUDENT", "Former student"),
                            ("SERVICE", "Service"),
                        ],
                        max_length=15,
                        blank=True,
                        verbose_name="role",
                        default="",
                    ),
                ),
                (
                    "department",
                    models.CharField(
                        choices=[
                            ("TC", "TC"),
                            ("IMSI", "IMSI"),
                            ("IMAP", "IMAP"),
                            ("INFO", "INFO"),
                            ("GI", "GI"),
                            ("E", "E"),
                            ("EE", "EE"),
                            ("GESC", "GESC"),
                            ("GMC", "GMC"),
                            ("MC", "MC"),
                            ("EDIM", "EDIM"),
                            ("HUMA", "Humanities"),
                            ("NA", "N/A"),
                        ],
                        max_length=15,
                        blank=True,
                        verbose_name="department",
                        default="NA",
                    ),
                ),
                (
                    "dpt_option",
                    models.CharField(
                        max_length=32, blank=True, verbose_name="dpt option", default=""
                    ),
                ),
                (
                    "semester",
                    models.CharField(
                        max_length=5, blank=True, verbose_name="semester", default=""
                    ),
                ),
                (
                    "quote",
                    models.CharField(
                        max_length=256, blank=True, verbose_name="quote", default=""
                    ),
                ),
                (
                    "school",
                    models.CharField(
                        max_length=80, blank=True, verbose_name="school", default=""
                    ),
                ),
                (
                    "promo",
                    models.IntegerField(
                        null=True,
                        verbose_name="promo",
                        validators=[core.models.validate_promo],
                        blank=True,
                    ),
                ),
                (
                    "forum_signature",
                    models.TextField(
                        max_length=256,
                        blank=True,
                        verbose_name="forum signature",
                        default="",
                    ),
                ),
                (
                    "second_email",
                    models.EmailField(
                        max_length=254,
                        null=True,
                        verbose_name="second email address",
                        blank=True,
                    ),
                ),
                (
                    "phone",
                    phonenumber_field.modelfields.PhoneNumberField(
                        max_length=128, null=True, verbose_name="phone", blank=True
                    ),
                ),
                (
                    "parent_phone",
                    phonenumber_field.modelfields.PhoneNumberField(
                        max_length=128,
                        null=True,
                        verbose_name="parent phone",
                        blank=True,
                    ),
                ),
                (
                    "address",
                    models.CharField(
                        max_length=128, blank=True, verbose_name="address", default=""
                    ),
                ),
                (
                    "parent_address",
                    models.CharField(
                        max_length=128,
                        blank=True,
                        verbose_name="parent address",
                        default="",
                    ),
                ),
                (
                    "is_subscriber_viewable",
                    models.BooleanField(
                        verbose_name="is subscriber viewable", default=True
                    ),
                ),
Skia's avatar
Skia committed
270
            ],
Sli's avatar
Sli committed
271
272
            options={"abstract": False},
            managers=[("objects", django.contrib.auth.models.UserManager())],
Skia's avatar
Skia committed
273
        ),
274
        migrations.CreateModel(
Sli's avatar
Sli committed
275
            name="Group",
276
            fields=[
Sli's avatar
Sli committed
277
278
279
                (
                    "group_ptr",
                    models.OneToOneField(
280
                        on_delete=django.db.models.deletion.CASCADE,
Sli's avatar
Sli committed
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
                        primary_key=True,
                        parent_link=True,
                        serialize=False,
                        to="auth.Group",
                        auto_created=True,
                    ),
                ),
                (
                    "is_meta",
                    models.BooleanField(
                        help_text="Whether a group is a meta group or not",
                        verbose_name="meta group status",
                        default=False,
                    ),
                ),
                (
                    "description",
                    models.CharField(max_length=60, verbose_name="description"),
                ),
300
            ],
Sli's avatar
Sli committed
301
            bases=("auth.group",),
302
        ),
303
        migrations.CreateModel(
Sli's avatar
Sli committed
304
            name="Page",
305
            fields=[
Sli's avatar
Sli committed
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
                (
                    "id",
                    models.AutoField(
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                        auto_created=True,
                    ),
                ),
                ("name", models.CharField(max_length=30, verbose_name="page name")),
                (
                    "_full_name",
                    models.CharField(
                        max_length=255, blank=True, verbose_name="page name"
                    ),
                ),
                (
                    "edit_groups",
                    models.ManyToManyField(
                        related_name="editable_page",
                        to="core.Group",
                        blank=True,
                        verbose_name="edit group",
                    ),
                ),
                (
                    "owner_group",
                    models.ForeignKey(
334
                        on_delete=django.db.models.deletion.CASCADE,
Sli's avatar
Sli committed
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
                        default=1,
                        related_name="owned_page",
                        verbose_name="owner group",
                        to="core.Group",
                    ),
                ),
                (
                    "parent",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.SET_NULL,
                        null=True,
                        related_name="children",
                        verbose_name="parent",
                        to="core.Page",
                        blank=True,
                    ),
                ),
                (
                    "view_groups",
                    models.ManyToManyField(
                        related_name="viewable_page",
                        to="core.Group",
                        blank=True,
                        verbose_name="view group",
                    ),
                ),
361
362
            ],
            options={
Sli's avatar
Sli committed
363
364
365
366
367
368
369
                "permissions": (
                    (
                        "change_prop_page",
                        "Can change the page's properties (groups, ...)",
                    ),
                    ("view_page", "Can view the page"),
                )
370
371
            },
        ),
372
        migrations.CreateModel(
Sli's avatar
Sli committed
373
            name="PageRev",
374
            fields=[
Sli's avatar
Sli committed
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
                (
                    "id",
                    models.AutoField(
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                        auto_created=True,
                    ),
                ),
                ("revision", models.IntegerField(verbose_name="revision")),
                (
                    "title",
                    models.CharField(
                        max_length=255, blank=True, verbose_name="page title"
                    ),
                ),
                ("content", models.TextField(blank=True, verbose_name="page content")),
                ("date", models.DateTimeField(verbose_name="date", auto_now=True)),
                (
                    "author",
                    models.ForeignKey(
396
397
398
399
400
401
402
403
404
405
406
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                        related_name="page_rev",
                    ),
                ),
                (
                    "page",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="core.Page",
                        related_name="revisions",
Sli's avatar
Sli committed
407
408
                    ),
                ),
409
            ],
Sli's avatar
Sli committed
410
            options={"ordering": ["date"]},
411
        ),
Skia's avatar
Skia committed
412
        migrations.CreateModel(
Sli's avatar
Sli committed
413
            name="Preferences",
Skia's avatar
Skia committed
414
            fields=[
Sli's avatar
Sli committed
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
                (
                    "id",
                    models.AutoField(
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                        auto_created=True,
                    ),
                ),
                (
                    "show_my_stats",
                    models.BooleanField(
                        help_text="Show your account statistics to others",
                        verbose_name="define if we show a users stats",
                        default=False,
                    ),
                ),
                (
                    "user",
                    models.OneToOneField(
435
436
437
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                        related_name="preferences",
Sli's avatar
Sli committed
438
439
                    ),
                ),
Skia's avatar
Skia committed
440
            ],
441
        ),
Skia's avatar
Skia committed
442
        migrations.CreateModel(
Sli's avatar
Sli committed
443
            name="SithFile",
Skia's avatar
Skia committed
444
            fields=[
Sli's avatar
Sli committed
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
                (
                    "id",
                    models.AutoField(
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                        auto_created=True,
                    ),
                ),
                ("name", models.CharField(max_length=30, verbose_name="file name")),
                (
                    "file",
                    models.FileField(
                        upload_to=core.models.get_directory,
                        null=True,
                        verbose_name="file",
                        blank=True,
                    ),
                ),
                (
                    "is_folder",
                    models.BooleanField(verbose_name="is folder", default=True),
                ),
                (
                    "mime_type",
                    models.CharField(max_length=30, verbose_name="mime type"),
                ),
                ("size", models.IntegerField(default=0, verbose_name="size")),
                ("date", models.DateTimeField(verbose_name="date", auto_now=True)),
                (
                    "edit_groups",
                    models.ManyToManyField(
                        related_name="editable_files",
                        to="core.Group",
                        blank=True,
                        verbose_name="edit group",
                    ),
                ),
                (
                    "owner",
                    models.ForeignKey(
486
                        on_delete=django.db.models.deletion.CASCADE,
Sli's avatar
Sli committed
487
488
489
490
491
492
493
494
                        verbose_name="owner",
                        to=settings.AUTH_USER_MODEL,
                        related_name="owned_files",
                    ),
                ),
                (
                    "parent",
                    models.ForeignKey(
495
                        on_delete=django.db.models.deletion.CASCADE,
Sli's avatar
Sli committed
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
                        null=True,
                        related_name="children",
                        verbose_name="parent",
                        to="core.SithFile",
                        blank=True,
                    ),
                ),
                (
                    "view_groups",
                    models.ManyToManyField(
                        related_name="viewable_files",
                        to="core.Group",
                        blank=True,
                        verbose_name="view group",
                    ),
                ),
Skia's avatar
Skia committed
512
            ],
Sli's avatar
Sli committed
513
            options={"verbose_name": "file"},
Skia's avatar
Skia committed
514
        ),
515
        migrations.AddField(
Sli's avatar
Sli committed
516
517
518
519
520
521
522
523
524
525
            model_name="user",
            name="avatar_pict",
            field=models.OneToOneField(
                blank=True,
                on_delete=django.db.models.deletion.SET_NULL,
                null=True,
                related_name="avatar_of",
                verbose_name="avatar",
                to="core.SithFile",
            ),
526
527
        ),
        migrations.AddField(
Sli's avatar
Sli committed
528
529
530
            model_name="user",
            name="home",
            field=models.OneToOneField(
531
                on_delete=django.db.models.deletion.CASCADE,
Sli's avatar
Sli committed
532
533
534
535
536
537
                blank=True,
                null=True,
                related_name="home_of",
                verbose_name="home",
                to="core.SithFile",
            ),
538
539
        ),
        migrations.AddField(
Sli's avatar
Sli committed
540
541
542
543
544
545
546
547
548
549
            model_name="user",
            name="profile_pict",
            field=models.OneToOneField(
                blank=True,
                on_delete=django.db.models.deletion.SET_NULL,
                null=True,
                related_name="profile_of",
                verbose_name="profile",
                to="core.SithFile",
            ),
550
551
        ),
        migrations.AddField(
Sli's avatar
Sli committed
552
553
554
555
556
557
558
559
560
561
            model_name="user",
            name="scrub_pict",
            field=models.OneToOneField(
                blank=True,
                on_delete=django.db.models.deletion.SET_NULL,
                null=True,
                related_name="scrub_of",
                verbose_name="scrub",
                to="core.SithFile",
            ),
562
        ),
Skia's avatar
Skia committed
563
        migrations.CreateModel(
Sli's avatar
Sli committed
564
565
566
567
568
            name="MetaGroup",
            fields=[],
            options={"proxy": True},
            bases=("core.group",),
            managers=[("objects", core.models.MetaGroupManager())],
Skia's avatar
Skia committed
569
570
        ),
        migrations.CreateModel(
Sli's avatar
Sli committed
571
572
573
574
575
            name="RealGroup",
            fields=[],
            options={"proxy": True},
            bases=("core.group",),
            managers=[("objects", core.models.RealGroupManager())],
576
        ),
577
        migrations.AlterUniqueTogether(
Sli's avatar
Sli committed
578
            name="page", unique_together=set([("name", "parent")])
579
        ),
Skia's avatar
Skia committed
580
        migrations.AddField(
Sli's avatar
Sli committed
581
582
583
584
585
            model_name="user",
            name="groups",
            field=models.ManyToManyField(
                to="core.RealGroup", blank=True, related_name="users"
            ),
Skia's avatar
Skia committed
586
        ),
Skia's avatar
Skia committed
587
    ]