Skip to content
Snippets Groups Projects
Commit c1dbf140 authored by Aydin, Mehmet Can (PG/T - Comp Sci & Elec Eng)'s avatar Aydin, Mehmet Can (PG/T - Comp Sci & Elec Eng)
Browse files

final fixes after seen in deployment

parent 5ace905f
Branches main
No related tags found
No related merge requests found
CONFIGURATION_SETUP="config.DevelopmentConfig"
CONFIGURATION_SETUP="config.ProductionConfig"
......@@ -11,7 +11,7 @@ from flask_ckeditor import CKEditorField
class CreatePostForm(FlaskForm):
'''Create post form'''
title = StringField('Title', validators=[InputRequired()])
title = StringField('Title', validators=[InputRequired(), Length(max=40)])
category = SelectField('Category', choices=[
('activities', 'Activities'),
('courses&modules', 'Courses&Modules'),
......@@ -24,14 +24,14 @@ class CreatePostForm(FlaskForm):
('other', 'Other'),
])
content = CKEditorField('Content', validators=[
InputRequired(), Length(min=20)])
InputRequired(), Length(min=20, max=300)])
image = FileField('Upload an image')
submit = SubmitField('CREATE POST', validators=[
FileAllowed(['jpg', 'jpeg', 'png'])])
class CommentForm(FlaskForm):
'''Comment post form'''
content = CKEditorField('Comment', validators=[InputRequired()])
content = CKEditorField('Comment', validators=[InputRequired(), Length(max=120)])
submit = SubmitField('SUBMIT')
class SearchForm(FlaskForm):
......
......@@ -129,8 +129,16 @@ def get_posts(page=1):
offset = (page - 1) * per_page
posts = PostClient.get_posts(per_page,offset)
categories = ['activities','courses&modules','societies',
'student_union','accommodation','transportation','lost&found','sale&rental','other']
if posts == 404:
return redirect(url_for('frontend.get_posts'))
if PostClient.get_posts(per_page,0) != 404:
return redirect(url_for('frontend.get_posts'))
elif page == 1:
return render_template('forum/index.html',categories=categories, page=1, page_limit=False)
else :
return redirect(url_for('frontend.get_posts'))
page_limit = True
offset_ = (page) * per_page
......@@ -142,10 +150,7 @@ def get_posts(page=1):
for post in posts:
user = UserClient.get_otheruser(post['user_id'])
image_urls.append(user['image_url'])
categories = ['activities','courses&modules','societies',
'student_union','accommodation','transportation','lost&found','sale&rental','other']
image_urls.append(user['image_url'])
return render_template('forum/index.html',
data=zip(posts,image_urls), categories=categories,page=page, page_limit=page_limit)
......@@ -163,7 +168,7 @@ def categories(category, page=1):
posts = PostClient.get_category_posts(category,per_page,offset)
if posts == 404:
flash('No post found in the category', 'fail')
flash('None or more post found in the category', 'fail')
return redirect(url_for('frontend.get_posts'))
page_limit = True
......@@ -205,7 +210,7 @@ def search(page=1):
posts = PostClient.get_search(words,per_page,offset)
if posts == 404:
flash('No result found', 'fail')
flash('None or more result found', 'fail')
return redirect(url_for('frontend.get_posts'))
page_limit = True
......@@ -239,7 +244,7 @@ def get_hot_posts(page=1):
return redirect(url_for('frontend.get_posts'))
if posts == 404:
flash('No post in last 7 days', 'fail')
flash('No hot posts for last 7 days', 'fail')
return redirect(url_for('frontend.get_posts'))
page_limit = True
......
......@@ -8,6 +8,7 @@
background: linear-gradient(rgba(0, 0, 0, 0.4),rgba(0, 0, 0, 0.4)),url('/static/images/background.jpg');
background-size: cover;
background-position: center;
background-attachment: fixed; /* added property */
position: relative;
}
......@@ -16,8 +17,12 @@
background-color: rgba(255, 255, 255, 1);
border-radius: 10px;
width: fit-content;
margin: 10% auto;
margin: 0 auto; /* modified property */
padding: 50px;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
......
......@@ -8,6 +8,7 @@
background: linear-gradient(rgba(0, 0, 0, 0.4),rgba(0, 0, 0, 0.4)),url('/static/images/background.jpg');
background-size: cover;
background-position: center;
background-attachment: fixed; /* added property */
position: relative;
}
......
{# application/templates/forum/post.html #}
<style>
.profile-image {
width: 60px;
......@@ -19,7 +18,7 @@
object-fit:contain;
}
.tile__author {
font-size: 16px;
font-size: 14px;
}
.latest {
padding: 40px 0;
......@@ -41,24 +40,27 @@
.tile__author {
display: flex;
align-items: center;
margin-bottom: 20px;
margin-bottom: 5px;
margin-top: 13px;
}
.tile__author img {
margin-right: 15px;
}
.tile__header {
font-size: 28px;
font-size: 20px;
font-weight: 700;
margin-bottom: 20px;
margin-bottom:-7px;
}
.tile__text {
font-size: 18px;
font-size: 16px;
line-height: 1.5;
margin-bottom: 20px;
margin-bottom: -3px;
}
.post-image {
max-width: 100%;
margin-bottom: 20px;
margin-bottom: 3px;
margin-top: -5px;
}
.tile__date {
font-size: 14px;
......@@ -69,7 +71,7 @@
display: flex;
flex-direction: row;
justify-content: space-between;
margin-bottom: 20px;
margin-bottom: 10px;
}
.comment__box--self {
flex-direction: row-reverse;
......@@ -120,8 +122,7 @@
.comment__form {
display: flex;
flex-direction: column;
margin-top: 40px;
margin-bottom: 60px;
margin-top: -5px;
}
.post-btn {
background-color: #4CAF50;
......@@ -145,21 +146,18 @@
border-radius: 5px;
font-size: 16px;
cursor: pointer;
margin-bottom: 20px;
margin-top: 5px;
}
</style>
<title>POST PAGE</title>
<a class="home-btn" href="{{ url_for('frontend.get_posts') }}">Home</a>
{% from 'macros.html' import displayField %}
{% include '_messages.html' %}
<br>
<!-- START posts -->
<div class="col-md-8">
<div class="post-container" style="height: 40%; width: 100%; overflow-y: auto;
word-wrap: break-word; white-space: normal">
<div class="post-container" style="height: 40%; width: 100%; overflow-y: auto; word-wrap: break-word; white-space: normal; position: fixed;">
<a class="home-btn" href="{{ url_for('frontend.get_posts') }}">Home</a>
<div class="tile__author">
<img class="profile-image" src="images/users/{{ owner_image }}">
<h2 ><a href="{{ url_for('frontend.display_user', user_id=post.user_id) }}">{{ post['user_name'] }}</a></h2>
......@@ -176,7 +174,7 @@
<p class="tile__date">{{ post['date_added'] }}</p>
{% if current_user_id == post['user_id'] %}
<div class="tile__buttons">
<a class="tile__btn" href="{{ url_for('frontend.delete_post', post_id=post.id) }}">Delete Post</a>
<a class="tile__btn" href="{{ url_for('frontend.delete_post', post_id=post.id) }}" style="float: left; text-align: left;">Delete Post</a>
</div>
{% endif %}
</div>
......@@ -185,8 +183,8 @@
<!-- START comments -->
<div class="comment-container" style="overflow-y: auto; height: 60%; width: 100%">
<h3 class="comment__title">COMMENTS</h3>
<div class="comment-container" style="overflow-y: auto; height: 60%; width: 100%; bottom: 0;position: fixed;">
<h3 class="comment__title" style="text-align: center;">COMMENTS</h3>
{% if comments %}
{% for comment, image in comments %}
<div class="comment__box{% if current_user_id == comment['user_id'] %} comment__box--self{% else %} comment__box--other{% endif %}">
......
CONFIGURATION_SETUP="config.DevelopmentConfig"
CONFIGURATION_SETUP="config.ProductionConfig"
......@@ -36,8 +36,6 @@ def get_hot_posts(per_page,offset):
if data == []:
abort(404)
print(data)
response = jsonify(data)
return response
......
No preview for this file type
CONFIGURATION_SETUP="config.DevelopmentConfig"
CONFIGURATION_SETUP="config.ProductionConfig"
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment