Skip to content

Commit

Permalink
Merge pull request #9 from ProdByGodfather/main
Browse files Browse the repository at this point in the history
Main
  • Loading branch information
ProdByGodfather authored Jan 5, 2024
2 parents 3eab841 + 6199d32 commit 7ad074f
Show file tree
Hide file tree
Showing 18 changed files with 155 additions and 168 deletions.
82 changes: 54 additions & 28 deletions .idea/workspace.xml

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

10 changes: 10 additions & 0 deletions README-FA.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
جنگو چنلز در قالب یک برنامه پیام‌رسان طراحی شده است که کلاینت آن جاوا اسکریپت است و بک‌اند آن یک اتصال مبتنی بر وب سوکت با جنگو ایجاد کرده است.
با این حال بیشتر عملیات نمایش بر سمت کلاینت میباشد و بک اند تنها طبق نیاز json های خود را ارسال میکند.

<center><img src="static/img/dashboard.png" width="100%"></center>


علاوه بر قسمت سوپر چت، بخش داشبورد برای کاربران در نظر گرفته شده است که بخش ها و تنظیمات حساب کاربری کاربر را قابل دسترسی میکند. اصولا نمایش تعداد پیغام های کاربر، تعداد چت روم هایی که کاربر در آن حضور دارد به همراه بخش حذف و نمایش چت رومَ، آخرین ورود به حساب و تاریخ ثبت نام را به کاربر نمایش میدهد.
بخش های دیگر این داشبورد شامل بخش های زیر میباشد:
1. تغییر رمز عبور.
2. تنظیمات حساب کاربری و ویرایش نمایه کاربر.
3. بخش خروج از حساب کاربری.

در واقع بخش اصلی، داشبورد کاربر میباشد که دسترسی به آن فقط با ورود به حساب کاربری امکان پذیر میباشد.
## کارایی

> [!NOTE]
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ All messages are received in the form of json through the client, and the main p

`django channels` is designed in the form of a messenger application whose client is javascript and its back-end has created a websocket-based connection with django.

<center><img src="static/img/dashboard.png" width="100%"></center>

In addition to the Super Chat section, the dashboard section is intended for users, which makes the sections and settings of the user's account accessible. Basically, it shows the number of user messages, the number of chat rooms in which the user is present, along with the deletion and display section of the chat room, the last login to the account and the date of registration.
Other sections of this dashboard include the following sections:
1. Changing the password.
2. User account settings and user profile editing.
3. Logging out of the user account.

In fact, the main part is the user dashboard, which can be accessed only by logging into the user account.


## Performance
Expand Down
11 changes: 11 additions & 0 deletions chat/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
User = get_user_model()

# Create Model Chat
'''
chat models have a room name for get message from were room
members can only be viewed once
create time for show to user when message is send
'''
class Chat(models.Model):
roomname = models.CharField(max_length=75,blank=True)
members = models.ManyToManyField(User, null=True,blank=True)
Expand All @@ -18,6 +23,12 @@ def __str__(self):


# Create Model Message
'''
every message have one chat.
every message have one author.
every message have content ( this content maybe base64 image or text )
every message have an image ( this image save from author image )
'''
class Message(models.Model):
author = models.ForeignKey(User, on_delete=models.CASCADE)
content = models.TextField()
Expand Down
6 changes: 4 additions & 2 deletions chat/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from django.urls import path
from . import views

from users.views import panel

urlpatterns = [
path("", views.index, name="index"),
# this func has returned another view. new its expired
# path("", views.index, name="index"),
path("", panel, name="index"),
path("<str:room_name>/", views.room, name="room"),
path("<str:room_name>/delete", views.del_room, name="del_room"),

Expand Down
44 changes: 33 additions & 11 deletions chat/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,36 @@

from chat import models

@login_required()
def index(request):
# get user
user = request.user
# get user chatrooms
chat_rooms = models.Chat.objects.filter(members = user)

context = {
'chat_rooms':chat_rooms,
}
'''
login required
this function send user to index chat page
this page shows to user chat rooms and a input for create chat rooms
basicly this page expired
'''
# @login_required()
# def index(request):
# # get user
# user = request.user
# # get user chatrooms
# chat_rooms = models.Chat.objects.filter(members = user)
#
# context = {
# 'chat_rooms':chat_rooms,
# }
#
# NOTE : index.html deleted
# return render(request, "chat/index.html",context)


return render(request, "chat/index.html",context)


'''
index chat room page
we send room-name chat-model members-list and usernumbers
'''
@login_required()
def room(request, room_name):
chat_model = models.Chat.objects.filter(roomname=room_name)
Expand All @@ -43,6 +58,13 @@ def room(request, room_name):
}
return render(request, "chat/room.html", context)



'''
this is new function
users can delete chat room for her selves
just chat room never show on user panel
'''
def del_room(request, room_name):
user = request.user
cat = models.Chat.objects.get(roomname=room_name)
Expand Down
Binary file modified db.sqlite3
Binary file not shown.
9 changes: 8 additions & 1 deletion django_channels/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,17 @@
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'


# Login page configs
LOGIN_URL = reverse_lazy('login')

# If login successfully user redirect to panel
LOGIN_REDIRECT_URL = reverse_lazy("panel")
AUTH_USER_MODEL = "users.User"


'''
media settings for work with images
we just use this settings for user images
'''

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
2 changes: 2 additions & 0 deletions django_channels/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@


urlpatterns = [
# include chat ( chat room, index chat room page )
path("chat/", include("chat.urls")),
path('admin/', admin.site.urls),
# include users ( user panel, login page, register page )
path('',include("users.urls"))
]

Expand Down
Binary file added static/img/dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions templates/chat/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
<div id="app" class="app">
<section id="main-right" class="main-right">

<!-- Content -->

{% block content %}{% endblock %}

</section>
Expand Down
69 changes: 0 additions & 69 deletions templates/chat/index.html

This file was deleted.

6 changes: 1 addition & 5 deletions templates/chat/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,19 @@

{% block content %}
<div id="header-right" class="header-right">
<!-- profile pict -->
<div id="header-img" class="profile header-img">
<img src="{% static 'images/Sample_User_Icon.png' %}" alt="">
</div>

<!-- name -->
<h4 class="name friend-name">
{% if user.is_authenticated %}
{{ just_username }}
{% else %}
<span style="color: red">Login Form</span>
{% endif %}
</h4>

<!-- some btn -->
<div class="some-btn">
<span class="glyphicon glyphicon-user"></span>
<a href="{% url 'panel' %}" class="btn btn-danger"><span class="glyphicon glyphicon-home"></span></a>
</div>
</div>

Expand Down
Loading

0 comments on commit 7ad074f

Please sign in to comment.