Skip to content

Commit

Permalink
bugfix for delateview, it found by test process.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluebamus committed Oct 21, 2024
1 parent 73a94b7 commit 78957b5
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 54 deletions.
20 changes: 10 additions & 10 deletions blog/views/blog/blog_blog.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,21 @@ def get(self, request, *args, **kwargs):
return self.post(request, *args, **kwargs)

def post(self, request, *args, **kwargs):
# 객체를 가져오고, 없으면 404 에러 발생
post = get_object_or_404(self.model, id=kwargs.get("pk"))
if not post:
raise Http404("Post not found")

# 권한 확인
if self.request.user != post.author:
raise PermissionDenied()
dredis_cache_delete(
self.cache_prefix,
kwargs.get("pk"),
)
dredis_cache_delete(
self.cache_reply_prefix,
kwargs.get("pk"),
)

# 캐시 삭제
dredis_cache_delete(self.cache_prefix, kwargs.get("pk"))
dredis_cache_delete(self.cache_reply_prefix, kwargs.get("pk"))

# 객체 삭제 처리
post.is_deleted = True
post.save()

return redirect(self.success_url)


Expand Down
20 changes: 10 additions & 10 deletions blog/views/books/books_blog.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,21 +200,21 @@ def get(self, request, *args, **kwargs):
return self.post(request, *args, **kwargs)

def post(self, request, *args, **kwargs):
# 객체를 가져오고, 없으면 404 에러 발생
post = get_object_or_404(self.model, id=kwargs.get("pk"))
if not post:
raise Http404("Post not found")

# 권한 확인
if self.request.user != post.author:
raise PermissionDenied()
dredis_cache_delete(
self.cache_prefix,
kwargs.get("pk"),
)
dredis_cache_delete(
self.cache_reply_prefix,
kwargs.get("pk"),
)

# 캐시 삭제
dredis_cache_delete(self.cache_prefix, kwargs.get("pk"))
dredis_cache_delete(self.cache_reply_prefix, kwargs.get("pk"))

# 객체 삭제 처리
post.is_deleted = True
post.save()

return redirect(self.success_url)


Expand Down
20 changes: 10 additions & 10 deletions blog/views/online_study/online_study_blog.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,21 +197,21 @@ def get(self, request, *args, **kwargs):
return self.post(request, *args, **kwargs)

def post(self, request, *args, **kwargs):
# 객체를 가져오고, 없으면 404 에러 발생
post = get_object_or_404(self.model, id=kwargs.get("pk"))
if not post:
raise Http404("Post not found")

# 권한 확인
if self.request.user != post.author:
raise PermissionDenied()
dredis_cache_delete(
self.cache_prefix,
kwargs.get("pk"),
)
dredis_cache_delete(
self.cache_reply_prefix,
kwargs.get("pk"),
)

# 캐시 삭제
dredis_cache_delete(self.cache_prefix, kwargs.get("pk"))
dredis_cache_delete(self.cache_reply_prefix, kwargs.get("pk"))

# 객체 삭제 처리
post.is_deleted = True
post.save()

return redirect(self.success_url)


Expand Down
23 changes: 11 additions & 12 deletions blog/views/opensource/opensource_blog.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,22 +199,21 @@ def get(self, request, *args, **kwargs):
return self.post(request, *args, **kwargs)

def post(self, request, *args, **kwargs):
# 객체를 가져오고, 없으면 404 에러 발생
post = get_object_or_404(self.model, id=kwargs.get("pk"))
if not post:
raise Http404("Post not found")

# 권한 확인
if self.request.user != post.author:
raise PermissionDenied()
dredis_cache_delete(
self.cache_prefix,
kwargs.get("pk"),
)
dredis_cache_delete(
self.cache_reply_prefix,
kwargs.get("pk"),
)
# Update the is_deleted field and save the instance

# 캐시 삭제
dredis_cache_delete(self.cache_prefix, kwargs.get("pk"))
dredis_cache_delete(self.cache_reply_prefix, kwargs.get("pk"))

# 객체 삭제 처리
post.is_deleted = True
post.save() # Save the changes to the database
post.save()

return redirect(self.success_url)


Expand Down
24 changes: 12 additions & 12 deletions blog/views/project/project_blog.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,21 @@ def get(self, request, *args, **kwargs):
return self.post(request, *args, **kwargs)

def post(self, request, *args, **kwargs):
post = self.model.objects.filter(id=kwargs.get("pk"))
if not post:
raise Http404("Post not found")
if self.request.user != post[0].author:
# 객체를 가져오고, 없으면 404 에러 발생
post = get_object_or_404(self.model, id=kwargs.get("pk"))

# 권한 확인
if self.request.user != post.author:
raise PermissionDenied()
dredis_cache_delete(
self.cache_prefix,
kwargs.get("pk"),
)
dredis_cache_delete(
self.cache_reply_prefix,
kwargs.get("pk"),
)

# 캐시 삭제
dredis_cache_delete(self.cache_prefix, kwargs.get("pk"))
dredis_cache_delete(self.cache_reply_prefix, kwargs.get("pk"))

# 객체 삭제 처리
post.is_deleted = True
post.save()

return redirect(self.success_url)


Expand Down

0 comments on commit 78957b5

Please sign in to comment.