Skip to content

Commit

Permalink
add content model
Browse files Browse the repository at this point in the history
  • Loading branch information
sudan45 committed Sep 13, 2024
1 parent ee2d84a commit b011616
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 7 deletions.
7 changes: 7 additions & 0 deletions content/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
from django.contrib import admin

from content.models import Content

# Register your models here.


@admin.register(Content)
class ContentAdmin(admin.ModelAdmin):
list_display = ["title", "content_id"]
4 changes: 2 additions & 2 deletions content/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@


class ContentConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'content'
default_auto_field = "django.db.models.BigAutoField"
name = "content"
34 changes: 33 additions & 1 deletion content/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
import uuid

from django.db import models
from django.utils.translation import gettext_lazy as _


class Tag(models.Model):
name = models.CharField(max_length=20)
description = models.CharField(max_length=50, null=True, blank=True)


class Content(models.Model):
# TODO need to create UserResource models for user model
class DocumentType(models.IntegerChoices):
WORD = 1, _("Word")
PDF = 2, _("PDF")

class DocumenetStatus(models.IntegerChoices):
PENDING = 1, _("Pending")
TEXT_EXTRACTED = 2, _("Text extracted")
ADDED_TO_VECTOR = 3, _("Added to vector")
DELETED_FROM_VECTOR = 4, _("Deleted from vector")

# Create your models here.
title = models.CharField(max_length=100)
document_type = models.IntegerField(choices=DocumentType.choices)
document_file = models.FileField(upload_to="documents")
extracted_file = models.FileField(upload_to="documents")
content_id = models.UUIDField(default=uuid.uuid4, editable=False)
description = models.TextField()
tag = models.ManyToManyField("Tag")
created_at = models.DateTimeField(auto_now_add=True)
created_by = models.ForeignKey("user.User", on_delete=models.PROTECT)
is_deleted = models.BooleanField(default=False)
deleted_at = models.DateTimeField(null=True)
deleted_by = models.ForeignKey("user.User", null=True, on_delete=models.PROTECT)
2 changes: 0 additions & 2 deletions content/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from django.test import TestCase

# Create your tests here.
2 changes: 0 additions & 2 deletions content/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from django.shortcuts import render

# Create your views here.

0 comments on commit b011616

Please sign in to comment.