mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-25 08:41:00 +00:00
Merge timelineevent, urls and post type migration
This commit is contained in:
parent
a408cbaa27
commit
35102fbdd4
4 changed files with 90 additions and 36 deletions
|
@ -323,6 +323,7 @@ class Migration(migrations.Migration):
|
||||||
("liked", "Liked"),
|
("liked", "Liked"),
|
||||||
("followed", "Followed"),
|
("followed", "Followed"),
|
||||||
("boosted", "Boosted"),
|
("boosted", "Boosted"),
|
||||||
|
("announcement", "Announcement"),
|
||||||
],
|
],
|
||||||
max_length=100,
|
max_length=100,
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
# Generated by Django 4.1.4 on 2022-12-16 02:52
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
("activities", "0004_emoji_post_emojis"),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name="post",
|
|
||||||
name="type",
|
|
||||||
field=models.CharField(
|
|
||||||
choices=[
|
|
||||||
("Article", "Article"),
|
|
||||||
("Audio", "Audio"),
|
|
||||||
("Event", "Event"),
|
|
||||||
("Image", "Image"),
|
|
||||||
("Note", "Note"),
|
|
||||||
("Page", "Page"),
|
|
||||||
("Question", "Question"),
|
|
||||||
("Video", "Video"),
|
|
||||||
],
|
|
||||||
default="Note",
|
|
||||||
max_length=20,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name="post",
|
|
||||||
name="type_data",
|
|
||||||
field=models.JSONField(blank=True, null=True),
|
|
||||||
),
|
|
||||||
]
|
|
85
activities/migrations/0005_post_type_timeline_urls.py
Normal file
85
activities/migrations/0005_post_type_timeline_urls.py
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
# Generated by Django 4.1.4 on 2022-12-16 02:52
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
def timeline_event_populate(apps, schema_editor):
|
||||||
|
"""
|
||||||
|
Populates all timeline events with a published date before 2001
|
||||||
|
with their created date instead
|
||||||
|
"""
|
||||||
|
TimelineEvent = apps.get_model("activities", "timelineevent")
|
||||||
|
TimelineEvent.objects.filter(
|
||||||
|
published__lt=datetime.datetime(2001, 1, 1, tzinfo=datetime.timezone.utc)
|
||||||
|
).update(published=models.F("created"))
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("activities", "0004_emoji_post_emojis"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="post",
|
||||||
|
name="type",
|
||||||
|
field=models.CharField(
|
||||||
|
choices=[
|
||||||
|
("Article", "Article"),
|
||||||
|
("Audio", "Audio"),
|
||||||
|
("Event", "Event"),
|
||||||
|
("Image", "Image"),
|
||||||
|
("Note", "Note"),
|
||||||
|
("Page", "Page"),
|
||||||
|
("Question", "Question"),
|
||||||
|
("Video", "Video"),
|
||||||
|
],
|
||||||
|
default="Note",
|
||||||
|
max_length=20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="post",
|
||||||
|
name="type_data",
|
||||||
|
field=models.JSONField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="timelineevent",
|
||||||
|
name="published",
|
||||||
|
field=models.DateTimeField(
|
||||||
|
default=datetime.datetime(
|
||||||
|
2000, 1, 1, 0, 0, tzinfo=datetime.timezone.utc
|
||||||
|
)
|
||||||
|
),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="timelineevent",
|
||||||
|
name="seen",
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="post",
|
||||||
|
name="object_uri",
|
||||||
|
field=models.CharField(blank=True, max_length=2048, null=True, unique=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="post",
|
||||||
|
name="type_data",
|
||||||
|
field=models.JSONField(
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="post",
|
||||||
|
name="url",
|
||||||
|
field=models.CharField(blank=True, max_length=2048, null=True),
|
||||||
|
),
|
||||||
|
migrations.RunPython(
|
||||||
|
code=timeline_event_populate,
|
||||||
|
reverse_code=lambda a, s: None,
|
||||||
|
),
|
||||||
|
]
|
|
@ -16,6 +16,7 @@ class TimelineEvent(models.Model):
|
||||||
liked = "liked" # Someone liking one of our posts
|
liked = "liked" # Someone liking one of our posts
|
||||||
followed = "followed"
|
followed = "followed"
|
||||||
boosted = "boosted" # Someone boosting one of our posts
|
boosted = "boosted" # Someone boosting one of our posts
|
||||||
|
announcement = "announcement" # Server announcement
|
||||||
|
|
||||||
# The user this event is for
|
# The user this event is for
|
||||||
identity = models.ForeignKey(
|
identity = models.ForeignKey(
|
||||||
|
@ -50,6 +51,9 @@ class TimelineEvent(models.Model):
|
||||||
related_name="timeline_events_about_us",
|
related_name="timeline_events_about_us",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
published = models.DateTimeField()
|
||||||
|
seen = models.BooleanField(default=False)
|
||||||
|
|
||||||
created = models.DateTimeField(auto_now_add=True)
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
Loading…
Reference in a new issue