Skip to content

Commit 1a1ed39

Browse files
committed
use colors customization
1 parent f63908f commit 1a1ed39

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

chat/models.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,15 @@ class Meta:
159159

160160
class Customize(models.Model):
161161
default_fields = {
162-
"your-group-color": ("#198754", "گروه های شما"),
163-
"hot-group-color": ("#dc3545", "داغ ترین گروه ها"),
164-
"last-group-color": ("#0a58ca", "آخرین گروه ها"),
165-
"create-group-color": ("#0d6efd", "دکمه ساختن گروه"),
166-
"group-list-color": ("#6c757d", "لیست گروه ها"),
162+
"your_group_color": ("#198754", "گروه های شما"),
163+
"hot_group_color": ("#dc3545", "داغ ترین گروه ها"),
164+
"last_group_color": ("#0a58ca", "آخرین گروه ها"),
165+
"group_list_color": ("#6c757d", "لیست گروه ها"),
167166
"reply": ("#16a085", "پیام فرستنده"),
168167
"send": ("#2980b9", "پیام شما"),
169168
"input": ("#bdc3c7", "رنگ ورودی پیام"),
170-
"input-button": ("#7f8c8d", "رنگ دکمه های چت"),
171-
"input-button-hover": ("#95a5a6", "هاور شدن دکمه های چت"),
169+
"input_button": ("#7f8c8d", "رنگ دکمه های چت"),
170+
"input_button_hover": ("#95a5a6", "هاور شدن دکمه های چت"),
172171
"placeholder": ("#565f62", "رنگ placeholder"),
173172
"time": ("#333333", "رنگ زمان"),
174173
}
@@ -197,7 +196,7 @@ def create_default_fields(cls):
197196
@classmethod
198197
def get_all_fields(cls):
199198
fields: QuerySet[Customize] = Customize.objects.all()
200-
fields = {field.name: field.color for field in fields}
199+
return {field.name: field.color for field in fields}
201200

202201
def __str__(self):
203202
return self.name

chat/templates/chat/group-list.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ <h1 style="margin-top: 20px;">لیست تمام گروه ها</h1>
1414
<ul>
1515
{% for group_name in page_obj %}
1616
<a href="{% url 'index' %}{{ group_name }}">
17-
<li class="btn btn-outline-secondary all-group-btn">{{ group_name }}</li>
17+
<li style="color: {{group_list_color}}; border-color: {{group_list_color}};"
18+
class="btn btn-outline-secondary all-group-btn">{{ group_name }}</li>
1819
</a>
1920
{% endfor %}
2021
</ul>

chat/templates/chat/index.html

+6-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ <h1 class="title">گروه های شما</h1>
2121
<ul>
2222
{% for group_name in your_groups %}
2323
<a href="{% url 'index' %}{{ group_name }}">
24-
<li class="btn btn-outline-success custom-btn">{{ group_name }}</li>
24+
<li style="color: {{your_group_color}}; border-color: {{your_group_color}};"
25+
class="btn btn-outline-success custom-btn">{{ group_name }}</li>
2526
</a>
2627
{% endfor %}
2728
</ul>
@@ -31,7 +32,8 @@ <h1 class="title">داغ ترین گروه ها 🔥</h1>
3132
<ul>
3233
{% for group_name in best_groups %}
3334
<a href="{% url 'index' %}{{ group_name }}">
34-
<li class="btn btn-outline-danger custom-btn">{{ group_name }}</li>
35+
<li style="color: {{hot_group_color}}; border-color: {{hot_group_color}};"
36+
class="btn btn-outline-danger custom-btn">{{ group_name }}</li>
3537
</a>
3638
{% endfor %}
3739
</ul>
@@ -40,7 +42,8 @@ <h1 class="title">آخرین گروه ها 🆕</h1>
4042
<ul>
4143
{% for group_name in last_groups %}
4244
<a href="{% url 'index' %}{{ group_name }}">
43-
<li class="btn btn-outline-primary custom-btn">{{ group_name }}</li>
45+
<li style="color: {{last_group_color}}; border-color: {{last_group_color}};"
46+
class="btn btn-outline-primary custom-btn">{{ group_name }}</li>
4447
</a>
4548
{% endfor %}
4649
</ul>

chat/views.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def index(request: object):
2020
your_groups = Chat.your_group(user)
2121
context['your_groups'] = your_groups
2222
context['your_groups_len'] = len(your_groups)
23-
return render(request, "chat/index.html", context.update(color_fields))
23+
context = {**context, **color_fields}
24+
return render(request, "chat/index.html", context)
2425

2526

2627
@login_required(login_url="auth:register")
@@ -49,12 +50,12 @@ def group_list(request: object):
4950
context = {
5051
'page_obj': page_obj
5152
}
52-
return render(request, "chat/group-list.html", context.update(color_fields))
53+
context = {**context, **color_fields}
54+
return render(request, "chat/group-list.html", context)
5355

5456

5557
def create_group(request: object):
56-
context = Customize.get_all_fields()
57-
return render(request, "chat/create-group.html", context)
58+
return render(request, "chat/create-group.html")
5859

5960

6061
@login_required(login_url="auth:register")
@@ -80,7 +81,8 @@ def group_view(request: object, room_id: str):
8081
"room": chat_model[0].name,
8182
"listener_id": listener.room_id
8283
}
83-
return render(request, "chat/room.html", context.update(color_fields))
84+
context = {**context, **color_fields}
85+
return render(request, "chat/room.html", context)
8486

8587

8688
def about(request: object):

0 commit comments

Comments
 (0)