Remove Contact app & add about template
This commit is contained in:
parent
3ca3f6616d
commit
1017ca86b7
18 changed files with 40 additions and 183 deletions
|
@ -38,7 +38,6 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'imagekit',
|
'imagekit',
|
||||||
'contact',
|
|
||||||
'gallery'
|
'gallery'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ from django.urls import include, path
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
path('contact/', include(('contact.urls', 'contact'), namespace='contact')),
|
|
||||||
path('', include(('gallery.urls', 'gallery'), namespace='gallery')),
|
path('', include(('gallery.urls', 'gallery'), namespace='gallery')),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
from django.contrib import admin
|
|
||||||
|
|
||||||
from .models import Feedback
|
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Feedback)
|
|
||||||
class LocationAdmin(admin.ModelAdmin):
|
|
||||||
list_display = ('subject', 'name', 'date', 'message',)
|
|
||||||
list_display_links = ('subject',)
|
|
||||||
search_fields = ('name', 'message', 'subject',)
|
|
||||||
list_per_page = 30
|
|
|
@ -1,6 +0,0 @@
|
||||||
from django.apps import AppConfig
|
|
||||||
|
|
||||||
|
|
||||||
class ContactConfig(AppConfig):
|
|
||||||
default_auto_field = 'django.db.models.BigAutoField'
|
|
||||||
name = 'contact'
|
|
|
@ -1,25 +0,0 @@
|
||||||
from django import forms
|
|
||||||
from django.conf import settings
|
|
||||||
from django.core.mail import send_mail
|
|
||||||
|
|
||||||
from .models import Feedback
|
|
||||||
|
|
||||||
|
|
||||||
class FeedbackForm(forms.ModelForm):
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
model = Feedback
|
|
||||||
exclude = ['ip', 'agent']
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super(FeedbackForm, self).__init__(*args, **kwargs)
|
|
||||||
self.fields['name'].widget.attrs.update({'class': 'uk-input', 'placeholder': 'Name'})
|
|
||||||
self.fields['email'].widget.attrs.update({'class': 'uk-input', 'placeholder': 'E-mail'})
|
|
||||||
self.fields['subject'].widget.attrs.update({'class': 'uk-input', 'placeholder': 'Subject'})
|
|
||||||
self.fields['message'].widget.attrs.update({'class': 'uk-textarea', 'placeholder': 'Message'})
|
|
||||||
|
|
||||||
def send_email(self):
|
|
||||||
subject = "Gallery Feedback: " + self.cleaned_data['subject']
|
|
||||||
from_email = self.cleaned_data['email']
|
|
||||||
message = self.cleaned_data['message']
|
|
||||||
send_mail(subject, message, from_email, [settings.EMAIL_TO])
|
|
|
@ -1,25 +0,0 @@
|
||||||
# Generated by Django 5.1.4 on 2025-02-02 19:12
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
initial = True
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='Feedback',
|
|
||||||
fields=[
|
|
||||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('name', models.CharField(max_length=150, verbose_name='Name')),
|
|
||||||
('email', models.EmailField(max_length=150, verbose_name='E-mail')),
|
|
||||||
('date', models.DateTimeField(auto_now_add=True, verbose_name='Sended')),
|
|
||||||
('subject', models.CharField(max_length=150, verbose_name='Subject')),
|
|
||||||
('message', models.TextField(verbose_name='Message')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,12 +0,0 @@
|
||||||
from django.db import models
|
|
||||||
|
|
||||||
|
|
||||||
class Feedback(models.Model):
|
|
||||||
name = models.CharField(max_length=150, verbose_name="Name")
|
|
||||||
email = models.EmailField(max_length=150, verbose_name="E-mail")
|
|
||||||
date = models.DateTimeField(auto_now_add=True, auto_now=False, verbose_name="Sended")
|
|
||||||
subject = models.CharField(max_length=150, verbose_name="Subject")
|
|
||||||
message = models.TextField(verbose_name="Message")
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return '{}'.format(self.name)
|
|
|
@ -1,61 +0,0 @@
|
||||||
{% extends "base_dark.html" %}
|
|
||||||
|
|
||||||
<!-- Title -->
|
|
||||||
{% block title %} Gallery : Contact {% endblock %}
|
|
||||||
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
<div uk-grid>
|
|
||||||
<div class="uk-width-1-1 uk-width-3-4@m">
|
|
||||||
|
|
||||||
<form method='POST'>
|
|
||||||
<fieldset class="uk-fieldset">
|
|
||||||
<legend class="uk-legend">Contact</legend>
|
|
||||||
{% csrf_token %}
|
|
||||||
|
|
||||||
<div class="uk-margin">
|
|
||||||
{{ form.name.errors }}
|
|
||||||
{{ form.name }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="uk-margin">
|
|
||||||
{{ form.email.errors }}
|
|
||||||
{{ form.email }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="uk-margin">
|
|
||||||
{{ form.subject.errors }}
|
|
||||||
{{ form.subject }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="uk-margin">
|
|
||||||
{{ form.message.errors }}
|
|
||||||
{{ form.message }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="uk-margin">
|
|
||||||
<input type='submit' value='Send' class="uk-button-primary uk-button-large" />
|
|
||||||
<input type='reset' value='Reset' class="uk-button-default uk-button-large" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</fieldset>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="uk-margin-top uk-width-1-4@m uk-visible@m">
|
|
||||||
<div class="uk-card uk-card-default uk-card-body uk-padding-small">
|
|
||||||
{% load static %}
|
|
||||||
<img src="{% static 'img/profile.png' %}" alt="Contact">
|
|
||||||
|
|
||||||
<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>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
# Create your tests here.
|
|
|
@ -1,9 +0,0 @@
|
||||||
from django.urls import path
|
|
||||||
|
|
||||||
from . import views
|
|
||||||
|
|
||||||
app_name = 'contact'
|
|
||||||
|
|
||||||
urlpatterns = [
|
|
||||||
path('', views.Contact.as_view(), name="contact_url")
|
|
||||||
]
|
|
|
@ -1,25 +0,0 @@
|
||||||
from django.contrib import messages
|
|
||||||
from django.shortcuts import redirect, render
|
|
||||||
from django.views.generic.base import View
|
|
||||||
|
|
||||||
from .forms import FeedbackForm
|
|
||||||
from .models import Feedback
|
|
||||||
|
|
||||||
|
|
||||||
class Contact(View):
|
|
||||||
|
|
||||||
def post(self, request):
|
|
||||||
form = FeedbackForm(request.POST or None)
|
|
||||||
if form.is_valid():
|
|
||||||
profile = form.save(commit=False)
|
|
||||||
profile.save()
|
|
||||||
form.send_email()
|
|
||||||
messages.success(request, 'Your message was sent successfully! Thank you!')
|
|
||||||
return redirect('gallery:main_url')
|
|
||||||
else:
|
|
||||||
messages.warning(request, 'Error occured while sending message.')
|
|
||||||
return render(request, 'contact/main.html', {'form': form})
|
|
||||||
|
|
||||||
def get(self, request):
|
|
||||||
form = FeedbackForm()
|
|
||||||
return render(request, 'contact/main.html', {'form': form})
|
|
24
gallery/templates/gallery/about.html
Normal file
24
gallery/templates/gallery/about.html
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{% extends "base_dark.html" %}
|
||||||
|
{% load top_tags %}
|
||||||
|
|
||||||
|
<!-- Title -->
|
||||||
|
{% block title %} Gallery : About{% endblock %}
|
||||||
|
|
||||||
|
<!-- 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">
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -1,3 +1,4 @@
|
||||||
|
from django.shortcuts import redirect
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
@ -7,9 +8,15 @@ app_name = 'gallery'
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
|
||||||
path('', views.AlbumsList.as_view(), name='main_url'),
|
path('', views.AlbumsList.as_view(), name='main_url'),
|
||||||
|
path('about/', views.About.as_view(), name='about_url'),
|
||||||
path('photostream/', views.PhotosList.as_view(), name='photos_url'),
|
path('photostream/', views.PhotosList.as_view(), name='photos_url'),
|
||||||
path('albums/<path:album_slug>/<int:photo_slug>/', views.PhotoDetail.as_view(), name='photo_url'),
|
path('albums/<path:album_slug>/<int:photo_slug>/', views.PhotoDetail.as_view(), name='photo_url'),
|
||||||
path('albums/<path:album_slug>/', views.AlbumDetail.as_view(), name='album_url'),
|
path('albums/<path:album_slug>/', views.AlbumDetail.as_view(), name='album_url'),
|
||||||
path('albums/', views.AlbumsList.as_view(), name='albums_url'),
|
path('albums/', views.AlbumsList.as_view(), name='albums_url'),
|
||||||
path('<path:redir_path>/', views.redirect_to_album, name='redirect_to_album'),
|
path('<path:redir_path>/', views.redirect_to_album, name='redirect_to_album'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def custom_404_view(request, exception):
|
||||||
|
return redirect('/')
|
||||||
|
|
||||||
|
handler404 = 'gallery.urls.custom_404_view'
|
|
@ -89,6 +89,11 @@ class PhotoDetail(DetailView):
|
||||||
return redirect('gallery:photo_url', album_slug=self.kwargs['album_slug'], photo_slug=self.kwargs['photo_slug'])
|
return redirect('gallery:photo_url', album_slug=self.kwargs['album_slug'], photo_slug=self.kwargs['photo_slug'])
|
||||||
|
|
||||||
|
|
||||||
|
class About(TemplateView):
|
||||||
|
template_name = "gallery/about.html"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def redirect_to_album(request, redir_path):
|
def redirect_to_album(request, redir_path):
|
||||||
redir = get_object_or_404(Redir, path=redir_path)
|
redir = get_object_or_404(Redir, path=redir_path)
|
||||||
return redirect('gallery:album_url', album_slug=redir.album.slug)
|
return redirect('gallery:album_url', album_slug=redir.album.slug)
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-navbar-right uk-margin-right">
|
<div class="uk-navbar-right uk-margin-right">
|
||||||
<ul class="uk-navbar-nav">
|
<ul class="uk-navbar-nav">
|
||||||
<li class="uk-visible@m"><a href="#">Contact</a></li>
|
<li class="uk-visible@m"><a href="{% url 'gallery:about_url' %}">About</a></li>
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<li class="uk-visible@m"><a href="{% url 'admin:index' %}">Admin</a></li>
|
<li class="uk-visible@m"><a href="{% url 'admin:index' %}">Admin</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
<li><a href="{% url 'gallery:main_url' %}">Home</a></li>
|
<li><a href="{% url 'gallery:main_url' %}">Home</a></li>
|
||||||
<li><a href="{% url 'gallery:albums_url' %}">Albums</a></li>
|
<li><a href="{% url 'gallery:albums_url' %}">Albums</a></li>
|
||||||
<li><a href="{% url 'gallery:photos_url' %}">Photostream</a></li>
|
<li><a href="{% url 'gallery:photos_url' %}">Photostream</a></li>
|
||||||
<li><a href="#">Contact</a></li>
|
<li><a href="{% url 'gallery:about_url' %}">About</a></li>
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<li><a href="{% url 'admin:index' %}">Admin</a></li>
|
<li><a href="{% url 'admin:index' %}">Admin</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-navbar-right uk-margin-right">
|
<div class="uk-navbar-right uk-margin-right">
|
||||||
<ul class="uk-navbar-nav">
|
<ul class="uk-navbar-nav">
|
||||||
<li class="uk-visible@m"><a href="{% url 'contact:contact_url' %}">Contact</a></li>
|
<li class="uk-visible@m"><a href="{% url 'gallery:about_url' %}">About</a></li>
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<li class="uk-visible@m"><a href="{% url 'admin:index' %}">Admin</a></li>
|
<li class="uk-visible@m"><a href="{% url 'admin:index' %}">Admin</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
<li><a href="{% url 'gallery:main_url' %}">Home</a></li>
|
<li><a href="{% url 'gallery:main_url' %}">Home</a></li>
|
||||||
<li><a href="{% url 'gallery:albums_url' %}">Albums</a></li>
|
<li><a href="{% url 'gallery:albums_url' %}">Albums</a></li>
|
||||||
<li><a href="{% url 'gallery:photos_url' %}">Photostream</a></li>
|
<li><a href="{% url 'gallery:photos_url' %}">Photostream</a></li>
|
||||||
<li><a href="{% url 'contact:contact_url' %}">Contact</a></li>
|
<li><a href="{% url 'gallery:about_url' %}">About</a></li>
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<li><a href="{% url 'admin:index' %}">Admin</a></li>
|
<li><a href="{% url 'admin:index' %}">Admin</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Add table
Reference in a new issue