Rename BaseFeed fields

This commit is contained in:
Aarni Halinen
2022-07-27 00:17:16 +03:00
parent 9651725bb3
commit a35b86af43
2 changed files with 44 additions and 11 deletions
@@ -0,0 +1,33 @@
# Generated by Django 2.2.28 on 2022-07-26 21:16
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("webapp", "0091_remove_jobad_created_at"),
]
operations = [
migrations.RenameField(
model_name="basefeed",
old_name="autohide_enabled",
new_name="autoUnpublish",
),
migrations.RenameField(
model_name="basefeed",
old_name="visible",
new_name="isPublished",
),
migrations.RenameField(
model_name="basefeed",
old_name="publish_time",
new_name="publishAt",
),
migrations.RenameField(
model_name="basefeed",
old_name="autohide",
new_name="unpublishAt",
),
]
+11 -11
View File
@@ -48,21 +48,21 @@ class BaseFeed(models.Model):
image = models.ImageField(blank=True, null=True)
tags = models.ManyToManyField(Tag, related_name="feeds", blank=True)
# isNotDraft
visible = models.BooleanField(default=True)
# Automatically publish after this time, unless isDraft
publish_time = models.DateTimeField(default=timezone.now)
# Automatically unpublish after this if autohide_enabled
autohide = models.DateTimeField(default=month_from_now)
autohide_enabled = models.BooleanField(default=False)
# Require explicit publishing from creator
isPublished = models.BooleanField(default=True)
# Automatically publish after this time, unless still in draft (!isPublished)
publishAt = models.DateTimeField(default=timezone.now)
autoUnpublish = models.BooleanField(default=False)
# Automatically unpublish after this if auto_unpublish==True
unpublishAt = models.DateTimeField(default=month_from_now)
webhookUrl = ""
hookType = ""
previousVisible = False
wasPublishedBefore = False
def __init__(self, *args, **kwargs):
super(BaseFeed, self).__init__(*args, **kwargs)
self.previousVisible = self.visible
self.wasPublishedBefore = self.isPublished
def __str__(self):
delete_str = _("Deleted: ") if self.deleted else ""
@@ -72,7 +72,7 @@ class BaseFeed(models.Model):
created = self.pk is None
super(BaseFeed, self).save(force_insert, force_update, *args, **kwargs)
if self.visible and (created or not self.previousVisible):
if self.isPublished and (created or not self.wasPublishedBefore):
self.refresh_from_db() # Fetch so we can use primary key
url = f"{self.webhookUrl}/{self.pk}"
processHooks(
@@ -81,7 +81,7 @@ class BaseFeed(models.Model):
),
eventType=self.hookType,
)
self.previousVisible = self.visible
self.wasPublishedBefore = self.isPublished
class Feed(BaseFeed):