Skip to content

Commit

Permalink
Fixed broken validation
Browse files Browse the repository at this point in the history
  • Loading branch information
nilandev committed Jan 10, 2024
1 parent 2427b45 commit 8c27f60
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bloggy/templates/pages/user_profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h1 class="h2 my-3">{{ userProfile.username }}</h1>
<h1 class="h2 py-3 px-2">My articles(so far)</h1>
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-2 g-3 mb-3">
{% if posts|length <= 0 %}
<p class="lead my-3 text-muted">Currently, there are no published posts.</p>
<p class="text-muted">Currently, there are no published posts.</p>
{% else %}
{% for post in posts %}
<div class="col">{% include "partials/post_list_item.html" with post=post cssClass="" %}</div>
Expand Down
4 changes: 1 addition & 3 deletions bloggy/templates/profile/my_dashboard_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
<div class="col-12 col-lg-9 col-xl-8">
<div class="card p-lg-5 p-3 card-bordered card-shadowd">
<h1 class="h2">Dashboard</h1>


{% if posts|length <= 0 %}
<p class="lead my-3 text-muted">Currently, there are no published posts.</p>
<p class="text-muted">Currently, there are no published posts.</p>
{% else %}
{% for post in posts %}
{% include 'partials/article_row_list.html' with post=post %}
Expand Down
2 changes: 1 addition & 1 deletion bloggy/templates/widgets/feedback-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h3 class="h3" id="feedbackModalLabel">Give Feedback</h3>
<div class="mb-3">
<input type="hidden" name="source" value="{{ meta_title }}"/>
<input type="hidden" name="sourceLink" value="{{ request.build_absolute_uri }}"/>

<input type="hidden" name="honeypot" value="" class="d-none"/>
{% if user.is_authenticated %}
<input type="hidden" name="name" value="{{ request.user.get_full_name_or_username }}"/>
<input type="hidden" name="email" value="{{ request.user.email }}"/>
Expand Down
5 changes: 2 additions & 3 deletions bloggy/views/my_dashboard_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ class DashboardView(DetailView):
DEFAULT_PAGE_SIZE = 12

def get_object(self, **kwargs):
username = self.request.user # self.kwargs.get("username")
return get_object_or_404(User, username=username)
return get_object_or_404(User, username=self.request.user.username)

def get_context_data(self, *args, **kwargs):
context = super().get_context_data(*args, **kwargs)
Expand Down Expand Up @@ -40,4 +39,4 @@ def get_context_data(self, *args, **kwargs):
if user.profile_photo:
context['meta_image'] = settings.SITE_LOGO

return context
return context
14 changes: 12 additions & 2 deletions bloggy_api/views/feedback_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,22 @@


class FeedbackApi(viewsets.ViewSet):

def feedback(self, request):
message = request.POST["message"]

honeypot = request.POST.get("honeypot", None)
if honeypot:
return HttpResponse(
json.dumps({'success': False,
'message': "This is a community for learners! "
"We encourage genuine engagement and learning. "
"Please refrain from using automated bots or cheating methods. "
"Let's keep this space focused on authentic educational experiences."}),
content_type="application/json"
)

if StringUtils.is_not_blank(message):
subject = 'New Feedback'

message_content = (f'Name: {request.POST.get("name", "-")}'
f'\n\nEmail: {request.POST.get("email", "-")}'
f'\n\nMessage: {message}'
Expand Down

0 comments on commit 8c27f60

Please sign in to comment.