mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-24 07:19:36 +02:00
Add link field to collection and fix the visited counter in collection page
This commit is contained in:
parent
7d9bc16588
commit
1e61032692
8 changed files with 68 additions and 14 deletions
18
backend/server/adventures/migrations/0010_collection_link.py
Normal file
18
backend/server/adventures/migrations/0010_collection_link.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 5.0.8 on 2024-10-08 03:05
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('adventures', '0009_alter_adventure_type'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='collection',
|
||||
name='link',
|
||||
field=models.URLField(blank=True, max_length=2083, null=True),
|
||||
),
|
||||
]
|
|
@ -117,6 +117,7 @@ class Collection(models.Model):
|
|||
updated_at = models.DateTimeField(auto_now=True)
|
||||
is_archived = models.BooleanField(default=False)
|
||||
shared_with = models.ManyToManyField(User, related_name='shared_with', blank=True)
|
||||
link = models.URLField(blank=True, null=True, max_length=2083)
|
||||
|
||||
|
||||
# if connected adventures are private and collection is public, raise an error
|
||||
|
|
|
@ -176,8 +176,7 @@ class CollectionSerializer(serializers.ModelSerializer):
|
|||
|
||||
class Meta:
|
||||
model = Collection
|
||||
# fields are all plus the adventures field
|
||||
fields = ['id', 'description', 'user_id', 'name', 'is_public', 'adventures', 'created_at', 'start_date', 'end_date', 'transportations', 'notes', 'updated_at', 'checklists', 'is_archived', 'shared_with']
|
||||
fields = ['id', 'description', 'user_id', 'name', 'is_public', 'adventures', 'created_at', 'start_date', 'end_date', 'transportations', 'notes', 'updated_at', 'checklists', 'is_archived', 'shared_with', 'link']
|
||||
read_only_fields = ['id', 'created_at', 'updated_at', 'user_id']
|
||||
|
||||
def to_representation(self, instance):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue