Skip to content

Commit

Permalink
Merge branch 'bugfix/playbook-view'
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Sołek committed Feb 23, 2021
2 parents 7c93370 + 7288348 commit ca4df06
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 17 deletions.
6 changes: 6 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### v1.26.1

##### Bugfixes
- Bugfix playbook view ([#321](https://github.com/Code-Poets/project-liberation/pull/321))


### v1.26.0

##### Features
Expand Down
5 changes: 0 additions & 5 deletions common/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,3 @@ def create_image(
if return_relative_path:
return os.path.join(tmp_dir, file_name)
return file_path


def read_file(path: str) -> bytes:
with open(path, "rb") as file:
return file.read()
2 changes: 1 addition & 1 deletion company_website/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
url(r"^how-we-work/$", views.HowWeWorkView.as_view(), name="how_we_work"),
url(r"^privacy-and-policy/$", views.PrivacyAndPolicyView.as_view(), name="privacy_and_policy"),
url(r"^thank-you/$", views.ThankYouView.as_view(), name="thank_you"),
url(r"^CodePoetsPlaybook/$", views.display_playbook_view, name="display_playbook"),
url(r"^CodePoetsPlaybook/$", views.PlaybookView.as_view(), name="display_playbook"),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
19 changes: 11 additions & 8 deletions company_website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from django.urls import reverse_lazy
from django.views.generic import FormView
from django.views.generic import ListView
from django.views.generic import View

from common.helpers import read_file
from company_website.constants import ESTIMATE_PROJECT_EMAIL_SUBJECT
from company_website.constants import ESTIMATE_PROJECT_EMAIL_TEMPLATE_NAME
from company_website.constants import PageNames
Expand Down Expand Up @@ -102,14 +102,17 @@ class ThankYouView(CustomTemplateView):
page_name = PageNames.THANK_YOU.name


def display_playbook_view(request: HttpRequest) -> HttpResponse:
playbook_file_name = "CodePoetsPlaybook.pdf"
playbook_path = os.path.join(settings.STATIC_ROOT, "how_we_work", "files", playbook_file_name)

if request.method == "GET":
class PlaybookView(View):
def get(self, _request: HttpRequest) -> HttpResponse:
playbook_file_name = "CodePoetsPlaybook.pdf"
playbook_path = os.path.join(settings.STATIC_ROOT, "how_we_work", "files", playbook_file_name)
if os.path.isfile(playbook_path):
response = HttpResponse(read_file(playbook_path), content_type="application/pdf")
response = HttpResponse(self.read_file(playbook_path), content_type="application/pdf")
response["Content-Disposition"] = f"filename={playbook_file_name}"
return response
return HttpResponse(status=404)
return HttpResponse(status=405)

@staticmethod
def read_file(path: str) -> bytes:
with open(path, "rb") as file:
return file.read()
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "project-liberation",
"version": "v1.26.0",
"version": "v1.26.1",
"description": "Packages needed for proper application work.",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "project-liberation"
version = "v1.26.0"
version = "v1.26.1"
description = "Necessary packages for Project Liberation"
authors = ["Karol Beker <[email protected]>"]

Expand Down

0 comments on commit ca4df06

Please sign in to comment.