updated links

This commit is contained in:
Christoph J. Scherr 2023-10-10 12:29:43 +02:00
parent 4e322f7211
commit 39757f64a7
6 changed files with 65 additions and 21 deletions

View File

@ -24,7 +24,6 @@ class LinkAdmin(admin.ModelAdmin):
"""
Admin Interface for Links
"""
list_display = ["title_en", "title_de", "url",
"suburl", "favicon", "status", "personal"]
ordering = ['status', 'title_de', 'title_en']
list_display = ["title_en", "title_de", "url", "favicon", "personal"]
ordering = ['title_de', 'title_en']
actions = [regenerate]

View File

@ -0,0 +1,17 @@
# Generated by Django 4.2.6 on 2023-10-10 10:09
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('start', '0002_initial'),
]
operations = [
migrations.RemoveField(
model_name='link',
name='status',
),
]

View File

@ -0,0 +1,33 @@
# Generated by Django 4.2.6 on 2023-10-10 10:10
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('start', '0003_remove_link_status'),
]
operations = [
migrations.RemoveField(
model_name='link',
name='date',
),
migrations.RemoveField(
model_name='link',
name='subtitle_de',
),
migrations.RemoveField(
model_name='link',
name='subtitle_en',
),
migrations.RemoveField(
model_name='link',
name='suburl',
),
migrations.RemoveField(
model_name='link',
name='update',
),
]

View File

@ -32,24 +32,19 @@ class Link(models.Model):
contains all my interesting links
"""
FAVICON_DIR: str = "img/links/favicons"
# the actual link
url = models.URLField(unique=True, null=False, primary_key=True)
favicon_dir: str = "img/links/favicons"
favicon = models.ImageField(blank=True, upload_to=favicon_dir, null=True)
status = models.BooleanField(default=False)
favicon = models.ImageField(blank=True, upload_to=FAVICON_DIR, null=True)
personal = models.BooleanField(default=False)
title_de = models.CharField(max_length=50, default="Nicht übersetzt")
title_en = models.CharField(max_length=50, default="Not translated")
subtitle_de = models.CharField(max_length=50, blank=True)
subtitle_en = models.CharField(max_length=50, blank=True)
desc_de = models.TextField(
blank=True, max_length=250, unique=False, default="Keine Beschreibung")
desc_en = models.TextField(
blank=True, max_length=250, unique=False, default="no description")
date = models.DateTimeField(blank=True, null=True)
update = models.DateTimeField(blank=True, null=True)
keywords = models.ManyToManyField(Keyword, blank=True)
suburl = models.CharField(max_length=200, blank=True, null=True)
public = models.BooleanField(default=False)
def __str__(self):

View File

@ -11,17 +11,17 @@
<div class="card col m-2 p-0">
<a class="text-reset link-offset-2 link-underline link-underline-opacity-0" href="{{ link.url }}" target="_blank">
<div class="card-body" style="height: 150px;">
<img src="{{ link.favicon.url }}" class="card-img-top rounded float-end" style="max-height: 32px; max-width: 32px;" alt="">
<img src="{% if link.favicon_url %}{{ link.favicon.url }}{% endif %}" class="card-img-top rounded float-end" style="max-height: 32px; max-width: 32px;" alt="">
{% if LANGUAGE_CODE == "de" %}
<h5 class="card-title" style="height: 35px;">{{ link.title_de }}<small class="text-body-secondary">{{ link.subtitle }}</small></h5>
<h5 class="card-title">{{ link.title_de }}<small class="text-body-secondary">{{ link.subtitle }}</small></h5>
<hr>
<p class="card-text">{{ link.desc_de }}</p>
{% elif LANGUAGE_CODE == "en" %}
<h5 class="card-title" style="height: 35px;">{{ link.title_en }}<small class="text-body-secondary">{{ link.subtitle }}</small></h5>
<h5 class="card-title">{{ link.title_en }}<small class="text-body-secondary">{{ link.subtitle }}</small></h5>
<hr>
<p class="card-text">{{ link.desc_en }}</p>
{% else %}
<h5 class="card-title" style="height: 35px;">{{ link.title_en }}<small class="text-body-secondary">{{ link.subtitle }}</small></h5>
<h5 class="card-title">{{ link.title_en }}<small class="text-body-secondary">{{ link.subtitle }}</small></h5>
<hr>
<p class="card-text">{{ link.desc_en }}</p>
{% endif %}
@ -55,17 +55,17 @@
<div class="card col m-2 p-0">
<a class="text-reset link-offset-2 link-underline link-underline-opacity-0" href="{{ link.url }}" target="_blank">
<div class="card-body" style="height: 150px;">
<img src="{{ link.favicon.url }}" class="card-img-top rounded float-end" style="max-height: 32px; max-width: 32px;" alt="">
<img src="{% if link.favicon %}{{ link.favicon.url }}{% endif %}" class="card-img-top rounded float-end" style="max-height: 32px; max-width: 32px;" alt="">
{% if LANGUAGE_CODE == "de" %}
<h5 class="card-title" style="height: 35px;">{{ link.title_de }}<small class="text-body-secondary">{{ link.subtitle }}</small></h5>
<h5 class="card-title">{{ link.title_de }}<small class="text-body-secondary">{{ link.subtitle }}</small></h5>
<hr>
<p class="card-text">{{ link.desc_de }}</p>
{% elif LANGUAGE_CODE == "en" %}
<h5 class="card-title" style="height: 35px;">{{ link.title_en }}<small class="text-body-secondary">{{ link.subtitle }}</small></h5>
<h5 class="card-title">{{ link.title_en }}<small class="text-body-secondary">{{ link.subtitle }}</small></h5>
<hr>
<p class="card-text">{{ link.desc_en }}</p>
{% else %}
<h5 class="card-title" style="height: 35px;">{{ link.title_en }}<small class="text-body-secondary">{{ link.subtitle }}</small></h5>
<h5 class="card-title">{{ link.title_en }}<small class="text-body-secondary">{{ link.subtitle }}</small></h5>
<hr>
<p class="card-text">{{ link.desc_en }}</p>
{% endif %}

View File

@ -65,13 +65,13 @@ class Links(ListView):
def get_queryset(self) -> QuerySet:
object_list = Link.objects.filter(
status=True, public=True, personal=False
public=True, personal=False
)
return object_list
def get_queryset_personal_links(self) -> QuerySet:
object_list = Link.objects.filter(
status=True, public=True, personal=True
public=True, personal=True
)
return object_list