Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into feature/user-page
Browse files Browse the repository at this point in the history
  • Loading branch information
bitterteriyaki authored Nov 22, 2023
2 parents e0c8128 + 9986d37 commit 79f04f0
Show file tree
Hide file tree
Showing 18 changed files with 175 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ repos:
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
rev: v1.6.1
hooks:
- id: mypy
additional_dependencies:
Expand Down
2 changes: 2 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
release: python manage.py migrate
web: gunicorn server.wsgi
16 changes: 16 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"repository": "https://github.com/unb-mds/2023-2-Squad06",
"addons": ["heroku-postgresql:mini", "papertrail:choklad"],
"buildpacks": [
{
"url": "https://github.com/moneymeets/python-poetry-buildpack.git"
},
{
"url": "heroku/python"
}
],
"env": {
"PYTHON_RUNTIME_VERSION": "3.11.5",
"POETRY_VERSION": "1.6.1"
}
}
29 changes: 29 additions & 0 deletions apps/users/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.utils.translation import gettext as _

from apps.users.admin import UserAdmin
from apps.users.forms import CreateUserForm
from apps.users.models import User


Expand Down Expand Up @@ -88,6 +89,34 @@ def test_add_fieldsets(self) -> None:

self.assertEqual(UserAdmin.add_fieldsets, expected_add_fieldsets)

class RegisterViewTest(TestCase):
def setUp(self) -> None:
self.url = reverse("users:register")
self.valid_data = {
"username": "testuser",
"email": "[email protected]",
"password1": "TestPassword123",
"password2": "TestPassword123",
}

def test_register_view_get(self) -> None:
response = self.client.get(self.url)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "registration/register.html")
self.assertIsInstance(response.context["form"], CreateUserForm)

def test_post_valid_data(self) -> None:
response = self.client.post(
self.url, data=self.valid_data, follow=True
)

user = User.objects.get(username=self.valid_data["username"])

self.assertRedirects(response, reverse("home"))
self.assertIsNotNone(user)
self.client.force_login(user)
self.assertTrue(self.client.session["_auth_user_id"])

def test_email(self) -> None:
user = User.objects.create_user(
username="testuser",
Expand Down
10 changes: 8 additions & 2 deletions apps/users/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.contrib.auth import login
from django.http import HttpRequest, HttpResponse
from django.shortcuts import get_object_or_404, redirect, render
from django.views import View
Expand All @@ -16,8 +17,13 @@ def get(self, request: HttpRequest) -> HttpResponse:
def post(self, request: HttpRequest) -> HttpResponse:
form = CreateUserForm(self.request.POST)
if form.is_valid():
form.save()
return redirect("login")
user = form.save()

# Since we have multiple authentication backends, we need to
# specify which one we want to use. In this case, we want to
# use the :class:`ModelBackend`, which is the default one.
login(request, user, "django.contrib.auth.backends.ModelBackend")
return redirect("home")

return render(request, self.template_name, {"form": form})

Expand Down
6 changes: 3 additions & 3 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ executará as migrações. Faça isso com o seguinte comando:

.. code-block:: bash
$ docker compose run --rm web python manage.py migrate
$ docker compose run --rm django python manage.py migrate
.. hint::

Expand Down Expand Up @@ -221,10 +221,10 @@ seguinte comando:

.. code-block:: bash
$ docker compose run --rm web python manage.py createsuperuser
$ docker compose run --rm django python manage.py createsuperuser
E para criar migrações do banco de dados, use o seguinte comando:

.. code-block:: bash
$ docker compose run --rm web python manage.py makemigrations
$ docker compose run --rm django python manage.py makemigrations
2 changes: 1 addition & 1 deletion docs/source/reunioes/atas/reuniao-04.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Reunião 04
==========

:bdg-info:`18/10/2023` :bdg-warning:`Sprint 2`
:bdg-info:`18/10/2023` :bdg-warning:`Sprint 2`

Resumo
------
Expand Down
10 changes: 10 additions & 0 deletions docs/source/reunioes/atas/reuniao-05.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Reunião 04
==========

:bdg-info:`25/10/2023` :bdg-warning:`Sprint 3`

Resumo
------

Esta reunião teve como objetivos nivelar o nivel de conhecimento dos integrantes e retirada
de duvidas.
10 changes: 10 additions & 0 deletions docs/source/reunioes/atas/reuniao-06.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Reunião 06
==========

:bdg-info:`13/11/2023` :bdg-warning:`Sprint 4`

Resumo
------

Esta reunião teve como objetivos discutir o progresso, anunciar a saida de um
integrante.
10 changes: 10 additions & 0 deletions docs/source/reunioes/atas/reuniao-07.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Reunião 07
==========

:bdg-info:`16/11/2023` :bdg-warning:`Sprint 4`

Resumo
------

Esta reunião teve como objetivos redistribuir as partes de cada integrante e a
redução do prazo para entrega das issues.
3 changes: 3 additions & 0 deletions docs/source/reunioes/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ Atas
atas/reuniao-02
atas/reuniao-03
atas/reuniao-04
atas/reuniao-05
atas/reuniao-06
atas/reuniao-07
1 change: 1 addition & 0 deletions docs/source/scrum/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ Sprints
sprints/sprint-1
sprints/sprint-2
sprints/sprint-3
sprints/sprint-4
32 changes: 32 additions & 0 deletions docs/source/scrum/sprints/sprint-4.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Sprint 4
========

:bdg-info:`19/11/2023`

Resumo
------

Nesta sprint, a equipe de desenvolvimento começou a trabalhar na segunda release. As
principais atividades foram o início do desenvolvimento da parte de submissões e a
estilização da página de login para melhor acessibilidade do usuário.


Changelog
----------

- `Criar app de submissões (#66) <https://github.com/unb-mds/2023-2-Squad06/issues/66>`_
- `App inicial de submissões (PR) (#77) <https://github.com/unb-mds/2023-2-Squad06/pull/77>`_
- `Adicionar validadores em todas as páginas de admin (PR) (#76) <https://github.com/unb-mds/2023-2-Squad06/pull/76>`_
- `Estilizar página de login (#63) <https://github.com/unb-mds/2023-2-Squad06/issues/63>`_
- `Estilizar página de login (PR) (#75) <https://github.com/unb-mds/2023-2-Squad06/issues/75>`_
- `Adicionar documentação da Sprint 03 (#62) <https://github.com/unb-mds/2023-2-Squad06/issues/62>`_
- `Adicionar Documentação da Sprint 03 (PR) (#73) <https://github.com/unb-mds/2023-2-Squad06/issues/73>`_
- `Retirar nome de ex-integrante do grupo (#72) <https://github.com/unb-mds/2023-2-Squad06/issues/72>`_
- `Remover Nome de ex-Integrante (PR) (#74) <https://github.com/unb-mds/2023-2-Squad06/issues/74>`_
- `Adicionar Documentação da Sprint 02 (#67) <https://github.com/unb-mds/2023-2-Squad06/issues/67>`_
- `Adicionar documentação da Sprint 02 (PR) (#70) <https://github.com/unb-mds/2023-2-Squad06/issues/70>`_
- `Renomear o app apps.problems para apps.tasks (#31) <https://github.com/unb-mds/2023-2-Squad06/issues/31>`_
- `Rename apps.problems to apps.tasks (PR) (#61) <https://github.com/unb-mds/2023-2-Squad06/issues/61>`_
- `Initial problems form development (PR) (#65) <https://github.com/unb-mds/2023-2-Squad06/issues/65>`_
- `Add integrations with CI services (PR) (#59) <https://github.com/unb-mds/2023-2-Squad06/issues/59>`_
- `Bump django from 4.2.5 to 4.2.7 (PR) (#58) <https://github.com/unb-mds/2023-2-Squad06/issues/58>`_
36 changes: 35 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ django-guardian = "^2.4.0"
django-bootstrap-v5 = "^1.0.11"
django-crispy-forms = "^2.1"
crispy-bootstrap5 = "^2023.10"
gunicorn = "^21.2.0"
whitenoise = "^6.6.0"

[tool.poetry.group.dev.dependencies]
pre-commit = "^3.5.0"
Expand Down
9 changes: 9 additions & 0 deletions server/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
Expand Down Expand Up @@ -130,6 +131,14 @@

STATIC_URL = "/static/"

STATIC_ROOT = BASE_DIR / "static"

STORAGES = {
"staticfiles": {
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
},
}

####################
# Authentication #
####################
Expand Down
2 changes: 2 additions & 0 deletions server/settings/development.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"localhost",
"0.0.0.0",
"127.0.0.1",
".herokuapp.com",
"develop.squad06.com",
]

# In development, we don't need a secure password hasher. We can use
Expand Down
2 changes: 1 addition & 1 deletion server/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

from django.core.wsgi import get_wsgi_application

environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings")
environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings.development")

application = get_wsgi_application()

0 comments on commit 79f04f0

Please sign in to comment.