Commit 429faa25 authored by Alice's avatar Alice

simplify the model

parent a2fed472
Pipeline #6441 passed with stage
in 27 seconds
# -*- coding: utf-8 -*-
# Generated by Django 1.11.22 on 2019-11-18 15:26
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('djangoldp_like', '0006_auto_20191114_1402'),
]
operations = [
migrations.AlterUniqueTogether(
name='like',
unique_together=set([]),
),
migrations.RemoveField(
model_name='like',
name='receiver_content_type',
),
migrations.RemoveField(
model_name='like',
name='receiver_object_id',
),
]
......@@ -8,24 +8,24 @@ from django.utils import timezone
class Like(Model):
sender = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, related_name='likes')
receiver_content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
receiver_object_id = models.IntegerField(verbose_name="receiver_object_id")
receiver = GenericForeignKey(
ct_field="receiver_content_type",
fk_field="receiver_object_id"
)
# receiver_content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
# receiver_object_id = models.IntegerField(verbose_name="receiver_object_id")
# receiver = GenericForeignKey(
# ct_field="receiver_content_type",
# fk_field="receiver_object_id"
# )
timestamp = models.DateTimeField(default=timezone.now)
# Please refer to Django documentation
class Meta:
container_path = 'likes/'
rdf_type = 'coopstarter:like'
serializer_fields = ["@id", 'sender', 'receiver', 'timestamp']
serializer_fields = ["@id", 'sender', 'timestamp']
anonymous_perms = ['view']
authenticated_perms = ['inherit', 'add']
owner_perms = ['inherit', 'change', 'control', 'delete']
owner_field = "sender"
unique_together = (('sender', 'receiver_content_type', 'receiver_object_id'),)
#unique_together = (('sender', 'receiver_content_type', 'receiver_object_id'),)
def __str__(self):
return str(self.sender.name())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment