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

WIP: Remove tags from news (1) #423

Open
wants to merge 9 commits into
base: master
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
2 changes: 1 addition & 1 deletion news/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_changeform_initial_data(self, request):
"More options",
{
"classes": ("collapse",),
"fields": ("author", ("status", "allow_comments"), "tease", "tags"),
"fields": ("author", ("status", "allow_comments"), "tease"),
},
),
)
Expand Down
111 changes: 111 additions & 0 deletions news/migrations/0001_squashed_0004_remove_post_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Generated by Django 2.2.28 on 2023-04-16 19:47

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import news.models


class Migration(migrations.Migration):
replaces = [
("news", "0001_initial"),
("news", "0002_auto_20170417_1857"),
("news", "0003_auto_20221208_1758"),
("news", "0004_remove_post_tags"),
]

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name="Category",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("title", models.CharField(max_length=100, verbose_name="title")),
("slug", models.SlugField(unique=True, verbose_name="slug")),
("image", models.ImageField(upload_to=news.models.get_upload_name)),
],
options={
"ordering": ("title",),
"db_table": "news_categories",
"verbose_name": "category",
"verbose_name_plural": "categories",
},
),
migrations.CreateModel(
name="Post",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("title", models.CharField(max_length=200, verbose_name="title")),
(
"slug",
models.SlugField(unique_for_date="publish", verbose_name="slug"),
),
(
"body",
models.TextField(
help_text="Text entered here will be rendered using Markdown",
verbose_name="body",
),
),
("tease", models.TextField(blank=True, verbose_name="tease")),
(
"status",
models.IntegerField(
choices=[(1, "Draft"), (2, "Public")],
default=2,
verbose_name="status",
),
),
(
"allow_comments",
models.BooleanField(default=True, verbose_name="allow comments"),
),
("publish", models.DateTimeField(verbose_name="publish")),
(
"created",
models.DateTimeField(auto_now_add=True, verbose_name="created"),
),
(
"modified",
models.DateTimeField(auto_now=True, verbose_name="modified"),
),
(
"author",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to=settings.AUTH_USER_MODEL,
),
),
("categories", models.ManyToManyField(blank=True, to="news.Category")),
],
options={
"ordering": ("-publish",),
"db_table": "news_posts",
"verbose_name": "post",
"verbose_name_plural": "posts",
"get_latest_by": "publish",
},
),
]
16 changes: 16 additions & 0 deletions news/migrations/0004_remove_post_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 2.2.28 on 2023-02-11 11:53

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("news", "0003_auto_20221208_1758"),
]

operations = [
migrations.RemoveField(
model_name="post",
name="tags",
),
]
4 changes: 1 addition & 3 deletions news/models.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import User
from tagging.fields import TagField
from news.managers import PublicManager
from django.urls import reverse
import datetime
import tagging


def get_upload_name(inst, fn):
Expand Down Expand Up @@ -56,7 +54,7 @@ class Post(models.Model):
created = models.DateTimeField(_("created"), auto_now_add=True)
modified = models.DateTimeField(_("modified"), auto_now=True)
categories = models.ManyToManyField(Category, blank=True)
tags = TagField()

objects = PublicManager()

class Meta:
Expand Down