From 235f0426aed296bd32870b4202f3d19eafe598ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eck=20Bal=C3=A1zs=20Istv=C3=A1n?= <eckbalu@sch.bme.hu> Date: Sun, 6 Apr 2025 19:26:44 +0000 Subject: [PATCH] Revert "asd" This reverts commit 9f29ae9d2ddc94c5723972ed72756ee57aef0e09 --- imageuploader/imageuploader/urls.py | 2 +- .../templates/posts/pictures_list.html | 23 -------------- imageuploader/pictures/urls.py | 11 ------- imageuploader/pictures/views.py | 28 ------------------ imageuploader/{pictures => posts}/__init__.py | 0 .../__pycache__/__init__.cpython-313.pyc | Bin .../__pycache__/admin.cpython-313.pyc | Bin .../__pycache__/apps.cpython-313.pyc | Bin .../__pycache__/forms.cpython-313.pyc | Bin .../__pycache__/models.cpython-313.pyc | Bin .../__pycache__/urls.cpython-313.pyc | Bin .../__pycache__/views.cpython-313.pyc | Bin imageuploader/{pictures => posts}/admin.py | 0 imageuploader/{pictures => posts}/apps.py | 2 +- imageuploader/{pictures => posts}/forms.py | 0 .../migrations/0001_initial.py | 0 .../migrations/0002_post_banner.py | 0 .../migrations/0003_post_author.py | 0 .../migrations/0004_alter_post_author.py | 0 .../migrations/__init__.py | 0 .../__pycache__/0001_initial.cpython-313.pyc | Bin .../0002_post_banner.cpython-313.pyc | Bin .../0003_post_author.cpython-313.pyc | Bin .../0004_alter_post_author.cpython-313.pyc | Bin .../__pycache__/__init__.cpython-313.pyc | Bin imageuploader/{pictures => posts}/models.py | 2 +- .../templates/posts/post_new.html} | 8 ++--- .../templates/posts/post_page.html} | 12 ++++---- .../posts/templates/posts/posts_list.html | 23 ++++++++++++++ imageuploader/{pictures => posts}/tests.py | 0 imageuploader/posts/urls.py | 11 +++++++ imageuploader/posts/views.py | 28 ++++++++++++++++++ imageuploader/templates/layout.html | 8 ++--- 33 files changed, 79 insertions(+), 79 deletions(-) delete mode 100644 imageuploader/pictures/templates/posts/pictures_list.html delete mode 100644 imageuploader/pictures/urls.py delete mode 100644 imageuploader/pictures/views.py rename imageuploader/{pictures => posts}/__init__.py (100%) rename imageuploader/{pictures => posts}/__pycache__/__init__.cpython-313.pyc (100%) rename imageuploader/{pictures => posts}/__pycache__/admin.cpython-313.pyc (100%) rename imageuploader/{pictures => posts}/__pycache__/apps.cpython-313.pyc (100%) rename imageuploader/{pictures => posts}/__pycache__/forms.cpython-313.pyc (100%) rename imageuploader/{pictures => posts}/__pycache__/models.cpython-313.pyc (100%) rename imageuploader/{pictures => posts}/__pycache__/urls.cpython-313.pyc (100%) rename imageuploader/{pictures => posts}/__pycache__/views.cpython-313.pyc (100%) rename imageuploader/{pictures => posts}/admin.py (100%) rename imageuploader/{pictures => posts}/apps.py (84%) rename imageuploader/{pictures => posts}/forms.py (100%) rename imageuploader/{pictures => posts}/migrations/0001_initial.py (100%) rename imageuploader/{pictures => posts}/migrations/0002_post_banner.py (100%) rename imageuploader/{pictures => posts}/migrations/0003_post_author.py (100%) rename imageuploader/{pictures => posts}/migrations/0004_alter_post_author.py (100%) rename imageuploader/{pictures => posts}/migrations/__init__.py (100%) rename imageuploader/{pictures => posts}/migrations/__pycache__/0001_initial.cpython-313.pyc (100%) rename imageuploader/{pictures => posts}/migrations/__pycache__/0002_post_banner.cpython-313.pyc (100%) rename imageuploader/{pictures => posts}/migrations/__pycache__/0003_post_author.cpython-313.pyc (100%) rename imageuploader/{pictures => posts}/migrations/__pycache__/0004_alter_post_author.cpython-313.pyc (100%) rename imageuploader/{pictures => posts}/migrations/__pycache__/__init__.cpython-313.pyc (100%) rename imageuploader/{pictures => posts}/models.py (93%) rename imageuploader/{pictures/templates/posts/picture_new.html => posts/templates/posts/post_new.html} (60%) rename imageuploader/{pictures/templates/posts/picture_page.html => posts/templates/posts/post_page.html} (51%) create mode 100644 imageuploader/posts/templates/posts/posts_list.html rename imageuploader/{pictures => posts}/tests.py (100%) create mode 100644 imageuploader/posts/urls.py create mode 100644 imageuploader/posts/views.py diff --git a/imageuploader/imageuploader/urls.py b/imageuploader/imageuploader/urls.py index fc23a52..f7302ca 100644 --- a/imageuploader/imageuploader/urls.py +++ b/imageuploader/imageuploader/urls.py @@ -27,7 +27,7 @@ urlpatterns = [ path('admin/', admin.site.urls), path('', views.homepage), path('about/', views.about), - path('pictures/', include('pictures.urls')), + path('posts/', include('posts.urls')), path('users/', include('users.urls')) ] diff --git a/imageuploader/pictures/templates/posts/pictures_list.html b/imageuploader/pictures/templates/posts/pictures_list.html deleted file mode 100644 index b17308e..0000000 --- a/imageuploader/pictures/templates/posts/pictures_list.html +++ /dev/null @@ -1,23 +0,0 @@ -{% extends 'layout.html' %} - -{% block title %} - Pictures -{% endblock %} - -{% block content %} - <section> - <h1>Pictures</h1> - - {% for picture in pictures %} - <article class="post"> - <h2> - <a href="{% url 'pictures:page' slug=picture.slug %}"> - {{ picture.title }} - </a> - </h2> - <p>{{ picture.date }} by {{ picture.author }}</p> - <p>{{ picture.body }}</p> - </article> - {% endfor %} -</section> -{% endblock %} \ No newline at end of file diff --git a/imageuploader/pictures/urls.py b/imageuploader/pictures/urls.py deleted file mode 100644 index 2ea0e73..0000000 --- a/imageuploader/pictures/urls.py +++ /dev/null @@ -1,11 +0,0 @@ -from django.contrib import admin -from django.urls import path -from . import views - -app_name = "pictures" - -urlpatterns = [ - path("", views.pictures_list, name="list"), - path('new-picture/', views.picture_new, name="new-picture"), - path("<slug:slug>", views.picture_page, name="page") -] \ No newline at end of file diff --git a/imageuploader/pictures/views.py b/imageuploader/pictures/views.py deleted file mode 100644 index e5818e1..0000000 --- a/imageuploader/pictures/views.py +++ /dev/null @@ -1,28 +0,0 @@ -from django.shortcuts import render, redirect -from .models import Post -from django.contrib.auth.decorators import login_required -from . import forms - - - -def pictures_list(request): - pictures = Post.objects.all().order_by('-date') - return render(request, 'posts/posts_list.html', {'pictures': pictures}) - - -def picture_page(request, slug): - picture = Post.objects.get(slug=slug) - return render(request, 'pictures/picture_page.html', {'picture': picture}) - -@login_required(login_url="/users/login/") -def picture_new(request): - if request.method == 'POST': - form = forms.CreatePost(request.POST, request.FILES) - if form.is_valid(): - newpicture = form.save(commit=False) - newpicture.author = request.user - newpicture.save() - return redirect('pictures:list') - else: - form = forms.CreatePost() - return render(request, 'pictures/picture_new.html', { 'form': form }) \ No newline at end of file diff --git a/imageuploader/pictures/__init__.py b/imageuploader/posts/__init__.py similarity index 100% rename from imageuploader/pictures/__init__.py rename to imageuploader/posts/__init__.py diff --git a/imageuploader/pictures/__pycache__/__init__.cpython-313.pyc b/imageuploader/posts/__pycache__/__init__.cpython-313.pyc similarity index 100% rename from imageuploader/pictures/__pycache__/__init__.cpython-313.pyc rename to imageuploader/posts/__pycache__/__init__.cpython-313.pyc diff --git a/imageuploader/pictures/__pycache__/admin.cpython-313.pyc b/imageuploader/posts/__pycache__/admin.cpython-313.pyc similarity index 100% rename from imageuploader/pictures/__pycache__/admin.cpython-313.pyc rename to imageuploader/posts/__pycache__/admin.cpython-313.pyc diff --git a/imageuploader/pictures/__pycache__/apps.cpython-313.pyc b/imageuploader/posts/__pycache__/apps.cpython-313.pyc similarity index 100% rename from imageuploader/pictures/__pycache__/apps.cpython-313.pyc rename to imageuploader/posts/__pycache__/apps.cpython-313.pyc diff --git a/imageuploader/pictures/__pycache__/forms.cpython-313.pyc b/imageuploader/posts/__pycache__/forms.cpython-313.pyc similarity index 100% rename from imageuploader/pictures/__pycache__/forms.cpython-313.pyc rename to imageuploader/posts/__pycache__/forms.cpython-313.pyc diff --git a/imageuploader/pictures/__pycache__/models.cpython-313.pyc b/imageuploader/posts/__pycache__/models.cpython-313.pyc similarity index 100% rename from imageuploader/pictures/__pycache__/models.cpython-313.pyc rename to imageuploader/posts/__pycache__/models.cpython-313.pyc diff --git a/imageuploader/pictures/__pycache__/urls.cpython-313.pyc b/imageuploader/posts/__pycache__/urls.cpython-313.pyc similarity index 100% rename from imageuploader/pictures/__pycache__/urls.cpython-313.pyc rename to imageuploader/posts/__pycache__/urls.cpython-313.pyc diff --git a/imageuploader/pictures/__pycache__/views.cpython-313.pyc b/imageuploader/posts/__pycache__/views.cpython-313.pyc similarity index 100% rename from imageuploader/pictures/__pycache__/views.cpython-313.pyc rename to imageuploader/posts/__pycache__/views.cpython-313.pyc diff --git a/imageuploader/pictures/admin.py b/imageuploader/posts/admin.py similarity index 100% rename from imageuploader/pictures/admin.py rename to imageuploader/posts/admin.py diff --git a/imageuploader/pictures/apps.py b/imageuploader/posts/apps.py similarity index 84% rename from imageuploader/pictures/apps.py rename to imageuploader/posts/apps.py index b38c60c..b18ed0d 100644 --- a/imageuploader/pictures/apps.py +++ b/imageuploader/posts/apps.py @@ -3,4 +3,4 @@ from django.apps import AppConfig class PostsConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' - name = 'pictures' + name = 'posts' diff --git a/imageuploader/pictures/forms.py b/imageuploader/posts/forms.py similarity index 100% rename from imageuploader/pictures/forms.py rename to imageuploader/posts/forms.py diff --git a/imageuploader/pictures/migrations/0001_initial.py b/imageuploader/posts/migrations/0001_initial.py similarity index 100% rename from imageuploader/pictures/migrations/0001_initial.py rename to imageuploader/posts/migrations/0001_initial.py diff --git a/imageuploader/pictures/migrations/0002_post_banner.py b/imageuploader/posts/migrations/0002_post_banner.py similarity index 100% rename from imageuploader/pictures/migrations/0002_post_banner.py rename to imageuploader/posts/migrations/0002_post_banner.py diff --git a/imageuploader/pictures/migrations/0003_post_author.py b/imageuploader/posts/migrations/0003_post_author.py similarity index 100% rename from imageuploader/pictures/migrations/0003_post_author.py rename to imageuploader/posts/migrations/0003_post_author.py diff --git a/imageuploader/pictures/migrations/0004_alter_post_author.py b/imageuploader/posts/migrations/0004_alter_post_author.py similarity index 100% rename from imageuploader/pictures/migrations/0004_alter_post_author.py rename to imageuploader/posts/migrations/0004_alter_post_author.py diff --git a/imageuploader/pictures/migrations/__init__.py b/imageuploader/posts/migrations/__init__.py similarity index 100% rename from imageuploader/pictures/migrations/__init__.py rename to imageuploader/posts/migrations/__init__.py diff --git a/imageuploader/pictures/migrations/__pycache__/0001_initial.cpython-313.pyc b/imageuploader/posts/migrations/__pycache__/0001_initial.cpython-313.pyc similarity index 100% rename from imageuploader/pictures/migrations/__pycache__/0001_initial.cpython-313.pyc rename to imageuploader/posts/migrations/__pycache__/0001_initial.cpython-313.pyc diff --git a/imageuploader/pictures/migrations/__pycache__/0002_post_banner.cpython-313.pyc b/imageuploader/posts/migrations/__pycache__/0002_post_banner.cpython-313.pyc similarity index 100% rename from imageuploader/pictures/migrations/__pycache__/0002_post_banner.cpython-313.pyc rename to imageuploader/posts/migrations/__pycache__/0002_post_banner.cpython-313.pyc diff --git a/imageuploader/pictures/migrations/__pycache__/0003_post_author.cpython-313.pyc b/imageuploader/posts/migrations/__pycache__/0003_post_author.cpython-313.pyc similarity index 100% rename from imageuploader/pictures/migrations/__pycache__/0003_post_author.cpython-313.pyc rename to imageuploader/posts/migrations/__pycache__/0003_post_author.cpython-313.pyc diff --git a/imageuploader/pictures/migrations/__pycache__/0004_alter_post_author.cpython-313.pyc b/imageuploader/posts/migrations/__pycache__/0004_alter_post_author.cpython-313.pyc similarity index 100% rename from imageuploader/pictures/migrations/__pycache__/0004_alter_post_author.cpython-313.pyc rename to imageuploader/posts/migrations/__pycache__/0004_alter_post_author.cpython-313.pyc diff --git a/imageuploader/pictures/migrations/__pycache__/__init__.cpython-313.pyc b/imageuploader/posts/migrations/__pycache__/__init__.cpython-313.pyc similarity index 100% rename from imageuploader/pictures/migrations/__pycache__/__init__.cpython-313.pyc rename to imageuploader/posts/migrations/__pycache__/__init__.cpython-313.pyc diff --git a/imageuploader/pictures/models.py b/imageuploader/posts/models.py similarity index 93% rename from imageuploader/pictures/models.py rename to imageuploader/posts/models.py index e255e6f..6aafd6b 100644 --- a/imageuploader/pictures/models.py +++ b/imageuploader/posts/models.py @@ -1,7 +1,7 @@ from django.db import models from django.contrib.auth.models import User -class Picture(models.Model): +class Post(models.Model): title = models.CharField(max_length=75) body = models.TextField() slug = models.SlugField() diff --git a/imageuploader/pictures/templates/posts/picture_new.html b/imageuploader/posts/templates/posts/post_new.html similarity index 60% rename from imageuploader/pictures/templates/posts/picture_new.html rename to imageuploader/posts/templates/posts/post_new.html index 11741b0..637fd62 100644 --- a/imageuploader/pictures/templates/posts/picture_new.html +++ b/imageuploader/posts/templates/posts/post_new.html @@ -1,16 +1,16 @@ {% extends 'layout.html' %} {% block title %} - New Picture + New Post {% endblock %} {% block content %} <section> - <h1>New Picture</h1> - <form class="form-with-validation" action="{% url 'posts:new-picture' %}" method="post" enctype="multipart/form-data"> + <h1>New Post</h1> + <form class="form-with-validation" action="{% url 'posts:new-post' %}" method="post" enctype="multipart/form-data"> {% csrf_token %} {{ form }} - <button class="form-submit">Add Picture</button> + <button class="form-submit">Add Post</button> </form> </section> {% endblock %} \ No newline at end of file diff --git a/imageuploader/pictures/templates/posts/picture_page.html b/imageuploader/posts/templates/posts/post_page.html similarity index 51% rename from imageuploader/pictures/templates/posts/picture_page.html rename to imageuploader/posts/templates/posts/post_page.html index d828673..b2e965d 100644 --- a/imageuploader/pictures/templates/posts/picture_page.html +++ b/imageuploader/posts/templates/posts/post_page.html @@ -1,21 +1,21 @@ {% extends 'layout.html' %} {% block title %} - {{ picture.title }} + {{ post.title }} {% endblock %} {% block content %} <section> <img class="banner" - src="{{ picture.banner.url }}" - alt="{{ picture.title }}" + src="{{ post.banner.url }}" + alt="{{ post.title }}" /> <h1> - {{ picture.title }} + {{ post.title }} </h1> - <p>{{ picture.date }}</p> - <p>{{ picture.body }}</p> + <p>{{ post.date }}</p> + <p>{{ post.body }}</p> </section> {% endblock %} \ No newline at end of file diff --git a/imageuploader/posts/templates/posts/posts_list.html b/imageuploader/posts/templates/posts/posts_list.html new file mode 100644 index 0000000..1fd39c2 --- /dev/null +++ b/imageuploader/posts/templates/posts/posts_list.html @@ -0,0 +1,23 @@ +{% extends 'layout.html' %} + +{% block title %} + Posts +{% endblock %} + +{% block content %} + <section> + <h1>Posts</h1> + + {% for post in posts %} + <article class="post"> + <h2> + <a href="{% url 'posts:page' slug=post.slug %}"> + {{ post.title }} + </a> + </h2> + <p>{{ post.date }} by {{ post.author }}</p> + <p>{{ post.body }}</p> + </article> + {% endfor %} +</section> +{% endblock %} \ No newline at end of file diff --git a/imageuploader/pictures/tests.py b/imageuploader/posts/tests.py similarity index 100% rename from imageuploader/pictures/tests.py rename to imageuploader/posts/tests.py diff --git a/imageuploader/posts/urls.py b/imageuploader/posts/urls.py new file mode 100644 index 0000000..930f131 --- /dev/null +++ b/imageuploader/posts/urls.py @@ -0,0 +1,11 @@ +from django.contrib import admin +from django.urls import path +from . import views + +app_name = "posts" + +urlpatterns = [ + path("", views.posts_list, name="list"), + path('new-post/', views.post_new, name="new-post"), + path("<slug:slug>", views.post_page, name="page") +] \ No newline at end of file diff --git a/imageuploader/posts/views.py b/imageuploader/posts/views.py new file mode 100644 index 0000000..8676287 --- /dev/null +++ b/imageuploader/posts/views.py @@ -0,0 +1,28 @@ +from django.shortcuts import render, redirect +from .models import Post +from django.contrib.auth.decorators import login_required +from . import forms + + + +def posts_list(request): + posts = Post.objects.all().order_by('-date') + return render(request, 'posts/posts_list.html', {'posts': posts}) + + +def post_page(request, slug): + post = Post.objects.get(slug=slug) + return render(request, 'posts/post_page.html', {'post': post}) + +@login_required(login_url="/users/login/") +def post_new(request): + if request.method == 'POST': + form = forms.CreatePost(request.POST, request.FILES) + if form.is_valid(): + newpost = form.save(commit=False) + newpost.author = request.user + newpost.save() + return redirect('posts:list') + else: + form = forms.CreatePost() + return render(request, 'posts/post_new.html', { 'form': form }) \ No newline at end of file diff --git a/imageuploader/templates/layout.html b/imageuploader/templates/layout.html index d248ac0..a3f76b8 100644 --- a/imageuploader/templates/layout.html +++ b/imageuploader/templates/layout.html @@ -21,11 +21,11 @@ <span role="img" aria-label="About" title="About">😀</span> </a> | {% if user.is_authenticated %} - <a href="{% url 'pictures:list' %}"> - <span role="img" aria-label="pictures" title="pictures">📰</span> + <a href="{% url 'posts:list' %}"> + <span role="img" aria-label="Posts" title="Posts">📰</span> </a> | - <a href="{% url 'pictures:new-picture' %}"> - <span role="img" aria-label="New picture" title="New picture">🆕</span> + <a href="{% url 'posts:new-post' %}"> + <span role="img" aria-label="New Post" title="New Post">🆕</span> </a> | <form class="logout" action="{% url 'users:logout' %}" method="post"> {% csrf_token %} -- GitLab