Skip to content

Commit

Permalink
Merge pull request #266 from unb-mds/Development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Davi-KLevy authored Sep 5, 2024
2 parents 54a5288 + ef6ea2c commit 5fc457e
Show file tree
Hide file tree
Showing 22 changed files with 528 additions and 167 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ __pycache__/
local_settings.py
db.sqlite3
db.sqlite3-journal
media

# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
# in your Git repository. Update and uncomment the following line accordingly.
Expand Down
2 changes: 2 additions & 0 deletions forunb/forunb/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
'NAME': BASE_DIR / 'db.sqlite3',
}
}

DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
2 changes: 2 additions & 0 deletions forunb/forunb/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@
DEFAULT_FILE_STORAGE = 'cloudinary_storage.storage.MediaCloudinaryStorage'

MEDIA_URL = 'https://res.cloudinary.com/dmezdx5mc/image/upload/'

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
17 changes: 11 additions & 6 deletions forunb/main/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
from users.models import CustomUser
from cloudinary.models import CloudinaryField

if settings.DEBUG:
ImageField = models.ImageField
else:
from cloudinary.models import CloudinaryField
ImageField = CloudinaryField

class Forum(models.Model):
"""Model for a forum."""
Expand Down Expand Up @@ -53,7 +58,7 @@ class Question(Post):
default=0, verbose_name='Favorited Count'
)
is_anonymous = models.BooleanField(default=False, verbose_name='')
image = CloudinaryField('image', blank=True, null=True)
image = ImageField('image', blank=True, null=True)
upvoters = models.ManyToManyField(
settings.AUTH_USER_MODEL, related_name='upvoted_questions', blank=True
)
Expand All @@ -69,12 +74,12 @@ def save(self, *args, **kwargs):
"""Save method for a question."""
super().save(*args, **kwargs)

if self.image:
"""if self.image:
img = Image.open(self.image.path) # pylint: disable=E1101
if img.height > 800 or img.width > 800:
output_size = (800, 800)
img.thumbnail(output_size)
img.save(self.image.path) # pylint: disable=E1101
img.save(self.image.path) # pylint: disable=E1101"""

def toggle_upvote(self, user):
"""Toggles the upvote of a question for a user."""
Expand All @@ -100,7 +105,7 @@ class Answer(Post):
is_anonymous = models.BooleanField(
default=False, verbose_name='Modo anônimo'
)
image = CloudinaryField('image', blank=True, null=True)
image = ImageField('image', blank=True, null=True)
upvoters = models.ManyToManyField(
settings.AUTH_USER_MODEL, related_name='upvoted_answers', blank=True
)
Expand All @@ -117,12 +122,12 @@ def save(self, *args, **kwargs):
"""Save method for an answer."""
super().save(*args, **kwargs)

if self.image:
"""if self.image:
img = Image.open(self.image.path) # pylint: disable=E1101
if img.height > 800 or img.width > 800:
output_size = (800, 800)
img.thumbnail(output_size)
img.save(self.image.path) # pylint: disable=E1101
img.save(self.image.path) # pylint: disable=E1101"""

def toggle_upvote(self, user):
"""Toggles the upvote of an answer for a user."""
Expand Down
131 changes: 131 additions & 0 deletions forunb/main/templates/main/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{% extends "base.html" %}

{% block content %}
<style>
body {
margin: 0;
padding: 0;
min-height: 100vh;
display: flex;
flex-direction: column;
}

.container {
padding: 20px;
flex: 1;
display: flex;
flex-direction: column;
overflow: auto;
/* Garante que a rolagem funcione quando necessário */
}

h1 {
font-size: 3rem;
margin-bottom: 1rem;
}

h2 {
font-size: 2rem;
margin-top: 2rem;
margin-bottom: 1rem;
}

p {
font-size: 1.2rem;
margin-bottom: 1rem;
}
</style>

<div class="container">
<h2 class="home-head">Sobre</h2>

<p>
O forUnB é uma plataforma de fórum inspirada no conceito do Stack Overflow, criada para fomentar a colaboração e
a troca de conhecimento entre <strong>alunos</strong> da Universidade de
Brasília.
Nosso objetivo é construir uma comunidade unida, onde os estudantes possam compartilhar dúvidas, obter respostas
e
colaborar em diversas disciplinas.
</p>

<h2 class="home-head">Como utilizar?</h2>
<p>
Dentro da plataforma, os usuários logados podem criar perguntas e respostas em fóruns específicos que já
disponibilizamos de toda a FGA, facilitando a comunicação
entre
alunos. Além disso, contamos com um sistema de avaliação que destaca as melhores respostas,
garantindo
que o conteúdo mais útil e relevante seja facilmente acessível a todos.
</p>

<h2 class="home-head">Equipe</h2>

<div style="display: flex; flex-direction: column; align-items: center; gap: 25px;">
<div style="display: flex; align-items: end; justify-content: center; gap: 50px;">
<div style="text-align: center;">
Alexandre Junior
<br />
<a href="https://github.com/AlexandreLJr" target="_blank" rel="noopener">
<img src="https://github.com/AlexandreLJr.png" alt="Foto Alexandre" width="130px" height="auto"
style="border-radius:50%" />
</a>
</div>
<div style="text-align: center;">
Bruno Bragança
<br />
<a href="https://github.com/BrunoBReis" target="_blank" rel="noopener">
<img src="https://github.com/BrunoBReis.png" alt="Foto Bruno" width="130px" height="auto"
style="border-radius:50%" />
</a>
</div>
<div style="text-align: center;">
Davi Klein
<br />
<a href="https://github.com/davi-Klevy" target="_blank" rel="noopener">
<img src="https://github.com/davi-Klevy.png" alt="Foto Davi" width="130px" height="auto"
style="border-radius:50%" />
</a>
</div>
</div>
<div style="display: flex; align-items: end; justify-content: center; gap: 50px;">
<div style="text-align: center;">
Manoela Garcia
<br />
<a href="https://github.com/manu-sgc" target="_blank" rel="noopener">
<img src="https://github.com/manu-sgc.png" alt="Foto Manoela" width="130px" height="auto"
style="border-radius:50%" />
</a>
</div>
<div style="text-align: center;">
Pedro Lopes
<br />
<a href="https://github.com/pLopess" target="_blank" rel="noopener">
<img src="https://github.com/pLopess.png" alt="Foto Pedro" width="130px" height="auto"
style="border-radius:50%" />
</a>
</div>
<div style="text-align: center;">
Victor Hugo Bernardes
<br />
<a href="https://github.com/VHbernardes" target="_blank" rel="noopener">
<img src="https://github.com/VHbernardes.png" alt="Foto Victor" width="130px" height="auto"
style="border-radius:50%" />
</a>
</div>
</div>
</div>


<script>
function scrollToBottom() {
window.scrollTo({
top: document.body.scrollHeight,
behavior: 'smooth' // Rola suavemente até o final da página
});
}

window.onload = function () {
scrollToBottom();
};
</script>
{% endblock %}
10 changes: 5 additions & 5 deletions forunb/main/templates/main/forum_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h1 class="forum-title flex-grow-1">
{% endif %}
</h1>
</div>
<div class="d-flex forum-buttons">
<div class="d-flex forum-buttons mt-3">
<div class="dropdown me-3">
<button class="btn btn-question dropdown-toggle" type="button" id="dropdownMenuButton"
data-bs-toggle="dropdown" aria-expanded="false">
Expand Down Expand Up @@ -51,7 +51,7 @@ <h1 class="forum-title flex-grow-1">
<div class="questions-container">
{% if questions %}
{% for question in questions %}
<div class="question-item">
<div class="question-item mt-3">
<div class="question-meta">
{% load static %}
<img class="profile-picture"
Expand All @@ -67,8 +67,8 @@ <h1 class="forum-title flex-grow-1">
<span class="question-date">há {{ question.created_at|custom_timesince }}</span>
</div>
<a href="{% url 'main:question_detail' question.id %}">
<h5 class="question-title">{{ question.title }}</h5>
<p class="question-description">{{ question.description }}</p>
<h5 class="question-title mt-2">{{ question.title }}</h5>
<p class="question-description mt-2 preformatted-text">{{ question.description }}</p>
</a>
{% if question.image %}
<img src="{{ question.image.url }}" alt="Descrição da imagem relacionada à pergunta"
Expand All @@ -85,7 +85,7 @@ <h5 class="question-title">{{ question.title }}</h5>
</a>
</div>
</div>
<hr class="question-separator">
<hr class="question-separator mt-2">
{% endfor %}
{% else %}
<p>Nenhuma pergunta encontrada neste fórum.</p>
Expand Down
2 changes: 1 addition & 1 deletion forunb/main/templates/main/forums.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h2 class="titulo fw-bold p-4">Resultados da pesquisa para "{{ query }}"</h2>
{% endif %}


<div class="scroll-container p-3 rounded">
<div class="scroll-container p-3 rounded mt-4">
{% for forum in forums %}
<div class="list-group col-xxl-12">
<a class="foruns list-group-item list-group-item-action" href="{% url 'main:forum_detail' forum.id %}">
Expand Down
14 changes: 7 additions & 7 deletions forunb/main/templates/main/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="forum-header">
<h2 class="home-head">Últimas Perguntas</h2>
<div class="dropdown">
<button class="btn btn-question dropdown-toggle mb-2" type="button" id="dropdownMenuButton"
<button class="btn btn-question dropdown-toggle mb-2 ms-3" type="button" id="dropdownMenuButton"
data-bs-toggle="dropdown" aria-expanded="false">Filtrar</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<li><a class="dropdown-item" href="{% url 'main:index' %}?filter_by=latest">Últimas Perguntas Gerais</a>
Expand All @@ -20,7 +20,7 @@ <h2 class="home-head">Últimas Perguntas</h2>

{% load custom_filters %}

<div class="home-container">
<div class="home-container mt-4">
{% for question in latest_questions %}
<div class="question-item">
<div class="home-meta">
Expand All @@ -34,16 +34,16 @@ <h2 class="home-head">Últimas Perguntas</h2>
{% else %}
{{ question.author.username }}
{% endif %}
</span>
<span class="question-date">há {{ question.created_at|custom_timesince }}</span>
</span>
<span class="question-date ms-1">há {{ question.created_at|custom_timesince }}</span>
<a href="{% url 'main:forum_detail' question.forum.id %}" class="forum-label">
<span class="label-full">{{ question.forum.title }}</span>
<span class="label-short">{{ question.forum.title|first_word }}</span>
</a>
</div>
<a href="{% url 'main:question_detail' question.id %}">
<h5 class="question-title">{{ question.title }}</h5>
<p class="question-description">{{ question.description }}</p>
<h5 class="question-title mt-2">{{ question.title }}</h5>
<p class="question-description mt-2 preformatted-text">{{ question.description }}</p>
</a>
{% if question.image %}
<img src="{{ question.image.url }}" alt="Descrição da imagem relacionada à pergunta"
Expand All @@ -60,7 +60,7 @@ <h5 class="question-title">{{ question.title }}</h5>
</a>
</div>
</div>
<hr class="question-separator">
<hr class="question-separator mt-2">
{% endfor %}
</div>

Expand Down
Loading

0 comments on commit 5fc457e

Please sign in to comment.