Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a featured field in stori models #159

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 4.1.3 on 2024-03-06 15:58

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("accounts", "0005_alter_user_verification_code"),
]

operations = [
migrations.AlterField(
model_name="user",
name="first_name",
field=models.CharField(max_length=150),
),
migrations.AlterField(
model_name="user",
name="last_name",
field=models.CharField(max_length=150),
),
migrations.AlterField(
model_name="user",
name="verification_code",
field=models.CharField(default="684941", max_length=6, unique=True),
),
]
18 changes: 18 additions & 0 deletions blog/migrations/0003_stori_featured.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.3 on 2024-03-06 15:58

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("blog", "0002_initial"),
]

operations = [
migrations.AddField(
model_name="stori",
name="featured",
field=models.BooleanField(default=False),
),
]
JimmyTron marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Status(models.TextChoices):
content = RichTextUploadingField()
created_by = models.ForeignKey(Account, on_delete=models.SET_NULL, null=True)
status = models.CharField(max_length=9,choices=Status.choices, default=Status.Draft) #"""This here serves to indicate whether a stori has been published or not."""
featured = models.BooleanField(default=False) #"""This here serves to indicate whether a stori is featured or not."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addition of the featured field (models.BooleanField(default=False)) is a practical enhancement to the Stori model, enabling the ability to distinguish featured content

category = models.ForeignKey(Category,on_delete=models.PROTECT)


Expand Down
2 changes: 1 addition & 1 deletion blog/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BlogSerializer(serializers.ModelSerializer):
# comment = CommentSerializer(many=True,read_only=True)
class Meta:
model = Stori
fields = ['id', 'title', 'slug', 'description', 'content', 'status', 'category']
fields = ['id', 'title', 'slug', 'description', 'content', 'status', 'featured', 'category']
JimmyTron marked this conversation as resolved.
Show resolved Hide resolved
read_only_fields = ("slug",)


Expand Down
Loading