Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
b50e5fe
register
Rox0z Mar 20, 2025
8ba8f8b
user list
Rox0z Mar 20, 2025
4e5d9e5
adiciona delete
yasminddias Mar 24, 2025
19bf05f
Merge pull request #1 from yasminddias/delete
Rox0z Mar 25, 2025
b71a20e
fix delete e manage user page
Rox0z Mar 25, 2025
825d519
Merge pull request #2 from Rox0z/leonardo
Rox0z Mar 25, 2025
2efe83b
change register to staff only
Rox0z Mar 26, 2025
704cdf7
Merge pull request #3 from Rox0z/leonardo
Rox0z Mar 26, 2025
3a992c6
Criar perspetiva
laurarodrigues3 Apr 1, 2025
e6e8558
Revert "Criar perspetiva"
Rox0z Apr 1, 2025
5afda8e
groups and fix
Rox0z Jun 1, 2025
388045b
script
Rox0z Jun 1, 2025
a6c4974
setup script
Rox0z Jun 1, 2025
b464eb2
file permissions
Rox0z Jun 1, 2025
af1f0e7
update scripts
Rox0z Jun 1, 2025
ae89247
update script
Rox0z Jun 1, 2025
2ebaa58
update db string
Rox0z Jun 1, 2025
d5ef097
update start
Rox0z Jun 1, 2025
0a5ff3e
update setup
Rox0z Jun 1, 2025
00a4dff
Adiciona Discussões e Implementa chat
yasminddias Jun 8, 2025
5229ea2
Merge pull request #4 from Rox0z/ChatDiscussoes
Rox0z Jun 8, 2025
d9fb269
Delete Users com mensagens BD
yasminddias Jun 8, 2025
2ed0b19
Merge pull request #5 from Rox0z/Delete-Users
Rox0z Jun 8, 2025
c46bbd3
scripts
Rox0z Jun 9, 2025
3f14dbd
adiciona histórico de discussões
yasminddias Jun 10, 2025
f616206
Merge pull request #6 from Rox0z/Histórico-de-Discussões-e-ações
Rox0z Jun 10, 2025
ec8fc07
add more setup
Rox0z Jun 11, 2025
f06049d
tentativa de script para windows
Rox0z Jun 11, 2025
21b377b
adiciona pagina de discrepancias
yasminddias Jun 11, 2025
5f759d9
Merge pull request #7 from Rox0z/Discrepancias
Rox0z Jun 11, 2025
3173cec
script to change all passwords to password
Rox0z Jun 11, 2025
9e15164
Add group management
Rox0z Jun 12, 2025
31b060f
Merge pull request #8 from Rox0z/groups
Rox0z Jun 12, 2025
d4020da
allow python3.9
Rox0z Jun 12, 2025
c2ca451
trying more
Rox0z Jun 12, 2025
87a1424
trying
Rox0z Jun 12, 2025
c88e70a
giving up
Rox0z Jun 12, 2025
73146a9
fix
Rox0z Jun 12, 2025
89f4f6a
fixing
Rox0z Jun 12, 2025
72971f0
try
Rox0z Jun 12, 2025
2e619c5
Merge pull request #9 from Rox0z/dataset-fix
Rox0z Jun 12, 2025
680fda8
melhorias no criar utilizador
laurarodrigues3 Jun 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adiciona histórico de discussões
  • Loading branch information
yasminddias committed Jun 10, 2025
commit 3f14dbda1c2cbd2245d45aec50b0fcb16880a04c
25 changes: 25 additions & 0 deletions backend/discussions/migrations/0004_chatmessage_reply_to.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.2.15 on 2025-06-09 19:34

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
("discussions", "0003_rename_message_chatmessage_alter_chatmessage_options"),
]

operations = [
migrations.AddField(
model_name="chatmessage",
name="reply_to",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="replies",
to="discussions.chatmessage",
),
),
]
17 changes: 17 additions & 0 deletions backend/discussions/migrations/0005_remove_chatmessage_reply_to.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.15 on 2025-06-09 19:38

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("discussions", "0004_chatmessage_reply_to"),
]

operations = [
migrations.RemoveField(
model_name="chatmessage",
name="reply_to",
),
]
35 changes: 29 additions & 6 deletions backend/discussions/urls.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,50 @@
from django.urls import path
from .views import DiscussionViewSet, ChatMessageViewSet

# Endpoints de discussões
# Mapeia os métodos HTTP para as ações da ViewSet
# GET/POST para a lista de discussões
discussion_list = DiscussionViewSet.as_view({
'get': 'list',
'post': 'create'
})

# GET/PUT/PATCH/DELETE para uma discussão específica
discussion_detail = DiscussionViewSet.as_view({
'get': 'retrieve'
'get': 'retrieve',
'put': 'update',
'patch': 'partial_update',
'delete': 'destroy'
})

# Endpoints de mensagens no chat de uma discussão
# Ação customizada para encerrar uma discussão
discussion_close = DiscussionViewSet.as_view({
'post': 'close_discussion'
})

# Ação customizada para reabrir uma discussão
discussion_reopen = DiscussionViewSet.as_view({
'post': 'reopen_discussion'
})


# GET/POST para a lista de mensagens de um chat
chat_list = ChatMessageViewSet.as_view({
'get': 'list',
'post': 'create'
})

# Lista de todos os endpoints da aplicação 'discussions'
urlpatterns = [
# Discussões por projeto
# Rotas para criar e listar discussões de um projeto
path('projects/<int:project_id>/discussions/', discussion_list, name='discussion-list'),

# Rotas para ver, editar e excluir uma discussão específica
path('projects/<int:project_id>/discussions/<int:pk>/', discussion_detail, name='discussion-detail'),

# Chat da discussão
# Rotas para as ações customizadas
path('projects/<int:project_id>/discussions/<int:pk>/close/', discussion_close, name='discussion-close'),
path('projects/<int:project_id>/discussions/<int:pk>/reopen/', discussion_reopen, name='discussion-reopen'),

# Rota para o chat de uma discussão
path('discussions/<int:discussion_id>/chat/', chat_list, name='chat-list'),
]
]
43 changes: 41 additions & 2 deletions backend/discussions/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
from rest_framework import viewsets, permissions


from rest_framework import viewsets, permissions, status
from rest_framework.decorators import action
from rest_framework.response import Response
from django.utils import timezone
from django.shortcuts import get_object_or_404 # Garanta que este import está presente

from .models import Discussion, ChatMessage
from .serializers import DiscussionSerializer, ChatMessageSerializer
from projects.models import Project


class DiscussionViewSet(viewsets.ModelViewSet):
queryset = Discussion.objects.all()
serializer_class = DiscussionSerializer
Expand All @@ -14,9 +22,40 @@ def get_queryset(self):

def perform_create(self, serializer):
project_id = self.kwargs.get('project_id')
project = Project.objects.get(id=project_id)
project = get_object_or_404(Project, id=project_id)
serializer.save(project=project)

@action(detail=True, methods=['post'], url_path='close')
def close_discussion(self, request, project_id=None, pk=None):
"""
Encerra a discussão atual definindo a data de fim como a data atual.
"""
discussion = self.get_object()
discussion.end_date = timezone.now().date()
discussion.save()
serializer = self.get_serializer(discussion)
return Response(serializer.data, status=status.HTTP_200_OK)

@action(detail=True, methods=['post'], url_path='reopen')
def reopen_discussion(self, request, project_id=None, pk=None):
"""
Reabre uma discussão definindo uma nova data de fim.
"""
discussion = self.get_object()
new_end_date = request.data.get('end_date')

if not new_end_date:
return Response(
{'error': 'A nova data de fim (end_date) é obrigatória.'},
status=status.HTTP_400_BAD_REQUEST
)

discussion.end_date = new_end_date
discussion.save()

# Retorna a discussão atualizada para o frontend
serializer = self.get_serializer(discussion)
return Response(serializer.data, status=status.HTTP_200_OK)

class ChatMessageViewSet(viewsets.ModelViewSet):
serializer_class = ChatMessageSerializer
Expand Down
Loading