mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-24 07:19:36 +02:00
feat: Convert activity input to lowercase for consistency
This commit is contained in:
parent
c723d2836d
commit
5e70130000
4 changed files with 44 additions and 18 deletions
|
@ -42,6 +42,7 @@ class Adventure(models.Model):
|
||||||
raise ValidationError('Adventures associated with a public collection must be public. Collection: ' + self.trip.name + ' Adventure: ' + self.name)
|
raise ValidationError('Adventures associated with a public collection must be public. Collection: ' + self.trip.name + ' Adventure: ' + self.name)
|
||||||
if self.user_id != self.collection.user_id:
|
if self.user_id != self.collection.user_id:
|
||||||
raise ValidationError('Adventures must be associated with collections owned by the same user. Collection owner: ' + self.collection.user_id.username + ' Adventure owner: ' + self.user_id.username)
|
raise ValidationError('Adventures must be associated with collections owned by the same user. Collection owner: ' + self.collection.user_id.username + ' Adventure owner: ' + self.user_id.username)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,11 @@ class AdventureSerializer(serializers.ModelSerializer):
|
||||||
representation['image'] = f"{public_url}/media/{instance.image.name}"
|
representation['image'] = f"{public_url}/media/{instance.image.name}"
|
||||||
return representation
|
return representation
|
||||||
|
|
||||||
|
def validate_activity_types(self, value):
|
||||||
|
if value:
|
||||||
|
return [activity.lower() for activity in value]
|
||||||
|
return value
|
||||||
|
|
||||||
class CollectionSerializer(serializers.ModelSerializer):
|
class CollectionSerializer(serializers.ModelSerializer):
|
||||||
adventures = AdventureSerializer(many=True, read_only=True, source='adventure_set')
|
adventures = AdventureSerializer(many=True, read_only=True, source='adventure_set')
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
function addActivity() {
|
function addActivity() {
|
||||||
if (inputVal && activities) {
|
if (inputVal && activities) {
|
||||||
const trimmedInput = inputVal.trim();
|
const trimmedInput = inputVal.trim().toLocaleLowerCase();
|
||||||
if (trimmedInput && !activities.includes(trimmedInput)) {
|
if (trimmedInput && !activities.includes(trimmedInput)) {
|
||||||
activities = [...activities, trimmedInput];
|
activities = [...activities, trimmedInput];
|
||||||
inputVal = '';
|
inputVal = '';
|
||||||
|
|
|
@ -83,6 +83,25 @@
|
||||||
<li>
|
<li>
|
||||||
<button on:click={() => goto('/map')}>Map</button>
|
<button on:click={() => goto('/map')}>Map</button>
|
||||||
</li>
|
</li>
|
||||||
|
<form class="flex gap-2">
|
||||||
|
<label class="input input-bordered flex items-center gap-2">
|
||||||
|
<input type="text" bind:value={query} class="grow" placeholder="Search" />
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 16 16"
|
||||||
|
fill="currentColor"
|
||||||
|
class="h-4 w-4 opacity-70"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
fill-rule="evenodd"
|
||||||
|
d="M9.965 11.026a5 5 0 1 1 1.06-1.06l2.755 2.754a.75.75 0 1 1-1.06 1.06l-2.755-2.754ZM10.5 7a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0Z"
|
||||||
|
clip-rule="evenodd"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</label>
|
||||||
|
<button on:click={searchGo} type="submit" class="btn btn-neutral">Search</button>
|
||||||
|
</form>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if !data.user}
|
{#if !data.user}
|
||||||
|
@ -115,24 +134,25 @@
|
||||||
<li>
|
<li>
|
||||||
<button class="btn btn-neutral" on:click={() => goto('/map')}>Map</button>
|
<button class="btn btn-neutral" on:click={() => goto('/map')}>Map</button>
|
||||||
</li>
|
</li>
|
||||||
<label class="input input-bordered flex items-center gap-2">
|
<form class="flex gap-2">
|
||||||
<form>
|
<label class="input input-bordered flex items-center gap-2">
|
||||||
<input type="text" bind:value={query} class="grow" placeholder="Search" />
|
<input type="text" bind:value={query} class="grow" placeholder="Search" />
|
||||||
</form>
|
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
viewBox="0 0 16 16"
|
viewBox="0 0 16 16"
|
||||||
fill="currentColor"
|
fill="currentColor"
|
||||||
class="h-4 w-4 opacity-70"
|
class="h-4 w-4 opacity-70"
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
fill-rule="evenodd"
|
fill-rule="evenodd"
|
||||||
d="M9.965 11.026a5 5 0 1 1 1.06-1.06l2.755 2.754a.75.75 0 1 1-1.06 1.06l-2.755-2.754ZM10.5 7a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0Z"
|
d="M9.965 11.026a5 5 0 1 1 1.06-1.06l2.755 2.754a.75.75 0 1 1-1.06 1.06l-2.755-2.754ZM10.5 7a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0Z"
|
||||||
clip-rule="evenodd"
|
clip-rule="evenodd"
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
</label>
|
</label>
|
||||||
<button on:click={searchGo} type="submit" class="btn btn-neutral">Search</button>
|
<button on:click={searchGo} type="submit" class="btn btn-neutral">Search</button>
|
||||||
|
</form>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if !data.user}
|
{#if !data.user}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue