Skip to content

Commit

Permalink
Modify the report functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
MariosK1574 committed Jul 1, 2024
1 parent a58e3a7 commit 2a7a3c6
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,23 @@ def show_post(post_id):
@login_required
def report_post():
if request.method == 'POST':
url = request.form['url']
post_id = request.form['postId']

valid_id = True

try:
post_id = int(post_id)
except:
valid_id = False

if not post_id or valid_id == False:
return render_template('report_post.html', error_message="Please provide a valid post ID.")


url = f"http://users-service:5000/posts/{post_id}"
requests.get(f"http://admin-bot-service:3000/report?url={url}")


return render_template('report_url.html', success_message="The admin will visit your URL soon.")
return render_template('report_post.html', success_message="The admin will visit your post soon.")

return render_template('report_url.html')
return render_template('report_post.html')
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h1 class="text-center neon-text-blue">Add New Post</h1>
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="/auth/logout">Log Out</a>
<a class="dropdown-item" href="/posts/report">Report URL</a>
<a class="dropdown-item" href="/posts/report">Report Post</a>
<a class="dropdown-item" href="/posts">My Posts</a>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@
</head>
<body class="neon-glow">
<h1 class="text-center neon-text-blue">{{ post.title }}</h1>

<nav class="navbar fixed-top justify-content-between">
<a href="/" class="btn btn-primary neon-border-blue"><i class="fas fa-home"></i></a>
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="/auth/logout">Log Out</a>
<a class="dropdown-item" href="/posts/report">Report Post</a>
<a class="dropdown-item" href="/posts/add">Add Post</a>
<a class="dropdown-item" href="/posts">My Posts</a>
</div>
</div>
</nav>

<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-lg-8 col-md-10 col-12">
Expand All @@ -32,26 +47,13 @@ <h1 class="text-center neon-text-blue">{{ post.title }}</h1>
<h5 class="card-title neon-text-blue">{{ post.title }}</h5>
<p class="card-text">{{ post.content | safe}}</p>
<p class="card-text"><small class="text-muted">Posted by {{ user.username }}</small></p>
<p class="card-text"><small class="text-muted">Post ID: {{ post.id }}</small></p>
</div>
</div>
</div>
</div>
</div>

<nav class="navbar fixed-top justify-content-between">
<a href="/" class="btn btn-primary neon-border-blue"><i class="fas fa-home"></i></a>
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="/auth/logout">Log Out</a>
<a class="dropdown-item" href="/posts/report">Report URL</a>
<a class="dropdown-item" href="/posts/add">Add Post</a>
<a class="dropdown-item" href="/posts">My Posts</a>
</div>
</div>
</nav>

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h1 class="text-center neon-text-blue">My Posts</h1>
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="/auth/logout">Log Out</a>
<a class="dropdown-item" href="/posts/report">Report URL</a>
<a class="dropdown-item" href="/posts/report">Report Post</a>
<a class="dropdown-item" href="/posts/add">Add Post</a>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Report URL</title>
<title>Report Post</title>
<link rel="stylesheet" href="https://hackerthemes.com/bootstrap-themes/demo/theme-machine/neon-glow/css/bootstrap4-neon-glow.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<style>
Expand Down Expand Up @@ -38,7 +38,7 @@
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6">
<h1 class="text-center neon-text-blue">Report URL</h1>
<h1 class="text-center neon-text-blue">Report Post</h1>

<!-- Success Message -->
{% if success_message %}
Expand All @@ -47,24 +47,17 @@ <h1 class="text-center neon-text-blue">Report URL</h1>
</div>
{% endif %}

<nav class="navbar fixed-top justify-content-between">
<a href="/" class="btn btn-primary neon-border-blue"><i class="fas fa-home"></i></a>
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="/auth/logout">Log Out</a>
<a class="dropdown-item" href="/posts/report">Report URL</a>
<a class="dropdown-item" href="/posts/add">Add Post</a>
<a class="dropdown-item" href="/posts">My Posts</a>
</div>
</div>
</nav>
<!-- Error Message -->
{% if error_message %}
<div class="alert alert-danger" role="alert">
{{ error_message }}
</div>
{% endif %}

<form action="/posts/report" method="post">
<div class="form-group">
<label for="url" class="neon-text-blue">URL</label>
<input type="url" class="form-control neon-border-blue" id="url" name="url" required>
<label for="postId" class="neon-text-blue">Post ID</label>
<input type="text" class="form-control neon-border-blue" id="postId" name="postId" required>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary neon-border-blue">Report</button>
Expand Down

0 comments on commit 2a7a3c6

Please sign in to comment.