• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

gcivil-nyu-org / Wednesday-Fall2023-Team-5 / 901

10 Dec 2023 02:45AM UTC coverage: 86.714% (-1.4%) from 88.104%
901

Pull #201

travis-pro

web-flow
Merge 7ac0ae996 into bba3f4208
Pull Request #201: Front end changes for chat

6 of 31 new or added lines in 3 files covered. (19.35%)

2 existing lines in 2 files now uncovered.

1227 of 1415 relevant lines covered (86.71%)

0.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

47.62
/chat/views.py
1
import json
1✔
2

3
# import logging
4

5
from django.contrib.auth.models import User
1✔
6
from django.shortcuts import render
1✔
7
from django.contrib.auth.decorators import login_required
1✔
8

9
# from common import db_retrieve_or_none
10
# from matching.models import UserTripMatches
11

12
# from common import db_retrieve_or_none
13
# from matching.models import UserTripMatches
14
from .models import Thread, ChatMessage
1✔
15
from django.db.models import Q
1✔
16

17

18
@login_required
1✔
19
def threads_page(request):
1✔
20
    threads = (
×
21
        Thread.objects.filter(Q(first_user=request.user) | Q(second_user=request.user))
22
        .prefetch_related("chat_message")
23
        .order_by("timestamp")
24
    )
25
    # if not threads:
26
    #     print("No threads present")
27
    #     first_user = request.user
28
    #     print(first_user)
29
    #     matches = UserTripMatches.objects.values().filter(Q(match_status="Matched"))
30
    #     print(matches)
31
    #     for match in matches:
32
    #         print("sender id: ")
33
    #         print(match["sender_id"])
34
    #         print("receiver id: ")
35
    #         print(match["receiver_id"])
36
    #         print("request_id: ")
37
    #         print(request.user.id)
38
    #         if request.user.id == match["sender_id"]:
39
    #             second_user = db_retrieve_or_none(User, match["receiver_id"])
40
    #             print("second_user: ")
41
    #             print(second_user.id)
42
    #             if second_user:
43
    #                 if second_user.id != first_user.id:
44
    #                     t = Thread.objects.get_or_create(
45
    #                         first_user=first_user, second_user=second_user
46
    #                     )
47
    #                 #         # print(t)
48
    #                     print("Created thread for")
49
    #                     print(first_user)
50
    #                     print(second_user)
51

52
    # Thread.objects.create()
53
    return render(request, "chat/threads.html", {"threads": threads})
×
54

55

56
@login_required
1✔
57
def messages_page(request, thread_id, other_user_id):
1✔
NEW
58
    threads = (
×
59
        Thread.objects.filter(Q(first_user=request.user) | Q(second_user=request.user))
60
        .prefetch_related("chat_message")
61
        .order_by("timestamp")
62
    )
63

UNCOV
64
    message_history = ChatMessage.objects.filter(thread=thread_id)
×
65

66
    json_data = {
×
67
        "thread_id": thread_id,
68
        "other_user_id": other_user_id,
69
        "self_user_id": request.user.id,
70
    }
71

NEW
72
    other_user = User.objects.get(id=other_user_id)
×
73

NEW
74
    chat_data = {"thread_id": thread_id, "other_user_instance": other_user}
×
75

76
    print(request.user.id)
×
77
    print(other_user_id)
×
78

NEW
79
    context = {
×
80
        "dump": json.dumps(json_data),
81
        "chat_data": chat_data,
82
        "message_history": message_history,
83
        "threads": threads,
84
    }
85

86
    return render(request, "chat/message_room.html", context)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc