Artteiv commited on
Commit
4b81092
1 Parent(s): ac138d7
chat/database_manage.py CHANGED
@@ -4,10 +4,10 @@ import uuid
4
  class DataManage:
5
  def __init__(self):
6
  pass
7
-
8
  def DeleteRoom(self, roomid):
9
  try:
10
  room = Room.objects.get(RoomID=roomid)
 
11
  room.delete()
12
  return True
13
  except Room.DoesNotExist:
 
4
  class DataManage:
5
  def __init__(self):
6
  pass
 
7
  def DeleteRoom(self, roomid):
8
  try:
9
  room = Room.objects.get(RoomID=roomid)
10
+ ChatDetails.objects.filter(RoomID=room.RoomID).delete()
11
  room.delete()
12
  return True
13
  except Room.DoesNotExist:
chat/templates/index.html CHANGED
@@ -62,9 +62,9 @@
62
  {% for x in rooms %}
63
  <li class="p-2 bg-[#4A4A4A] mb-2 rounded flex justify-between items-center">
64
  <a :href="`/chat?id={{x.id}}`" class="cursor-pointer">{{ x.name }}</a>
65
- <button @click="deleteChat(index)" class="bg-red-500 text-white px-2 py-1 rounded">
66
  Xoá
67
- </button>
68
  </li>
69
  {% endfor %}
70
  </ul>
@@ -247,6 +247,10 @@
247
  refresh() {
248
  this.send(true);
249
  },
 
 
 
 
250
  sendMessage() {
251
  if (this.id == null) {
252
  window.location.href = '/chat/newchat?ques=' + this.message;
 
62
  {% for x in rooms %}
63
  <li class="p-2 bg-[#4A4A4A] mb-2 rounded flex justify-between items-center">
64
  <a :href="`/chat?id={{x.id}}`" class="cursor-pointer">{{ x.name }}</a>
65
+ <a :href="`/chat/delete?id={{x.id}}`" class="bg-red-500 text-white px-2 py-1 rounded">
66
  Xoá
67
+ </a>
68
  </li>
69
  {% endfor %}
70
  </ul>
 
247
  refresh() {
248
  this.send(true);
249
  },
250
+ deleteChat(id) {
251
+ window.location.href = '/chat/delete?id=' + id;
252
+ return;
253
+ },
254
  sendMessage() {
255
  if (this.id == null) {
256
  window.location.href = '/chat/newchat?ques=' + this.message;
chat/urls.py CHANGED
@@ -6,5 +6,6 @@ app_name = 'chat'
6
  urlpatterns = [
7
  path('', views.index, name='index'),
8
  path('newchat/',views.newchat,name = 'newchat'),
 
9
  path("<str:room_name>/", views.room, name="room"),
10
  ]
 
6
  urlpatterns = [
7
  path('', views.index, name='index'),
8
  path('newchat/',views.newchat,name = 'newchat'),
9
+ path('delete/',views.deletechat,name = 'delete'),
10
  path("<str:room_name>/", views.room, name="room"),
11
  ]
chat/views.py CHANGED
@@ -37,4 +37,10 @@ def newchat(request):
37
 
38
 
39
  def room(request, room_name):
40
- return render(request, "chat/room.html", {"room_name": room_name})
 
 
 
 
 
 
 
37
 
38
 
39
  def room(request, room_name):
40
+ return render(request, "chat/room.html", {"room_name": room_name})
41
+ @login_required
42
+ def deletechat(request):
43
+ data = DataManage()
44
+ roomid = request.GET.get('id')
45
+ data.DeleteRoom(roomid)
46
+ return redirect('/chat')
db.sqlite3 CHANGED
Binary files a/db.sqlite3 and b/db.sqlite3 differ
 
users/templates/users/login.html CHANGED
@@ -42,6 +42,19 @@
42
  background-color: #25732a; /* Green button */
43
  border: none;
44
  color: white;
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  padding: 15px 120px;
46
  text-align: center;
47
  text-decoration: none;
@@ -71,9 +84,12 @@
71
  <input type="hidden" name="next" value="{{ request.GET.next }}" />
72
  {% endif %}
73
  <br>
74
- <div class="text-align:center:">
75
 
76
  <button class="form-submit center">Submit</button>
 
 
 
77
  </div>
78
  </form>
79
  </div>
 
42
  background-color: #25732a; /* Green button */
43
  border: none;
44
  color: white;
45
+ padding: 15px 125px;
46
+ text-align: center;
47
+ text-decoration: none;
48
+ display: inline-block;
49
+ font-size: 16px;
50
+ border-radius: 5px;
51
+ cursor: pointer;
52
+ transition: background-color 0.3s ease;
53
+ }
54
+ .form-regist {
55
+ background-color: #4f4f4f; /* Green button */
56
+ border: none;
57
+ color: white;
58
  padding: 15px 120px;
59
  text-align: center;
60
  text-decoration: none;
 
84
  <input type="hidden" name="next" value="{{ request.GET.next }}" />
85
  {% endif %}
86
  <br>
87
+ <div class="text-align:center">
88
 
89
  <button class="form-submit center">Submit</button>
90
+ <br>
91
+ <br>
92
+ <a href="{% url 'users:register' %}" class="form-regist center">Register</a>
93
  </div>
94
  </form>
95
  </div>