Skip to content

Commit

Permalink
update(id field): move id field to BaseModel from models
Browse files Browse the repository at this point in the history
  • Loading branch information
erfan-rfmhr committed Mar 26, 2024
1 parent fa6a627 commit 5b78ff4
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 10 deletions.
4 changes: 0 additions & 4 deletions content/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


class Topic(BaseModel):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=32, verbose_name=_('topic name'))

class Meta:
Expand All @@ -28,7 +27,6 @@ def save(self, *args, **kwargs):


class Post(BaseModel):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
content = models.TextField(verbose_name=_('post content'))
image = models.ImageField(verbose_name=_('post image'), upload_to="post_photos/", blank=True, null=True)
like_count = models.IntegerField(verbose_name=_('post like count'), default=0)
Expand Down Expand Up @@ -74,7 +72,6 @@ def save(self, *args, **kwargs):


class Comment(BaseModel):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
content = models.TextField(verbose_name=_('comment content'))
like_count = models.IntegerField(verbose_name=_('comment like count'), default=0)
commenter = models.ForeignKey(
Expand Down Expand Up @@ -106,7 +103,6 @@ def __str__(self):


class Repost(BaseModel):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
post = models.ForeignKey(
Post,
verbose_name=_('reposted post'),
Expand Down
3 changes: 0 additions & 3 deletions engagement/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


class LikedPost(BaseModel):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
like_count = models.IntegerField(verbose_name=_('post like count'), default=0)
post = models.ForeignKey(
Post,
Expand Down Expand Up @@ -40,7 +39,6 @@ def __str__(self):


class LikedComment(BaseModel):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
like_count = models.IntegerField(verbose_name=_('comment like count'), default=0)
comment = models.ForeignKey(
Comment,
Expand Down Expand Up @@ -69,7 +67,6 @@ def __str__(self):


class LikeNotification(BaseModel):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
notified = models.ForeignKey(
User,
verbose_name=_('notified user'),
Expand Down
3 changes: 0 additions & 3 deletions relation/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import uuid

from django.contrib.auth import get_user_model
from django.db import models
from django.utils.translation import gettext_lazy as _
Expand All @@ -10,7 +8,6 @@


class Relation(BaseModel):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
following = models.ForeignKey(
User,
verbose_name=_('following'),
Expand Down
3 changes: 3 additions & 0 deletions utils/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import uuid

from django.db import models


class BaseModel(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
created_time = models.DateTimeField(auto_now_add=True)
modified_time = models.DateTimeField(auto_now=True)

Expand Down

0 comments on commit 5b78ff4

Please sign in to comment.