From efbd006c8c4559ec8c56e6b58b04ac2e9da10243 Mon Sep 17 00:00:00 2001 From: Victoria Date: Wed, 18 Sep 2024 22:33:18 +0200 Subject: [PATCH 1/5] Small fix for the contributing link on the main README.md page --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dd6f068..3d24470 100644 --- a/README.md +++ b/README.md @@ -20,4 +20,4 @@ Current tutorials are: ## Contributing These tutorials are maintained by [DjangoGirls](http://djangogirls.org/). If you find any mistakes or want to update the tutorial -please [follow the contributing guidelines](https://github.com/DjangoGirls/tutorial-extension/contributing/). +please [follow the contributing guidelines](./contributing/README.md). From 59e69a87002f57956e37559ecd90c454e5f068cd Mon Sep 17 00:00:00 2001 From: Victoria Date: Wed, 18 Sep 2024 23:08:25 +0200 Subject: [PATCH 2/5] Fix "Add publish button" and "delete" sections --- en/homework/README.md | 8 ++++---- package-lock.json | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/en/homework/README.md b/en/homework/README.md index 01a0132..5949874 100644 --- a/en/homework/README.md +++ b/en/homework/README.md @@ -84,7 +84,7 @@ into these: {{ post.published_date }} {% else %} -
{% csrf_token %} + {% csrf_token %}
{% endif %} @@ -101,7 +101,7 @@ Now, let's take a look at the details of the form. We are using a new attribute, Time to create a URL (in `blog/urls.py`): ```python -path('post//publish/', views.post_publish, name='post_publish'), +path('post//publish/', views.post_publish, name='post_publish'), ``` and finally, a *view* (as always, in `blog/views.py`): @@ -137,7 +137,7 @@ Congratulations! You are almost there. The last step is adding a delete button! Let's open `blog/templates/blog/post_detail.html` once again and add these lines: ```django -
{% csrf_token %} +{% csrf_token %} @@ -149,7 +149,7 @@ just under a line with the edit button. Now we need a URL (`blog/urls.py`): ```python -path('post//remove/', views.post_remove, name='post_remove'), +path('post//remove/', views.post_remove, name='post_remove'), ``` Now, time for a view! Open `blog/views.py` and add this code: diff --git a/package-lock.json b/package-lock.json index 8ece36a..ac97752 100644 --- a/package-lock.json +++ b/package-lock.json @@ -410,11 +410,11 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -1023,9 +1023,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -2569,9 +2569,9 @@ "optional": true }, "node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "bin": { "semver": "bin/semver" } From 92e202bebc5a978fa74ac7cc30ded6c1128bc658 Mon Sep 17 00:00:00 2001 From: Victoria Date: Thu, 19 Sep 2024 22:28:06 +0200 Subject: [PATCH 3/5] Removed outdated glyphicons --- en/homework/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/en/homework/README.md b/en/homework/README.md index 5949874..894adf6 100644 --- a/en/homework/README.md +++ b/en/homework/README.md @@ -21,7 +21,7 @@ Time to do something similar, but for draft posts. Let's add a link in `blog/templates/blog/base.html` in the header. We don't want to show our list of drafts to everybody, so we'll put it inside the {% raw %}`{% if user.is_authenticated %}`{% endraw %} check, right after the button for adding new posts. ```django - +Drafts ``` Next: urls! In `blog/urls.py` we add: @@ -85,7 +85,7 @@ into these: {% else %} {% csrf_token %} - + {% endif %} ``` @@ -139,7 +139,7 @@ Let's open `blog/templates/blog/post_detail.html` once again and add these lines ```django
{% csrf_token %}
``` From e86fad2a0622bf3f0fbee630fb6c31a34031bd42 Mon Sep 17 00:00:00 2001 From: Victoria Date: Thu, 19 Sep 2024 22:28:42 +0200 Subject: [PATCH 4/5] Revert back package-lock.json --- package-lock.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index ac97752..8ece36a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -410,11 +410,11 @@ } }, "node_modules/braces": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", - "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", "dependencies": { - "fill-range": "^7.1.1" + "fill-range": "^7.0.1" }, "engines": { "node": ">=8" @@ -1023,9 +1023,9 @@ } }, "node_modules/fill-range": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", - "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -2569,9 +2569,9 @@ "optional": true }, "node_modules/semver": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", - "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", "bin": { "semver": "bin/semver" } From d6d2b380116bda76121ee017104641725bb69923 Mon Sep 17 00:00:00 2001 From: Victoria Date: Thu, 19 Sep 2024 22:54:33 +0200 Subject: [PATCH 5/5] Added code changes for all languages --- es/homework/README.md | 22 +++++++++++++++------- fa/homework/README.md | 24 ++++++++++++++++-------- ja/homework/README.md | 22 +++++++++++++++------- ko/homework/README.md | 26 +++++++++++++++++--------- 4 files changed, 63 insertions(+), 31 deletions(-) diff --git a/es/homework/README.md b/es/homework/README.md index b07ee80..7725bcf 100644 --- a/es/homework/README.md +++ b/es/homework/README.md @@ -21,7 +21,7 @@ Es tiempo de hacer algo similiar, pero con borradores. Vamos a añadir un enlace en `blog/templates/blog/base.html` en el encabezado. No queremos mostrar nuestro borradores a todo el mundo, entonces vamos a colocarlo dentro de la verificación {% raw %}`{% if user.is_authenticated %}`{% endraw %}, justo después del botón de agregar posts. ```django - +Drafts ``` Siguiente: ¡urls! en `blog/urls.py` vamos a agregar: @@ -84,7 +84,9 @@ por estas: {{ post.published_date }} {% else %} - Publish +
{% csrf_token %} + +
{% endif %} ``` @@ -93,7 +95,7 @@ Como puedes ver, hemos agregado la línea {% raw %}`{% else %}`{% endraw %}. Est Tiempo de crear una URL (en `blog/urls.py`): ```python -path('post//publish/', views.post_publish, name='post_publish'), +path('post//publish/', views.post_publish, name='post_publish'), ``` Y finalmente una *vista* (como siempre, en `blog/views.py`): @@ -101,7 +103,8 @@ Y finalmente una *vista* (como siempre, en `blog/views.py`): ```python def post_publish(request, pk): post = get_object_or_404(Post, pk=pk) - post.publish() + if request.method=='POST': + post.publish() return redirect('post_detail', pk=pk) ``` @@ -126,7 +129,11 @@ Y de nuevo al publicar el post, ¡somos redirigidos inmediatamente a la página Vamos a abrir `blog/templates/blog/post_detail.html` de nuevo y vamos a añadir esta línea ```django - +
{% csrf_token %} + +
``` Justo debajo de la línea co el botón editar. @@ -134,7 +141,7 @@ Justo debajo de la línea co el botón editar. Ahora necesitamos una URL (`blog/urls.py`): ```python -path('post//remove/', views.post_remove, name='post_remove'), +path('post//remove/', views.post_remove, name='post_remove'), ``` Ahora, ¡Tiempo para la vista! Abre `blog/views.py` y agrega este código: @@ -142,7 +149,8 @@ Ahora, ¡Tiempo para la vista! Abre `blog/views.py` y agrega este código: ```python def post_remove(request, pk): post = get_object_or_404(Post, pk=pk) - post.delete() + if request.method=='POST': + post.delete() return redirect('post_list') ``` diff --git a/fa/homework/README.md b/fa/homework/README.md index fca3438..14a877b 100644 --- a/fa/homework/README.md +++ b/fa/homework/README.md @@ -21,7 +21,7 @@ post.published_date = timezone.now() حالا می‌خواهیم در هدر فایل `blog/templates/blog/base.html` یک لینک اضافه کنیم. از آنجا که نمی‌خواهیم لیست پست‌های پیش‌نویس را به همه نشان بدهیم، پس این لینک رادر عبارت کنترلی {% raw %}`{% if user.is_authenticated %}`{% endraw %} و دقیقاً بعد از دکمه مربوط به اضافه کردن پست جدید، اضافه می‌کنیم. ```django - +Drafts ``` حالا وقت اصلاح urlها در فایل `blog/urls.py` است: @@ -84,7 +84,9 @@ def post_draft_list(request): {{ post.published_date }} {% else %} - Publish +
{% csrf_token %} + +
{% endif %} ``` @@ -93,7 +95,7 @@ def post_draft_list(request): زمان ساختن یک URL (در فایل `blog/urls.py`) است: ```python -path('post//publish/', views.post_publish, name='post_publish'), +path('post//publish/', views.post_publish, name='post_publish'), ``` و در نهایت یک *ویو* (مانند همیشه در فایل `blog/views.py`) می‌سازیم: @@ -101,7 +103,8 @@ path('post//publish/', views.post_publish, name='post_publish'), ```python def post_publish(request, pk): post = get_object_or_404(Post, pk=pk) - post.publish() + if request.method=='POST': + post.publish() return redirect('post_detail', pk=pk) ``` @@ -115,7 +118,7 @@ def publish(self): حالا بالاخره می‌توانیم از آن استفاده کنیم! -و یک بار دیگر بعد از انتشار پست ما بلافاصله به صفحه جزییات پست یا `post_detail` هدایت خواهیم شد! +و یک بار دیگر بعد از انتشار پست ما بلافاصله به صفحه جزییات پست یا `post_detail` هدایت خواهیم شد! ![Publish button](images/publish2.png) @@ -126,7 +129,11 @@ def publish(self): بیایید یک بار دیگر فایل `blog/templates/blog/post_detail.html` را باز کنید و این خط را به آن اضافه کنید: ```django - +
{% csrf_token %} + +
``` دقیقاً زیر خطی که دکمه اصلاح یا Edit button قرار دارد. @@ -134,7 +141,7 @@ def publish(self): حالا یک URL لازم داریم (`blog/urls.py`): ```python -path('post//remove/', views.post_remove, name='post_remove'), +path('post//remove/', views.post_remove, name='post_remove'), ``` و الان زمان اضافه کردن یک ویو است! فایل `blog/views.py` را باز کنید و این کد را به آن اضافه کنید: @@ -142,7 +149,8 @@ path('post//remove/', views.post_remove, name='post_remove'), ```python def post_remove(request, pk): post = get_object_or_404(Post, pk=pk) - post.delete() + if request.method=='POST': + post.delete() return redirect('post_list') ``` diff --git a/ja/homework/README.md b/ja/homework/README.md index 8312a79..9189136 100644 --- a/ja/homework/README.md +++ b/ja/homework/README.md @@ -21,7 +21,7 @@ Djangoのクエリセットを勉強した章を覚えていますか? `post_lis `blog/templates/blog/base.html` のヘッダーにリンクを追加しましょう。草稿の一覧は誰でも見られるようにはしません。なので、 {% raw %}`{% if user.is_authenticated %}`{% endraw %} という条件の確認に続く箇所で、新しい投稿を追加するボタンのすぐ後にリンクを書いてください。 ```django - +Drafts ``` 次は `blog/urls.py` に、urlを追加しましょう! @@ -84,7 +84,9 @@ def post_draft_list(request): {{ post.published_date }} {% else %} - Publish +
{% csrf_token %} + +
{% endif %} ``` @@ -93,7 +95,7 @@ def post_draft_list(request): それでは新しいURLを追加しましょう。( `blog/urls.py` に) ```python -path('post//publish/', views.post_publish, name='post_publish'), +path('post//publish/', views.post_publish, name='post_publish'), ``` 最後に *ビュー* を追加します。(いつものように `blog/views.py` に) @@ -101,7 +103,8 @@ path('post//publish/', views.post_publish, name='post_publish'), ```python def post_publish(request, pk): post = get_object_or_404(Post, pk=pk) - post.publish() + if request.method=='POST': + post.publish() return redirect('post_detail', pk=pk) ``` @@ -127,13 +130,17 @@ def publish(self): 下の行を編集ボタンの行の直後に追加します: ```django - +
{% csrf_token %} + +
``` URLも必要ですね。( `blog/urls.py` に) ```python -path('post//remove/', views.post_remove, name='post_remove'), +path('post//remove/', views.post_remove, name='post_remove'), ``` 次はビューも作りましょう。 `blog/views.py` を開いて下のコードを追加してください。 @@ -141,7 +148,8 @@ path('post//remove/', views.post_remove, name='post_remove'), ```python def post_remove(request, pk): post = get_object_or_404(Post, pk=pk) - post.delete() + if request.method=='POST': + post.delete() return redirect('post_list') ``` diff --git a/ko/homework/README.md b/ko/homework/README.md index 307022a..b5fabd7 100644 --- a/ko/homework/README.md +++ b/ko/homework/README.md @@ -22,13 +22,13 @@ post.published_date = timezone.now() 새 글 추가하기 버튼 근처에 `blog/templates/blog/base.html` 링크를 추가하세요({% raw %}`

Django Girls Blog

`{% endraw %}위에 바로 추가하면 됩니다!). 발행 전 미리 보기가 모두에게 보이는 걸 원치 않을 거예요. 새로운 글 추가하기 바로 아래에 {% raw %}`{% if user.is_authenticated %}`{% endraw %}을 추가해 주세요. ```django - +Drafts ``` 다음: url입니다! `blog/urls.py`을 열고 아래 내용을 추가할 거에요. ```python -url(r'^drafts/$', views.post_draft_list, name='post_draft_list'), +path('drafts/', views.post_draft_list, name='post_draft_list'), ``` `blog/views.py`에 view를 생성할 차례입니다. @@ -59,7 +59,7 @@ def post_draft_list(request): `post_list.html` 템플릿과 코드가 많이 비슷해보이죠? -브라우저로 `http://127.0.0.1:8000/draft/` 페이지를 열어보면, 미 게시된 글목록을 확인할 수 있어요. +브라우저로 `http://127.0.0.1:8000/drafts/` 페이지를 열어보면, 미 게시된 글목록을 확인할 수 있어요. 야호! 첫 번째 일이 마쳤어요! @@ -85,7 +85,9 @@ def post_draft_list(request): {{ post.published_date }} {% else %} - Publish +
{% csrf_token %} + +
{% endif %} ``` @@ -94,7 +96,7 @@ def post_draft_list(request): `blog/urls.py`에 URL 패턴을 추가해봅시다. ```python -url(r'^post/(?P\d+)/publish/$', views.post_publish, name='post_publish'), +path('post//publish/', views.post_publish, name='post_publish'), ``` 마지막으로 `post_publish` *뷰*를 `blog/views.py` 에 추가해봅시다. @@ -102,7 +104,8 @@ url(r'^post/(?P\d+)/publish/$', views.post_publish, name='post_publish'), ```python def post_publish(request, pk): post = get_object_or_404(Post, pk=pk) - post.publish() + if request.method=='POST': + post.publish() return redirect('post_detail', pk=pk) ``` @@ -127,7 +130,11 @@ def publish(self): `blog/templates/blog/post_detail.html` 파일에 아래 코드를 추가해주세요. ```django - +
{% csrf_token %} + +
``` 수정 버튼 바로 아래 줄에 추가해주세요. @@ -135,7 +142,7 @@ def publish(self): (`blog/urls.py`)에 URL 패턴을 추가해봅시다: ```python -url(r'^post/(?P\d+)/remove/$', views.post_remove, name='post_remove'), +path('post//remove/', views.post_remove, name='post_remove'), ``` 이제 post_remove 뷰를 구현해봅시다. `blog/views.py` 에 아래 코드를 추가해주세요. @@ -143,7 +150,8 @@ url(r'^post/(?P\d+)/remove/$', views.post_remove, name='post_remove'), ```python def post_remove(request, pk): post = get_object_or_404(Post, pk=pk) - post.delete() + if request.method=='POST': + post.delete() return redirect('post_list') ```