mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-22 22:39:36 +02:00
admin fixes
This commit is contained in:
parent
94159d3624
commit
2ff47cbaf3
2 changed files with 11 additions and 8 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import os
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.utils.html import mark_safe
|
from django.utils.html import mark_safe
|
||||||
from .models import Adventure
|
from .models import Adventure
|
||||||
|
@ -10,7 +11,9 @@ class AdventureAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
def image_display(self, obj):
|
def image_display(self, obj):
|
||||||
if obj.image:
|
if obj.image:
|
||||||
return mark_safe(f'<img src="{obj.image.url}" width="100px" height="100px"')
|
public_url = os.environ.get('PUBLIC_URL', 'http://127.0.0.1:8000').rstrip('/')
|
||||||
|
public_url = public_url.replace("'", "")
|
||||||
|
return mark_safe(f'<img src="{public_url}/media/{obj.image.name}" width="100px" height="100px"')
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -48,7 +51,9 @@ class CustomUserAdmin(UserAdmin):
|
||||||
)
|
)
|
||||||
def image_display(self, obj):
|
def image_display(self, obj):
|
||||||
if obj.profile_pic:
|
if obj.profile_pic:
|
||||||
return mark_safe(f'<img src="{obj.profile_pic.url}" width="100px" height="100px"')
|
public_url = os.environ.get('PUBLIC_URL', 'http://127.0.0.1:8000').rstrip('/')
|
||||||
|
public_url = public_url.replace("'", "")
|
||||||
|
return mark_safe(f'<img src="{public_url}/media/{obj.profile_pic.name}" width="100px" height="100px"')
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -58,16 +58,16 @@ export const actions: Actions = {
|
||||||
|
|
||||||
let currentUser = (await resCurrent.json()) as User;
|
let currentUser = (await resCurrent.json()) as User;
|
||||||
|
|
||||||
if (username === currentUser.username) {
|
if (username === currentUser.username || !username) {
|
||||||
username = undefined;
|
username = undefined;
|
||||||
}
|
}
|
||||||
if (first_name === currentUser.first_name) {
|
if (first_name === currentUser.first_name || !first_name) {
|
||||||
first_name = undefined;
|
first_name = undefined;
|
||||||
}
|
}
|
||||||
if (last_name === currentUser.last_name) {
|
if (last_name === currentUser.last_name || !last_name) {
|
||||||
last_name = undefined;
|
last_name = undefined;
|
||||||
}
|
}
|
||||||
if (currentUser.profile_pic && !profile_pic) {
|
if (currentUser.profile_pic && profile_pic?.size === 0) {
|
||||||
profile_pic = undefined;
|
profile_pic = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,8 +101,6 @@ export const actions: Actions = {
|
||||||
return fail(res.status, response);
|
return fail(res.status, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
let user = response as User;
|
|
||||||
|
|
||||||
return { success: true };
|
return { success: true };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue