add personal_links

This commit is contained in:
Christoph J. Scherr 2023-07-15 14:28:44 +02:00
parent 6016a864d9
commit 002656ea72
Signed by: PlexSheep
GPG Key ID: 7CDD0B14851A08EF
13 changed files with 114 additions and 10 deletions

View File

@ -1,8 +1,17 @@
# gawa # gawa
Gawa is my personal website. I've personally written it using the django framework.
Gawa is my personal website. I've personally written it using the Django framework.
## Credentials
These are the Credentials for logging into the admin panel:
| Username | Password |
|----------|----------|
| root | root |
## License ## License
Bootstrap: MIT Licensed Bootstrap: MIT Licensed
Django: BSD 3-Clause "New" or "Revised" License Django: BSD 3-Clause "New" or "Revised" License
###### Gawa: MIT Licensed, see LICENSE __Gawa: MIT Licensed, see LICENSE__

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

View File

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

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.19 on 2023-07-15 12:29
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('start', '0009_alter_link_favicon'),
]
operations = [
migrations.AddField(
model_name='link',
name='personal',
field=models.BooleanField(default=False),
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 3.2.19 on 2023-07-15 12:41
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('start', '0010_link_personal'),
]
operations = [
migrations.AlterField(
model_name='searchable',
name='desc_de',
field=models.TextField(default='Beschreibung DE', max_length=250),
),
migrations.AlterField(
model_name='searchable',
name='desc_en',
field=models.TextField(default='Description EN', max_length=250),
),
]

View File

@ -37,8 +37,8 @@ class Searchable(models.Model):
title_en = models.CharField(max_length=50, default="title EN") title_en = models.CharField(max_length=50, default="title EN")
subtitle_de = models.CharField(max_length=50, blank=True) subtitle_de = models.CharField(max_length=50, blank=True)
subtitle_en = models.CharField(max_length=50, blank=True) subtitle_en = models.CharField(max_length=50, blank=True)
desc_de = models.CharField(max_length=250, unique=False, default="Beschreibung DE") desc_de = models.TextField(max_length=250, unique=False, default="Beschreibung DE")
desc_en = models.CharField(max_length=250, unique=False, default="Description EN") desc_en = models.TextField(max_length=250, unique=False, default="Description EN")
# may be empty/blank for some entries # may be empty/blank for some entries
date = models.DateField(blank=True, null=True) date = models.DateField(blank=True, null=True)
keywords = models.ManyToManyField(Keyword) keywords = models.ManyToManyField(Keyword)
@ -99,6 +99,7 @@ class Link(Searchable):
favicon_dir: str = "img/links/favicons" favicon_dir: str = "img/links/favicons"
favicon = models.ImageField(blank=True, upload_to=favicon_dir, null=True) favicon = models.ImageField(blank=True, upload_to=favicon_dir, null=True)
status = models.BooleanField(default=False) status = models.BooleanField(default=False)
personal = models.BooleanField(default=False)
def __str__(self): def __str__(self):
return f"{{<{self.__class__.__name__}>\"{self.title_en}\"}}" return f"{{<{self.__class__.__name__}>\"{self.title_en}\"}}"

View File

@ -5,11 +5,55 @@
{% block title %}{% translate "cscherr.de" %} - {% translate "Links" %}{% endblock title %} {% block title %}{% translate "cscherr.de" %} - {% translate "Links" %}{% endblock title %}
{% block main %} {% block main %}
<div class="container-fluid mt-5"> <div class="container-fluid mt-5">
<h4 class="">{% trans "Links" %}</h4> <h4 class="">{% trans "Personal" %}</h4>
<div class="row row-cols-1 row-cols-md-6 my-4">
{% for link in personal_links %}
<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="">
{% if LANGUAGE_CODE == "de" %}
<h5 class="card-title" style="height: 35px;">{{ 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>
<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>
<hr>
<p class="card-text">{{ link.desc_en }}</p>
{% endif %}
</div>
<div class="container pt-5 mt-3">
<ul class="list-group list-group-flush">
{% for keyword in link.keywords.all %}
{% if LANGUAGE_CODE == "de" %}
<li class="list-group-item">{{ keyword.text_de }}</li>
{% elif LANGUAGE_CODE == "en" %}
<li class="list-group-item">{{ keyword.text_en }}</li>
{% else %}
<li class="list-group-item">{{ keyword.text_en }}</li>
{% endif %}
{% endfor %}
<li class="list-group-item">
<i class="bi-box-arrow-up-right"></i>
{% translate "visit" %}
</li>
</ul>
</div>
</a>
</div>
{% endfor %}
</div>
</div>
<div class="container-fluid mt-5">
<h4 class="">{% trans "Others" %}</h4>
<div class="row row-cols-1 row-cols-md-6 my-4"> <div class="row row-cols-1 row-cols-md-6 my-4">
{% for link in links %} {% for link in links %}
<div class="card col m-2 p-0"> <div class="card col m-2 p-0">
<a class="text-reset link-offset-2 link-underline link-underline-opacity-0" href="{{ link.url }}"> <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;"> <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="{{ link.favicon.url }}" class="card-img-top rounded float-end" style="max-height: 32px; max-width: 32px;" alt="">
{% if LANGUAGE_CODE == "de" %} {% if LANGUAGE_CODE == "de" %}

View File

@ -21,7 +21,6 @@ def change_lang(context, lang="de", *args, **kwargs):
""" """
path = context['request'].get_raw_uri() path = context['request'].get_raw_uri()
logger.debug(f"requestdir: {dir(context['request'])}")
url = path url = path
try: try:
cur_lang: str = get_language() cur_lang: str = get_language()

View File

@ -104,7 +104,17 @@ class Links(ListView):
def get_queryset(self) -> QuerySet: def get_queryset(self) -> QuerySet:
object_list = Link.objects.filter( object_list = Link.objects.filter(
status=True, public=True status=True, public=True, personal=False
) )
object_list = object_list.filter(public=True)
return object_list return object_list
def get_queryset_personal_links(self) -> QuerySet:
object_list = Link.objects.filter(
status=True, public=True, personal=True
)
return object_list
def get_context_data(self, *, object_list=None, **kwargs):
context = super().get_context_data(object_list=object_list, **kwargs)
context['personal_links'] = self.get_queryset_personal_links()
return context