From 1017ca86b7dfa2b6edda8e606213680c41c6b455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DNyymix=E2=80=9D?= Date: Tue, 18 Mar 2025 23:16:40 +0200 Subject: [PATCH] Remove Contact app & add about template --- config/settings.py | 1 - config/urls.py | 1 - contact/__init__.py | 0 contact/admin.py | 11 ----- contact/apps.py | 6 --- contact/forms.py | 25 ------------ contact/migrations/0001_initial.py | 25 ------------ contact/migrations/__init__.py | 0 contact/models.py | 12 ------ contact/templates/contact/main.html | 61 ---------------------------- contact/tests.py | 3 -- contact/urls.py | 9 ---- contact/views.py | 25 ------------ gallery/templates/gallery/about.html | 24 +++++++++++ gallery/urls.py | 7 ++++ gallery/views.py | 5 +++ templates/base.html | 4 +- templates/base_dark.html | 4 +- 18 files changed, 40 insertions(+), 183 deletions(-) delete mode 100644 contact/__init__.py delete mode 100644 contact/admin.py delete mode 100644 contact/apps.py delete mode 100644 contact/forms.py delete mode 100644 contact/migrations/0001_initial.py delete mode 100644 contact/migrations/__init__.py delete mode 100644 contact/models.py delete mode 100644 contact/templates/contact/main.html delete mode 100644 contact/tests.py delete mode 100644 contact/urls.py delete mode 100644 contact/views.py create mode 100644 gallery/templates/gallery/about.html diff --git a/config/settings.py b/config/settings.py index f38b528..c1634d3 100644 --- a/config/settings.py +++ b/config/settings.py @@ -38,7 +38,6 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'imagekit', - 'contact', 'gallery' ] diff --git a/config/urls.py b/config/urls.py index 099caeb..daa6e4d 100644 --- a/config/urls.py +++ b/config/urls.py @@ -5,7 +5,6 @@ from django.urls import include, path urlpatterns = [ path('admin/', admin.site.urls), - path('contact/', include(('contact.urls', 'contact'), namespace='contact')), path('', include(('gallery.urls', 'gallery'), namespace='gallery')), ] diff --git a/contact/__init__.py b/contact/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/contact/admin.py b/contact/admin.py deleted file mode 100644 index 633ae9f..0000000 --- a/contact/admin.py +++ /dev/null @@ -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 diff --git a/contact/apps.py b/contact/apps.py deleted file mode 100644 index 002d6c2..0000000 --- a/contact/apps.py +++ /dev/null @@ -1,6 +0,0 @@ -from django.apps import AppConfig - - -class ContactConfig(AppConfig): - default_auto_field = 'django.db.models.BigAutoField' - name = 'contact' diff --git a/contact/forms.py b/contact/forms.py deleted file mode 100644 index 0f16877..0000000 --- a/contact/forms.py +++ /dev/null @@ -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]) diff --git a/contact/migrations/0001_initial.py b/contact/migrations/0001_initial.py deleted file mode 100644 index fde2d6f..0000000 --- a/contact/migrations/0001_initial.py +++ /dev/null @@ -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')), - ], - ), - ] diff --git a/contact/migrations/__init__.py b/contact/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/contact/models.py b/contact/models.py deleted file mode 100644 index 6f97d55..0000000 --- a/contact/models.py +++ /dev/null @@ -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) diff --git a/contact/templates/contact/main.html b/contact/templates/contact/main.html deleted file mode 100644 index 74e7104..0000000 --- a/contact/templates/contact/main.html +++ /dev/null @@ -1,61 +0,0 @@ -{% extends "base_dark.html" %} - - -{% block title %} Gallery : Contact {% endblock %} - - -{% block content %} - -
-
- -
-
- Contact - {% csrf_token %} - -
- {{ form.name.errors }} - {{ form.name }} -
- -
- {{ form.email.errors }} - {{ form.email }} -
- -
- {{ form.subject.errors }} - {{ form.subject }} -
- -
- {{ form.message.errors }} - {{ form.message }} -
- -
- - -
- -
-
- -
- -
-
- {% load static %} - Contact - -
- - - -
- -
-
-
-{% endblock %} \ No newline at end of file diff --git a/contact/tests.py b/contact/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/contact/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/contact/urls.py b/contact/urls.py deleted file mode 100644 index 51d8b14..0000000 --- a/contact/urls.py +++ /dev/null @@ -1,9 +0,0 @@ -from django.urls import path - -from . import views - -app_name = 'contact' - -urlpatterns = [ - path('', views.Contact.as_view(), name="contact_url") -] diff --git a/contact/views.py b/contact/views.py deleted file mode 100644 index 6b9525b..0000000 --- a/contact/views.py +++ /dev/null @@ -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}) diff --git a/gallery/templates/gallery/about.html b/gallery/templates/gallery/about.html new file mode 100644 index 0000000..157d51a --- /dev/null +++ b/gallery/templates/gallery/about.html @@ -0,0 +1,24 @@ +{% extends "base_dark.html" %} +{% load top_tags %} + + +{% block title %} Gallery : About{% endblock %} + + +{% block content %} + +
+
+ {% load static %} + Contact + +
+ + + +
+ +
+
+ + {% endblock %} \ No newline at end of file diff --git a/gallery/urls.py b/gallery/urls.py index e4c696b..27c69ff 100644 --- a/gallery/urls.py +++ b/gallery/urls.py @@ -1,3 +1,4 @@ +from django.shortcuts import redirect from django.urls import path from . import views @@ -7,9 +8,15 @@ app_name = 'gallery' urlpatterns = [ 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('albums///', views.PhotoDetail.as_view(), name='photo_url'), path('albums//', views.AlbumDetail.as_view(), name='album_url'), path('albums/', views.AlbumsList.as_view(), name='albums_url'), path('/', views.redirect_to_album, name='redirect_to_album'), ] + +def custom_404_view(request, exception): + return redirect('/') + +handler404 = 'gallery.urls.custom_404_view' \ No newline at end of file diff --git a/gallery/views.py b/gallery/views.py index bf80354..89af30b 100644 --- a/gallery/views.py +++ b/gallery/views.py @@ -89,6 +89,11 @@ class PhotoDetail(DetailView): 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): redir = get_object_or_404(Redir, path=redir_path) return redirect('gallery:album_url', album_slug=redir.album.slug) diff --git a/templates/base.html b/templates/base.html index 6302c02..bdee05b 100644 --- a/templates/base.html +++ b/templates/base.html @@ -35,7 +35,7 @@
    -
  • Contact
  • +
  • About
  • {% if user.is_authenticated %}
  • Admin
  • {% endif %} @@ -53,7 +53,7 @@
  • Home
  • Albums
  • Photostream
  • -
  • Contact
  • +
  • About
  • {% if user.is_authenticated %}
  • Admin
  • {% endif %} diff --git a/templates/base_dark.html b/templates/base_dark.html index 4b02b28..ade49bd 100644 --- a/templates/base_dark.html +++ b/templates/base_dark.html @@ -37,7 +37,7 @@