Skip to content

Commit

Permalink
adicionando flex-wrap para o footer, e adição de converção de datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
thisiscleverson committed Feb 2, 2024
1 parent d8c0a8c commit 9ede43f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
19 changes: 18 additions & 1 deletion app/blog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import uuid
import pytz
from flask import Blueprint, request, redirect, render_template, abort

from .models import Contents, db
Expand All @@ -10,6 +11,13 @@
@blog.route('/', methods=['GET'])
def get_blog():
contents = Contents.query.filter(Contents.status == "published").order_by(Contents.created_at.desc()).all()

utc_timezone = pytz.timezone('UTC')
user_timezone = pytz.timezone('America/Sao_Paulo')

for content in contents:
content.created_at = convert_datetime(content.created_at)

return render_template('index.html', contents=contents)


Expand All @@ -25,7 +33,16 @@ def render_text(slug):

title = data.title
body = data.body
date = data.created_at.strftime("%d/%m/%Y, %H:%M %p")
date = convert_datetime(data.created_at).strftime("%d/%m/%Y, %H:%M %p")

return render_template('blog/render_text.html', title=title, body=body, date=date)


def convert_datetime(datetime):
utc_timezone = pytz.timezone('UTC')
user_timezone = pytz.timezone('America/Sao_Paulo')

hour_utc = utc_timezone.localize(datetime)
return hour_utc.astimezone(user_timezone)


8 changes: 4 additions & 4 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class Contents(db.Model):
status = Column(String, CheckConstraint("status IN ('published', 'draft')"), default='draft')
accessType = Column(String, CheckConstraint("type IN ('public', 'private')"), default='public')
description = Column(String(1000), default='')
created_at = Column(DateTime, default=datetime.now)
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now)
created_at = Column(DateTime, default=datetime.utcnow)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)


def __init__(self, id: str, title: str, body:str, slug:str, status:str, accessType:str, description:str) -> None:
Expand All @@ -42,8 +42,8 @@ class Users(db.Model):
username = Column(String(50), nullable=False, unique=True)
password = Column(String(100), nullable=False)
userType = Column(String, CheckConstraint("userType IN ('admin' , 'user')"), nullable=False, default='user')
created_at = db.Column(db.DateTime, default=datetime.now)
updated_at = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now)
created_at = db.Column(db.DateTime, default=datetime.utcnow)
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)

def __init__(self, id:str, username: str, password:str, userType:str) -> None:
self.id = id
Expand Down
1 change: 1 addition & 0 deletions static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ footer{
.social-media{
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
gap: 25px;
padding-top: 20px;
Expand Down
2 changes: 1 addition & 1 deletion templates/components/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="wrapper">
<div class="social-media">
<a href="https://github.com/thisiscleverson" target="_blank" rel="noopener noreferrer">GitHub</a>
<!-- <a href="mailto:[email protected]" target="_blank" rel="noopener noreferrer">Email</a> -->
<a href="mailto:[email protected]" target="_blank" rel="noopener noreferrer">Email</a>
<a href="https://linkedin.com/in/cleverson-silva" target="_blank" rel="noopener noreferrer">Linkedin</a>
<a href="https://tabnews.com.br/Cleverson" target="_blank" rel="noopener noreferrer">TabNews</a>
<a href="https://twitter.com/cl3verson3_" target="_blank" rel="noopener noreferrer">𝕏</a>
Expand Down

0 comments on commit 9ede43f

Please sign in to comment.