Update about page
This commit is contained in:
parent
c86eca4dbb
commit
5f529dc2b9
8 changed files with 102 additions and 25 deletions
|
@ -138,19 +138,13 @@ MEDIA_ROOT = BASE_DIR / 'media'
|
|||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
|
||||
# Import local settings
|
||||
try:
|
||||
from .local_settings import *
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
# Session lifetime 1 year
|
||||
SESSION_COOKIE_AGE = 31556000
|
||||
|
||||
|
||||
# Gotify
|
||||
#GOTIFY_URL = "https://gotify....."
|
||||
#GOTIFY_TOKEN = "topsecret"
|
||||
# GOTIFY_URL = "https://gotify....."
|
||||
# GOTIFY_TOKEN = "topsecret"
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
|
@ -166,10 +160,10 @@ LOGGING = {
|
|||
},
|
||||
},
|
||||
'handlers': {
|
||||
#'gotify': {
|
||||
# 'gotify': {
|
||||
# 'level': 'ERROR',
|
||||
# 'class': 'gallery.logging_handlers.GotifyHandler',
|
||||
#},
|
||||
# 'class': 'gallery.logging_handlers.GotifyHandler',
|
||||
# },
|
||||
'error_file': {
|
||||
'level': 'ERROR',
|
||||
'class': 'logging.FileHandler',
|
||||
|
@ -185,10 +179,31 @@ LOGGING = {
|
|||
},
|
||||
'loggers': {
|
||||
'django': {
|
||||
#'handlers': ['error_file', 'warning_file', 'gotify'],
|
||||
# 'handlers': ['error_file', 'warning_file', 'gotify'],
|
||||
'handlers': ['error_file', 'warning_file'],
|
||||
'level': 'WARNING',
|
||||
'propagate': True,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
ABOUT_PAGE_SETTINGS = {
|
||||
|
||||
"title": "Muistox gallery",
|
||||
"description": "Just another wannabe photographer...",
|
||||
"profile_image": "img/default.png",
|
||||
|
||||
"contact_email": "muistox@gallery.invalid",
|
||||
|
||||
"bluesky_url": "https://bsky.app/",
|
||||
"twitter_url": "https://twitter.com/",
|
||||
"instagram_url": "https://www.instagram.com/",
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Import local settings
|
||||
try:
|
||||
from .local_settings import *
|
||||
except ImportError:
|
||||
pass
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 5.1.4 on 2025-02-23 15:54
|
||||
# Generated by Django 5.1.7 on 2025-03-28 19:11
|
||||
|
||||
import datetime
|
||||
import django.db.models.deletion
|
||||
|
@ -56,7 +56,7 @@ class Migration(migrations.Migration):
|
|||
name='Photo',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('slug', models.CharField(editable=False, max_length=15, verbose_name='Photo Slug')),
|
||||
('slug', models.CharField(editable=False, max_length=15, unique=True, verbose_name='Photo Slug')),
|
||||
('photo', models.ImageField(height_field='height', upload_to=gallery.models.photo.get_upload_path, verbose_name='Photo', width_field='width')),
|
||||
('width', models.PositiveIntegerField(default=0, editable=False, verbose_name='Photo Width')),
|
||||
('height', models.PositiveIntegerField(default=0, editable=False, verbose_name='Photo Height')),
|
||||
|
@ -88,4 +88,8 @@ class Migration(migrations.Migration):
|
|||
'verbose_name_plural': 'Redirs',
|
||||
},
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='photo',
|
||||
constraint=models.UniqueConstraint(fields=('slug',), name='unique_photo_slug'),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends "base_dark.html" %}
|
||||
{% load top_tags %}
|
||||
{% load static %}
|
||||
{% load stats %}
|
||||
|
||||
<!-- Title -->
|
||||
{% block title %} Gallery : About{% endblock %}
|
||||
|
@ -7,17 +8,48 @@
|
|||
<!-- Content -->
|
||||
{% block content %}
|
||||
|
||||
<div class="uk-margin-top uk-width-1-4@m">
|
||||
<div class="uk-card uk-card-default uk-card-body uk-padding-small">
|
||||
{% load static %}
|
||||
<img src="{% static 'img/profile.png' %}" alt="Contact">
|
||||
{% gallery_stats as counts %}
|
||||
|
||||
<div class="uk-container uk-margin-small-top">
|
||||
<a href="https://bsky.app/profile/nyymix.net" uk-icon="icon: bluesky"></a>
|
||||
<a href="https://twitter.com/nyymix" uk-icon="icon: twitter"></a>
|
||||
<a href="https://www.instagram.com/nyymix/" uk-icon="icon: instagram"></a>
|
||||
<div class="uk-container uk-margin-top">
|
||||
<div class="uk-card uk-card-default uk-card-hover uk-card-body uk-padding-small uk-text-center">
|
||||
<h3 class="uk-card-title uk-text-bold">{{ about.title }}</h3>
|
||||
|
||||
<img class="uk-border-circle uk-box-shadow-small uk-margin-small"
|
||||
src="{% static about.profile_image %}"
|
||||
alt="Nyymix profiilikuva" width="120">
|
||||
|
||||
<p class="uk-text-muted uk-margin-small">
|
||||
{{ about.description }}
|
||||
</p>
|
||||
|
||||
|
||||
<p class="uk-text-muted uk-margin-small">
|
||||
Contact:
|
||||
<a href="mailto:{{ about.contact_email }}">
|
||||
{{ about.contact_email }}
|
||||
</a>
|
||||
</p>
|
||||
|
||||
|
||||
<div class="uk-flex uk-flex-center uk-child-width-auto uk-margin-small-top" uk-grid>
|
||||
{% if about.bluesky_url %}
|
||||
<a href="{{ about.bluesky_url }}" uk-icon="icon: bluesky" uk-tooltip="Bluesky"></a>
|
||||
{% endif %}
|
||||
{% if about.twitter_url %}
|
||||
<a href="{{ about.twitter_url }}" uk-icon="icon: twitter" uk-tooltip="Twitter"></a>
|
||||
{% endif %}
|
||||
{% if about.instagram_url %}
|
||||
<a href="{{ about.instagram_url }}" uk-icon="icon: instagram" uk-tooltip="Instagram"></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<hr class="uk-divider-icon">
|
||||
|
||||
<div class="uk-text-small uk-text-muted">
|
||||
<p>
|
||||
<strong>{{ counts.0 }}</strong> <a href="{% url 'gallery:albums_url' %}">Albums</a> (public {{ counts.1 }}),
|
||||
<strong>{{ counts.2 }}</strong> <a href="{% url 'gallery:photos_url' %}">Photos</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
</div>
|
||||
|
||||
<div class="uk-align-center uk-container-large">
|
||||
<div class="uk-align-center uk-container-large uk-padding-medium">
|
||||
|
||||
<ul uk-accordion>
|
||||
<li class="uk-open">
|
||||
|
|
13
gallery/templatetags/stats.py
Normal file
13
gallery/templatetags/stats.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
from django import template
|
||||
|
||||
from gallery.models import Album, Photo
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def gallery_stats():
|
||||
total_photos = Photo.objects.count()
|
||||
total_albums = Album.objects.count()
|
||||
public_albums = Album.objects.filter(is_public=True).count()
|
||||
return total_albums, public_albums, total_photos
|
|
@ -11,27 +11,34 @@ def last_albums(count=5):
|
|||
albums = Album.objects.filter(is_public=True).order_by("-album_date")[:count]
|
||||
return albums
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def top_photos(count=5):
|
||||
photos = Photo.objects.filter(album__is_public=True).order_by('-is_favorite', '-likes', '-views').select_related('album')[:count]
|
||||
return photos
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def random_photos_landscape(count=5):
|
||||
photos = Photo.objects.filter(album__is_public=True, width__gt=F('height')).order_by('?')[:count]
|
||||
return photos
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def top_photos_landscape(count=5):
|
||||
photos = Photo.objects.filter(album__is_public=True, width__gt=F('height')).order_by('-views').select_related('album')[:count]
|
||||
return photos
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def top_photos_portrait(count=5):
|
||||
photos = Photo.objects.filter(album__is_public=True, height__gt=F('width')).order_by('-views').select_related('album')[:count]
|
||||
return photos
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def top_photos_in_album(album, count=5):
|
||||
photos = Photo.objects.filter(album=album).order_by('-is_favorite', '-likes', '-views').select_related('album')[:count]
|
||||
return photos
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from django.conf import settings
|
||||
from django.core.paginator import Paginator
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.views.generic import DetailView, ListView, TemplateView
|
||||
|
@ -90,6 +91,11 @@ class PhotoDetail(DetailView):
|
|||
class About(TemplateView):
|
||||
template_name = "gallery/about.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["about"] = settings.ABOUT_PAGE_SETTINGS # Haetaan asetukset
|
||||
return context
|
||||
|
||||
|
||||
def redirect_to_album(request, redir_path):
|
||||
redir = get_object_or_404(Redir, path=redir_path)
|
||||
|
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Loading…
Add table
Reference in a new issue