Fakultas Ilmu Komputer UI

models.py 22.2 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import decimal
import uuid

from django.contrib.auth import models as auth_models
from django.contrib.postgres import fields
from django.core import validators
from django.db import models as db_models
from django.utils.translation import gettext_lazy as _
from phonenumber_field import modelfields
from solo import models as solo_models

from api import constants, utils


class User(auth_models.AbstractUser):
16
17
    REQUIRED_FIELDS=['phone_number']

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
    id = db_models.UUIDField(default=uuid.uuid4, primary_key=True, verbose_name=_('ID'))
    first_name = None
    last_name = None
    full_name = db_models.CharField(max_length=200, verbose_name=_('full name'))
    phone_number = modelfields.PhoneNumberField(unique=True, verbose_name=_('phone number'))
    address = db_models.CharField(max_length=200, verbose_name=_('address'))
    neighborhood = db_models.CharField(
        max_length=3,
        validators=[validators.int_list_validator(sep=''), validators.MinLengthValidator(3)],
        verbose_name=_('neighborhood')
    )
    hamlet = db_models.CharField(
        max_length=3,
        validators=[validators.int_list_validator(sep=''), validators.MinLengthValidator(3)],
        verbose_name=_('hamlet')
    )
    urban_village = db_models.CharField(max_length=100, verbose_name=_('urban village'))
    sub_district = db_models.CharField(max_length=100, verbose_name=_('sub-district'))
    profile_picture = db_models.ImageField(
        blank=True,
        null=True,
        upload_to=utils.get_upload_file_path,
        verbose_name=_('profile picture')
    )
    otp = db_models.CharField(blank=True, max_length=6, null=True, verbose_name=_('OTP'))
inez nabila's avatar
inez nabila committed
43
44
45
    number_of_transactions = db_models.PositiveIntegerField(default=0, verbose_name=_('number of transactions'))
    number_of_cash_donations = db_models.PositiveIntegerField(default=0, verbose_name=_('number of cash donations'))
    number_of_goods_donations = db_models.PositiveIntegerField(default=0, verbose_name=_('number of goods donations'))
46
47
48
49
50
51
52
53
54
55

    class Meta:
        ordering = ['username', 'id']
        verbose_name = _('user')
        verbose_name_plural = _('users')

    def __str__(self):
        return self.username


WILLIAM GATES's avatar
WILLIAM GATES committed
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
class BankAccountTransferDestination(db_models.Model):
    id = db_models.UUIDField(default=uuid.uuid4, primary_key=True, verbose_name=_('ID'))
    bank_name = db_models.CharField(max_length=100, verbose_name=_('bank name'))
    bank_account_number = db_models.CharField(max_length=100, verbose_name=_('bank account number'))
    bank_account_name = db_models.CharField(max_length=200, verbose_name=_('bank account name'))

    class Meta:
        ordering = ['bank_name', 'id']
        unique_together = ['bank_name', 'bank_account_number']
        verbose_name = _('bank account transfer destination')
        verbose_name_plural = _('bank account transfer destinations')

    def __str__(self):
        return '{} - {}'.format(self.bank_name, self.bank_account_number)


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
class Category(db_models.Model):
    id = db_models.UUIDField(default=uuid.uuid4, primary_key=True, verbose_name=_('ID'))
    name = fields.CICharField(max_length=50, unique=True, verbose_name=_('name'))
    image = db_models.ImageField(
        blank=True,
        null=True,
        upload_to=utils.get_upload_file_path,
        verbose_name=_('image')
    )

    class Meta:
        ordering = ['name', 'id']
        verbose_name = _('category')
        verbose_name_plural = _('categories')

    def __str__(self):
        return self.name


class Subcategory(db_models.Model):
    id = db_models.UUIDField(default=uuid.uuid4, primary_key=True, verbose_name=_('ID'))
    name = fields.CICharField(max_length=50, unique=True, verbose_name=_('name'))
    category = db_models.ForeignKey(
        'api.Category',
        on_delete=db_models.CASCADE,
        related_name='subcategories',
        verbose_name=_('category')
    )
    image = db_models.ImageField(
        blank=True,
        null=True,
        upload_to=utils.get_upload_file_path,
        verbose_name=_('image')
    )

    class Meta:
        ordering = ['category', 'name', 'id']
        verbose_name = _('subcategory')
        verbose_name_plural = _('subcategories')

    def __str__(self):
        return self.name


class Product(db_models.Model):
    id = db_models.UUIDField(default=uuid.uuid4, primary_key=True, verbose_name=_('ID'))
    code = db_models.CharField(
        default=utils.generate_code,
        max_length=6,
        unique=True,
        verbose_name=_('code')
    )
    name = db_models.CharField(max_length=200, verbose_name=_('name'))
    subcategory = db_models.ForeignKey(
        'api.Subcategory',
        on_delete=db_models.PROTECT,
        related_name='products',
        verbose_name=_('subcategory')
    )
    description = db_models.TextField(verbose_name=_('description'))
    price = db_models.DecimalField(
        decimal_places=2,
        max_digits=12,
        validators=[validators.MinValueValidator(decimal.Decimal('0.01'))],
        verbose_name=_('price')
    )
    stock = db_models.PositiveIntegerField(blank=True, null=True, verbose_name=_('stock'))
    pre_order = db_models.BooleanField(default=False, verbose_name=_('pre-order'))
    image = db_models.ImageField(
        blank=True,
        null=True,
        upload_to=utils.get_upload_file_path,
        verbose_name=_('image')
    )

    class Meta:
        ordering = ['subcategory', 'name', 'code', 'id']
        verbose_name = _('product')
        verbose_name_plural = _('products')

    def save(self, *args, **kwargs): # pylint: disable=arguments-differ
        if (self.pre_order) and (self.stock is not None):
            self.stock = None
        super().save(*args, **kwargs)

    def __str__(self):
        return self.code


class ShoppingCart(db_models.Model):
    id = db_models.UUIDField(default=uuid.uuid4, primary_key=True, verbose_name=_('ID'))
    user = db_models.OneToOneField('api.User', on_delete=db_models.CASCADE, verbose_name=_('user'))

    class Meta:
        ordering = ['user', 'id']
        verbose_name = _('shopping cart')
        verbose_name_plural = _('shopping carts')

    def __str__(self):
        return self.user.username


class CartItem(db_models.Model):
    id = db_models.UUIDField(default=uuid.uuid4, primary_key=True, verbose_name=_('ID'))
    shopping_cart = db_models.ForeignKey(
        'api.ShoppingCart',
        on_delete=db_models.CASCADE,
        related_name='cart_items',
        verbose_name=_('shopping cart')
    )
    product = db_models.ForeignKey(
        'api.Product',
        on_delete=db_models.CASCADE,
        related_name='cart_items',
        verbose_name=_('product')
    )
    quantity = db_models.PositiveIntegerField(default=0, verbose_name=_('quantity'))

    class Meta:
        ordering = ['shopping_cart', 'product', 'id']
        unique_together = ['shopping_cart', 'product']
        verbose_name = _('cart item')
        verbose_name_plural = _('cart items')

    def __str__(self):
        return self.product.code


class Transaction(db_models.Model):
    id = db_models.UUIDField(default=uuid.uuid4, primary_key=True, verbose_name=_('ID'))
    transaction_number = db_models.CharField(
        default=utils.generate_transaction_number,
        max_length=8,
        unique=True,
        verbose_name=_('transaction number')
    )
    user = db_models.ForeignKey(
        'api.User',
        null=True,
        on_delete=db_models.SET_NULL,
        related_name='transactions',
        verbose_name=_('user')
    )
    user_full_name = db_models.CharField(max_length=200, verbose_name=_('user full name'))
    user_phone_number = modelfields.PhoneNumberField(verbose_name=_('user phone number'))
    shipping_address = db_models.CharField(max_length=200, verbose_name=_('shipping address'))
    shipping_neighborhood = db_models.CharField(
        max_length=3,
        validators=[validators.int_list_validator(sep=''), validators.MinLengthValidator(3)],
        verbose_name=_('shipping neighborhood')
    )
    shipping_hamlet = db_models.CharField(
        max_length=3,
        validators=[validators.int_list_validator(sep=''), validators.MinLengthValidator(3)],
        verbose_name=_('shipping hamlet')
    )
    shipping_urban_village = db_models.CharField(
        max_length=100,
        verbose_name=_('shipping urban village')
    )
    shipping_sub_district = db_models.CharField(
        max_length=100,
        verbose_name=_('shipping sub-district')
    )
    shipping_costs = db_models.DecimalField(
WILLIAM GATES's avatar
WILLIAM GATES committed
237
        blank=True,
238
239
        decimal_places=2,
        max_digits=12,
WILLIAM GATES's avatar
WILLIAM GATES committed
240
        null=True,
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
        validators=[validators.MinValueValidator(decimal.Decimal('0'))],
        verbose_name=_('shipping costs')
    )
    payment_method = db_models.CharField(
        choices=constants.PAYMENT_METHOD_CHOICES,
        max_length=3,
        verbose_name=_('payment method')
    )
    donation = db_models.DecimalField(
        decimal_places=2,
        default=decimal.Decimal('0'),
        max_digits=12,
        validators=[validators.MinValueValidator(decimal.Decimal('0'))],
        verbose_name=_('donation')
    )
    transaction_status = db_models.CharField(
        choices=constants.TRANSACTION_STATUS_CHOICES,
        max_length=3,
        verbose_name=_('transaction status')
    )
    proof_of_payment = db_models.ImageField(
        blank=True,
        null=True,
        upload_to=utils.get_upload_file_path,
        verbose_name=_('proof of payment')
    )
WILLIAM GATES's avatar
WILLIAM GATES committed
267
268
269
270
271
272
    user_bank_name = db_models.CharField(
        blank=True,
        max_length=100,
        null=True,
        verbose_name=_('user bank name')
    )
273
274
275
276
277
278
    user_bank_account_name = db_models.CharField(
        blank=True,
        max_length=200,
        null=True,
        verbose_name=_('user bank account name')
    )
WILLIAM GATES's avatar
WILLIAM GATES committed
279
280
281
282
283
284
285
286
    bank_account_transfer_destination = db_models.ForeignKey(
        'api.BankAccountTransferDestination',
        null=True,
        on_delete=db_models.SET_NULL,
        related_name='transactions',
        verbose_name=_('bank account transfer destination')
    )
    transfer_destination_bank_name = db_models.CharField(
287
288
289
        blank=True,
        max_length=100,
        null=True,
WILLIAM GATES's avatar
WILLIAM GATES committed
290
291
292
293
294
295
296
297
298
299
300
301
302
        verbose_name=_('transfer destination bank name')
    )
    transfer_destination_bank_account_name = db_models.CharField(
        blank=True,
        max_length=200,
        null=True,
        verbose_name=_('transfer destination bank account name')
    )
    transfer_destination_bank_account_number = db_models.CharField(
        blank=True,
        max_length=100,
        null=True,
        verbose_name=_('transfer destination bank account number')
303
304
305
306
307
308
309
310
    )
    created_at = db_models.DateTimeField(
        auto_now_add=True,
        db_index=True,
        verbose_name=_('created at')
    )
    updated_at = db_models.DateTimeField(auto_now=True, db_index=True, verbose_name=_('updated at'))

311
312
313
314
315
316
317
318
    batch = db_models.ForeignKey(
            'api.Batch',
            null=True,
            blank=True,
            on_delete=db_models.CASCADE,
            related_name='transaction',
            verbose_name=_('batch')
        )
319
320

    batch_name = db_models.CharField(max_length=200, verbose_name=_('batch name'))
321
322
323
324
325

    end_date = db_models.DateField(
        null=True,
        verbose_name=_('end date')
    )
326
        
327
328
329
330
331
332
333
334
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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
    class Meta:
        ordering = ['-updated_at', '-created_at', 'transaction_number', 'id']
        verbose_name = _('transaction')
        verbose_name_plural = _('transactions')

    def __str__(self):
        return self.transaction_number


class TransactionItem(db_models.Model):
    id = db_models.UUIDField(default=uuid.uuid4, primary_key=True, verbose_name=_('ID'))
    transaction = db_models.ForeignKey(
        'api.Transaction',
        on_delete=db_models.CASCADE,
        related_name='transaction_items',
        verbose_name=_('transaction')
    )
    product = db_models.ForeignKey(
        'api.Product',
        null=True,
        on_delete=db_models.SET_NULL,
        related_name='transaction_items',
        verbose_name=_('product')
    )
    product_name = db_models.CharField(max_length=200, verbose_name=_('product name'))
    product_price = db_models.DecimalField(
        decimal_places=2,
        max_digits=12,
        validators=[validators.MinValueValidator(decimal.Decimal('0.01'))],
        verbose_name=_('product price')
    )
    product_pre_order = db_models.BooleanField(verbose_name=_('product pre-order'))
    quantity = db_models.PositiveIntegerField(verbose_name=_('quantity'))

    class Meta:
        ordering = ['transaction', 'product', 'id']
        verbose_name = _('transaction item')
        verbose_name_plural = _('transaction items')

    def __str__(self):
        return self.product_name


class Program(db_models.Model):
    id = db_models.UUIDField(default=uuid.uuid4, primary_key=True, verbose_name=_('ID'))
    code = db_models.CharField(
        default=utils.generate_code,
        max_length=6,
        unique=True,
        verbose_name=_('code')
    )
    name = db_models.CharField(max_length=200, verbose_name=_('name'))
    description = db_models.TextField(verbose_name=_('description'))
    start_date_time = db_models.DateTimeField(
        blank=True,
        db_index=True,
        null=True,
        verbose_name=_('start date and time')
    )
    end_date_time = db_models.DateTimeField(
        blank=True,
        null=True,
        verbose_name=_('end date and time')
    )
    location = db_models.CharField(
        blank=True,
        max_length=200,
        null=True,
        verbose_name=_('location')
    )
    speaker = db_models.CharField(blank=True, max_length=200, null=True, verbose_name=_('speaker'))
WILLIAM GATES's avatar
WILLIAM GATES committed
398
399
400
401
402
403
404
405
    open_donation = db_models.BooleanField(default=True, verbose_name=_('open for donation'))
    program_minutes = db_models.FileField(
        blank=True,
        null=True,
        upload_to=utils.get_upload_file_path,
        validators=[validators.FileExtensionValidator(allowed_extensions=['pdf'])],
        verbose_name=_('program minutes')
    )
406
407
408
409
410
411
    poster_image = db_models.ImageField(
        blank=True,
        null=True,
        upload_to=utils.get_upload_file_path,
        verbose_name=_('poster image')
    )
WILLIAM GATES's avatar
WILLIAM GATES committed
412
    link = db_models.URLField(blank=True, null=True, verbose_name=_('link'))
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430

    class Meta:
        ordering = ['-start_date_time', '-end_date_time', 'name', 'code', 'id']
        verbose_name = _('program')
        verbose_name_plural = _('programs')

    def __str__(self):
        return self.code


class ProgramDonation(db_models.Model):
    id = db_models.UUIDField(default=uuid.uuid4, primary_key=True, verbose_name=_('ID'))
    donation_number = db_models.CharField(
        default=utils.generate_donation_number,
        max_length=6,
        unique=True,
        verbose_name=_('donation number')
    )
WILLIAM GATES's avatar
WILLIAM GATES committed
431
432
    program = db_models.ForeignKey(
        'api.Program',
433
434
435
        null=True,
        on_delete=db_models.SET_NULL,
        related_name='program_donations',
WILLIAM GATES's avatar
WILLIAM GATES committed
436
        verbose_name=_('program')
437
    )
WILLIAM GATES's avatar
WILLIAM GATES committed
438
439
    user = db_models.ForeignKey(
        'api.User',
440
441
442
        null=True,
        on_delete=db_models.SET_NULL,
        related_name='program_donations',
WILLIAM GATES's avatar
WILLIAM GATES committed
443
        verbose_name=_('user')
444
445
446
447
448
    )
    user_full_name = db_models.CharField(max_length=200, verbose_name=_('user full name'))
    user_phone_number = modelfields.PhoneNumberField(verbose_name=_('user phone number'))
    program_name = db_models.CharField(max_length=200, verbose_name=_('program name'))
    amount = db_models.DecimalField(
449
450
        blank=True,
        null=True,
451
452
453
454
455
456
457
458
459
460
461
        decimal_places=2,
        max_digits=12,
        validators=[validators.MinValueValidator(decimal.Decimal('0.01'))],
        verbose_name=_('amount')
    )
    donation_status = db_models.CharField(
        choices=constants.DONATION_STATUS_CHOICES,
        default='001',
        max_length=3,
        verbose_name=_('donation status')
    )
462
463
464
465
466
467
    donation_type = db_models.CharField(
        choices=constants.DONATION_TYPE_CHOICES,
        default='CSH',
        max_length=3,
        verbose_name=_('donation type')
    )
468
    proof_of_bank_transfer = db_models.ImageField(
469
470
        blank=True,
        null=True,
471
472
473
        upload_to=utils.get_upload_file_path,
        verbose_name=_('proof of bank transfer')
    )
WILLIAM GATES's avatar
WILLIAM GATES committed
474
475
476
    user_bank_name = db_models.CharField(
        blank=True,
        null=True,
477
        max_length=100,
WILLIAM GATES's avatar
WILLIAM GATES committed
478
479
        verbose_name=_('user bank name')
    )
480
    user_bank_account_name = db_models.CharField(
481
482
        blank=True,
        null=True,
483
484
485
        max_length=200,
        verbose_name=_('user bank account name')
    )
WILLIAM GATES's avatar
WILLIAM GATES committed
486
487
    bank_account_transfer_destination = db_models.ForeignKey(
        'api.BankAccountTransferDestination',
488
        blank=True,
WILLIAM GATES's avatar
WILLIAM GATES committed
489
490
491
492
493
494
495
496
        null=True,
        on_delete=db_models.SET_NULL,
        related_name='program_donations',
        verbose_name=_('bank account transfer destination')
    )
    transfer_destination_bank_name = db_models.CharField(
        blank=True,
        null=True,
497
        max_length=100,
WILLIAM GATES's avatar
WILLIAM GATES committed
498
499
500
501
502
        verbose_name=_('transfer destination bank name')
    )
    transfer_destination_bank_account_name = db_models.CharField(
        blank=True,
        null=True,
503
        max_length=200,
WILLIAM GATES's avatar
WILLIAM GATES committed
504
505
506
507
508
        verbose_name=_('transfer destination bank account name')
    )
    transfer_destination_bank_account_number = db_models.CharField(
        blank=True,
        null=True,
509
        max_length=100,
WILLIAM GATES's avatar
WILLIAM GATES committed
510
        verbose_name=_('transfer destination bank account number')
511
    )
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
    goods_quantity = db_models.DecimalField(
        blank=True,
        null=True,
        decimal_places=0,
        max_digits=12,
        validators=[validators.MinValueValidator(decimal.Decimal('1'))],
        verbose_name=_('goods quantity')
    )
    goods_description = db_models.CharField(
        blank=True,
        null=True,
        max_length=200,
        verbose_name=_('goods description')
    )
    delivery_method = db_models.CharField(
        choices=constants.DONATION_GOODS_DELIVERY_METHOD_CHOICES,
        blank=True,
        null=True,
        max_length=3,
        verbose_name=_('goods delivery method')
    )
    delivery_address = db_models.CharField(
        blank=True,
        null=True,
        max_length=200,
        verbose_name=_('goods delivery address')
    )
539
540
541
542
543
544
545
546
    created_at = db_models.DateTimeField(
        auto_now_add=True,
        db_index=True,
        verbose_name=_('created at')
    )
    updated_at = db_models.DateTimeField(auto_now=True, db_index=True, verbose_name=_('updated at'))

    class Meta:
WILLIAM GATES's avatar
WILLIAM GATES committed
547
        ordering = ['-updated_at', '-created_at', 'program', 'donation_number', 'id']
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
        verbose_name = _('program donation')
        verbose_name_plural = _('program donations')

    def __str__(self):
        return self.donation_number


class AppConfig(solo_models.SingletonModel):
    send_sms = db_models.BooleanField(default=False, verbose_name=_('send SMS'))

    class Meta:
        verbose_name = _('application configuration')
        verbose_name_plural = _('application configurations')

    def __str__(self):
        return 'Application Configuration'


WILLIAM GATES's avatar
WILLIAM GATES committed
566
567
class HelpContactConfig(solo_models.SingletonModel):
    email = db_models.EmailField(verbose_name=_('email'))
568
569

    class Meta:
WILLIAM GATES's avatar
WILLIAM GATES committed
570
571
        verbose_name = _('help contact configuration')
        verbose_name_plural = _('help contact configurations')
572
573

    def __str__(self):
WILLIAM GATES's avatar
WILLIAM GATES committed
574
        return 'Help Contact Configuration'
575

576

577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
class ShipmentConfig(solo_models.SingletonModel):
    hamlet = db_models.CharField(
        max_length=3,
        validators=[validators.int_list_validator(sep=''), validators.MinLengthValidator(3)],
        verbose_name=_('hamlet')
    )
    urban_village = db_models.CharField(
        max_length=100,
        verbose_name=_('urban village')
    )
    sub_district = db_models.CharField(
        max_length=100,
        verbose_name=_('sub-district')
    )
    same_hamlet_costs = db_models.DecimalField(
        decimal_places=2,
        default=decimal.Decimal('0'),
        max_digits=12,
        validators=[validators.MinValueValidator(decimal.Decimal('0'))],
        verbose_name=_(
            'shipping costs if the hamlet, urban village, and sub-district are the same as seller'
        )
    )
    same_urban_village_different_hamlet_costs = db_models.DecimalField(
        decimal_places=2,
        default=decimal.Decimal('0'),
        max_digits=12,
        validators=[validators.MinValueValidator(decimal.Decimal('0'))],
        verbose_name=_(
            'shipping costs if the urban village and sub-district are the same as seller'
        )
    )
    same_sub_district_different_urban_village_costs = db_models.DecimalField(
        decimal_places=2,
        default=decimal.Decimal('0'),
        max_digits=12,
        validators=[validators.MinValueValidator(decimal.Decimal('0'))],
        verbose_name=_('shipping costs if the sub-district is the same as seller')
    )

    class Meta:
        verbose_name = _('shipment configuration')
        verbose_name_plural = _('shipment configurations')

    def __str__(self):
        return 'Shipment Configuration'
inez nabila's avatar
inez nabila committed
623

624

625
626
627
628
629
class Batch(db_models.Model):
    id = db_models.UUIDField(default=uuid.uuid4, primary_key=True, verbose_name=_('ID'))
    
    batch_name = db_models.CharField(max_length=200, verbose_name=_('name'))

630
    start_date = db_models.DateField(
631
        blank=False,
632
        verbose_name=_('start date')
633
    )
634
    end_date = db_models.DateField(
635
        blank=False,
636
        verbose_name=_('end date')
637
638
639
    )

    shipping_cost = db_models.IntegerField(
640
        blank=True,
641
642
        verbose_name=_('shipping cost'),
        null=True
643
644
645
    )

    class Meta:
646
        ordering = ['-start_date', '-end_date', 'batch_name', 'id']
647
648
        verbose_name = _('batch')
        verbose_name_plural = _('batches')
inez nabila's avatar
inez nabila committed
649

650
    def __str__(self):
651
        return self.batch_name
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679

class ProgramProgress(db_models.Model):
    id = db_models.UUIDField(default=uuid.uuid4, primary_key=True, verbose_name=_('ID'))
    date = db_models.DateField(
        blank=False,
        verbose_name=_('date')
    )
    description = fields.CICharField(max_length=200, verbose_name=_('description'))
    image = db_models.ImageField(
        blank=True,
        null=True,
        upload_to=utils.get_upload_file_path,
        verbose_name=_('image')
    )
    program = db_models.ForeignKey(
        'api.Program',
        on_delete=db_models.CASCADE,
        related_name='program',
        verbose_name=_('program')
    )

    class Meta:
        ordering = ['-date', 'id']
        verbose_name = _('program progress')
        verbose_name_plural = _('program progress')

    def __str__(self):
        return self.name