mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-02 19:55:18 +02:00
Merge pull request #171 from seanmorley15/development
Mobile Optimization and Security Fixes
This commit is contained in:
commit
290505d4c0
5 changed files with 26 additions and 20 deletions
|
@ -7,6 +7,7 @@ class AdventureSerializer(serializers.ModelSerializer):
|
|||
class Meta:
|
||||
model = Adventure
|
||||
fields = '__all__'
|
||||
read_only_fields = ['id', 'created_at', 'updated_at', 'user_id']
|
||||
|
||||
def to_representation(self, instance):
|
||||
representation = super().to_representation(instance)
|
||||
|
@ -205,4 +206,4 @@ class CollectionSerializer(serializers.ModelSerializer):
|
|||
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']
|
||||
read_only_fields = ['id', 'created_at', 'updated_at']
|
||||
read_only_fields = ['id', 'created_at', 'updated_at', 'user_id']
|
||||
|
|
|
@ -105,19 +105,19 @@ from rest_framework import serializers
|
|||
from django.conf import settings
|
||||
import os
|
||||
|
||||
class AdventureSerializer(serializers.ModelSerializer):
|
||||
image = serializers.SerializerMethodField()
|
||||
# class AdventureSerializer(serializers.ModelSerializer):
|
||||
# image = serializers.SerializerMethodField()
|
||||
|
||||
class Meta:
|
||||
model = Adventure
|
||||
fields = ['id', 'user_id', 'type', 'name', 'location', 'activity_types', 'description',
|
||||
'rating', 'link', 'image', 'date', 'trip_id', 'is_public', 'longitude', 'latitude']
|
||||
# class Meta:
|
||||
# model = Adventure
|
||||
# fields = ['id', 'user_id', 'type', 'name', 'location', 'activity_types', 'description',
|
||||
# 'rating', 'link', 'image', 'date', 'trip_id', 'is_public', 'longitude', 'latitude']
|
||||
|
||||
def get_image(self, obj):
|
||||
if obj.image:
|
||||
public_url = os.environ.get('PUBLIC_URL', '')
|
||||
return f'{public_url}/media/{obj.image.name}'
|
||||
return None
|
||||
# def get_image(self, obj):
|
||||
# if obj.image:
|
||||
# public_url = os.environ.get('PUBLIC_URL', '')
|
||||
# return f'{public_url}/media/{obj.image.name}'
|
||||
# return None
|
||||
|
||||
class UserDetailsSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
|
@ -161,7 +161,7 @@ class UserDetailsSerializer(serializers.ModelSerializer):
|
|||
|
||||
model = UserModel
|
||||
fields = ('pk', *extra_fields)
|
||||
read_only_fields = ('email', 'date_joined', 'is_staff')
|
||||
read_only_fields = ('email', 'date_joined', 'is_staff', 'is_superuser', 'is_active', 'pk')
|
||||
|
||||
class CustomUserDetailsSerializer(UserDetailsSerializer):
|
||||
|
||||
|
|
|
@ -16,14 +16,16 @@ class CountrySerializer(serializers.ModelSerializer):
|
|||
class Meta:
|
||||
model = Country
|
||||
fields = '__all__' # Serialize all fields of the Adventure model
|
||||
read_only_fields = ['id', 'name', 'country_code', 'continent', 'flag_url']
|
||||
|
||||
class RegionSerializer(serializers.ModelSerializer):
|
||||
flag_url = ''
|
||||
class Meta:
|
||||
model = Region
|
||||
fields = '__all__' # Serialize all fields of the Adventure model
|
||||
read_only_fields = ['id', 'name', 'country']
|
||||
|
||||
class VisitedRegionSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = VisitedRegion
|
||||
fields = '__all__' # Serialize all fields of the Adventure model
|
||||
fields = '__all__' # Serialize all fields of the Adventure model
|
||||
read_only_fields = ['user_id', 'id']
|
|
@ -130,9 +130,9 @@
|
|||
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
||||
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
||||
<div class="modal-box" role="dialog" on:keydown={handleKeydown} tabindex="0">
|
||||
<h3 class="font-bold text-lg">Checklist Editor</h3>
|
||||
<h3 class="font-bold text-lg mb-2">Checklist Editor</h3>
|
||||
{#if initialName}
|
||||
<p class="font-semibold text-md mb-2">Editing note {initialName}</p>
|
||||
<p class="font-semibold text-md mb-2">Editing checklist {initialName}</p>
|
||||
{/if}
|
||||
|
||||
{#if (checklist && user?.pk == checklist?.user_id) || !checklist}
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
||||
<ul
|
||||
tabindex="0"
|
||||
class="menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-100 rounded-box w-52 gap-2"
|
||||
class="menu dropdown-content mt-3 z-[1] p-2 shadow bg-neutral text-neutral-content rounded-box gap-2 w-96"
|
||||
>
|
||||
{#if data.user}
|
||||
<li>
|
||||
|
@ -109,7 +109,7 @@
|
|||
/>
|
||||
</svg>
|
||||
</label>
|
||||
<button on:click={searchGo} type="submit" class="btn btn-neutral">Search</button>
|
||||
<button on:click={searchGo} type="submit" class="btn btn-primary">Search</button>
|
||||
</form>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -174,7 +174,10 @@
|
|||
<DotsHorizontal class="w-6 h-6" />
|
||||
</div>
|
||||
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
||||
<ul tabindex="0" class="dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box w-52">
|
||||
<ul
|
||||
tabindex="0"
|
||||
class="dropdown-content bg-neutral text-neutral-content z-[1] menu p-2 shadow rounded-box w-52"
|
||||
>
|
||||
<button class="btn" on:click={() => (isAboutModalOpen = true)}>About AdventureLog</button>
|
||||
<p class="font-bold m-4 text-lg">Theme Selection</p>
|
||||
<form method="POST" use:enhance={submitUpdateTheme}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue