<reponame>Hypest-Software/beta-backend<filename>beta_apis/models.py<gh_stars>0
import uuid
from django.db import models

# Create your models here.
class Users(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    username = models.CharField(max_length=255, null=False, blank=False)
    password = models.CharField(max_length=200, null=False, blank=False)
    email = models.CharField(max_length=255, null=True, blank=True)
    first_name = models.CharField(max_length=200, null=True, blank=True)
    last_name = models.CharField(max_length=200, null=True, blank=True)
    full_name = models.CharField(max_length=200, null=True, blank=True)
    photo = models.CharField(max_length=200, null=True, blank=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        db_table = 'users'
        verbose_name_plural = 'Users'

    @classmethod
    def validate_username(cls, username):
        for c in username:
            if (c >= 'a' and c <='z') or (c >= 'A' and c <= 'Z') or (c.isdigit()) or c == '_':
                continue
            return False
        return True

    @classmethod
    def validate_password(cls, password):
        if len(password) < 6:
            return False
        return True


class Report(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    user_id = models.CharField(max_length=255, null=False, blank=False)
    latitude = models.FloatField(null=False, blank=False)
    longitude = models.FloatField(null=False, blank=False)
    describe = models.CharField(max_length=255, null=True, blank=True)
    is_public = models.BooleanField(default=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    address = models.CharField(max_length=255, null=True, blank=True)

    class Meta:
        db_table = 'report'
        verbose_name_plural = 'Reports'

class ReportPhoto(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    report_id = models.CharField(max_length=255, null=True, blank=True)
    user_id = models.CharField(max_length=255, null=False, blank=False)
    public_url = models.CharField(max_length=255, null=False, blank=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        db_table = 'report_photo'
        verbose_name_plural = 'Report Photos'
import uuid
from django.db import models

# Create your models here.
class Users(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    username = models.CharField(max_length=255, null=False, blank=False)
    password = models.CharField(max_length=200, null=False, blank=False)
    email = models.CharField(max_length=255, null=True, blank=True)
    first_name = models.CharField(max_length=200, null=True, blank=True)
    last_name = models.CharField(max_length=200, null=True, blank=True)
    full_name = models.CharField(max_length=200, null=True, blank=True)
    photo = models.CharField(max_length=200, null=True, blank=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        db_table = 'users'
        verbose_name_plural = 'Users'

    @classmethod
    def validate_username(cls, username):
        for c in username:
            if (c >= 'a' and c <='z') or (c >= 'A' and c <= 'Z') or (c.isdigit()) or c == '_':
                continue
            return False
        return True

    @classmethod
    def validate_password(cls, password):
        if len(password) < 6:
            return False
        return True


class Report(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    user_id = models.CharField(max_length=255, null=False, blank=False)
    latitude = models.FloatField(null=False, blank=False)
    longitude = models.FloatField(null=False, blank=False)
    describe = models.CharField(max_length=255, null=True, blank=True)
    is_public = models.BooleanField(default=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    address = models.CharField(max_length=255, null=True, blank=True)

    class Meta:
        db_table = 'report'
        verbose_name_plural = 'Reports'

class ReportPhoto(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    report_id = models.CharField(max_length=255, null=True, blank=True)
    user_id = models.CharField(max_length=255, null=False, blank=False)
    public_url = models.CharField(max_length=255, null=False, blank=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        db_table = 'report_photo'
        verbose_name_plural = 'Report Photos'
# Create your models here.