salw/salw_admin/pssm_api/models.py
2024-11-28 16:06:12 +01:00

52 lines
1.9 KiB
Python

from django.db import models
import os
# Create your models here.
class Images(models.Model):
title = models.CharField(max_length=200)
image = models.ImageField(upload_to='images/')
copyright = models.CharField(max_length=200)
description = models.TextField(blank=True)
uploaded_at = models.DateTimeField(auto_now_add=True)
def __str__(self) -> str:
return self.title
class Impact_Stories(models.Model):
title = models.CharField(max_length=200)
file = models.FileField(upload_to='impact_stories/')
uploaded_at = models.DateTimeField(auto_now_add=True)
description = models.TextField(blank=True)
def __str__(self) -> str:
return self.title
class PSSM_Resources(models.Model):
title = models.CharField(max_length=200)
file = models.FileField(upload_to='pssm_resources/')
uploaded_at = models.DateTimeField(auto_now_add=True)
description = models.TextField(blank=True)
def __str__(self) -> str:
return self.title
class African_Countries(models.Model):
id = models.IntegerField(primary_key=True, unique=True)
name = models.CharField(max_length=50)
iso = models.CharField(max_length=5, default="")
def __str__(self) -> int:
return self.name
class PSSM_Countries(models.Model):
country = models.ForeignKey(African_Countries, on_delete=models.CASCADE)
recsa = models.BooleanField(default=False)
ecowas = models.BooleanField(default=False)
trained_participants = models.IntegerField(help_text="Number of participants trained")
pssm_instractors = models.IntegerField(help_text="Number of PSSM instractors")
senior_pssm_instractors = models.IntegerField(help_text="Number of senior PSSM instractors")
modefied_at = models.DateTimeField(auto_now_add=True, blank=True)
def __str__(self) -> str:
return self.country.name